1 #include "string_array.h"
4 #include "osrf_config.h"
5 #include "objson/object.h"
6 #include "objson/json_parser.h"
9 /* libxml stuff for the config reader */
10 #include <libxml/xmlmemory.h>
11 #include <libxml/parser.h>
12 #include <libxml/xpath.h>
13 #include <libxml/xpathInternals.h>
14 #include <libxml/tree.h>
18 #ifndef osrf_message_h
19 #define osrf_message_h
21 #define OSRF_XML_NAMESPACE "http://open-ils.org/xml/namespaces/oils_v1"
23 #define OSRF_STATUS_CONTINUE 100
25 #define OSRF_STATUS_OK 200
26 #define OSRF_STATUS_ACCEPTED 202
27 #define OSRF_STATUS_COMPLETE 205
29 #define OSRF_STATUS_REDIRECTED 307
31 #define OSRF_STATUS_BADREQUEST 400
32 #define OSRF_STATUS_UNAUTHORIZED 401
33 #define OSRF_STATUS_FORBIDDEN 403
34 #define OSRF_STATUS_NOTFOUND 404
35 #define OSRF_STATUS_NOTALLOWED 405
36 #define OSRF_STATUS_TIMEOUT 408
37 #define OSRF_STATUS_EXPFAILED 417
39 #define OSRF_STATUS_INTERNALSERVERERROR 500
40 #define OSRF_STATUS_NOTIMPLEMENTED 501
41 #define OSRF_STATUS_VERSIONNOTSUPPORTED 505
44 enum M_TYPE { CONNECT, REQUEST, RESULT, STATUS, DISCONNECT };
46 #define OSRF_MAX_PARAMS 128;
48 struct osrf_message_struct {
54 /* if we're a STATUS message */
57 /* if we're a STATUS or RESULT */
63 /* if we're a RESULT */
64 //json* result_content;
65 object* _result_content;
67 /* unparsed json string */
70 /* if we're a REQUEST */
75 /* in case anyone wants to make a list of us.
76 we won't touch this variable */
77 struct osrf_message_struct* next;
79 char* full_param_string;
82 typedef struct osrf_message_struct osrf_message;
85 osrf_message* osrf_message_init( enum M_TYPE type, int thread_trace, int protocol );
86 //void osrf_message_set_request_info( osrf_message*, char* param_name, json* params );
87 void osrf_message_set_status_info( osrf_message*, char* status_name, char* status_text, int status_code );
88 void osrf_message_set_result_content( osrf_message*, char* json_string );
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);
97 /** Pushes any message retreived from the xml into the 'msgs' array.
98 * it is assumed that 'msgs' has beenn pre-allocated.
99 * Returns the number of message that are in the buffer.
101 int osrf_message_from_xml( char* xml, osrf_message* msgs[] );
103 void osrf_message_set_params( osrf_message* msg, object* o );
104 void osrf_message_set_method( osrf_message* msg, char* method_name );
105 void osrf_message_add_object_param( osrf_message* msg, object* o );
106 void osrf_message_add_param( osrf_message*, char* param_string );