#include <ncpx_app.h>int NCPX_EventLoop(NCPX_EventLoopState
exitReason);
NCPX_EventLoop should be called after a developer-written HandlerMain has finished application-specific initialization and NCP extension registration. Calling NCPX_EventLoop is not optional and should not be delayed because extended NCPs begin queuing for services as soon as the extension is registered. See ``Writing an NCPX program'' for more information on HandlerMain.
NCPX_EventLoop has one parameter: this is a pointer to a variable of type NCPX_EventLoopState. When the EventLoop returns, it will set the NCPX_EventLoopState variable to a value identifying the reason why the EventLoop has exited.
typedef enum { EL_RUNNING = 0, /* Never returned. */ EL_EXIT_ERROR, EL_EXIT_ALL_HANDLERS_DEREGISTERED, EL_EXIT_SERVER_GOING_DOWN, EL_EXIT_SIGNAL_SHUTDOWN, } NCPX_EventLoopState;See ``NCPX in a UnixWare execution environment'' for more information on EventLoop.
int HandlerMain( int argc, char *argv[] ) { int ccode; void *queryData;NCPX_EventLoopState el_state;
/*********************************************/ /* Register the extension. */
ccode = NWRegisterNCPExtension("TEST EXTENSION", NCP_callback, ConnectionEvent_callback, NULL, /* No reply-buffer-manager callback. */ 1, /* major version */ 2, /* minor version */ 3, /* revision */ &queryData); if ( ccode != 0) { printf("%s had failure (ccode %d) registering NCP Extension.\n", ExecName, ccode); exit(1); }
/*********************************************/ /* Commence processing of NCPs: callbacks will come when we */ /* have work to do. */
NCPX_EventLoop( &el_state);
/*********************************************/ /* DeRegister the extension. */
ccode = NWDeRegisterNCPExtension( queryData); if ( ccode != 0) { printf("%s had failure (ccode %d) DEregistering NCP Extension.\n", ExecName, ccode); exit(1); }
return 0; }