This repository was archived by the owner on Jan 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.h
More file actions
65 lines (51 loc) · 1.53 KB
/
server.h
File metadata and controls
65 lines (51 loc) · 1.53 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
/*==================================================
Header for the server part
==================================================*/
#ifndef LINUX
#define XOPEN_SOURCE 500
#endif
#ifndef SERVER
#define SERVER
#include "init_cond.h"
#include "lpc_type.h"
#include "panic.h"
#include "pthread_error.h"
#include <fnctl.h>
#include <sys/stat.h>
#include <sys/type.h>
#include <sys/mman.h>
#include <signal.h>
#include <errno.h>
//#define NAMELEN 48 already define in lpc_type
#define LEN 256
#define CAPACITY 4096
#define NB_FUN 3 //to be updated if you wish to add more functions
//include new functions below
#include "trunc.h"
#include "concat.h"
#include "div.h"
lpc_function fun_tab[NB_FUN];
void init_fun_tab() //init of functions table
{
fptr f1 = &trunc;
const lpc_function truncat = {"truncate", f1};
fun_tab[0] = truncat;
fptr f2 = &concat;
const lpc_function concat = {"concatenate", f2};
fun_tab[1] = concat;
fptr f3 = ÷
const lpc_function divide = {"division", f3};
fun_tab[2] = divide;
//to add a new function, first update NB_FUN, then include your header and update init_fun_tab to include the new function following the above format
}
int (*find_fun_ptr(const char *name)) (void*) //check if a name is linked to a function inside the functions table
{
for(int i = 0; i < NB_FUN; i++)
{
if(strcmp(fun_tab[i].fun_name,name) ==0)
return fun_tab[i].fun;
}
return NULL;
}
void* lpc_create(const char* mem_object, size_t capacity);
int init_mutex(pthread_mutex_t* pmutex);