object web, etc
[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 void         n_open(n_object* o, char* uid, char* options);
32 PUBLIC char*        n_to_string(n_object* o);
33 PUBLIC char*        n_uid(n_object* o);
34 PUBLIC int          n_uid_is(n_object* o, char* uid);
35 PUBLIC char*        n_header(n_object* o, char* name);
36 PUBLIC k_hashtable* n_headers(n_object* o);
37 PUBLIC k_hashtable* n_content(n_object* o);
38 PUBLIC void         n_dispatch(n_event*);
39
40 /* -------------------------------------------------------------------------- */
41
42 PUBLIC char* ni_hostname(void);
43 PUBLIC void  ni_hostname_set(char* name);
44
45 /* -------------------------------------------------------------------------- */
46
47 typedef struct ni_resource{
48         char*        uri;
49         k_hashtable* ent_head;
50         void*        entity;
51 } ni_resource;
52
53 PUBLIC ni_resource* ni_resource_new(char*        uri,
54                                     k_hashtable* ent_head,
55                                     char*        entity);
56 PUBLIC ni_resource* ni_resource_dup(   ni_resource* res);
57 PUBLIC void         ni_resource_delete(ni_resource* res);
58 PUBLIC void         ni_resource_show(  ni_resource* res, char* text);
59 PUBLIC ni_resource* ni_resource_get(char* uri);
60
61 /* -------------------------------------------------------------------------- */
62
63 typedef struct ni_event{
64         char*        uri;
65         k_hashtable* evt_head;
66         k_hashtable* ent_head;
67         void*        entity;
68 } ni_event;
69
70 PUBLIC ni_event* ni_event_new(char*        uri,
71                               k_hashtable* evt_head,
72                               k_hashtable* ent_head,
73                               char*        entity);
74 PUBLIC ni_event* ni_event_dup(   ni_event* res);
75 PUBLIC void      ni_event_delete(ni_event* res);
76 PUBLIC void      ni_event_show(  ni_event* res, char* text);
77
78 /* -------------------------------------------------------------------------- */
79
80 PUBLIC ni_event* ni_res_to_evt(ni_resource* res);
81
82 /* -------------------------------------------------------------------------- */
83
84 typedef int  (*ni_handles_resource)(char*);
85 typedef void (*ni_sync_resource   )(ni_resource*);
86
87 PUBLIC void ni_register_driver(char*               name,
88                                ni_handles_resource handles_resource,
89                                ni_sync_resource    sync_resource);
90
91 /* -------------------------------------------------------------------------- */
92
93 PUBLIC ni_event* ni_get_request_headers( char* header);
94 PUBLIC ni_event* ni_get_response_headers(char* header);
95 PUBLIC char*     ni_get_headers( char* header, k_hashtable*, k_hashtable*);
96 PUBLIC void      ni_fix_http_headers(k_hashtable* ent_head);
97 PUBLIC void      ni_fix_ni_headers(k_hashtable* ent_head, int methead);
98 PUBLIC void      ni_response(ni_event* evt,
99                              char*      to,
100                              char*      method,
101                              char*      protocol,
102                              char*      connection,
103                              k_channel* chan);
104 PUBLIC void      ni_request(ni_event* evt,
105                             char*      to,
106                             char*      method,
107                             k_channel* chan);
108
109 /* -------------------------------------------------------------------------- */
110
111 #endif
112