+++ /dev/null
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <time.h>
-
-/* libxml stuff for the config reader */
-#include <libxml/xmlmemory.h>
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
-#include <libxml/xpathInternals.h>
-#include <libxml/tree.h>
-
-#include "utils.h"
-
-#ifndef GENERIC_UTILS_H
-#define GENERIC_UTILS_H
-
-#define LOG_ERROR 1
-#define LOG_WARNING 2
-#define LOG_INFO 3
-#define LOG_DEBUG 4
-
-
-#define equals(a,b) !strcmp(a,b)
-
-
-/*
-inline void* safe_malloc( int size );
-
-#define BUFFER_MAX_SIZE 10485760
-
-struct growing_buffer_struct {
- char *buf;
- int n_used;
- int size;
-};
-typedef struct growing_buffer_struct growing_buffer;
-
-growing_buffer* buffer_init( int initial_num_bytes);
-int buffer_addchar(growing_buffer* gb, char c);
-int buffer_add(growing_buffer* gb, char* c);
-int buffer_reset( growing_buffer* gb);
-char* buffer_data( growing_buffer* gb);
-int buffer_free( growing_buffer* gb );
-int buffer_fadd(growing_buffer* gb, const char* format, ... );
-*/
-
-
-void log_free();
-
-// Utility method
-void get_timestamp( char buf_36chars[]);
-double get_timestamp_millis();
-
-// ---------------------------------------------------------------------------------
-// Error handling interface.
-// ---------------------------------------------------------------------------------
-
-void fatal_handler( char* message, ...);
-void warning_handler( char* message, ... );
-void info_handler( char* message, ... );
-void debug_handler( char* message, ... );
-
-/** If we return 0 either the log level is less than LOG_ERROR
- * or we could not open the log file
- */
-int log_init( int log_level, char* log_file );
-
-// ---------------------------------------------------------------------------------
-// Config file module
-// ---------------------------------------------------------------------------------
-struct config_reader_struct {
- xmlDocPtr config_doc;
- xmlXPathContextPtr xpathCx;
- char* name;
- struct config_reader_struct* next;
-};
-typedef struct config_reader_struct config_reader;
-config_reader* conf_reader;
-
-//void config_reader_init( char* config_file );
-void config_reader_init( char* name, char* config_file );
-
-void config_reader_free();
-
-// allocastes a char*. FREE me.
-char* config_value( const char* config_name, const char* xp_query, ... );
-
-#endif
+++ /dev/null
-#include "libjson/json.h"
-#include "opensrf/transport_client.h"
-#include "opensrf/generic_utils.h"
-#include "osrf_message.h"
-#include "osrf_system.h"
-#include "opensrf/string_array.h"
-
-#ifndef OSRF_APP_SESSION
-#define OSRF_APP_SESSION
-
-
-#define DEF_RECV_TIMEOUT 6 /* receive timeout */
-#define DEF_QUEUE_SIZE
-
-enum OSRF_SESSION_STATE { OSRF_SESSION_CONNECTING, OSRF_SESSION_CONNECTED, OSRF_SESSION_DISCONNECTED };
-enum OSRF_SESSION_TYPE { OSRF_SESSION_SERVER, OSRF_SESSION_CLIENT };
-
-struct osrf_app_request_struct {
- /** Our controlling session */
- struct osrf_app_session_struct* session;
-
- /** our "id" */
- int request_id;
- /** True if we have received a 'request complete' message from our request */
- int complete;
- /** Our original request payload */
- osrf_message* payload;
- /** List of responses to our request */
- osrf_message* result;
-
- /** So we can be listified */
- struct osrf_app_request_struct* next;
-};
-typedef struct osrf_app_request_struct osrf_app_request;
-
-struct osrf_app_session_struct {
-
- /** Our messag passing object */
- transport_client* transport_handle;
- /** Cache of active app_request objects */
- osrf_app_request* request_queue;
-
- /** The original remote id of the remote service we're talking to */
- char* orig_remote_id;
- /** The current remote id of the remote service we're talking to */
- char* remote_id;
-
- /** Who we're talking to */
- char* remote_service;
-
- /** The current request thread_trace */
- int thread_trace;
- /** Our ID */
- char* session_id;
-
- /* true if this session does not require connect messages */
- int stateless;
-
- /** The connect state */
- enum OSRF_SESSION_STATE state;
-
- /** SERVER or CLIENT */
- enum OSRF_SESSION_TYPE type;
-
- /** So we can be listified */
- struct osrf_app_session_struct* next;
-};
-typedef struct osrf_app_session_struct osrf_app_session;
-
-
-
-// --------------------------------------------------------------------------
-// PUBLIC API ***
-// --------------------------------------------------------------------------
-
-/** Allocates a initializes a new app_session */
-osrf_app_session* osrf_app_client_session_init( char* remote_service );
-
-/** Allocates and initializes a new server session. The global session cache
- * is checked to see if this session already exists, if so, it's returned
- */
-osrf_app_session* osrf_app_server_session_init(
- char* session_id, char* our_app, char* remote_service, char* remote_id );
-
-/** returns a session from the global session hash */
-osrf_app_session* osrf_app_session_find_session( char* session_id );
-
-/** Builds a new app_request object with the given payload andn returns
- * the id of the request. This id is then used to perform work on the
- * requeset.
- */
-int osrf_app_session_make_request(
- osrf_app_session* session, json* params,
- char* method_name, int protocol, string_array* arr );
-
-/** Sets the given request to complete state */
-void osrf_app_session_set_complete( osrf_app_session* session, int request_id );
-
-/** Returns true if the given request is complete */
-int osrf_app_session_request_complete( osrf_app_session* session, int request_id );
-
-/** Does a recv call on the given request */
-osrf_message* osrf_app_session_request_recv(
- osrf_app_session* session, int request_id, int timeout );
-
-/** Removes the request from the request set and frees the reqest */
-void osrf_app_session_request_finish( osrf_app_session* session, int request_id );
-
-/** Resends the orginal request with the given request id */
-int osrf_app_session_request_resend( osrf_app_session*, int request_id );
-
-/** Resets the remote connection target to that of the original*/
-void osrf_app_session_reset_remote( osrf_app_session* );
-
-/** Sets the remote target to 'remote_id' */
-void osrf_app_session_set_remote( osrf_app_session* session, char* remote_id );
-
-/** pushes the given message into the result list of the app_request
- * whose request_id matches the messages thread_trace
- */
-int osrf_app_session_push_queue( osrf_app_session*, osrf_message* msg );
-
-/** Attempts to connect to the remote service. Returns 1 on successful
- * connection, 0 otherwise.
- */
-int osrf_app_session_connect( osrf_app_session* );
-
-/** Sends a disconnect message to the remote service. No response is expected */
-int osrf_app_session_disconnect( osrf_app_session* );
-
-/** Waits up to 'timeout' seconds for some data to arrive.
- * Any data that arrives will be processed according to its
- * payload and message type. This method will return after
- * any data has arrived.
- */
-int osrf_app_session_queue_wait( osrf_app_session*, int timeout );
-
-/** Disconnects (if client), frees any attached app_reuqests, removes the session from the
- * global session cache and frees the session. Needless to say, only call this when the
- * session is completey done.
- */
-void osrf_app_session_destroy ( osrf_app_session* );
-
-
-
-// --------------------------------------------------------------------------
-// --------------------------------------------------------------------------
-// Request functions
-// --------------------------------------------------------------------------
-
-/** Allocations and initializes a new app_request object */
-osrf_app_request* _osrf_app_request_init( osrf_app_session* session, osrf_message* msg );
-
-/** Frees memory used by an app_request object */
-void _osrf_app_request_free( osrf_app_request * req );
-
-/** Pushes the given message onto the list of 'responses' to this request */
-void _osrf_app_request_push_queue( osrf_app_request*, osrf_message* payload );
-
-/** Checks the receive queue for messages. If any are found, the first
- * is popped off and returned. Otherwise, this method will wait at most timeout
- * seconds for a message to appear in the receive queue. Once it arrives it is returned.
- * If no messages arrive in the timeout provided, null is returned.
- */
-osrf_message* _osrf_app_request_recv( osrf_app_request* req, int timeout );
-
-/** Resend this requests original request message */
-int _osrf_app_request_resend( osrf_app_request* req );
-
-
-// --------------------------------------------------------------------------
-// --------------------------------------------------------------------------
-// Session functions
-// --------------------------------------------------------------------------
-
-/** Returns the app_request with the given thread_trace (request_id) */
-osrf_app_request* _osrf_app_session_get_request( osrf_app_session*, int thread_trace );
-
-/** frees memory held by a session. Note: We delete all requests in the request list */
-void _osrf_app_session_free( osrf_app_session* );
-
-/** adds a session to the global session cache */
-void _osrf_app_session_push_session( osrf_app_session* );
-
-/** removes from global session cache */
-void _osrf_app_session_remove_session( char* session_id );
-
-/** Adds an app_request to the request set */
-void _osrf_app_session_push_request( osrf_app_session*, osrf_app_request* req );
-
-/** Removes an app_request from this session request set, freeing the request object */
-void _osrf_app_session_remove_request( osrf_app_session*, osrf_app_request* req );
-
-/** Send the given message */
-int _osrf_app_session_send( osrf_app_session*, osrf_message* msg );
-
-#endif
+++ /dev/null
-#include "libjson/json.h"
-#include "opensrf/generic_utils.h"
-#include "opensrf/string_array.h"
-
-#ifndef osrf_message_h
-#define osrf_message_h
-
-#define OSRF_XML_NAMESPACE "http://open-ils.org/xml/namespaces/oils_v1"
-
-#define OSRF_STATUS_CONTINUE 100
-
-#define OSRF_STATUS_OK 200
-#define OSRF_STATUS_ACCEPTED 202
-#define OSRF_STATUS_COMPLETE 205
-
-#define OSRF_STATUS_REDIRECTED 307
-
-#define OSRF_STATUS_BADREQUEST 400
-#define OSRF_STATUS_UNAUTHORIZED 401
-#define OSRF_STATUS_FORBIDDEN 403
-#define OSRF_STATUS_NOTFOUND 404
-#define OSRF_STATUS_NOTALLOWED 405
-#define OSRF_STATUS_TIMEOUT 408
-#define OSRF_STATUS_EXPFAILED 417
-
-#define OSRF_STATUS_INTERNALSERVERERROR 500
-#define OSRF_STATUS_NOTIMPLEMENTED 501
-#define OSRF_STATUS_VERSIONNOTSUPPORTED 505
-
-
-enum M_TYPE { CONNECT, REQUEST, RESULT, STATUS, DISCONNECT };
-
-#define OSRF_MAX_PARAMS 128;
-
-struct osrf_message_struct {
-
- enum M_TYPE m_type;
- int thread_trace;
- int protocol;
-
- int parse_json_result;
- int parse_json_params;
-
- /* if we're a STATUS message */
- char* status_name;
-
- /* if we're a STATUS or RESULT */
- char* status_text;
- int status_code;
-
- int is_exception;
-
- /* if we're a RESULT */
- json* result_content;
-
- /* unparsed json string */
- char* result_string;
-
- /* if we're a REQUEST */
- char* method_name;
- json* params;
-
- /* in case anyone wants to make a list of us.
- we won't touch this variable */
- struct osrf_message_struct* next;
-
- string_array* parray;
- char* full_param_string;
-
-};
-typedef struct osrf_message_struct osrf_message;
-
-
-osrf_message* osrf_message_init( enum M_TYPE type, int thread_trace, int protocol );
-void osrf_message_set_request_info( osrf_message*, char* param_name, json* params );
-void osrf_message_set_status_info( osrf_message*, char* status_name, char* status_text, int status_code );
-void osrf_message_set_result_content( osrf_message*, char* json_string );
-void osrf_message_free( osrf_message* );
-char* osrf_message_to_xml( osrf_message* );
-/** Pushes any message retreived from the xml into the 'msgs' array.
- * it is assumed that 'msgs' has beenn pre-allocated.
- * Returns the number of message that are in the buffer.
- */
-int osrf_message_from_xml( char* xml, osrf_message* msgs[] );
-
-/* decides whether all message automatically parse incoming json data */
-/* to change a single message, set msg->parse_json accordingly */
-//void osrf_message_set_json_parse( int bool );
-
-void osrf_message_set_json_parse_result( int ibool );
-void osrf_message_set_json_parse_params( int ibool );
-
-
-void osrf_message_add_param( osrf_message*, char* param_string );
-
-
-
-
-#endif
+++ /dev/null
-#include "opensrf/transport_client.h"
-#include "osrf_message.h"
-#include "osrf_app_session.h"
-
-#ifndef OSRF_STACK_H
-#define OSRF_STACK_H
-
-/* the max number of oilsMessage blobs present in any one root packet */
-#define OSRF_MAX_MSGS_PER_PACKET 16
-// -----------------------------------------------------------------------------
-
-int osrf_stack_transport_handler( transport_message* msg );
-int osrf_stack_message_handler( osrf_app_session* session, osrf_message* msg );
-int osrf_stack_application_handler( osrf_app_session* session, osrf_message*msg );
-
-
-#endif
+++ /dev/null
-#include "opensrf/transport_client.h"
-
-#ifndef OSRF_SYSTEM_H
-#define OSRF_SYSTEM_H
-
-/** Connects to jabber. Returns 1 on success, 0 on failure */
-int osrf_system_bootstrap_client();
-transport_client* osrf_system_get_transport_client();
-
-int osrf_system_shutdown();
-
-#endif
+++ /dev/null
-#include <stdio.h>
-
-#include "opensrf/generic_utils.h"
-
-#define STRING_ARRAY_MAX_SIZE 1024
-
-#ifndef STRING_ARRAY_H
-#define STRING_ARRAY_H
-
-struct string_array_struct {
- char** array;
- int size;
- int arr_size;
- int total_string_size;
-};
-typedef struct string_array_struct string_array;
-
-string_array* init_string_array(int size);
-void string_array_add(string_array*, char* string);
-
-char* string_array_get_string(string_array* arr, int index);
-void string_array_destroy(string_array*);
-
-/* total size of all included strings */
-int string_array_get_total_size(string_array* arr);
-
-
-#endif
+++ /dev/null
-#include "opensrf/transport_session.h"
-#include <time.h>
-
-#ifndef TRANSPORT_CLIENT_H
-#define TRANSPORT_CLIENT_H
-
-#define MESSAGE_LIST_HEAD 1
-#define MESSAGE_LIST_ITEM 2
-
-
-// ---------------------------------------------------------------------------
-// Represents a node in a linked list. The node holds a pointer to the next
-// node (which is null unless set), a pointer to a transport_message, and
-// and a type variable (which is not really curently necessary).
-// ---------------------------------------------------------------------------
-struct message_list_struct {
- struct message_list_struct* next;
- transport_message* message;
- int type;
-};
-
-typedef struct message_list_struct transport_message_list;
-typedef struct message_list_struct transport_message_node;
-
-// ---------------------------------------------------------------------------
-// Our client struct. We manage a list of messages and a controlling session
-// ---------------------------------------------------------------------------
-struct transport_client_struct {
- transport_message_list* m_list;
- transport_session* session;
-};
-typedef struct transport_client_struct transport_client;
-
-// ---------------------------------------------------------------------------
-// Allocates and initializes and transport_client. This does no connecting
-// The user must call client_free(client) when finished with the allocated
-// object.
-// ---------------------------------------------------------------------------
-transport_client* client_init( char* server, int port, int component );
-
-// ---------------------------------------------------------------------------
-// Connects to the Jabber server with the provided information. Returns 1 on
-// success, 0 otherwise.
-// ---------------------------------------------------------------------------
-int client_connect( transport_client* client,
- char* username, char* password, char* resource,
- int connect_timeout, enum TRANSPORT_AUTH_TYPE auth_type );
-
-int client_disconnect( transport_client* client );
-
-// ---------------------------------------------------------------------------
-// De-allocates memory associated with a transport_client object. Users
-// must use this method when finished with a client object.
-// ---------------------------------------------------------------------------
-int client_free( transport_client* client );
-
-// ---------------------------------------------------------------------------
-// Sends the given message. The message must at least have the recipient
-// field set.
-// ---------------------------------------------------------------------------
-int client_send_message( transport_client* client, transport_message* msg );
-
-// ---------------------------------------------------------------------------
-// Returns 1 if this client is currently connected to the server, 0 otherwise
-// ---------------------------------------------------------------------------
-int client_connected( transport_client* client );
-
-// ---------------------------------------------------------------------------
-// This is the message handler required by transport_session. This handler
-// takes all incoming messages and puts them into the back of a linked list
-// of messages.
-// ---------------------------------------------------------------------------
-void client_message_handler( void* client, transport_message* msg );
-
-// ---------------------------------------------------------------------------
-// If there are any message in the message list, the 'oldest' message is
-// returned. If not, this function will wait at most 'timeout' seconds
-// for a message to arrive. Specifying -1 means that this function will not
-// return unless a message arrives.
-// ---------------------------------------------------------------------------
-transport_message* client_recv( transport_client* client, int timeout );
-
-
-#endif
+++ /dev/null
-#include "opensrf/generic_utils.h"
-
-#include <string.h>
-#include <libxml/globals.h>
-#include <libxml/xmlerror.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/debugXML.h>
-#include <libxml/xmlmemory.h>
-
-#ifndef TRANSPORT_MESSAGE_H
-#define TRANSPORT_MESSAGE_H
-
-
-
-// ---------------------------------------------------------------------------------
-// Jabber message object.
-// ---------------------------------------------------------------------------------
-struct transport_message_struct {
- char* body;
- char* subject;
- char* thread;
- char* recipient;
- char* sender;
- char* router_from;
- char* router_to;
- char* router_class;
- char* router_command;
- int is_error;
- char* error_type;
- int error_code;
- int broadcast;
- char* msg_xml; /* the entire message as XML complete with entity encoding */
-};
-typedef struct transport_message_struct transport_message;
-
-// ---------------------------------------------------------------------------------
-// Allocates and returns a transport_message. All chars are safely re-allocated
-// within this method.
-// Returns NULL on error
-// ---------------------------------------------------------------------------------
-transport_message* message_init( char* body, char* subject,
- char* thread, char* recipient, char* sender );
-
-transport_message* new_message_from_xml( const char* msg_xml );
-
-
-void message_set_router_info( transport_message* msg, char* router_from,
- char* router_to, char* router_class, char* router_command, int broadcast_enabled );
-
-// ---------------------------------------------------------------------------------
-// Formats the Jabber message as XML for encoding.
-// Returns NULL on error
-// ---------------------------------------------------------------------------------
-char* message_to_xml( const transport_message* msg );
-
-
-// ---------------------------------------------------------------------------------
-// Call this to create the encoded XML for sending on the wire.
-// This is a seperate function so that encoding will not necessarily have
-// to happen on all messages (i.e. typically only occurs outbound messages).
-// ---------------------------------------------------------------------------------
-int message_prepare_xml( transport_message* msg );
-
-// ---------------------------------------------------------------------------------
-// Deallocates the memory used by the transport_message
-// Returns 0 on error
-// ---------------------------------------------------------------------------------
-int message_free( transport_message* msg );
-
-// ---------------------------------------------------------------------------------
-// Prepares the shared XML document
-// ---------------------------------------------------------------------------------
-//int message_init_xml();
-
-// ---------------------------------------------------------------------------------
-// Determines the username of a Jabber ID. This expects a pre-allocated char
-// array for the return value.
-// ---------------------------------------------------------------------------------
-void jid_get_username( const char* jid, char buf[] );
-
-// ---------------------------------------------------------------------------------
-// Determines the resource of a Jabber ID. This expects a pre-allocated char
-// array for the return value.
-// ---------------------------------------------------------------------------------
-void jid_get_resource( const char* jid, char buf[] );
-
-/** Puts the domain portion of the given jid into the pre-allocated buffer */
-void jid_get_domain( const char* jid, char buf[] );
-
-void set_msg_error( transport_message*, char* error_type, int error_code);
-
-
-#endif
+++ /dev/null
-// ---------------------------------------------------------------------------------
-// Manages the Jabber session. Data is taken from the TCP object and pushed into
-// a SAX push parser as it arrives. When key Jabber documetn elements are met,
-// logic ensues.
-// ---------------------------------------------------------------------------------
-#include "opensrf/transport_socket.h"
-#include "opensrf/transport_message.h"
-#include "opensrf/generic_utils.h"
-
-#include "sha.h"
-
-#include <string.h>
-#include <libxml/globals.h>
-#include <libxml/xmlerror.h>
-#include <libxml/parser.h>
-#include <libxml/parserInternals.h> /* only for xmlNewInputFromFile() */
-#include <libxml/tree.h>
-#include <libxml/debugXML.h>
-#include <libxml/xmlmemory.h>
-
-#ifndef TRANSPORT_SESSION_H
-#define TRANSPORT_SESSION_H
-
-#define CONNECTING_1 1 /* just starting the connection to Jabber */
-#define CONNECTING_2 2 /* First <stream> packet sent and <stream> packet received from server */
-
-/* Note. these are growing buffers, so all that's necessary is a sane starting point */
-#define JABBER_BODY_BUFSIZE 4096
-#define JABBER_SUBJECT_BUFSIZE 64
-#define JABBER_THREAD_BUFSIZE 64
-#define JABBER_JID_BUFSIZE 64
-#define JABBER_STATUS_BUFSIZE 16
-
-// ---------------------------------------------------------------------------------
-// Takes data from the socket handler and pushes it directly into the push parser
-// ---------------------------------------------------------------------------------
-void grab_incoming( void * session, char* data );
-
-// ---------------------------------------------------------------------------------
-// Callback for handling the startElement event. Much of the jabber logic occurs
-// in this and the characterHandler callbacks.
-// Here we check for the various top level jabber elements: body, iq, etc.
-// ---------------------------------------------------------------------------------
-void startElementHandler(
- void *session, const xmlChar *name, const xmlChar **atts);
-
-// ---------------------------------------------------------------------------------
-// Callback for handling the endElement event. Updates the Jabber state machine
-// to let us know the element is over.
-// ---------------------------------------------------------------------------------
-void endElementHandler( void *session, const xmlChar *name);
-
-// ---------------------------------------------------------------------------------
-// This is where we extract XML text content. In particular, this is useful for
-// extracting Jabber message bodies.
-// ---------------------------------------------------------------------------------
-void characterHandler(
- void *session, const xmlChar *ch, int len);
-
-void parseWarningHandler( void *session, const char* msg, ... );
-void parseErrorHandler( void *session, const char* msg, ... );
-
-// ---------------------------------------------------------------------------------
-// Tells the SAX parser which functions will be used as event callbacks
-// ---------------------------------------------------------------------------------
-static xmlSAXHandler SAXHandlerStruct = {
- NULL, /* internalSubset */
- NULL, /* isStandalone */
- NULL, /* hasInternalSubset */
- NULL, /* hasExternalSubset */
- NULL, /* resolveEntity */
- NULL, /* getEntity */
- NULL, /* entityDecl */
- NULL, /* notationDecl */
- NULL, /* attributeDecl */
- NULL, /* elementDecl */
- NULL, /* unparsedEntityDecl */
- NULL, /* setDocumentLocator */
- NULL, /* startDocument */
- NULL, /* endDocument */
- startElementHandler, /* startElement */
- endElementHandler, /* endElement */
- NULL, /* reference */
- characterHandler, /* characters */
- NULL, /* ignorableWhitespace */
- NULL, /* processingInstruction */
- NULL, /* comment */
- parseWarningHandler, /* xmlParserWarning */
- parseErrorHandler, /* xmlParserError */
- NULL, /* xmlParserFatalError : unused */
- NULL, /* getParameterEntity */
- NULL, /* cdataBlock; */
- NULL, /* externalSubset; */
- 1,
- NULL,
- NULL, /* startElementNs */
- NULL, /* endElementNs */
- NULL /* xmlStructuredErrorFunc */
-};
-
-// ---------------------------------------------------------------------------------
-// Our SAX handler pointer.
-// ---------------------------------------------------------------------------------
-static const xmlSAXHandlerPtr SAXHandler = &SAXHandlerStruct;
-
-// ---------------------------------------------------------------------------------
-// Jabber state machine. This is how we know where we are in the Jabber
-// conversation.
-// ---------------------------------------------------------------------------------
-struct jabber_state_machine_struct {
- int connected;
- int connecting;
- int in_message;
- int in_message_body;
- int in_thread;
- int in_subject;
- int in_error;
- int in_message_error;
- int in_iq;
- int in_presence;
- int in_status;
-};
-typedef struct jabber_state_machine_struct jabber_machine;
-
-
-enum TRANSPORT_AUTH_TYPE { AUTH_PLAIN, AUTH_DIGEST };
-
-// ---------------------------------------------------------------------------------
-// Transport session. This maintains all the various parts of a session
-// ---------------------------------------------------------------------------------
-struct transport_session_struct {
-
- /* our socket connection */
- transport_socket* sock_obj;
- /* our Jabber state machine */
- jabber_machine* state_machine;
- /* our SAX push parser context */
- xmlParserCtxtPtr parser_ctxt;
-
- /* our text buffers for holding text data */
- growing_buffer* body_buffer;
- growing_buffer* subject_buffer;
- growing_buffer* thread_buffer;
- growing_buffer* from_buffer;
- growing_buffer* recipient_buffer;
- growing_buffer* status_buffer;
- growing_buffer* message_error_type;
- growing_buffer* session_id;
- int message_error_code;
-
- /* for OILS extenstions */
- growing_buffer* router_to_buffer;
- growing_buffer* router_from_buffer;
- growing_buffer* router_class_buffer;
- growing_buffer* router_command_buffer;
- int router_broadcast;
-
- /* this can be anything. It will show up in the
- callbacks for your convenience. We will *not*
- deallocate whatever this is when we're done. That's
- your job.
- */
- void* user_data;
-
- int component; /* true if we're a component */
-
- /* the Jabber message callback */
- void (*message_callback) ( void* user_data, transport_message* msg );
- //void (iq_callback) ( void* user_data, transport_iq_message* iq );
-};
-typedef struct transport_session_struct transport_session;
-
-
-// ------------------------------------------------------------------
-// Allocates and initializes the necessary transport session
-// data structures.
-// ------------------------------------------------------------------
-transport_session* init_transport( char* server, int port, void* user_data, int component );
-
-// ------------------------------------------------------------------
-// Returns the value of the given XML attribute
-// The xmlChar** construct is commonly returned from SAX event
-// handlers. Pass that in with the name of the attribute you want
-// to retrieve.
-// ------------------------------------------------------------------
-char* get_xml_attr( const xmlChar** atts, char* attr_name );
-
-// ------------------------------------------------------------------
-// Waits at most 'timeout' seconds for data to arrive from the
-// TCP handler. A timeout of -1 means to wait indefinitely.
-// ------------------------------------------------------------------
-int session_wait( transport_session* session, int timeout );
-
-// ---------------------------------------------------------------------------------
-// Sends the given Jabber message
-// ---------------------------------------------------------------------------------
-int session_send_msg( transport_session* session, transport_message* msg );
-
-// ---------------------------------------------------------------------------------
-// Returns 1 if this session is connected to the jabber server. 0 otherwise
-// ---------------------------------------------------------------------------------
-int session_connected( transport_session* );
-
-// ------------------------------------------------------------------
-// Deallocates session memory
-// ------------------------------------------------------------------
-int session_free( transport_session* session );
-
-// ------------------------------------------------------------------
-// Connects to the Jabber server. Waits at most connect_timeout
-// seconds before failing
-// ------------------------------------------------------------------
-int session_connect( transport_session* session,
- const char* username, const char* password,
- const char* resource, int connect_timeout,
- enum TRANSPORT_AUTH_TYPE auth_type );
-
-int session_disconnect( transport_session* session );
-
-int reset_session_buffers( transport_session* session );
-
-#endif
+++ /dev/null
-#include "opensrf/generic_utils.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <errno.h>
-
-//---------------------------------------------------------------
-// WIN32
-//---------------------------------------------------------------
-#ifdef WIN32
-#include <Windows.h>
-#include <Winsock.h>
-#else
-
-//---------------------------------------------------------------
-// Unix headers
-//---------------------------------------------------------------
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#endif
-
-#ifndef TRANSPORT_SOCKET_H
-#define TRANSPORT_SOCKET_H
-
-/* how many characters we read from the socket at a time */
-#ifdef _ROUTER
-#define BUFSIZE 412
-#else
-#define BUFSIZE 4096
-#endif
-
-/* we maintain the socket information */
-struct transport_socket_struct {
- int sock_fd;
- int connected;
- char* server;
- int port;
- void * user_data;
- /* user_data may be anything. it's whatever you wish
- to see showing up in the callback in addition to
- the acutal character data*/
- void (*data_received_callback) (void * user_data, char*);
-};
-typedef struct transport_socket_struct transport_socket;
-
-int tcp_connect( transport_socket* obj );
-int tcp_send( transport_socket* obj, const char* data );
-int tcp_disconnect( transport_socket* obj );
-int tcp_wait( transport_socket* obj, int timeout );
-int tcp_connected( transport_socket* obj );
-
-/* utility methods */
-int set_fl( int fd, int flags );
-int clr_fl( int fd, int flags );
-
-
-#endif