RegisterForEventNotification

Registers an operation to be called when the specified event occurs.

Library:LibC
Classification:NetWare OS
Service:NetWare Platform

Syntax

  #include <event.h> 
   
  event_handle_t RegisterForEventNotification (
     rtag_t     rtag,
     int        type,
     int        priority,
     Warn_t     warn,
     Report_t   report,
     void      *userParm);
  

Parameters

rtag

(IN) Specifies a resource tag. See AllocateResourceTag.

type

(IN) Specifies the event type. See Event Types.

priority

(IN) Specifies the priority for the operation and uses one of the following:

Flag

Value

Description

EVENT_PRIORITY_APPLICATION

20

Highest priority

EVENT_PRIORITY_DEVICE

40

Lowest priority

warn

(IN) Specifies the warning routine. This can be NULL if the report parameter is not also NULL.

report

(IN) Specifies the reporting routine. This can be NULL if the warn parameter is not also NULL.

userParm

(IN) Points to an optional parameter, which you define for your use.

Return Values

If successful, returns an event handle. Otherwise, returns 0.

Remarks

If your application is multiprocessor safe, you must OR the EVENT_CONSUMER_MT_SAFE flag with the type parameter when registering for a nonblocking event.

You do not have to supply both a warn routine and a report routine, but to register for event notification you must supply one or other. If both are NULL, you fail to register for the event. The function pointer to these callback routines must be wrappered with the NX_WRAP_INTERFACE macro to ensure accurate library context is established.

The warn routine notifies you before the event occurs, and the report routine notifies you after the event has occurred. The type of routine must correlate with the event. For example, if the event type is server down, then the routine needs to be a warn routine because the server cannot process a report routine after it is down.

Report Routine

The report routine has the following syntax:

  typedef void (*Report_t)(
     void   *parm,
     void   *userParm);
  
  
parm

Points to the data type or structure associated with the event type. For list of these data types, see Event Types.

userParm

Points to an optional parameter, which you define for your use.

Warn Routine

The warn routine has the following syntax:

  typedef int (*Warn_t)(
     void   *printf,
     void   *parm,
     void   *userParm);
  
  
printf

Points to a print format command.

parm

Points to the data type or structure associated with the event type. For list of these data types, see Event Types.

userParm

Points to an optional parameter, which you define for your use.

See Also

Example

  #include <event.h>
  rtag_t            eventRTag;
  event_handle_t    downEvent;
  
  eventRTag = AllocateResourceTag(NLMHandle, "Server down
              event", EventSignature);
  
  downEvent = RegisterForEventNotification(eventRTag,
              EVENT_DOWN_SERVER | EVENT_CONSUMER_MT_SAFE ,
              EVENT_PRIORITY_APPLICATION,
              warnFunc, (void *) NULL, NULL);
  
  . . . 
  
  UnRegisterEventNotification(downEvent);