
/*
 * This file was generated by the SOM Compiler.
 * FileName: eventi.c.
 * Generated using:
 *     SOM Precompiler somipc: 2.29.1.19
 *     SOM Emitter emitimod.dll: 2.49
 */
/*
 * The functions contained within this source file are used to
 * initialize/uninitialize the SOMObjects 3.0 style class library named
 * event.dll.
 *
 * The functions contained are:
 *
 * - createClasses               Calls NewClass procedures for all classes
 * - somInitTermDependents       For initializing dependent classes
 * - eventSOMInitTerm    Main init/term function
 * - SOMInitModule               Entry used by SOM runtime after library loading
 *
 * The following functions in this source file may be customized:
 *
 * - somInitTermDependents
 * - eventSOMInitTerm
 *
 * Search for lines containing !!! for the the places where these functions
 * may be customized.
 *
 * This source file may be conditionally compiled for OS/2, AIX and Windows.
 *
 *    OS/2 C Set ++ users:  Compile with flag -DDYNA_LINK_C if you are
 *                          dynamically linking the C runtimes.
 *
 *    Windows users:        Compile with flag -D_WIN16
 *
 *    AIX users:            Be sure to customize somInitTermDependents
 *                          appropriately.
 *
 * Note: This file was generated based on the contents of the file
 *       imod.efw in the toolkit include directory.
 *
 */
#if defined __OS2__
  #define INCL_DOSMODULEMGR
  #include <os2.h>
#elif defined(_WIN32)
  #define WIN32_LEAN_AND_MEAN
  #include <windows.h>
#else
  #ifdef _WIN16
  #include <windows.h>
  #endif
#endif
#include <som.h>
#define SOM_LIBRARY_INITIALIZE 0L
#define SOM_LIBRARY_TERMINATE  1L
#ifdef SOM_STRICT_IDL
  typedef SOMClass imodSOMClass;
#else
  typedef SOMClass *imodSOMClass;
#endif
#if defined(__IBMC__) &&  defined(__OS2__)
#pragma linkage(SOMInitModule, system)
#pragma linkage(eventSOMInitTerm, system)
#pragma linkage(somTP_NewClassFn, system)
#pragma linkage(createClasses, system)
#endif
typedef imodSOMClass SOMLINK somTP_NewClassFn(integer4 majv, integer4 minv);
typedef somTP_NewClassFn *SOMNewClassFnPtr;

/* <NewClassProcExterns> follow this line. Do not remove this line. */
SOMEXTERN imodSOMClass SOMLINK CellNewClass(integer4 majv, integer4 minv);
SOMEXTERN imodSOMClass SOMLINK EventChannelAdmin_ConsumerAdminNewClass(integer4 majv, integer4 minv);
SOMEXTERN imodSOMClass SOMLINK EventChannelAdmin_SupplierAdminNewClass(integer4 majv, integer4 minv);
SOMEXTERN imodSOMClass SOMLINK EventChannelAdmin_EventChannelNewClass(integer4 majv, integer4 minv);
SOMEXTERN imodSOMClass SOMLINK EventComm_EventConnectionNewClass(integer4 majv, integer4 minv);
SOMEXTERN imodSOMClass SOMLINK EventComm_ConsumerNewClass(integer4 majv, integer4 minv);
SOMEXTERN imodSOMClass SOMLINK EventComm_SupplierNewClass(integer4 majv, integer4 minv);
/* <NewClassProcExterns> inserted above this line. Do not remove this line. */

/* Do not change the name of the following array. The imod emitter  */
/* depends on the name of the array to locate and add               */
/* secondary NewClass calls.                                        */
static SOMNewClassFnPtr somInitModArray[] = {
 (SOMNewClassFnPtr)CellNewClass,
 (SOMNewClassFnPtr)EventChannelAdmin_ConsumerAdminNewClass,
 (SOMNewClassFnPtr)EventChannelAdmin_SupplierAdminNewClass,
 (SOMNewClassFnPtr)EventChannelAdmin_EventChannelNewClass,
 (SOMNewClassFnPtr)EventComm_EventConnectionNewClass,
 (SOMNewClassFnPtr)EventComm_ConsumerNewClass,
 (SOMNewClassFnPtr)EventComm_SupplierNewClass,
}; /* Do not remove this line. */

static long numSOMClasses = sizeof(somInitModArray)/sizeof(SOMNewClassFnPtr);

/* This function is called to create the SOM class objects for this
 * class library. The class objects are destroyed at termination time.
 */
