summaryrefslogtreecommitdiff
path: root/src/netops.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2012-07-24 19:03:22 +0200
committerCarlos Martín Nieto <carlos@cmartin.tk>2012-07-30 20:28:16 +0200
commitb49c8f71aef574ce6606282a498627f5106220d5 (patch)
treeb4a9d07716c80b48e68f36d8fb3fb6c142447ac6 /src/netops.c
parent114dc6e14c47ff574b4c97d4519782de3f9d28b2 (diff)
downloadlibgit2-b49c8f71aef574ce6606282a498627f5106220d5.tar.gz
remote: use the same code to control git and http
This allows us to add capabilitites to both at the same time, keeps them in sync and removes a lot of code. gitno_buffer now uses a callback to fill its buffer, allowing us to use the same interface for git and http (which uses callbacks).
Diffstat (limited to 'src/netops.c')
-rw-r--r--src/netops.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/netops.c b/src/netops.c
index b369e5106..918ca1dec 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -61,7 +61,7 @@ static int ssl_set_error(gitno_ssl *ssl, int error)
}
#endif
-void gitno_buffer_setup(git_transport *t, gitno_buffer *buf, char *data, unsigned int len)
+void gitno_buffer_setup_callback(git_transport *t, gitno_buffer *buf, char *data, unsigned int len, int (*recv)(gitno_buffer *buf), void *cb_data)
{
memset(buf, 0x0, sizeof(gitno_buffer));
memset(data, 0x0, len);
@@ -73,6 +73,19 @@ void gitno_buffer_setup(git_transport *t, gitno_buffer *buf, char *data, unsigne
if (t->encrypt)
buf->ssl = &t->ssl;
#endif
+
+ buf->recv = recv;
+ buf->cb_data = cb_data;
+}
+
+void gitno_buffer_setup(git_transport *t, gitno_buffer *buf, char *data, unsigned int len)
+{
+ gitno_buffer_setup_callback(t, buf, data, len, gitno__recv, NULL);
+}
+
+int gitno_recv(gitno_buffer *buf)
+{
+ return buf->recv(buf);
}
#ifdef GIT_SSL
@@ -91,7 +104,7 @@ static int ssl_recv(gitno_ssl *ssl, void *data, size_t len)
}
#endif
-int gitno_recv(gitno_buffer *buf)
+int gitno__recv(gitno_buffer *buf)
{
int ret;