3 #include "libjson/json.h"
6 struct oils_method_struct {
8 struct oils_param_struct* params;
9 char (*to_json_string) (struct oils_method_struct*);
11 typedef struct oils_method_struct oils_method;
13 struct oils_param_struct {
14 struct oils_param_struct* next;
16 char (*to_json_string) (struct oils_param_struct*);
18 typedef struct oils_param_struct oils_param;
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* );
30 oils_method* oils_method_init( char* name ) {
33 perror( "null method name" );
35 oils_method* method = (oils_method*) malloc(sizeof(oils_method));
36 memset( method, 0, sizeof(oils_method));
38 method->method_name = strdup( name );
43 int oils_method_add( oils_method* method, oils_param* param ) {
45 if( method->params == NULL ) {
46 method->params = param;
51 if( method->params->next == NULL ) {
52 method->params->next = param;
55 method->params = method->params->next;
61 oils_param* oils_param_init( void* param ) {
64 perror( "Null param" );
66 oils_param* par = (oils_param*) malloc(sizeof(oils_param));
67 memset( par, 0, sizeof(oils_param));
74 json_object* oils_method_to_json( oils_method* method ) {
75 struct json_object *method_obj;
80 json_object* oils_param_to_json( oils_param* param ) {
85 printf( "Hello world\n" );