-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.h
46 lines (38 loc) · 969 Bytes
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef UTILS_H
#define UTILS_H
#ifndef SOL_TCP
#define SOL_TCP 6 // socket options TCP level
#endif
#ifndef TCP_USER_TIMEOUT
#define TCP_USER_TIMEOUT 18 // how long for loss retry before timeout [ms]
#endif
#ifndef __USE_XOPEN2K
#define __USE_XOPEN2K
#endif
#include <stdint.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
typedef struct Uri_t
{
char *_line;
char *Scheme;
char *UserInfo;
char *Host;
char *Port;
int PortInt;
char *Path;
char *Query;
char *Uri;
struct addrinfo *_servinfo;
} Uri_t;
int mkpath(const char *path, mode_t mode);
void UriFree(Uri_t *uri);
Uri_t *UriParce(char *uri);
int UriConnect(Uri_t *uri);
int UriAddrInfo(Uri_t *uri);
char *base64_encode(uint8_t *data, size_t input_length, size_t *output_length);
int make_socket_non_blocking(int sfd);
int recvnb(int fd, char *in_buff, int in_buff_size, int *ret);
int path_open(char *path, char *file_name, mode_t mode);
#endif