Thunderstone Software Document Search, Retrieval, and Management
Search:
Texis Manual
 

Special Types: ncgfunc

The ncgfunc type is used to setup callbacks from the server to the client. A callback registration function uses ncgfunc where it expects the callback function pointer. A callback registration function must also have at least one "void *" argument that will also be passed to the callback function.

The prototype for the func arg of the callback registration function is obtained from an "extern ncgfunc" declaration of the callback function name. All callbacks return an int indicating whether to continue or cancel the process that called it. Zero means cancel, non-zero means continue.

Example:

/* globals to remember callback in */
int (*g_callback)(void *usr,SRCH *sr,ncgstr url);
void *g_usrdata;
%%
/* provide prototype for "ncgfunc cb" arg of reghitcb() */
extern ncgfunc cb(void *usr,SRCH *sr,ncgstr hit);

int reghitcb(void *usr,ncgfunc cb)
{
 g_usrdata=usr;
 g_callback=cb;
}
int search(SRCH *sr)
{
 ...
 while(moretosearch)
    if(hitfound)
         if(!(*g_callback)(g_usrdata,sr,hit))
              break;
 ...
}
%%
int mycallback(void *mystuff,SRCH *sr,char *hit)
{
 ...
 puts(hit);
 ...
}
main()
{
 SERVER *se;
 SRCH *sr;
 void *mystuff;
 ...
    n_reghitcb(se,mystuff,mycallback);
    n_search(se,sr);
 ...
}


Copyright © Thunderstone Software     Last updated: Sun Mar 17 21:14:49 EDT 2013
 
Home   ::   Products   ::   Solutions   ::   How to Buy   ::   Support   ::   Contact Us   ::   News   ::   About
Copyright © 2013 Thunderstone Software LLC. All rights reserved.