-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.h
66 lines (47 loc) · 2.23 KB
/
server.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
61
62
63
64
65
66
#ifndef SERVER_H
#define SERVER_H
#include <netinet/in.h>
#include <sys/types.h>
/*** Symbols defined in common.c. ************************************/
/* The name of this program. */
extern const char* program_name;
/* If nonzero, print verbose messages. */
extern int verbose;
/* Like malloc, except aborts the program if allocation fails. */
extern void* xmalloc (size_t size);
/* like realloc, except aborts the program if allocation fails. */
extern void* xrealloc (void* ptr, size_t size);
/* Like strdup, except aborts the program if allocation fails. */
extern char* xstrdup (const char* s);
/* Print an error message for a failed call OPERATION, using the value
* of errno, and end the program. */
extern void system_error (const char* operation);
/* Print an error message for failure involving CAUSE, including a
* descriptive MESSAGE, and end the program. */
extern void error (const char* cause, const char* message);
/* return the directory containing the running program's executable.
* The return value is a memory buffer that the caller must deallocate
* using free. This function calls abort on failure. */
extern char* get_self_executable_directory ();
/*** Symbols defined in module.c **************************************/
/* An instance of a loaded server module. */
struct server_module {
/* The shared library handle corresponding to the loaded module. */
void* handle;
/* A name describing the module. */
const char* name;
/* The function that generates the HTML reults for this module. */
void (* generate_function) (int);
};
/* The directory from which modules are loaded. */
extern char* module_dir;
/* Attempt to load a server module with the name MODULE_PATH. If a
* server module exists with this path, loads the module and returns a
* server_module structure representing it. Otherwise, return NULL. */
extern struct server_module* module_open (const char* module_path);
/* Close a server module and deallocate the MODULE object. */
extern void module_close (struct server_module* module);
/*** Symbols defined in server.c. ************************************/
/* Run the server on LOCAL_ADDRESS and PORT. */
extern void server_run (struct in_addr local_address, uint16_t port);
#endif /* SERVER_H */