-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.h
executable file
·60 lines (45 loc) · 982 Bytes
/
util.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef UT_HEADER
#define UT_HEADER
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#define DEFAULT_PORT 8888
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
enum content_type {
STATIC_CONTENT,
DYNAMIC_CONTENT,
AUTOMATIC_DETECTION
};
struct server_options {
int verbose;
int port;
enum content_type typeof_content;
char *target_directory;
};
/* error printing macro */
#define ERR(call_description) \
do { \
fprintf(stderr, "(%s, %d): ", \
__FILE__, __LINE__); \
perror(call_description); \
} while (0)
/* print error (call ERR) and exit */
#define DIE(assertion, call_description) \
do { \
if (assertion) { \
ERR(call_description); \
exit(EXIT_FAILURE); \
} \
} while (0)
const char *get_filename_extension(const char*);
void as_logger(const char*);
void as_logger_arg(char*, char*);
void as_arg_parse(int, char**);
int as_directory_exists(char*);
#ifdef __cplusplus
}
#endif
#endif