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( const char* body, const char* subject,
46 const char* thread, const char* recipient, const char* sender );
48 transport_message* new_message_from_xml( const char* msg_xml );
51 void message_set_router_info( transport_message* msg, const char* router_from,
52 const char* router_to, const char* router_class, const char* router_command,
53 int broadcast_enabled );
55 void message_set_osrf_xid( transport_message* msg, const char* osrf_xid );
57 // ---------------------------------------------------------------------------------
58 // Formats the Jabber message as XML for encoding.
59 // Returns NULL on error
60 // ---------------------------------------------------------------------------------
61 char* message_to_xml( const transport_message* msg );
64 // ---------------------------------------------------------------------------------
65 // Call this to create the encoded XML for sending on the wire.
66 // This is a seperate function so that encoding will not necessarily have
67 // to happen on all messages (i.e. typically only occurs outbound messages).
68 // ---------------------------------------------------------------------------------
69 int message_prepare_xml( transport_message* msg );
71 // ---------------------------------------------------------------------------------
72 // Deallocates the memory used by the transport_message
74 // ---------------------------------------------------------------------------------
75 int message_free( transport_message* msg );
77 // ---------------------------------------------------------------------------------
78 // Prepares the shared XML document
79 // ---------------------------------------------------------------------------------
80 //int message_init_xml();
82 // ---------------------------------------------------------------------------------
83 // Determines the username of a Jabber ID. This expects a pre-allocated char
84 // array for the return value.
85 // ---------------------------------------------------------------------------------
86 void jid_get_username( const char* jid, char buf[], int size );
88 // ---------------------------------------------------------------------------------
89 // Determines the resource of a Jabber ID. This expects a pre-allocated char
90 // array for the return value.
91 // ---------------------------------------------------------------------------------
92 void jid_get_resource( const char* jid, char buf[], int size );
94 /** Puts the domain portion of the given jid into the pre-allocated buffer */
95 void jid_get_domain( const char* jid, char buf[], int size );
97 void set_msg_error( transport_message*, const char* error_type, int error_code);