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>
18 #define OSRF_XML_NAMESPACE "http://open-ils.org/xml/namespaces/oils_v1"
20 #define OSRF_STATUS_CONTINUE 100
22 #define OSRF_STATUS_OK 200
23 #define OSRF_STATUS_ACCEPTED 202
24 #define OSRF_STATUS_COMPLETE 205
26 #define OSRF_STATUS_REDIRECTED 307
28 #define OSRF_STATUS_BADREQUEST 400
29 #define OSRF_STATUS_UNAUTHORIZED 401
30 #define OSRF_STATUS_FORBIDDEN 403
31 #define OSRF_STATUS_NOTFOUND 404
32 #define OSRF_STATUS_NOTALLOWED 405
33 #define OSRF_STATUS_TIMEOUT 408
34 #define OSRF_STATUS_EXPFAILED 417
36 #define OSRF_STATUS_INTERNALSERVERERROR 500
37 #define OSRF_STATUS_NOTIMPLEMENTED 501
38 #define OSRF_STATUS_VERSIONNOTSUPPORTED 505
41 enum M_TYPE { CONNECT, REQUEST, RESULT, STATUS, DISCONNECT };
43 #define OSRF_MAX_PARAMS 128;
45 struct osrf_message_struct {
51 /* if we're a STATUS message */
54 /* if we're a STATUS or RESULT */
60 /* if we're a RESULT */
61 jsonObject* _result_content;
63 /* unparsed json string */
66 /* if we're a REQUEST */
71 /* in case anyone wants to make a list of us.
72 we won't touch this variable */
73 struct osrf_message_struct* next;
75 /* magical LOCALE hint */
78 /* timezone offset from GMT of sender, in seconds */
82 typedef struct osrf_message_struct osrfMessage;
84 const char* osrf_message_set_locale( osrfMessage* msg, const char* locale );
86 const char* osrf_message_set_default_locale( const char* locale );
88 const char* osrf_message_get_last_locale(void);
90 osrfMessage* osrf_message_init( enum M_TYPE type, int thread_trace, int protocol );
92 void osrf_message_set_status_info( osrfMessage*,
93 const char* status_name, const char* status_text, int status_code );
95 void osrf_message_set_result_content( osrfMessage*, const char* json_string );
97 void osrfMessageFree( osrfMessage* );
99 char* osrf_message_to_xml( osrfMessage* );
101 char* osrf_message_serialize(const osrfMessage*);
103 osrfList* osrfMessageDeserialize( const char* string, osrfList* list );
105 int osrf_message_deserialize(const char* json, osrfMessage* msgs[], int count);
107 void osrf_message_set_params( osrfMessage* msg, const jsonObject* o );
109 void osrf_message_set_method( osrfMessage* msg, const char* method_name );
111 void osrf_message_add_object_param( osrfMessage* msg, const jsonObject* o );
113 void osrf_message_add_param( osrfMessage*, const char* param_string );
115 jsonObject* osrfMessageGetResult( osrfMessage* msg );
117 char* osrfMessageSerializeBatch( osrfMessage* msgs [], int count );