1 #include "libjson/json.h"
2 #include "opensrf/generic_utils.h"
7 #define OSRF_XML_NAMESPACE "http://open-ils.org/xml/namespaces/oils_v1"
9 #define OSRF_STATUS_CONTINUE 100
11 #define OSRF_STATUS_OK 200
12 #define OSRF_STATUS_ACCEPTED 202
13 #define OSRF_STATUS_COMPLETE 205
15 #define OSRF_STATUS_REDIRECTED 307
17 #define OSRF_STATUS_BADREQUEST 400
18 #define OSRF_STATUS_UNAUTHORIZED 401
19 #define OSRF_STATUS_FORBIDDEN 403
20 #define OSRF_STATUS_NOTFOUND 404
21 #define OSRF_STATUS_NOTALLOWED 405
22 #define OSRF_STATUS_TIMEOUT 408
23 #define OSRF_STATUS_EXPFAILED 417
25 #define OSRF_STATUS_INTERNALSERVERERROR 500
26 #define OSRF_STATUS_NOTIMPLEMENTED 501
27 #define OSRF_STATUS_VERSIONNOTSUPPORTED 505
30 enum M_TYPE { CONNECT, REQUEST, RESULT, STATUS, DISCONNECT };
32 struct osrf_message_struct {
38 /* if we're a STATUS message */
41 /* if we're a STATUS or RESULT */
47 /* if we're a RESULT */
50 /* if we're a REQUEST */
54 /* in case anyone wants to make a list of us.
55 we won't touch this variable */
56 struct osrf_message_struct* next;
59 typedef struct osrf_message_struct osrf_message;
62 osrf_message* osrf_message_init( enum M_TYPE type, int thread_trace, int protocol );
63 void osrf_message_set_request_info( osrf_message*, char* param_name, json* params );
64 void osrf_message_set_status_info( osrf_message*, char* status_name, char* status_text, int status_code );
65 void osrf_message_set_result_content( osrf_message*, json* result_content );
66 void osrf_message_free( osrf_message* );
67 char* osrf_message_to_xml( osrf_message* );
68 /** Pushes any message retreived from the xml into the 'msgs' array.
69 * it is assumed that 'msgs' has beenn pre-allocated.
70 * Returns the number of message that are in the buffer.
72 int osrf_message_from_xml( char* xml, osrf_message* msgs[] );