diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-01 15:19:54 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-12-10 01:17:41 +0100 |
| commit | 468d7b11f9642f37a2c54e6fd6d539b223a103aa (patch) | |
| tree | afa778c340a451e6a5d9d29fb07f82e528f309e3 /src/socket_stream.c | |
| parent | dd4ff2c9b53dc9c8ba623477ead3e05f9baf73a0 (diff) | |
| download | libgit2-468d7b11f9642f37a2c54e6fd6d539b223a103aa.tar.gz | |
Add an OpenSSL IO stream
This unfortunately isn't as stackable as could be possible, as it
hard-codes the socket stream. This is because the method of using a
custom openssl BIO is not clear, and we do not need this for now. We can
still bring this in if and as we need it.
Diffstat (limited to 'src/socket_stream.c')
| -rw-r--r-- | src/socket_stream.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/socket_stream.c b/src/socket_stream.c index c182d6d6c..113b8f698 100644 --- a/src/socket_stream.c +++ b/src/socket_stream.c @@ -7,8 +7,9 @@ #include "common.h" #include "posix.h" -#include "stream.h" #include "netops.h" +#include "stream.h" +#include "socket_stream.h" #ifndef _WIN32 # include <sys/types.h> @@ -67,18 +68,11 @@ static int close_socket(GIT_SOCKET s) } -typedef struct { - git_stream parent; - char *host; - char *port; - GIT_SOCKET s; -} socket_stream; - int socket_connect(git_stream *stream) { struct addrinfo *info = NULL, *p; struct addrinfo hints; - socket_stream *st = (socket_stream *) stream; + git_socket_stream *st = (git_socket_stream *) stream; GIT_SOCKET s = INVALID_SOCKET; int ret; @@ -142,7 +136,7 @@ ssize_t socket_write(git_stream *stream, void *data, size_t len, int flags) { ssize_t ret; size_t off = 0; - socket_stream *st = (socket_stream *) stream; + git_socket_stream *st = (git_socket_stream *) stream; while (off < len) { errno = 0; @@ -161,7 +155,7 @@ ssize_t socket_write(git_stream *stream, void *data, size_t len, int flags) ssize_t socket_read(git_stream *stream, void *data, size_t len) { ssize_t ret; - socket_stream *st = (socket_stream *) stream; + git_socket_stream *st = (git_socket_stream *) stream; if ((ret = p_recv(st->s, data, len, 0)) < 0) net_set_error("Error receiving socket data"); @@ -171,7 +165,7 @@ ssize_t socket_read(git_stream *stream, void *data, size_t len) int socket_close(git_stream *stream) { - socket_stream *st = (socket_stream *) stream; + git_socket_stream *st = (git_socket_stream *) stream; int error; error = close_socket(st->s); @@ -182,7 +176,7 @@ int socket_close(git_stream *stream) void socket_free(git_stream *stream) { - socket_stream *st = (socket_stream *) stream; + git_socket_stream *st = (git_socket_stream *) stream; git__free(st->host); git__free(st->port); @@ -191,11 +185,11 @@ void socket_free(git_stream *stream) int git_socket_stream_new(git_stream **out, const char *host, const char *port) { - socket_stream *st; + git_socket_stream *st; assert(out && host); - st = git__calloc(1, sizeof(socket_stream)); + st = git__calloc(1, sizeof(git_socket_stream)); GITERR_CHECK_ALLOC(st); st->host = git__strdup(host); |
