2 #include <libxml/globals.h>
3 #include <libxml/xmlerror.h>
4 #include <libxml/parser.h>
5 #include <libxml/tree.h>
6 #include <libxml/debugXML.h>
7 #include <libxml/xmlmemory.h>
9 #include <opensrf/utils.h>
10 #include <opensrf/xml_utils.h>
11 #include <opensrf/log.h>
13 #ifndef TRANSPORT_MESSAGE_H
14 #define TRANSPORT_MESSAGE_H
18 // ---------------------------------------------------------------------------------
19 // Jabber message object.
20 // ---------------------------------------------------------------------------------
21 struct transport_message_struct {
36 char* msg_xml; /* the entire message as XML complete with entity encoding */
38 typedef struct transport_message_struct transport_message;
40 // ---------------------------------------------------------------------------------
41 // Allocates and returns a transport_message. All chars are safely re-allocated
42 // within this method.
43 // Returns NULL on error
44 // ---------------------------------------------------------------------------------
45 transport_message* message_init( char* body, char* subject,
46 char* thread, char* recipient, char* sender );
48 transport_message* new_message_from_xml( const char* msg_xml );
51 void message_set_router_info( transport_message* msg, char* router_from,
52 char* router_to, char* router_class, char* router_command, int broadcast_enabled );
54 void message_set_osrf_xid( transport_message* msg, char* osrf_xid );
56 // ---------------------------------------------------------------------------------
57 // Formats the Jabber message as XML for encoding.
58 // Returns NULL on error
59 // ---------------------------------------------------------------------------------
60 char* message_to_xml( const transport_message* msg );
63 // ---------------------------------------------------------------------------------
64 // Call this to create the encoded XML for sending on the wire.
65 // This is a seperate function so that encoding will not necessarily have
66 // to happen on all messages (i.e. typically only occurs outbound messages).
67 // ---------------------------------------------------------------------------------
68 int message_prepare_xml( transport_message* msg );
70 // ---------------------------------------------------------------------------------
71 // Deallocates the memory used by the transport_message
73 // ---------------------------------------------------------------------------------
74 int message_free( transport_message* msg );
76 // ---------------------------------------------------------------------------------
77 // Prepares the shared XML document
78 // ---------------------------------------------------------------------------------
79 //int message_init_xml();
81 // ---------------------------------------------------------------------------------
82 // Determines the username of a Jabber ID. This expects a pre-allocated char
83 // array for the return value.
84 // ---------------------------------------------------------------------------------
85 void jid_get_username( const char* jid, char buf[], int size );
87 // ---------------------------------------------------------------------------------
88 // Determines the resource of a Jabber ID. This expects a pre-allocated char
89 // array for the return value.
90 // ---------------------------------------------------------------------------------
91 void jid_get_resource( const char* jid, char buf[], int size );
93 /** Puts the domain portion of the given jid into the pre-allocated buffer */
94 void jid_get_domain( const char* jid, char buf[], int size );
96 void set_msg_error( transport_message*, char* error_type, int error_code);