1 #include "libjson/json.h"
2 #include "opensrf/generic_utils.h"
3 #include "opensrf/string_array.h"
8 #define OSRF_XML_NAMESPACE "http://open-ils.org/xml/namespaces/oils_v1"
10 #define OSRF_STATUS_CONTINUE 100
12 #define OSRF_STATUS_OK 200
13 #define OSRF_STATUS_ACCEPTED 202
14 #define OSRF_STATUS_COMPLETE 205
16 #define OSRF_STATUS_REDIRECTED 307
18 #define OSRF_STATUS_BADREQUEST 400
19 #define OSRF_STATUS_UNAUTHORIZED 401
20 #define OSRF_STATUS_FORBIDDEN 403
21 #define OSRF_STATUS_NOTFOUND 404
22 #define OSRF_STATUS_NOTALLOWED 405
23 #define OSRF_STATUS_TIMEOUT 408
24 #define OSRF_STATUS_EXPFAILED 417
26 #define OSRF_STATUS_INTERNALSERVERERROR 500
27 #define OSRF_STATUS_NOTIMPLEMENTED 501
28 #define OSRF_STATUS_VERSIONNOTSUPPORTED 505
31 enum M_TYPE { CONNECT, REQUEST, RESULT, STATUS, DISCONNECT };
33 #define OSRF_MAX_PARAMS 128;
35 struct osrf_message_struct {
41 int parse_json_result;
42 int parse_json_params;
44 /* if we're a STATUS message */
47 /* if we're a STATUS or RESULT */
53 /* if we're a RESULT */
56 /* unparsed json string */
59 /* if we're a REQUEST */
63 /* in case anyone wants to make a list of us.
64 we won't touch this variable */
65 struct osrf_message_struct* next;
68 char* full_param_string;
71 typedef struct osrf_message_struct osrf_message;
74 osrf_message* osrf_message_init( enum M_TYPE type, int thread_trace, int protocol );
75 void osrf_message_set_request_info( osrf_message*, char* param_name, json* params );
76 void osrf_message_set_status_info( osrf_message*, char* status_name, char* status_text, int status_code );
77 void osrf_message_set_result_content( osrf_message*, char* json_string );
78 void osrf_message_free( osrf_message* );
79 char* osrf_message_to_xml( osrf_message* );
80 /** Pushes any message retreived from the xml into the 'msgs' array.
81 * it is assumed that 'msgs' has beenn pre-allocated.
82 * Returns the number of message that are in the buffer.
84 int osrf_message_from_xml( char* xml, osrf_message* msgs[] );
86 /* decides whether all message automatically parse incoming json data */
87 /* to change a single message, set msg->parse_json accordingly */
88 //void osrf_message_set_json_parse( int bool );
90 void osrf_message_set_json_parse_result( int ibool );
91 void osrf_message_set_json_parse_params( int ibool );
94 void osrf_message_add_param( osrf_message*, char* param_string );