-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.h
More file actions
76 lines (61 loc) · 1.21 KB
/
Core.h
File metadata and controls
76 lines (61 loc) · 1.21 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// Core.h
// superchat
//
// Created by Hugo on 11/11/2016.
// Copyright © 2016 hfqt. All rights reserved.
//
#ifndef Core_h
#define Core_h
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h> /* close */
#include <netdb.h> /* gethostbyname */
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define closesocket(s) close(s)
typedef int SOCKET;
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct sockaddr SOCKADDR;
typedef struct in_addr IN_ADDR;
struct Socket {
SOCKET sock;
SOCKADDR_IN sockaddr_in;
SOCKADDR sockaddr;
IN_ADDR in_addr;
};
#define CRLF "\r\n"
#define PORT 1977
#define BUF_SIZE 1024
/*
Split une string dans un array.
**/
char** strsplit(const char* str, const char* delim, size_t* numtokens);
/*
Init.
**/
void init(void);
/*
End.
**/
void end(void);
/*
Close socket connection.
**/
void end_connection(struct Socket sock);
/*
Read socket buffer.
**/
int read_buffer(struct Socket sock, char *buffer);
/*
Write to socket.
**/
void write_buffer(struct Socket sock, const char *buffer);
#endif /* Core_h */