static void SOMLINK createClasses(void)
{
   SOMNewClassFnPtr *ncp;
   int i;
   for (i = 0, ncp = (SOMNewClassFnPtr *)somInitModArray;
        i < numSOMClasses ; ncp++, i++)
      (*ncp)(0,0);
}

#if defined(__OS2__)||defined(_WIN32)
  #define SOM_SYS_DEPENDENT_INITTERM(flag) 0
  /*
   * Init/term processing for load time links is handled by the OS.
   */
#else
  /*
   * The somInitTermDependents function is provided for systems that must
   * perform init/term processing for references to other SOM class
   * library externals that this class library is dependent upon and
   * that are resolved at load time (as opposed to references resolved by run
   * time dynamic linking).
   *
   * On AIX, for example: if this class library, a.dll, has explicit
   * references to externals in the class library b.dll that are resolved
   * at link time, then somInitTermDependents should call that class library's
   * <dllstem>SOMInitTerm function explicitly:
   *
   *        rc = bSOMInitTerm(flag);
   *
   */
  #define SOM_SYS_DEPENDENT_INITTERM(flag) somInitTermDependents(flag)
  static long somInitTermDependents(unsigned long flag)
  {
     long rc = 0L; /* success */

     /*
      *  !!! Place user customization here !!!
      *  for example:  rc = bSOMInitTerm(flag);
      */
     return(rc);
  }
#endif

/*
 * This function provides an initialization and termination function for a
 * SOM class library.
 *
 * The function returns zero to indicate success.
 *
 * System notes:
 *
 *    AIX: This function must be exported by the class library.
 *
 *    OS2: This function may be exported by the class library but it is not
 *         required.
 *
 */
SOMEXTERN long SOMLINK eventSOMInitTerm (unsigned long flag)
{
   long rc = 0L; /* success */

   switch (flag) {
      case SOM_LIBRARY_INITIALIZE:
         if (SOM_SYS_DEPENDENT_INITTERM(flag) == 0) {
            somRegisterClassLibrary("event.dll",
                                    (somMethodProc*)createClasses);
            /*
             *  !!! Place user customization here !!!
             */
         }
         break;

      case SOM_LIBRARY_TERMINATE:
         somUnregisterClassLibrary("event.dll");
         rc = SOM_SYS_DEPENDENT_INITTERM(flag);
         /*
          *  !!! Place user customization here !!!
          */
         break;

       default:
         rc = 1L; /* Failure */
   }
   return(rc);
}

/*
 * This function is called by the SOM run time in response to
 * a call to somFindClass, following the loading of a class library.
 */
SOMEXTERN void SOMLINK SOMInitModule( long majorVersion,
                                      long minorVersion,
                                      string className )
{
   eventSOMInitTerm(SOM_LIBRARY_INITIALIZE);
}

#if defined(__OS2__) || defined(_WIN32)
#define INITTERM_SUCCESS 1
#define INITTERM_FAILURE 0

#if defined(__IBMC__)||defined(__IBMCPP__) /* IBM C Set ++ */
  #ifdef __cplusplus
  extern "C" {
  #endif
  int _CRT_init (void);
  void _CRT_term (void);
  void __ctordtorInit(void);
  void __ctordtorTerm(void);
#ifdef _WIN32
  #define DLL_INITTERM \
   unsigned long _System _DLL_InitTerm (HMODULE hMod , \
                                        DWORD fdwReason, LPVOID lpvReserved)
#else
  #define DLL_INITTERM \
   unsigned long _System _DLL_InitTerm (unsigned long hModule, \
                                        unsigned long flag)
#endif
  #ifdef __cplusplus
  }
  #endif
  /*
   * Note: define DYNA_LINK_C if you are dynamically linking to the
   *       C runtime library.
   */
  #ifndef DYNA_LINK_C /* C Set runtime is not dynamically linked (default) */
     #define CRUNTIME_INIT if (_CRT_init() == -1) \
                              return(INITTERM_FAILURE)
  #else
     #define CRUNTIME_INIT
  #endif
  #ifndef DYNA_LINK_C /* C Set runtime is not dynamically linked (default) */
     #define CRUNTIME_TERM _CRT_term()
  #else
     #define CRUNTIME_TERM
  #endif
  #define CPPRUNTIME_INIT __ctordtorInit()
  #define CPPRUNTIME_TERM __ctordtorTerm()

