]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/libjson/oilsMessage.c
oopsie
[OpenSRF.git] / src / libjson / oilsMessage.c
1 #include <stdio.h>
2 #include <string.h>
3 #include "libjson/json.h"
4
5
6 struct oils_method_struct {
7         char* method_name;
8         struct oils_param_struct* params;
9         char (*to_json_string) (struct oils_method_struct*);
10 };
11 typedef struct oils_method_struct oils_method;
12
13 struct oils_param_struct {
14         struct oils_param_struct* next;
15         void* param;
16         char (*to_json_string) (struct oils_param_struct*);
17 };
18 typedef struct oils_param_struct oils_param;
19
20
21 oils_method* oils_method_init( char* name );
22 int oils_method_add( oils_method*, oils_param* param );
23 oils_param* oils_param_init( void* param );
24 char* oils_method_to_json( oils_method* );
25 char* oils_param_to_json( oils_param* );
26 int main();
27
28
29
30 oils_method* oils_method_init( char* name ) {
31
32         if( name == NULL )
33                 perror( "null method name" );
34
35         oils_method* method = (oils_method*) malloc(sizeof(oils_method));
36         memset( method, 0, sizeof(oils_method));
37
38         method->method_name = strdup( name );
39
40         return method;
41 }
42
43 int oils_method_add( oils_method* method, oils_param* param ) {
44
45         if( method->params == NULL ) {
46                 method->params = param;
47                 return 1;
48         }
49
50         while(1) {
51                 if( method->params->next == NULL ) {
52                         method->params->next = param;
53                         return 1;
54                 }
55                 method->params = method->params->next;
56         }
57
58         return 0;
59 }
60
61 oils_param* oils_param_init( void* param ) {
62
63         if( param == NULL )
64                 perror( "Null param" );
65
66         oils_param* par = (oils_param*) malloc(sizeof(oils_param));
67         memset( par, 0, sizeof(oils_param));
68
69         par->param = param;
70         return par;
71 }
72
73
74 json_object* oils_method_to_json( oils_method* method ) {
75   struct json_object *method_obj;
76
77 }
78
79
80 json_object* oils_param_to_json( oils_param* param ) {
81
82 }
83
84 int main() {
85         printf( "Hello world\n" );
86
87 }