home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sams Cobol 24 Hours
/
Sams_Cobol_24_Hours.iso
/
Cobol32
/
CRW
/
32BIT
/
DISK6
/
UFMAIN.C_
/
UFMAIN.C
Wrap
C/C++ Source or Header
|
1995-08-29
|
4KB
|
173 lines
/*
** File: UFMain.c
** Author: Rick Cameron, Rex Benning
** Date: 7 Mar 93
**
** Purpose: The main file for a user-defined function DLL.
*/
#include <Windows.h>
#include "UFDll.h"
#include "UFFuncs.h"
#include "UFMain.h"
#include "UFUser.h"
HINSTANCE UFInstance = 0;
UFFunctionDefStringList FunctionDefStringList =
{
{sizeof (UFFunctionDefStringList)},
{FunctionDefStrings}
};
UFFunctionTemplateList FunctionTemplateList =
{
{sizeof (UFFunctionTemplateList)},
{FunctionTemplates}
};
UFFunctionExampleList FunctionExampleList =
{
{sizeof (UFFunctionExampleList)},
{FunctionExamples}
};
#if defined(WIN16)
int FAR PASCAL LibMain (HINSTANCE hInstance,
WORD wDataSeg,
WORD cbHeapSize,
LPSTR lpCmdLine)
{
UFInstance = hInstance;
return TRUE;
}
int FAR PASCAL WEP (int nParam)
{
return 1;
}
#elif defined(WIN32)
BOOL WINAPI DllEntryPoint(HINSTANCE hInstance, // handle of DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved) // reserved
{
UFInstance = hInstance;
return TRUE;
}
#endif
ExternC UFError FAR PASCAL _export UFInitialize ()
{
return (UFNoError);
}
ExternC short FAR _export PASCAL UFGetVersion ()
{
return CurVersionNumber;
}
ExternC UFError FAR PASCAL _export UFTerminate ()
{
return (UFNoError);
}
ExternC UFFunctionTemplateList FAR * FAR PASCAL _export UFGetFunctionTemplates ()
{
return (&FunctionTemplateList);
}
ExternC UFFunctionExampleList FAR * FAR PASCAL _export UFGetFunctionExamples ()
{
return (&FunctionExampleList);
}
ExternC UFFunctionDefStringList FAR * FAR _export PASCAL UFGetFunctionDefStrings ()
{
return (&FunctionDefStringList);
}
ExternC char FAR * FAR _export PASCAL UFErrorRecovery (UFParamBlock FAR *paramPtr,
UFError errN)
{
return ErrorTable [(UFTInt16u)paramPtr->ReturnValue.UFReturnUserError];
}
ExternC void FAR _export PASCAL UFStartJob (UFTInt32u jobId)
{
// initialize any job-related data structures
InitForJob (jobId);
}
ExternC void FAR _export PASCAL UFEndJob (UFTInt32u jobId)
{
// clean up any job-related data structures
TermForJob (jobId);
}
/* GetParam
** This is a routine internal to the DLL. It should be copied into every
** DLL as a standard access to the parameter block.
*/
UFParamListElement FAR *GetParam (UFParamBlock FAR *Param,
UFTInt16s ParamNumber)
{
UFParamListElement FAR *ParamPtr = Param->UFParamList;
while (--ParamNumber && (ParamPtr != NULL))
ParamPtr = ParamPtr->NextParam;
return ParamPtr;
}
/* GetMemCalcParam
** This routine gets the parameters from the list passed to memory allocation
** (string length or array size) calculation routine.
*/
UFMemCalcParam FAR *GetMemCalcParam (UFMemCalcBlock FAR *Param,
UFTInt16s ParamNumber)
{
UFMemCalcParam FAR *ParamPtr = Param->UFMemCalcParamList;
while (--ParamNumber && (ParamPtr != NULL))
ParamPtr = ParamPtr->NextMemCalcParam;
return ParamPtr;
}
/* GetMemCalcParam
** This routines gets array-element sub-arguments from the chain
** of arguments passed to the memory calculation routines.
*/
UFMemCalcParam FAR *GetMemCalcArrayElement (UFMemCalcParam FAR *Param,
UFTInt16s ParamNumber)
{
UFMemCalcParam FAR *ParamPtr = Param->MemCalcParameter.MemCalcSubParam;
while (--ParamNumber && (ParamPtr != NULL))
ParamPtr = ParamPtr->NextMemCalcParam;
return ParamPtr;
}
/* GetMemCalcRunParam
** This is a routine internal to the DLL. It should be copied into every
** DLL as a standard access to the parameter block.
*/
UFParamListElement FAR *GetMemCalcRunParam (UFMemCalcBlock FAR *Param,
UFTInt16s ParamNumber)
{
UFParamListElement FAR *ParamPtr = Param->UFParamList;
while (--ParamNumber && (ParamPtr != NULL))
ParamPtr = ParamPtr->NextParam;
return ParamPtr;
}