/*@P************************************************************************
 * File           : EVCHK32.C
 * Project        : EVERLOCK EVCHK.OBJ Win32S Interface DLL
 * Author         : M. Brendan Van Horn
 * Compiler       : Borland C++ v4.02
 * Description    :
 *
 * Copyright (c) 1995 Az-Tech Software, Inc.
 * ALL RIGHTS RESERVED
 ************************************************************************P@*/

#define STRICT
#define W32SUT_32                // indicate 32-bit side of Win32S interface
#include <windows.h>
#include <w32sut.h>
#include "evsb.h"
#include "evchk32.h"

static int cProcessesAttached = 0;
static UT32PROC pThunk = 0;

//@PB
#pragma argsused
BOOL WINAPI __export DllEntryPoint( HINSTANCE hInstance, DWORD dwReason, LPVOID junk )
{
   switch ( dwReason )
   {
      case DLL_PROCESS_ATTACH:

         // increment the process attach count & possibly just return
         if ( cProcessesAttached++ )
            return TRUE;

         // register a universal thunk to access the 16-bit EVCHK3.DLL
         return UTRegister( hInstance, "EVCHK3.DLL", NULL, "evchk_proc", &pThunk,
                            NULL, NULL );

      case DLL_PROCESS_DETACH:

         // decrement the process attach count & possibly just return
         if ( --cProcessesAttached )
            return FALSE;

         // unregister the universal thunk we registered before
         UTUnRegister( hInstance );

         break;
   }

   return FALSE;
}

//@PB
int __pascal __export evchk32( SB *pSCB )
{
   // make sure the thunk has been setup previously
   if ( !pThunk )
   {
      // no thunk has been setup so let's report an error
      pSCB->stat1 = 0x7006;
      pSCB->stat2 = 0;
      pSCB->stat3 = 0;

      // return to the caller
      return 0;

   } else

      // use the given thunk to call the evchk_proc in the EVCHK3.DLL
      return (*pThunk)( pSCB, 0, NULL );
}
