1 #include "opensrf/string_array.h"
2 #include "opensrf/utils.h"
3 #include "opensrf/logging.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 //json* result_content;
64 jsonObject* _result_content;
66 /* unparsed json string */
69 /* if we're a REQUEST */
74 /* in case anyone wants to make a list of us.
75 we won't touch this variable */
76 struct osrf_message_struct* next;
78 char* full_param_string;
81 typedef struct osrf_message_struct osrf_message;
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 osrf_message_free( osrf_message* );
89 char* osrf_message_to_xml( osrf_message* );
90 char* osrf_message_serialize(osrf_message*);
92 /* count is the max number of messages we'll put into msgs[] */
93 int osrf_message_deserialize(char* json, osrf_message* msgs[], int count);
96 /** Pushes any message retreived from the xml into the 'msgs' array.
97 * it is assumed that 'msgs' has beenn pre-allocated.
98 * Returns the number of message that are in the buffer.
100 int osrf_message_from_xml( char* xml, osrf_message* msgs[] );
102 void osrf_message_set_params( osrf_message* msg, jsonObject* o );
103 void osrf_message_set_method( osrf_message* msg, char* method_name );
104 void osrf_message_add_object_param( osrf_message* msg, jsonObject* o );
105 void osrf_message_add_param( osrf_message*, char* param_string );