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