#elif defined(__BCPLUSPLUS__)||defined(__BORLANDC__)||defined(_MSC_VER)
  #define DLL_INITTERM \
     BOOL WINAPI DllMain(HMODULE hMod , \
                                        DWORD fdwReason, LPVOID lpvReserved)
     #define CRUNTIME_INIT
     #define CRUNTIME_TERM
     #define CPPRUNTIME_INIT 
     #define CPPRUNTIME_TERM 

#elif defined(__WATCOMC__)
  #define DLL_INITTERM \
   unsigned long _DLL_InitTerm (unsigned long hModule, \
                                unsigned long flag); \
   static unsigned long modHandle() \
   {HMODULE hModule; DosQueryModuleHandle("event", &hModule); \
    return((unsigned long)hModule);}\
   int __dll_initialize() \
   {return((int)_DLL_InitTerm(modHandle(), SOM_LIBRARY_INITIALIZE));}\
   int __dll_terminate() \
   {return((int)_DLL_InitTerm(modHandle(), SOM_LIBRARY_TERMINATE));}\
   unsigned long _DLL_InitTerm (unsigned long hModule, \
                                unsigned long flag)
  #define CRUNTIME_INIT
  #define CRUNTIME_TERM
  #define CPPRUNTIME_INIT
  #define CPPRUNTIME_TERM

#elif defined(__HIGHC__)
  #define DLL_INITTERM \
   unsigned long _DLL_InitTerm (unsigned long hModule, \
                                unsigned long flag)
  #define CRUNTIME_INIT
  #define CRUNTIME_TERM
  #define CPPRUNTIME_INIT
  #define CPPRUNTIME_TERM

#else  /* default */
  #define DLL_INITTERM \
   unsigned long _System _DLL_InitTerm (unsigned long hModule, \
                                        unsigned long flag)
  #define CRUNTIME_INIT
  #define CRUNTIME_TERM
  #define CPPRUNTIME_INIT
  #define CPPRUNTIME_TERM
#endif

#ifdef _WIN32
/* <_WIN32_EXIT_HANDLER>: DO NOT REMOVE THIS and the FOLLOWING LINE */
#undef _WIN32_EXIT_HANDLER

#ifdef _WIN32_EXIT_HANDLER
SOMEXTERN void SOMLINK SOM_TERMINATION_HANDLER(void);
#endif

DLL_INITTERM
{
unsigned long rc = INITTERM_SUCCESS;

  switch (fdwReason) {

    case DLL_PROCESS_ATTACH:
         CRUNTIME_INIT ; 
         CPPRUNTIME_INIT;
         rc = (eventSOMInitTerm(SOM_LIBRARY_INITIALIZE))?
		INITTERM_FAILURE :INITTERM_SUCCESS;
    break;

    case DLL_PROCESS_DETACH:
#ifdef _WIN32_EXIT_HANDLER
	SOM_TERMINATION_HANDLER();
#endif
         eventSOMInitTerm(SOM_LIBRARY_TERMINATE);
         CPPRUNTIME_TERM; /* Zeynal, defect 26191:calling order swaped. */
         CRUNTIME_TERM;
    break;

    case DLL_THREAD_ATTACH:
    break;

    case DLL_THREAD_DETACH:
    break;

    default:
         return 0UL;
  }

  return rc;
}
#else /* _WIN32 */
DLL_INITTERM
{
   unsigned long rc = INITTERM_SUCCESS;

   switch (flag) {
      case SOM_LIBRARY_INITIALIZE:
         CRUNTIME_INIT;
         CPPRUNTIME_INIT;
         rc = (eventSOMInitTerm(flag))?INITTERM_FAILURE
                                              :INITTERM_SUCCESS;
         break;

      case SOM_LIBRARY_TERMINATE:
         eventSOMInitTerm(flag);
         CPPRUNTIME_TERM;
         CRUNTIME_TERM;
         break;

       default:
         rc = INITTERM_FAILURE;
   }
   return(rc);
}
#endif /* _WIN32 */
#else /* __OS2__ || _WIN32 */
  #ifdef _WIN16
  int CALLBACK LibMain (HINSTANCE inst, WORD ds, WORD heapSize, LPSTR cmdLine)
  {
      SOM_IgnoreWarning (inst);
      SOM_IgnoreWarning (ds);
      SOM_IgnoreWarning (heapSize);
      SOM_IgnoreWarning (cmdLine);

      eventSOMInitTerm(SOM_LIBRARY_INITIALIZE);
      return 1;
  }
  #endif
#endif /* __OS2__ || _WIN32*/

