2 * Copyright (C) 2009-2012 the libgit2 contributors
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.
7 #ifndef INCLUDE_netops_h__
8 #define INCLUDE_netops_h__
14 # include <openssl/ssl.h>
26 typedef struct gitno_ssl gitno_ssl
;
28 /* Represents a socket that may or may not be using SSL */
34 typedef struct gitno_socket gitno_socket
;
41 int (*recv
)(struct gitno_buffer
*buffer
);
45 typedef struct gitno_buffer gitno_buffer
;
47 /* Flags to gitno_connect */
49 /* Attempt to create an SSL connection. */
50 GITNO_CONNECT_SSL
= 1,
52 /* Valid only when GITNO_CONNECT_SSL is also specified.
53 * Indicates that the server certificate should not be validated. */
54 GITNO_CONNECT_SSL_NO_CHECK_CERT
= 2,
57 void gitno_buffer_setup(gitno_socket
*t
, gitno_buffer
*buf
, char *data
, size_t len
);
58 void gitno_buffer_setup_callback(gitno_socket
*t
, gitno_buffer
*buf
, char *data
, size_t len
, int (*recv
)(gitno_buffer
*buf
), void *cb_data
);
59 int gitno_recv(gitno_buffer
*buf
);
61 void gitno_consume(gitno_buffer
*buf
, const char *ptr
);
62 void gitno_consume_n(gitno_buffer
*buf
, size_t cons
);
64 int gitno_connect(gitno_socket
*socket
, const char *host
, const char *port
, int flags
);
65 int gitno_send(gitno_socket
*socket
, const char *msg
, size_t len
, int flags
);
66 int gitno_close(gitno_socket
*s
);
67 int gitno_select_in(gitno_buffer
*buf
, long int sec
, long int usec
);
69 int gitno_extract_host_and_port(char **host
, char **port
, const char *url
, const char *default_port
);