Re: Any suggestion please how to transfer a struct as user data ?

"Gert Cuykens" <[email protected]>
Newsgroups gmane.text.xml.expat.general
Message-ID <[email protected]>
On 7/19/07, Nick MacDonald <[email protected]> wrote:
> Start with this, quickly typed by hand and not compiled, but should work:
>
>
> struct mydata
> {
>   unsigned int type;  /*  If you think you might need more than one
> type of structure */
>   unsigned int a;
>   unsigned int b;  /* or whatever */
> };
>
> typedef stuct mydata  *ptr2mydata;
>
> /* global instance */
> struct mydata myglobaldata;
>
>
> main()
> {
>   void* userDataPtr = &myglobaldata;
>   someExpatFunction(..., userDataPtr);
> }
>
>
> someExpatCallback(..., passes in userData,...)
> {
>   ptr2mydata myuserdata=(ptr2mydata)userData;  /* a cast */
>
>   printf("In function %s, userData->a=%u\n", __FUNCTION__, myuserdata->a);
>
>  /* and so on */
> }
>
> Good luck...
>

Works now :) thanks too Sebastian Pipping

static void
characterData(void *userData, const XML_Char *s, int l)
{
 PAGE *page = (PAGE *)userData;
 page->add(page,"test");
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.