1 #include "opensrf/string_array.h"
2 #include "opensrf/utils.h"
3 #include "opensrf/log.h"
4 #include "objson/object.h"
5 #include "objson/json_parser.h"
8 /* libxml stuff for the config reader */
9 #include <libxml/xmlmemory.h>
10 #include <libxml/parser.h>
11 #include <libxml/xpath.h>
12 #include <libxml/xpathInternals.h>
13 #include <libxml/tree.h>
17 #ifndef osrf_message_h
18 #define osrf_message_h
20 #define OSRF_XML_NAMESPACE "http://open-ils.org/xml/namespaces/oils_v1"
22 #define OSRF_STATUS_CONTINUE 100
24 #define OSRF_STATUS_OK 200
25 #define OSRF_STATUS_ACCEPTED 202
26 #define OSRF_STATUS_COMPLETE 205
28 #define OSRF_STATUS_REDIRECTED 307
30 #define OSRF_STATUS_BADREQUEST 400
31 #define OSRF_STATUS_UNAUTHORIZED 401
32 #define OSRF_STATUS_FORBIDDEN 403
33 #define OSRF_STATUS_NOTFOUND 404
34 #define OSRF_STATUS_NOTALLOWED 405
35 #define OSRF_STATUS_TIMEOUT 408
36 #define OSRF_STATUS_EXPFAILED 417
38 #define OSRF_STATUS_INTERNALSERVERERROR 500
39 #define OSRF_STATUS_NOTIMPLEMENTED 501
40 #define OSRF_STATUS_VERSIONNOTSUPPORTED 505
43 enum M_TYPE { CONNECT, REQUEST, RESULT, STATUS, DISCONNECT };
45 #define OSRF_MAX_PARAMS 128;
47 struct osrf_message_struct {
53 /* if we're a STATUS message */
56 /* if we're a STATUS or RESULT */
62 /* if we're a RESULT */
63 jsonObject* _result_content;
65 /* unparsed json string */
68 /* if we're a REQUEST */
73 /* in case anyone wants to make a list of us.
74 we won't touch this variable */
75 struct osrf_message_struct* next;
77 char* full_param_string;
80 typedef struct osrf_message_struct osrf_message;
81 typedef struct osrf_message_struct osrfMessage;
84 osrf_message* osrf_message_init( enum M_TYPE type, int thread_trace, int protocol );
85 //void osrf_message_set_request_info( osrf_message*, char* param_name, json* params );
86 void osrf_message_set_status_info( osrf_message*, char* status_name, char* status_text, int status_code );
87 void osrf_message_set_result_content( osrf_message*, char* json_string );
88 void osrfMessageFree( osrfMessage* );
89 void osrf_message_free( osrf_message* );
90 char* osrf_message_to_xml( osrf_message* );
91 char* osrf_message_serialize(osrf_message*);
93 /* count is the max number of messages we'll put into msgs[] */
94 int osrf_message_deserialize(char* json, osrf_message* msgs[], int count);
98 /** Pushes any message retreived from the xml into the 'msgs' array.
99 * it is assumed that 'msgs' has beenn pre-allocated.
100 * Returns the number of message that are in the buffer.
102 int osrf_message_from_xml( char* xml, osrf_message* msgs[] );
104 void osrf_message_set_params( osrf_message* msg, jsonObject* o );
105 void osrf_message_set_method( osrf_message* msg, char* method_name );
106 void osrf_message_add_object_param( osrf_message* msg, jsonObject* o );
107 void osrf_message_add_param( osrf_message*, char* param_string );
110 jsonObject* osrfMessageGetResult( osrfMessage* msg );
113 Returns the message as a jsonObject
114 @return The jsonObject which must be freed by the caller.
116 jsonObject* osrfMessageToJSON( osrfMessage* msg );
118 char* osrfMessageSerializeBatch( osrfMessage* msgs [], int count );