home *** CD-ROM | disk | FTP | other *** search
/ Sams Cobol 24 Hours / Sams_Cobol_24_Hours.iso / Cobol32 / CRW / 32BIT / DISK6 / UFMAIN.C_ / UFMAIN.C
C/C++ Source or Header  |  1995-08-29  |  4KB  |  173 lines

  1. /*
  2. ** File:    UFMain.c
  3. ** Author:  Rick Cameron, Rex Benning
  4. ** Date:    7 Mar 93
  5. **
  6. ** Purpose: The main file for a user-defined function DLL.
  7. */
  8.  
  9. #include <Windows.h>
  10. #include "UFDll.h"
  11. #include "UFFuncs.h"
  12. #include "UFMain.h"
  13. #include "UFUser.h"
  14.  
  15. HINSTANCE UFInstance = 0;
  16.  
  17. UFFunctionDefStringList FunctionDefStringList =
  18. {
  19.        {sizeof (UFFunctionDefStringList)},
  20.        {FunctionDefStrings}
  21. };
  22.  
  23. UFFunctionTemplateList FunctionTemplateList =
  24. {
  25.        {sizeof (UFFunctionTemplateList)},
  26.        {FunctionTemplates}
  27. };
  28.  
  29. UFFunctionExampleList FunctionExampleList =
  30. {
  31.        {sizeof (UFFunctionExampleList)},
  32.        {FunctionExamples}
  33. };
  34.  
  35. #if defined(WIN16)
  36. int FAR PASCAL LibMain (HINSTANCE hInstance,
  37.                         WORD      wDataSeg,
  38.                         WORD      cbHeapSize,
  39.                         LPSTR     lpCmdLine)
  40. {
  41.     UFInstance = hInstance;
  42.  
  43.     return TRUE;
  44. }
  45.  
  46. int FAR PASCAL WEP (int nParam)
  47. {
  48.     return 1;
  49. }
  50. #elif defined(WIN32)
  51. BOOL WINAPI DllEntryPoint(HINSTANCE  hInstance,    // handle of DLL module 
  52.                           DWORD  fdwReason,    // reason for calling function 
  53.                           LPVOID  lpvReserved)     // reserved 
  54. {
  55.     UFInstance = hInstance;
  56.     return TRUE;
  57. }
  58.  
  59. #endif
  60.  
  61. ExternC UFError FAR PASCAL _export UFInitialize ()
  62. {
  63.     return (UFNoError);
  64. }
  65.  
  66. ExternC short FAR _export PASCAL UFGetVersion ()
  67. {
  68.     return CurVersionNumber;
  69. }
  70.  
  71. ExternC UFError FAR PASCAL _export UFTerminate ()
  72. {
  73.     return (UFNoError);
  74. }
  75.  
  76. ExternC UFFunctionTemplateList FAR * FAR PASCAL _export UFGetFunctionTemplates ()
  77. {
  78.     return (&FunctionTemplateList);
  79. }
  80.  
  81. ExternC UFFunctionExampleList FAR * FAR PASCAL _export UFGetFunctionExamples ()
  82. {
  83.     return (&FunctionExampleList);
  84. }
  85.  
  86. ExternC UFFunctionDefStringList FAR * FAR _export PASCAL UFGetFunctionDefStrings ()
  87. {
  88.     return (&FunctionDefStringList);
  89. }
  90.  
  91. ExternC char FAR * FAR _export PASCAL UFErrorRecovery (UFParamBlock FAR *paramPtr,
  92.                                                        UFError errN)
  93. {
  94.     return ErrorTable [(UFTInt16u)paramPtr->ReturnValue.UFReturnUserError];
  95. }
  96.  
  97. ExternC void FAR _export PASCAL UFStartJob (UFTInt32u jobId)
  98. {
  99.     // initialize any job-related data structures
  100.     InitForJob (jobId);
  101. }
  102.  
  103. ExternC void FAR _export PASCAL UFEndJob (UFTInt32u jobId)
  104. {
  105.     // clean up any job-related data structures
  106.     TermForJob (jobId);
  107. }
  108.  
  109.  
  110. /* GetParam
  111. ** This is a routine internal to the DLL. It should be copied into every
  112. ** DLL as a standard access to the parameter block.
  113. */
  114.  
  115. UFParamListElement FAR *GetParam (UFParamBlock FAR *Param,
  116.                                   UFTInt16s ParamNumber)
  117. {
  118.     UFParamListElement FAR *ParamPtr = Param->UFParamList;
  119.  
  120.     while (--ParamNumber && (ParamPtr != NULL))
  121.         ParamPtr = ParamPtr->NextParam;
  122.  
  123.     return ParamPtr;
  124. }
  125.  
  126. /* GetMemCalcParam
  127. ** This routine gets the parameters from the list passed to memory allocation
  128. ** (string length or array size) calculation routine.
  129. */
  130.  
  131. UFMemCalcParam FAR *GetMemCalcParam (UFMemCalcBlock FAR *Param,
  132.                                      UFTInt16s ParamNumber)
  133. {
  134.     UFMemCalcParam FAR *ParamPtr = Param->UFMemCalcParamList;
  135.  
  136.     while (--ParamNumber && (ParamPtr != NULL))
  137.         ParamPtr = ParamPtr->NextMemCalcParam;
  138.  
  139.     return ParamPtr;
  140. }
  141.  
  142. /* GetMemCalcParam
  143. ** This routines gets array-element sub-arguments from the chain
  144. ** of arguments passed to the memory calculation routines.
  145. */
  146.  
  147. UFMemCalcParam FAR *GetMemCalcArrayElement (UFMemCalcParam FAR *Param,
  148.                                             UFTInt16s ParamNumber)
  149. {
  150.     UFMemCalcParam FAR *ParamPtr = Param->MemCalcParameter.MemCalcSubParam;
  151.  
  152.     while (--ParamNumber && (ParamPtr != NULL))
  153.         ParamPtr = ParamPtr->NextMemCalcParam;
  154.  
  155.     return ParamPtr;
  156. }
  157.  
  158. /* GetMemCalcRunParam
  159. ** This is a routine internal to the DLL. It should be copied into every
  160. ** DLL as a standard access to the parameter block.
  161. */
  162.  
  163. UFParamListElement FAR *GetMemCalcRunParam (UFMemCalcBlock FAR *Param,
  164.                                             UFTInt16s ParamNumber)
  165. {
  166.     UFParamListElement FAR *ParamPtr = Param->UFParamList;
  167.  
  168.     while (--ParamNumber && (ParamPtr != NULL))
  169.         ParamPtr = ParamPtr->NextParam;
  170.  
  171.     return ParamPtr;
  172. }
  173.