-#include "opensrf/generic_utils.h"
+#include "generic_utils.h"
#include <stdio.h>
#include "pthread.h"
#include <sys/timeb.h>
+/*
void get_timestamp( char buf_36chars[]) {
struct timeb tb;
free(localtime);
}
-/*
-double get_timestamp_millis() {
- struct timeb t;
- ftime(&t);
- double time = ( (int)t.time + ( ((double)t.millitm) / 1000 ) );
- return time;
-}
-
-
-inline void* safe_malloc( int size ) {
- void* ptr = (void*) malloc( size );
- if( ptr == NULL )
- fatal_handler("safe_malloc(): Out of Memory" );
- memset( ptr, 0, size );
- return ptr;
-}
-*/
-
-
static FILE* log_file = NULL;
static int log_level = -1;
static int logging = 0;
}
- /* also log to stderr for ERRORS*/
fprintf( stderr, "[%s %d] [%s] ", buf, pid, "ERR " );
va_start(args, msg);
vfprintf(stderr, msg, args);
}
+*/
+
/*
growing_buffer* buffer_init(int num_initial_bytes) {
-#include "opensrf/transport_session.h"
+#include "transport_session.h"
char stanza1[ size1 ];
memset( stanza1, 0, size1 );
sprintf( stanza1,
- "<stream:stream version='1.0' xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:component:accept' to='%s' from='%s' xml:lang='en'>",
+ "<stream:stream version='1.0' xmlns:stream='http://etherx.jabber.org/streams' "
+ "xmlns='jabber:component:accept' to='%s' from='%s' xml:lang='en'>",
username, our_hostname );
/* send the first stanze */
char stanza1[ size1 ];
memset( stanza1, 0, size1 );
sprintf( stanza1,
- "<stream:stream to='%s' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>",
+ "<stream:stream to='%s' xmlns='jabber:client' "
+ "xmlns:stream='http://etherx.jabber.org/streams'>",
server );
memset( stanza2, 0, size2 );
sprintf( stanza2,
- "<iq id='123456789' type='set'><query xmlns='jabber:iq:auth'><username>%s</username><password>%s</password><resource>%s</resource></query></iq>",
+ "<iq id='123456789' type='set'><query xmlns='jabber:iq:auth'>"
+ "<username>%s</username><password>%s</password><resource>%s</resource></query></iq>",
username, password, resource );
-
- /*
- <iq type='set' id='auth2'>
- <query xmlns='jabber:iq:auth'>
- <username>bill</username>
- <digest>48fc78be9ec8f86d8ce1c39c320c97c21d62334d</digest>
- <resource>globe</resource>
- </query>
- </iq>
- */
-
-
/* server acknowledges our existence, now see if we can login */
if( session->state_machine->connecting == CONNECTING_2 ) {
if( ! tcp_send( session->sock_obj, stanza2 ) ) {
memset( stanza2, 0, size2 );
sprintf( stanza2,
- "<iq id='123456789' type='set'><query xmlns='jabber:iq:auth'><username>%s</username><digest>%s</digest><resource>%s</resource></query></iq>",
+ "<iq id='123456789' type='set'><query xmlns='jabber:iq:auth'>"
+ "<username>%s</username><digest>%s</digest><resource>%s</resource></query></iq>",
username, hash, resource );
-
- /*
- <iq type='set' id='auth2'>
- <query xmlns='jabber:iq:auth'>
- <username>bill</username>
- <digest>48fc78be9ec8f86d8ce1c39c320c97c21d62334d</digest>
- <resource>globe</resource>
- </query>
- </iq>
- */
-
-
/* server acknowledges our existence, now see if we can login */
if( session->state_machine->connecting == CONNECTING_2 ) {
if( ! tcp_send( session->sock_obj, stanza2 ) ) {
if( strcmp( name, "message" ) == 0 ) {
+
+ /*
+ int bufsize;
+ xmlChar* xmlbuf;
+ xmlDocDumpFormatMemory( ses->parser_ctxt->myDoc, &xmlbuf, &bufsize, 0 );
+ debug_handler("endElementHandler SAX Doc:\n%s\n", (char*) xmlbuf );
+ xmlFree(xmlbuf);
+ */
+
/* pass off the message info the callback */
if( ses->message_callback ) {
va_list args;
va_start(args, msg);
- fprintf(stdout, "WARNING");
+ fprintf(stdout, "transport_session XML WARNING");
vfprintf(stdout, msg, args);
va_end(args);
fprintf(stderr, "XML WARNING: %s\n", msg );
va_list args;
va_start(args, msg);
- fprintf(stdout, "ERROR");
+ fprintf(stdout, "transport_session XML ERROR");
vfprintf(stdout, msg, args);
va_end(args);
fprintf(stderr, "XML ERROR: %s\n", msg );
-#include "opensrf/transport_socket.h"
+#include "transport_socket.h"
/*
// returns the socket fd, -1 on error
int tcp_connect( transport_socket* sock_obj ){
+
if( sock_obj == NULL ) {
fatal_handler( "connect(): null sock_obj" );
return -1;
}
+
struct sockaddr_in remoteAddr, localAddr;
struct hostent *hptr;
int sock_fd;
#endif
-
// ------------------------------------------------------------------
// Create the socket
// ------------------------------------------------------------------
}
+
int tcp_disconnect( transport_socket* sock_obj ){
if( sock_obj == NULL ) {
return 0;
}
+
int n = 0;
int retval = 0;
char buf[BUFSIZE];
int sock_fd = sock_obj->sock_fd;
-
fd_set read_set;
FD_ZERO( &read_set );
#ifdef _ROUTER
return n;
#else
- return 1;
+ return sock_fd;
#endif
}
-int set_fl( int fd, int flags ) {
-
- int val;
-
- if( (val = fcntl( fd, F_GETFL, 0) ) < 0 ) {
- fatal_handler("fcntl F_GETFL error");
- return -1;
- }
-
- val |= flags;
-
- if( fcntl( fd, F_SETFL, val ) < 0 ) {
- fatal_handler( "fcntl F_SETFL error" );
- return -1;
- }
- return 0;
-}
-
-int clr_fl( int fd, int flags ) {
-
- int val;
-
- if( (val = fcntl( fd, F_GETFL, 0) ) < 0 ) {
- fatal_handler("fcntl F_GETFL error" );
- return -1;
- }
-
- val &= ~flags;
-
- if( fcntl( fd, F_SETFL, val ) < 0 ) {
- fatal_handler( "fcntl F_SETFL error" );
- return -1;
- }
- return 0;
-}
-
/*
int tcp_connected( transport_socket* obj ) {