From 64dd0f8d7b0c20383c02eabd580c77e9a9218cd4 Mon Sep 17 00:00:00 2001 From: scottmk Date: Fri, 9 Jan 2009 18:51:01 +0000 Subject: [PATCH] Move the xmlSAXHandler out of the header and into the implementation file, along with the declarations of the associated callback functions (which are now static) git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1613 9efc2488-bf62-4759-914b-345cdb29e865 --- include/opensrf/transport_session.h | 67 ------------------------- src/libopensrf/transport_session.c | 77 +++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/include/opensrf/transport_session.h b/include/opensrf/transport_session.h index d7b4447..425b977 100644 --- a/include/opensrf/transport_session.h +++ b/include/opensrf/transport_session.h @@ -37,73 +37,6 @@ extern "C" { #define JABBER_JID_BUFSIZE 64 #define JABBER_STATUS_BUFSIZE 16 -// --------------------------------------------------------------------------------- -// 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. diff --git a/src/libopensrf/transport_session.c b/src/libopensrf/transport_session.c index 366f14c..f8eab3a 100644 --- a/src/libopensrf/transport_session.c +++ b/src/libopensrf/transport_session.c @@ -1,5 +1,72 @@ #include +// --------------------------------------------------------------------------------- +// 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. +// --------------------------------------------------------------------------------- +static 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. +// --------------------------------------------------------------------------------- +static 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. +// --------------------------------------------------------------------------------- +static void characterHandler( + void *session, const xmlChar *ch, int len); + +static void parseWarningHandler( void *session, const char* msg, ... ); +static 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; + #ifndef HOST_NAME_MAX #define HOST_NAME_MAX 256 #endif @@ -319,7 +386,7 @@ static void grab_incoming(void* blob, socket_manager* mgr, int sockid, char* dat } -void startElementHandler( +static void startElementHandler( void *session, const xmlChar *name, const xmlChar **atts) { transport_session* ses = (transport_session*) session; @@ -447,7 +514,7 @@ static char* get_xml_attr( const xmlChar** atts, const char* attr_name ) { // ------------------------------------------------------------------ // See which tags are ending // ------------------------------------------------------------------ -void endElementHandler( void *session, const xmlChar *name) { +static void endElementHandler( void *session, const xmlChar *name) { transport_session* ses = (transport_session*) session; if( ! ses ) { return; } @@ -562,7 +629,7 @@ static int reset_session_buffers( transport_session* ses ) { // takes data out of the body of the message and pushes it into // the appropriate buffer // ------------------------------------------------------------------ -void characterHandler( +static void characterHandler( void *session, const xmlChar *ch, int len) { const char* p = (const char*) ch; @@ -599,7 +666,7 @@ void characterHandler( } /* XXX change to warning handlers */ -void parseWarningHandler( void *session, const char* msg, ... ) { +static void parseWarningHandler( void *session, const char* msg, ... ) { va_list args; va_start(args, msg); @@ -609,7 +676,7 @@ void parseWarningHandler( void *session, const char* msg, ... ) { fprintf(stderr, "XML WARNING: %s\n", msg ); } -void parseErrorHandler( void *session, const char* msg, ... ){ +static void parseErrorHandler( void *session, const char* msg, ... ){ va_list args; va_start(args, msg); -- 2.43.2