how to intercept EVENT_LOGIN_USER (NetWare)
#include <nwadv.h>
#include <nwconn.h>
#include <nwerrno.h>
#include <nwthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
static int threadCount = 0;
static int exitRequested = 0;
static int mainThreadID;
static int mainThreadGroupID;
static void sigHandler( int sig_no) {
#ifdef __MWERKS__
#pragma unused( sig_no)
#endif
int saved_thread_group_ID = SetThreadGroupID( mainThreadGroupID);
signal( SIGTERM, sigHandler);
exitRequested = !0;
ResumeThread( mainThreadID);
while ( threadCount) delay( 100);
SetThreadGroupID( saved_thread_group_ID);
}
static void eventProc( LONG param, LONG user_param) {
#ifdef __MWERKS__
#pragma unused( user_param)
#endif
char objectName[ 256];
WORD objectType;
long objectID;
BYTE loginTime[ 7];
int ccode;
++threadCount;
printf( "logged in conn = %d, ", param);
ccode = GetConnectionInformation(( WORD) param, objectName, &objectType, &objectID, loginTime);
if ( ccode != 0) printf( "GetConnectionInformation failed, ccode = %d\n", ccode);
else printf( "objectName = %s\n", objectName);
--threadCount;
}
int main() {
LONG event_handle;
++threadCount;
mainThreadID = GetThreadID();
mainThreadGroupID = GetThreadGroupID();
signal( SIGTERM, sigHandler);
event_handle = RegisterForEvent( EVENT_LOGIN_USER, eventProc, NULL);
if ( event_handle == EFAILURE) {
signal( SIGTERM, SIG_DFL);
puts( "RegisterForEvent failed");
return EXIT_FAILURE;
}
puts( "Waiting...");
SuspendThread( mainThreadID);
UnregisterForEvent( event_handle);
--threadCount;
return EXIT_SUCCESS;
}
© 2008 Novell, Inc. All Rights Reserved.