2 * Copyright (C) the libgit2 contributors. All rights reserved.
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 typedef struct gitno_connection_data
{
76 } gitno_connection_data
;
79 * This replaces all the pointers in `data` with freshly-allocated strings,
80 * that the caller is responsible for freeing.
81 * `gitno_connection_data_free_ptrs` is good for this.
84 int gitno_connection_data_from_url(
85 gitno_connection_data
*data
,
87 const char *service_suffix
);
89 /* This frees all the pointers IN the struct, but not the struct itself. */
90 void gitno_connection_data_free_ptrs(gitno_connection_data
*data
);
92 int gitno_extract_url_parts(
98 const char *default_port
);