first import of old cilux linux platform code
[cilux] / src / include / ni.h
1
2 #ifndef ni_H
3 #define ni_H
4
5 /* -------------------------------------------------------------------------- */
6
7 PUBLIC char* ni_hostname(void);
8 PUBLIC void  ni_hostname_set(char* name);
9
10 /* -------------------------------------------------------------------------- */
11
12 typedef struct ni_resource{
13         char*        uri;
14         k_hashtable* ent_head;
15         void*        entity;
16 } ni_resource;
17
18 PUBLIC ni_resource* ni_resource_new(char*        uri,
19                                     k_hashtable* ent_head,
20                                     char*        entity);
21 PUBLIC ni_resource* ni_resource_dup(   ni_resource* res);
22 PUBLIC void         ni_resource_delete(ni_resource* res);
23 PUBLIC void         ni_resource_show(  ni_resource* res, char* text);
24 PUBLIC ni_resource* ni_resource_get(char* uri);
25
26 /* -------------------------------------------------------------------------- */
27
28 typedef struct ni_event{
29         char*        uri;
30         k_hashtable* evt_head;
31         k_hashtable* ent_head;
32         void*        entity;
33 } ni_event;
34
35 PUBLIC ni_event* ni_event_new(char*        uri,
36                               k_hashtable* evt_head,
37                               k_hashtable* ent_head,
38                               char*        entity);
39 PUBLIC ni_event* ni_event_dup(   ni_event* res);
40 PUBLIC void      ni_event_delete(ni_event* res);
41 PUBLIC void      ni_event_show(  ni_event* res, char* text);
42
43 /* -------------------------------------------------------------------------- */
44
45 PUBLIC ni_event* ni_res_to_evt(ni_resource* res);
46
47 /* -------------------------------------------------------------------------- */
48
49 typedef int  (*ni_handles_resource)(char*);
50 typedef void (*ni_sync_resource   )(ni_resource*);
51
52 PUBLIC void ni_register_driver(char*               name,
53                                ni_handles_resource handles_resource,
54                                ni_sync_resource    sync_resource);
55
56 /* -------------------------------------------------------------------------- */
57
58 PUBLIC ni_event* ni_get_request_headers( char* header);
59 PUBLIC ni_event* ni_get_response_headers(char* header);
60 PUBLIC char*     ni_get_headers( char* header, k_hashtable*, k_hashtable*);
61 PUBLIC void      ni_fix_http_headers(k_hashtable* ent_head);
62 PUBLIC void      ni_fix_ni_headers(k_hashtable* ent_head, int methead);
63 PUBLIC void      ni_response(ni_event* evt,
64                              char*      to,
65                              char*      method,
66                              char*      protocol,
67                              char*      connection,
68                              k_channel* chan);
69 EXPORT void      ni_request(ni_event* evt,
70                             char*      to,
71                             char*      method,
72                             k_channel* chan);
73
74 /* -------------------------------------------------------------------------- */
75
76 #endif
77