14a303080ba583f592095532041bbc3cf1b02025
[cilux] / src / include / notification.h
1
2 #ifndef ni_H
3 #define ni_H
4
5 /* -------------------------------------------------------------------------- */
6
7 typedef struct n_object{
8     k_hashtable* headers;
9     k_hashtable* content;
10 } n_object;
11
12 typedef struct n_event {
13     n_object* from;
14     n_object* to;
15 } n_event;
16
17 typedef int  (*n_handles_object)(char*);
18 typedef void (*n_view_event)(n_object*, n_object*);
19 typedef void (*n_cast_event)(n_object*, n_object*);
20 typedef void (*n_sync_object)(n_object*);
21
22 PUBLIC void n_register_driver(char*            name,
23                               n_handles_object handles_object,
24                               n_view_event     view_event,
25                               n_cast_event     cast_event,
26                               n_sync_object    sync_object );
27
28 PUBLIC n_object*    n_object_new(char* s);
29 PUBLIC void         n_commit(n_object* o);
30 PUBLIC n_object*    n_view(n_object* o, char* uid);
31 PUBLIC char*        n_to_string(n_object* o);
32 PUBLIC char*        n_uid(n_object* o);
33 PUBLIC int          n_uid_is(n_object* o, char* uid);
34 PUBLIC char*        n_header(n_object* o, char* name);
35 PUBLIC k_hashtable* n_headers(n_object* o);
36 PUBLIC k_hashtable* n_content(n_object* o);
37 PUBLIC void         n_dispatch(n_event*);
38
39 /* -------------------------------------------------------------------------- */
40
41 PUBLIC char* ni_hostname(void);
42 PUBLIC void  ni_hostname_set(char* name);
43
44 /* -------------------------------------------------------------------------- */
45
46 typedef struct ni_resource{
47         char*        uri;
48         k_hashtable* ent_head;
49         void*        entity;
50 } ni_resource;
51
52 PUBLIC ni_resource* ni_resource_new(char*        uri,
53                                     k_hashtable* ent_head,
54                                     char*        entity);
55 PUBLIC ni_resource* ni_resource_dup(   ni_resource* res);
56 PUBLIC void         ni_resource_delete(ni_resource* res);
57 PUBLIC void         ni_resource_show(  ni_resource* res, char* text);
58 PUBLIC ni_resource* ni_resource_get(char* uri);
59
60 /* -------------------------------------------------------------------------- */
61
62 typedef struct ni_event{
63         char*        uri;
64         k_hashtable* evt_head;
65         k_hashtable* ent_head;
66         void*        entity;
67 } ni_event;
68
69 PUBLIC ni_event* ni_event_new(char*        uri,
70                               k_hashtable* evt_head,
71                               k_hashtable* ent_head,
72                               char*        entity);
73 PUBLIC ni_event* ni_event_dup(   ni_event* res);
74 PUBLIC void      ni_event_delete(ni_event* res);
75 PUBLIC void      ni_event_show(  ni_event* res, char* text);
76
77 /* -------------------------------------------------------------------------- */
78
79 PUBLIC ni_event* ni_res_to_evt(ni_resource* res);
80
81 /* -------------------------------------------------------------------------- */
82
83 typedef int  (*ni_handles_resource)(char*);
84 typedef void (*ni_sync_resource   )(ni_resource*);
85
86 PUBLIC void ni_register_driver(char*               name,
87                                ni_handles_resource handles_resource,
88                                ni_sync_resource    sync_resource);
89
90 /* -------------------------------------------------------------------------- */
91
92 PUBLIC ni_event* ni_get_request_headers( char* header);
93 PUBLIC ni_event* ni_get_response_headers(char* header);
94 PUBLIC char*     ni_get_headers( char* header, k_hashtable*, k_hashtable*);
95 PUBLIC void      ni_fix_http_headers(k_hashtable* ent_head);
96 PUBLIC void      ni_fix_ni_headers(k_hashtable* ent_head, int methead);
97 PUBLIC void      ni_response(ni_event* evt,
98                              char*      to,
99                              char*      method,
100                              char*      protocol,
101                              char*      connection,
102                              k_channel* chan);
103 PUBLIC void      ni_request(ni_event* evt,
104                             char*      to,
105                             char*      method,
106                             k_channel* chan);
107
108 /* -------------------------------------------------------------------------- */
109
110 #endif
111