From 6ebcdc26987d467ced90b4ce44ca0889785a09ea Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 10 Oct 2005 20:23:41 +0000 Subject: [PATCH] various tweaks git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@547 9efc2488-bf62-4759-914b-345cdb29e865 --- bin/opensrf_all | 15 +++++++-------- src/Makefile | 2 +- src/libstack/Makefile | 1 + src/libtransport/transport_client.c | 6 +++++- src/srfsh/srfsh.c | 4 ++-- src/utils/socket_bundle.c | 8 ++++---- src/utils/xml_utils.c | 28 ++++++++++++++++++++++++++++ src/utils/xml_utils.h | 12 ++++++++++++ 8 files changed, 60 insertions(+), 16 deletions(-) diff --git a/bin/opensrf_all b/bin/opensrf_all index be84350..a8e7fce 100755 --- a/bin/opensrf_all +++ b/bin/opensrf_all @@ -38,15 +38,15 @@ ROUTER="1"; OPENSRF="1"; OPENSRFC="1"; -JSERVERSOCK="$PREFIX/var/sock/jserver.sock"; # jabber server socket file -JSERVERLOG="$LOGDIR/jserver.log" # jabber server log +#JSERVERSOCK="$PREFIX/var/sock/jserver.sock"; # jabber server socket file +#JSERVERLOG="$LOGDIR/jserver.log" # jabber server log JSERVERPORT=5222; # jabber server port -JSERVERLEVEL=3; # can be 1-4, 4 is the highest -JSERVERIP="*"; # can be "*" or a specific local IP address +#JSERVERLEVEL=3; # can be 1-4, 4 is the highest +#JSERVERIP="*"; # can be "*" or a specific local IP address # -------------------------------------------------------------------------- # -------------------------------------------------------------------------- -JSERVERBIN="jserver-c" +JSERVERBIN="chopchop" export LD_LIBRARY_PATH="$PREFIX/lib:$LD_LIBRARY_PATH"; export PERL5LIB="$PREFIX/lib/perl5:$PERL5LIB"; export PATH="$PREFIX/bin:$PATH"; @@ -76,8 +76,7 @@ function startJserver { [ ! -z "$ACTIVE" ] && fail "Port $JSERVERPORT is busy...exiting"; fi; - rm -f "$JSERVERSOCK"; - "$BINDIR/$JSERVERBIN" $JSERVERPORT "$JSERVERIP" "$JSERVERSOCK" "$JSERVERLEVEL" "$JSERVERLOG" + "$BINDIR/$JSERVERBIN" "$ETCDIR/opensrf_core.xml" "chopchop"; } @@ -139,7 +138,7 @@ function stopMe { sleep 1; echo "Stopping Chop Chop..."; - killall -9 jserver-c; + killall -9 chopchop; return 0; } diff --git a/src/Makefile b/src/Makefile index 10f9a17..6658318 100644 --- a/src/Makefile +++ b/src/Makefile @@ -80,7 +80,7 @@ libopensrf.so: objson/libobjson.so @echo stack make -C libstack @echo $@ - $(CC) -shared -W1 $(LDFLAGS) -lJudy -lmemcache -lobjson $(OPENSRF_TARGETS) -o $(TMPDIR)/$(LIBOPENSRF) + $(CC) -shared -W1 $(LDFLAGS) -lJudy -lxml2 -lmemcache -lobjson $(OPENSRF_TARGETS) -o $(TMPDIR)/$(LIBOPENSRF) @echo apps make -C c-apps diff --git a/src/libstack/Makefile b/src/libstack/Makefile index badde68..d773262 100644 --- a/src/libstack/Makefile +++ b/src/libstack/Makefile @@ -61,3 +61,4 @@ osrf_hash.o: osrf_hash.c osrf_hash.h clean: /bin/rm -f *.o libopensrf_stack.so xml_utils.h xml_utils.c opensrf + diff --git a/src/libtransport/transport_client.c b/src/libtransport/transport_client.c index 61af363..ba383ea 100644 --- a/src/libtransport/transport_client.c +++ b/src/libtransport/transport_client.c @@ -116,7 +116,10 @@ transport_message* client_recv( transport_client* client, int timeout ) { if( timeout == -1 ) { /* wait potentially forever for data to arrive */ while( client->m_list->next == NULL ) { - if( ! session_wait( client->session, -1 ) ) { + // if( ! session_wait( client->session, -1 ) ) { + int x; + if( (x = session_wait( client->session, -1 )) ) { + warning_handler("session_wait returned failure code %d\n", x); return NULL; } } @@ -161,6 +164,7 @@ transport_message* client_recv( transport_client* client, int timeout ) { msg = node->message; free( node ); return msg; + } else { return NULL; } diff --git a/src/srfsh/srfsh.c b/src/srfsh/srfsh.c index 6de6183..9d003bb 100644 --- a/src/srfsh/srfsh.c +++ b/src/srfsh/srfsh.c @@ -751,8 +751,8 @@ char* tabs(int count) { } int handle_math( char* words[] ) { - if( words[1] && words[2] ) - return do_math( atoi(words[1]), atoi(words[2]) ); + if( words[1] ) + return do_math( atoi(words[1]), 0 ); return 0; } diff --git a/src/utils/socket_bundle.c b/src/utils/socket_bundle.c index f2976dd..b3f1683 100644 --- a/src/utils/socket_bundle.c +++ b/src/utils/socket_bundle.c @@ -163,7 +163,7 @@ int socket_open_tcp_client(socket_manager* mgr, int port, char* dest_addr) { // Create the socket // ------------------------------------------------------------------ if( (sock_fd = socket( AF_INET, SOCK_STREAM, 0 )) < 0 ) { - fatal_handler( "tcp_connect(): Cannot create socket" ); + warning_handler( "tcp_connect(): Cannot create socket" ); return -1; } @@ -176,7 +176,7 @@ int socket_open_tcp_client(socket_manager* mgr, int port, char* dest_addr) { // Get the hostname // ------------------------------------------------------------------ if( (hptr = gethostbyname( dest_addr ) ) == NULL ) { - fatal_handler( "tcp_connect(): Unknown Host => %s", dest_addr ); + warning_handler( "tcp_connect(): Unknown Host => %s", dest_addr ); return -1; } @@ -201,7 +201,7 @@ int socket_open_tcp_client(socket_manager* mgr, int port, char* dest_addr) { // Bind to a local port // ------------------------------------------------------------------ if( bind( sock_fd, (struct sockaddr *) &localAddr, sizeof( localAddr ) ) < 0 ) { - fatal_handler( "tcp_connect(): Cannot bind to local port" ); + warning_handler( "tcp_connect(): Cannot bind to local port" ); return -1; } @@ -209,7 +209,7 @@ int socket_open_tcp_client(socket_manager* mgr, int port, char* dest_addr) { // Connect to server // ------------------------------------------------------------------ if( connect( sock_fd, (struct sockaddr*) &remoteAddr, sizeof( struct sockaddr_in ) ) < 0 ) { - fatal_handler( "tcp_connect(): Cannot connect to server %s", dest_addr ); + warning_handler( "tcp_connect(): Cannot connect to server %s", dest_addr ); return -1; } diff --git a/src/utils/xml_utils.c b/src/utils/xml_utils.c index 52071d4..15a350b 100644 --- a/src/utils/xml_utils.c +++ b/src/utils/xml_utils.c @@ -85,3 +85,31 @@ char* xmlDocToString(xmlDocPtr doc, int full) { } + + +char* xmlSaxAttr( const xmlChar** atts, char* name ) { + if( atts && name ) { + int i; + for(i = 0; (atts[i] != NULL); i++) { + if(!strcmp(atts[i], name)) { + if(atts[++i]) return (char*) atts[i]; + } + } + } + return NULL; +} + + +int xmlAddAttrs( xmlNodePtr node, const xmlChar** atts ) { + if( node && atts ) { + int i; + for(i = 0; (atts[i] != NULL); i++) { + if(atts[i+1]) { + xmlSetProp(node, atts[i], atts[i+1]); + i++; + } + } + } + return 0; +} + diff --git a/src/utils/xml_utils.h b/src/utils/xml_utils.h index 3b6c936..a329061 100644 --- a/src/utils/xml_utils.h +++ b/src/utils/xml_utils.h @@ -21,4 +21,16 @@ void recurse_doc( xmlNodePtr node ); */ char* xmlDocToString(xmlDocPtr doc, int full); + +/* Takes an xmlChar** from a SAX callback and returns the value + for the attribute with name 'name' + */ +char* xmlSaxAttr( const xmlChar** atts, char* name ); + +/** + Sets the xml attributes from atts to the given dom node + */ +int xmlAddAttrs( xmlNodePtr node, const xmlChar** atts ); + + #endif -- 2.11.0