On 21 Mar 2001, Jason E. Stewart wrote:

> "Aaron Kaplan" <[EMAIL PROTECTED]> writes:
> 
> > Basically what I am trying to do is: write a C wrapper so that
> > xerces can be embedded in an apache module. Maybe this is the wrong
> > approach, so any other suggestions would be welcome as well.  (note
> > however that I need to access it from C due to other restrictions)
> 
> I guess I'd have to know more about what you're tyring to do, to
> suggest a different approach. Does it need to be an apache module,
> meaning is CGI out of the question?


Hello,

yes CGI is out of the question.

Ok, here is what I am trying to do:
I want to use xerces as the front-end parser to xml , let it validate an
XML request against a dtd, build up the DOM tree and provide a C interface
for traversing the DOM and getting the node names / attribute values.

The calling backend C program takes this data (from traversing the DOM), 
processes the request and prints out XML answers to the client.


In other words:

   web client <----> httpd <----> module + xerces <-----> backend in C
                                                              ^
                                                              |
                                                              |
                                                              |
                                                              v
                                                           database

my C interface for the backend C program looks something like this:

----------- snip ----------

extern "C" {


#include <....xerces stuff >

typedef void*        pTDomNode;
typedef void*        pTDomParser;
typedef void*        pTDomAttr;


extern const char *TDomGetNodeName      ( const pTDomNode p );
extern const char *TDomGetNodeValue     ( const pTDomNode p );

extern   pTDomNode TDomGetParentNode    ( const pTDomNode p );
extern   pTDomNode TDomGetFirstChild    ( const pTDomNode p );
extern   pTDomNode TDomGetNextSibling   ( const pTDomNode p );
extern   int       TDomGetCountChildren ( const pTDomNode p );
extern   int       TDomHasChildNodes    ( const pTDomNode p );

/*---------------------------------------------------------------------------*/
                                            /* methods for TDomAttr */
extern BOOL        TDomHasAttributes    ( const pTDomNode p);
extern const char *TDomGetAttrName      ( const pTDomAttr p );
extern const char *TDomGetAttrValue     ( const pTDomAttr p );

extern   pTDomAttr TDomGetAttributeNode ( const pTDomNode p, const char
*name );
extern   pTDomAttr TDomGetParentAttributeNode ( const pTDomNode p, 
                                                const char *name );

/*---------------------------------------------------------------------------*/
                                            /* methods for Parser */

extern pTDomDocument TDomGetDocument ( const pTDomParser p );

/*---------------------------------------------------------------------------*/
                                            /* error handling */
                          
extern int   TDomLastError ( char *retBuf, int retBufSize );

/*---------------------------------------------------------------------------*/
                                            /* init, end */
                          
extern int TDomLibInit      ( void );
extern int TDomLibTerminate ( void );
extern int TDomTranscoderDelete  ( void );

extern int TDomCreateTranscoder ( char *targetEnc );
extern int TDomParserCreate ( pTDomParser *p );
extern int TDomParserReset  ( pTDomParser  p );

extern int TDomParserParse  ( pTDomParser  p, const char *fname );
extern int TDomParserDelete ( pTDomParser *p );

extern char *TDomGetEncoding ( const pTDomParser p );
extern int TDomTranscoderTranscode ( const char *buf, unsigned int srclen, 
                                char *dest, BOOL bDoEscape);

} /* end extern "C" */


----------- snip ----------


So you can see, basically I wrap up some Xerces functions by C functions.
These C functions are compiled with C++ and talk to xerces.

The calling C backend always holds a void* pointer to the current
DOM_Node, or DOMParser object. 

Memory keeps growing and growing int the C interface. 

Would you rather recommend using a C++ class to wrap things up instead of
using C functions which are compiled with C++ ?

greetings,
aaron.


 > 
> I have wrapped Xerces to provide the perl interface, but the wrapping
> is done in C++ to be friendly with Xerces' memory management.
> 
> jas.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to