| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
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_stream_h__ |
|
8
|
|
|
|
|
|
|
#define INCLUDE_stream_h__ |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#include "common.h" |
|
11
|
|
|
|
|
|
|
#include "git2/sys/stream.h" |
|
12
|
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
GIT_INLINE(int) git_stream_connect(git_stream *st) |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
0
|
|
|
|
|
|
return st->connect(st); |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
GIT_INLINE(int) git_stream_is_encrypted(git_stream *st) |
|
19
|
|
|
|
|
|
|
{ |
|
20
|
|
|
|
|
|
|
return st->encrypted; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
GIT_INLINE(int) git_stream_certificate(git_cert **out, git_stream *st) |
|
24
|
|
|
|
|
|
|
{ |
|
25
|
|
|
|
|
|
|
if (!st->encrypted) { |
|
26
|
|
|
|
|
|
|
git_error_set(GIT_ERROR_INVALID, "an unencrypted stream does not have a certificate"); |
|
27
|
|
|
|
|
|
|
return -1; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return st->certificate(out, st); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
GIT_INLINE(int) git_stream_supports_proxy(git_stream *st) |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
0
|
|
|
|
|
|
return st->proxy_support; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
GIT_INLINE(int) git_stream_set_proxy(git_stream *st, const git_proxy_options *proxy_opts) |
|
39
|
|
|
|
|
|
|
{ |
|
40
|
0
|
0
|
|
|
|
|
if (!st->proxy_support) { |
|
41
|
0
|
|
|
|
|
|
git_error_set(GIT_ERROR_INVALID, "proxy not supported on this stream"); |
|
42
|
0
|
|
|
|
|
|
return -1; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
return st->set_proxy(st, proxy_opts); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
GIT_INLINE(ssize_t) git_stream_read(git_stream *st, void *data, size_t len) |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
0
|
|
|
|
|
|
return st->read(st, data, len); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
GIT_INLINE(ssize_t) git_stream_write(git_stream *st, const char *data, size_t len, int flags) |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
0
|
|
|
|
|
|
return st->write(st, data, len, flags); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
GIT_INLINE(int) git_stream__write_full(git_stream *st, const char *data, size_t len, int flags) |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
|
|
|
|
|
|
size_t total_written = 0; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
while (total_written < len) { |
|
63
|
|
|
|
|
|
|
ssize_t written = git_stream_write(st, data + total_written, len - total_written, flags); |
|
64
|
|
|
|
|
|
|
if (written <= 0) |
|
65
|
|
|
|
|
|
|
return -1; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
total_written += written; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
return 0; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
GIT_INLINE(int) git_stream_close(git_stream *st) |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
0
|
|
|
|
|
|
return st->close(st); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
GIT_INLINE(void) git_stream_free(git_stream *st) |
|
79
|
|
|
|
|
|
|
{ |
|
80
|
0
|
0
|
|
|
|
|
if (!st) |
|
81
|
0
|
|
|
|
|
|
return; |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
st->free(st); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#endif |