Figure 127. Sample User Exit Program
/*********************************************************************** * Name: USEREXITSAMPLE.C * Description: Example user-exit program that is invoked by * the TSM V3 Server * Environment: ********************************************* * ** This is a platform-specific source file ** * ** versioned for: "WINDOWS NT" ** * ********************************************* ***********************************************************************/ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <io.h> #include <windows.h> #include "USEREXITSAMPLE.H" /************************************** *** Do not modify below this line. *** **************************************/ #define DllExport __declspec(dllexport) /**************** *** DLL MAIN *** ****************/ BOOL WINAPI DllMain(HMODULE hMod, DWORD fdwReason, LPVOID lpvReserved) { return(TRUE); } // End of WINAPI
/****************************************************************** * Procedure: adsmV3UserExit * If the user-exit is specified on the server, a valid and * appropriate event will cause an elEventRecvData structure * (see USEREXITSAMPLE.H) to be passed to a procedure named * adsmV3UserExit that returns a void. * * This procedure can be named differently: * ---------------------------------------- * The procedure name must match the function name specified in * the server options file (4th arg). The DLL name generated from * this module must also match in the server options file * (3rd arg). * INPUT : A (void *) to the elEventRecvData structure * RETURNS: Nothing ******************************************************************/ DllExport void adsmV3UserExit( void *anEvent ) { /* Typecast the event data passed */ elEventRecvData *eventData = (elEventRecvData *)anEvent; /************************************** *** Do not modify above this line. *** **************************************/ fprintf(stderr,"NT UserExit: Got event %d\n",eventData->eventNum); if( ( eventData->eventNum == USEREXIT_END_EVENTNUM ) || ( eventData->eventNum == END_ALL_RECEIVER_EVENTNUM ) ) { /* Server says to end this user-exit. Perform any cleanup, * * but do NOT exit() !!! */ return; } /* Field Access: eventData->.... */ /* Your code here ... */ return; /* For picky compilers */ } /* End of adsmV3UserExit() */