NCPX_EventLoop(3xti_ncp)


NCPX_EventLoop -- controls dispatch of incoming extended NCPs

Synopsis

#include <ncpx_app.h> 

int NCPX_EventLoop(NCPX_EventLoopState *exitReason);

Description

NCPX_EventLoop controls the dispatch of incoming extended NCPs to the developer-written callback functions. It also returns the results to the NWS server (which then returns the results to the client which originated the request).

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.

Parameters

(OUT) exitReason
Passes a pointer to a variable, the value of which identifies the reason why the EventLoop has exited.

Return values

0
Successful

non-zero
Unsuccessful

Examples

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; }


30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.