netops.h 1.03 KB
Newer Older
1
/*
Vicent Marti committed
2 3 4 5
 * Copyright (C) 2009-2011 the libgit2 contributors
 *
 * This file is part of libgit2, distributed under the GNU GPL v2 with
 * a Linking Exception. For full terms see the included COPYING file.
6 7 8 9
 */
#ifndef INCLUDE_netops_h__
#define INCLUDE_netops_h__

10
#ifndef GIT_WIN32
11 12
typedef int GIT_SOCKET;
#else
13
typedef SOCKET GIT_SOCKET;
14 15
#endif

16
typedef struct gitno_buffer {
17
	char *data;
18 19
	size_t len;
	size_t offset;
20
	GIT_SOCKET fd;
21 22
} gitno_buffer;

23
void gitno_buffer_setup(gitno_buffer *buf, char *data, unsigned int len, int fd);
24
int gitno_recv(gitno_buffer *buf);
25
void gitno_consume(gitno_buffer *buf, const char *ptr);
26
void gitno_consume_n(gitno_buffer *buf, size_t cons);
27

28
int gitno_connect(const char *host, const char *port);
29
int gitno_send(GIT_SOCKET s, const char *msg, size_t len, int flags);
30
int gitno_close(GIT_SOCKET s);
31
int gitno_send_chunk_size(int s, size_t len);
32
int gitno_select_in(gitno_buffer *buf, long int sec, long int usec);
33

34 35
int gitno_extract_host_and_port(char **host, char **port, const char *url, const char *default_port);

36
#endif