Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit cd305c2

Browse files
committed
Merge pull request libgit2#2678 from libgit2/cmn/io-stream
Introduce stackable IO streams
2 parents 3b6a566 + a2fd56a commit cd305c2

File tree

12 files changed

+857
-612
lines changed

12 files changed

+857
-612
lines changed

include/git2/sys/stream.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (C) the libgit2 contributors. All rights reserved.
3+
*
4+
* This file is part of libgit2, distributed under the GNU GPL v2 with
5+
* a Linking Exception. For full terms see the included COPYING file.
6+
*/
7+
#ifndef INCLUDE_sys_git_stream_h__
8+
#define INCLUDE_sys_git_stream_h__
9+
10+
#include "git2/common.h"
11+
#include "git2/types.h"
12+
13+
GIT_BEGIN_DECL
14+
15+
#define GIT_STREAM_VERSION 1
16+
17+
/**
18+
* Every stream must have this struct as its first element, so the
19+
* API can talk to it. You'd define your stream as
20+
*
21+
* struct my_stream {
22+
* git_stream parent;
23+
* ...
24+
* }
25+
*
26+
* and fill the functions
27+
*/
28+
typedef struct git_stream {
29+
int version;
30+
31+
int encrypted;
32+
int (*connect)(struct git_stream *);
33+
int (*certificate)(git_cert **, struct git_stream *);
34+
ssize_t (*read)(struct git_stream *, void *, size_t);
35+
ssize_t (*write)(struct git_stream *, const char *, size_t, int);
36+
int (*close)(struct git_stream *);
37+
void (*free)(struct git_stream *);
38+
} git_stream;
39+
40+
#endif

0 commit comments

Comments
 (0)