1 #include "libjson/json.h"
2 #include "string_array.h"
5 #include "osrf_config.h"
6 #include "objson/object.h"
7 #include "objson/json_parser.h"
10 /* libxml stuff for the config reader */
11 #include <libxml/xmlmemory.h>
12 #include <libxml/parser.h>
13 #include <libxml/xpath.h>
14 #include <libxml/xpathInternals.h>
15 #include <libxml/tree.h>
19 #ifndef osrf_message_h
20 #define osrf_message_h
22 #define OSRF_XML_NAMESPACE "http://open-ils.org/xml/namespaces/oils_v1"
24 #define OSRF_STATUS_CONTINUE 100
26 #define OSRF_STATUS_OK 200
27 #define OSRF_STATUS_ACCEPTED 202
28 #define OSRF_STATUS_COMPLETE 205
30 #define OSRF_STATUS_REDIRECTED 307
32 #define OSRF_STATUS_BADREQUEST 400
33 #define OSRF_STATUS_UNAUTHORIZED 401
34 #define OSRF_STATUS_FORBIDDEN 403
35 #define OSRF_STATUS_NOTFOUND 404
36 #define OSRF_STATUS_NOTALLOWED 405
37 #define OSRF_STATUS_TIMEOUT 408
38 #define OSRF_STATUS_EXPFAILED 417
40 #define OSRF_STATUS_INTERNALSERVERERROR 500
41 #define OSRF_STATUS_NOTIMPLEMENTED 501
42 #define OSRF_STATUS_VERSIONNOTSUPPORTED 505
45 enum M_TYPE { CONNECT, REQUEST, RESULT, STATUS, DISCONNECT };
47 #define OSRF_MAX_PARAMS 128;
49 struct osrf_message_struct {
55 int parse_json_result;
56 int parse_json_params;
58 /* if we're a STATUS message */
61 /* if we're a STATUS or RESULT */
67 /* if we're a RESULT */
69 object* _result_content;
71 /* unparsed json string */
74 /* if we're a REQUEST */
79 /* in case anyone wants to make a list of us.
80 we won't touch this variable */
81 struct osrf_message_struct* next;
84 char* full_param_string;
87 typedef struct osrf_message_struct osrf_message;
90 osrf_message* osrf_message_init( enum M_TYPE type, int thread_trace, int protocol );
91 void osrf_message_set_request_info( osrf_message*, char* param_name, json* params );
92 void osrf_message_set_status_info( osrf_message*, char* status_name, char* status_text, int status_code );
93 void osrf_message_set_result_content( osrf_message*, char* json_string );
94 void osrf_message_free( osrf_message* );
95 char* osrf_message_to_xml( osrf_message* );
96 /** Pushes any message retreived from the xml into the 'msgs' array.
97 * it is assumed that 'msgs' has beenn pre-allocated.
98 * Returns the number of message that are in the buffer.
100 int osrf_message_from_xml( char* xml, osrf_message* msgs[] );
102 /* decides whether all message automatically parse incoming json data */
103 /* to change a single message, set msg->parse_json accordingly */
104 //void osrf_message_set_json_parse( int bool );
106 void osrf_message_set_json_parse_result( int ibool );
107 void osrf_message_set_json_parse_params( int ibool );
110 void osrf_message_add_param( osrf_message*, char* param_string );