src/server/daemon/func.c

changeset 23
a2c8fc23c90e
parent 20
7b235fa88008
child 44
3da1f7b6847f
equal deleted inserted replaced
22:adb0bda54e6b 23:a2c8fc23c90e
28 28
29 29
30 #include <stdlib.h> 30 #include <stdlib.h>
31 31
32 #include "../public/nsapi.h" 32 #include "../public/nsapi.h"
33 33 #include "../util/pblock.h"
34 #include "../ucx/map.h" 34 #include "../ucx/map.h"
35 35
36 #include "func.h" 36 #include "func.h"
37 37
38 UcxMap *function_map; 38 UcxMap *function_map;
57 } 57 }
58 58
59 FuncStruct* get_function(char *name) { 59 FuncStruct* get_function(char *name) {
60 return ucx_map_cstr_get(function_map, name); 60 return ucx_map_cstr_get(function_map, name);
61 } 61 }
62
63 FuncStruct* func_resolve(pblock *pb, Session *sn, Request *rq) {
64 char *name = pblock_findkeyval(pb_key_fn, pb);
65 if(name == NULL) {
66 // TODO: error
67 return NULL;
68 }
69
70 FuncStruct *func = get_function(name);
71 if(func == NULL) {
72 // TODO: error
73 }
74 return func;
75 }
76
77 int func_exec (pblock *pb, Session *sn, Request *rq) {
78 FuncStruct *func = func_resolve(pb, sn, rq);
79 if(func == NULL) {
80 return REQ_ABORTED;
81 }
82 return func->func(pb, sn, rq);
83 }
84

mercurial