]> git.evergreen-ils.org Git - OpenSRF.git/blob - include/opensrf/transport_message.h
21e312057b4ca8fc04647ac74f2310c4be02c215
[OpenSRF.git] / include / opensrf / transport_message.h
1 #include "libxml.h"
2
3 #include "generic_utils.h"
4
5 #include <string.h>
6 #include <libxml/globals.h>
7 #include <libxml/xmlerror.h>
8 #include <libxml/parser.h>
9 #include <libxml/tree.h>
10 #include <libxml/debugXML.h>
11 #include <libxml/xmlmemory.h>
12
13 #ifdef DMALLOC
14 #include "dmalloc.h"
15 #endif
16
17 #ifndef TRANSPORT_MESSAGE_H
18 #define TRANSPORT_MESSAGE_H
19
20
21
22 // ---------------------------------------------------------------------------------
23 // Jabber message object.
24 // ---------------------------------------------------------------------------------
25 struct transport_message_struct {
26         char* body;
27         char* subject;
28         char* thread;
29         char* recipient;
30         char* sender;
31         char* router_from;
32         char* router_to;
33         char* router_class;
34         char* router_command;
35         int is_error;
36         char* error_type;
37         int error_code;
38         int broadcast;
39         char* msg_xml; /* the entire message as XML complete with entity encoding */
40 };
41 typedef struct transport_message_struct transport_message;
42
43 // ---------------------------------------------------------------------------------
44 // Allocates and returns a transport_message.  All chars are safely re-allocated
45 // within this method.
46 // Returns NULL on error
47 // ---------------------------------------------------------------------------------
48 transport_message* message_init( char* body, char* subject, 
49                 char* thread, char* recipient, char* sender );
50
51
52 void message_set_router_info( transport_message* msg, char* router_from,
53                 char* router_to, char* router_class, char* router_command, int broadcast_enabled );
54
55 // ---------------------------------------------------------------------------------
56 // Formats the Jabber message as XML for encoding. 
57 // Returns NULL on error
58 // ---------------------------------------------------------------------------------
59 char* message_to_xml( const transport_message* msg );
60
61
62 // ---------------------------------------------------------------------------------
63 // Call this to create the encoded XML for sending on the wire.
64 // This is a seperate function so that encoding will not necessarily have
65 // to happen on all messages (i.e. typically only occurs outbound messages).
66 // ---------------------------------------------------------------------------------
67 int message_prepare_xml( transport_message* msg );
68
69 // ---------------------------------------------------------------------------------
70 // Deallocates the memory used by the transport_message
71 // Returns 0 on error
72 // ---------------------------------------------------------------------------------
73 int message_free( transport_message* msg );
74
75 // ---------------------------------------------------------------------------------
76 // Prepares the shared XML document
77 // ---------------------------------------------------------------------------------
78 //int message_init_xml();
79
80 // ---------------------------------------------------------------------------------
81 // Determines the username of a Jabber ID.  This expects a pre-allocated char 
82 // array for the return value.
83 // ---------------------------------------------------------------------------------
84 void jid_get_username( const char* jid, char buf[] );
85
86 // ---------------------------------------------------------------------------------
87 // Determines the resource of a Jabber ID.  This expects a pre-allocated char 
88 // array for the return value.
89 // ---------------------------------------------------------------------------------
90 void jid_get_resource( const char* jid, char buf[] );
91
92 void set_msg_error( transport_message*, char* error_type, int error_code);
93
94 #endif