6 @brief Header for osrfMessage
9 #include <opensrf/string_array.h>
10 #include <opensrf/utils.h>
11 #include <opensrf/log.h>
12 #include <opensrf/osrf_json.h>
15 /* libxml stuff for the config reader */
16 #include <libxml/xmlmemory.h>
17 #include <libxml/parser.h>
18 #include <libxml/xpath.h>
19 #include <libxml/xpathInternals.h>
20 #include <libxml/tree.h>
26 #define OSRF_XML_NAMESPACE "http://open-ils.org/xml/namespaces/oils_v1"
28 #define OSRF_STATUS_CONTINUE 100
30 #define OSRF_STATUS_OK 200
31 #define OSRF_STATUS_ACCEPTED 202
32 #define OSRF_STATUS_COMPLETE 205
34 #define OSRF_STATUS_REDIRECTED 307
36 #define OSRF_STATUS_BADREQUEST 400
37 #define OSRF_STATUS_UNAUTHORIZED 401
38 #define OSRF_STATUS_FORBIDDEN 403
39 #define OSRF_STATUS_NOTFOUND 404
40 #define OSRF_STATUS_NOTALLOWED 405
41 #define OSRF_STATUS_TIMEOUT 408
42 #define OSRF_STATUS_EXPFAILED 417
44 #define OSRF_STATUS_INTERNALSERVERERROR 500
45 #define OSRF_STATUS_NOTIMPLEMENTED 501
46 #define OSRF_STATUS_VERSIONNOTSUPPORTED 505
49 enum M_TYPE { CONNECT, REQUEST, RESULT, STATUS, DISCONNECT };
51 #define OSRF_MAX_PARAMS 128;
53 struct osrf_message_struct {
59 /* if we're a STATUS message */
62 /* if we're a STATUS or RESULT */
68 /* if we're a RESULT */
69 jsonObject* _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;
83 /* magical LOCALE hint */
86 /* timezone offset from GMT of sender, in seconds */
90 typedef struct osrf_message_struct osrfMessage;
92 const char* osrf_message_set_locale( osrfMessage* msg, const char* locale );
94 const char* osrf_message_set_default_locale( const char* locale );
96 const char* osrf_message_get_last_locale(void);
98 osrfMessage* osrf_message_init( enum M_TYPE type, int thread_trace, int protocol );
100 void osrf_message_set_status_info( osrfMessage*,
101 const char* status_name, const char* status_text, int status_code );
103 void osrf_message_set_result_content( osrfMessage*, const char* json_string );
105 void osrfMessageFree( osrfMessage* );
107 char* osrf_message_to_xml( osrfMessage* );
109 char* osrf_message_serialize(const osrfMessage*);
111 osrfList* osrfMessageDeserialize( const char* string, osrfList* list );
113 int osrf_message_deserialize(const char* json, osrfMessage* msgs[], int count);
115 void osrf_message_set_params( osrfMessage* msg, const jsonObject* o );
117 void osrf_message_set_method( osrfMessage* msg, const char* method_name );
119 void osrf_message_add_object_param( osrfMessage* msg, const jsonObject* o );
121 void osrf_message_add_param( osrfMessage*, const char* param_string );
123 jsonObject* osrfMessageGetResult( osrfMessage* msg );
125 char* osrfMessageSerializeBatch( osrfMessage* msgs [], int count );