/*
_____       _    _    Corso   Italia,  178
(_|__   .  (_   |_|_  56125           Pisa
(_|_) |)|(()_)()| |   tel.  +39  050 46380
  |   |               picosoft@picosoft.it

 picoSqlNet - picoSQL client library

 Copyright (C) Picosoft s.r.l. 1994-2002

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
static char rcsid[] = "$Id: dllshell.cpp 4.0 1998/10/27 16:20:13 picoSoft Exp picoSoft $";

#include <windows.h>

extern "C" {
# include "connectn.h"
# include "except.h"
HINSTANCE ghInstance;
}

# ifdef WIN32

BOOL WINAPI DllMain (HANDLE hInstance, 
         ULONG ul_reason_for_call,
         LPVOID lpReserved)
{
   Exception *ex = 0;
   switch (ul_reason_for_call) {
   case DLL_PROCESS_ATTACH:
      ghInstance = (HINSTANCE) hInstance;
      CORBA_init();
      Connection_init(ex);
      return TRUE;
   case DLL_PROCESS_DETACH:
      Connection_exit(ex);
      return TRUE;
   case DLL_THREAD_ATTACH:
   case DLL_THREAD_DETACH:
      return TRUE;
   }
   return FALSE;
}

# else

int FAR PASCAL LibMain( HINSTANCE hInstance, WORD wDataSegment,
                                   WORD wHeapSize, LPSTR lpszCmdLine )
{
   Exception *ex = 0;
   ghInstance = hInstance;

   Connection_init(ex);
   return 1;
}
                            

int FAR PASCAL WEP ( int bSystemExit )
{
    Exception *ex = 0;
    Connection_exit(ex);
    return 1;
}
# endif
