home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / PERPRO_1.ZIP / FUNC_DLL / PERFFUNC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-06  |  4.5 KB  |  124 lines

  1. /***********************************************************************
  2.  *
  3.  *      Program   : perffunc.c
  4.  *
  5.  *      Comments  : PerFORM PRO custom function template
  6.  *
  7.  **********************************************************************/
  8.  
  9. #include "windows.h"
  10. #include "perffunc.h"
  11.  
  12. #include "stdlib.h"     /* required for the atof() functions */
  13.  
  14. /***********************************************************************
  15.  *
  16.  *      Procedure : LibMain (HANDLE, WORD, WORD, LPSTR)
  17.  *
  18.  *      Comments  :
  19.  *         Is called by LibEntry.  LibEntry is called by Windows when
  20.  *         the DLL is loaded.  The LibEntry routine is provided in
  21.  *         the LIBENTRY.OBJ in the SDK Link Libraries disk.  (The
  22.  *         source LIBENTRY.ASM is also provided.)  
  23.  * 
  24.  *         LibEntry initializes the DLL's heap, if a HEAPSIZE value is
  25.  *         specified in the DLL's DEF file.  Then LibEntry calls
  26.  *         LibMain.  The LibMain function below satisfies that call.
  27.  *         
  28.  *         The LibMain function should perform additional initialization
  29.  *         tasks required by the DLL.  In this example, no initialization
  30.  *         tasks are required.  LibMain should return a value of 1 if
  31.  *         the initialization is successful.
  32.  *
  33.  **********************************************************************/
  34. int FAR PASCAL LibMain(hModule, wDataSeg, cbHeapSize, lpszCmdLine)
  35. HANDLE  hModule;
  36. WORD    wDataSeg;
  37. WORD    cbHeapSize;
  38. LPSTR   lpszCmdLine;
  39. {
  40.     return 1;
  41. }
  42.  
  43. /***********************************************************************
  44.  *
  45.  *      Procedure : WEP (int)
  46.  *
  47.  *      Comments  :
  48.  *          Performs cleanup tasks when the DLL is unloaded.  WEP() is
  49.  *          called automatically by Windows when the DLL is unloaded
  50.  *          (no remaining tasks still have the DLL loaded).  It is
  51.  *          strongly recommended that a DLL have a WEP() function,
  52.  *          even if it does nothing but return, as in this example.
  53.  *
  54.  **********************************************************************/
  55. VOID FAR PASCAL WEP (bSystemExit)
  56. int  bSystemExit;
  57. {
  58.     return;
  59. }
  60.  
  61. /***********************************************************************
  62.  *
  63.  *      Procedure : PerformStrFunc
  64.  *
  65.  *      Comments  :
  66.  *              This is the user function that performs the calculation.
  67.  *              The routine is passed the maximum number of characters 
  68.  *              ('maxsize') that can be stored in the resulting string
  69.  *              (which is pointed to by the long pointer 'result'). All
  70.  *              the parameters ('parm1' to 'parm4') are all strings,
  71.  *              The designer need not utilize all of the parameters
  72.  *
  73.  *      Return Value :
  74.  *              The application can return an integer status indicator
  75.  *                  0 - success
  76.  *                  1 - failure
  77.  *              PerFORM will assume that no valid calculation data exists
  78.  *              if a return code of 1 is received
  79.  *
  80.  **********************************************************************/
  81. int FAR PASCAL PerformStrFunc (int maxsize, LPSTR result, LPSTR parm1, 
  82.                 LPSTR parm2, LPSTR parm3, LPSTR parm4)
  83. {
  84. /*
  85.  *  this sample simply concatenates the first and second parameters and 
  86.  *  stores the result string in the at 'result'
  87.  */
  88.     if (lstrlen(parm1) + lstrlen(parm2) > maxsize) {
  89.         return (1);
  90.     }
  91.     lstrcpy (result, parm1);
  92.     lstrcat (result, parm2);
  93.     return (0);
  94. }
  95.  
  96. /***********************************************************************
  97.  *
  98.  *      Procedure : PerformNumFunc
  99.  *
  100.  *      Comments  :
  101.  *              This is the user function that performs the calculation.
  102.  *              This function takes up to 4 string parameters and returns
  103.  *              a numeric result at the address pointed to by the 
  104.  *              'result' pointer. 
  105.  *              The parameters ('parm1' to 'parm4') are all strings,
  106.  *              The designer need not utilize all of the available
  107.  *              parameters.
  108.  *
  109.  *      Return Value :
  110.  *              The application can return an integer status indicator
  111.  *                  0 - success
  112.  *                  1 - failure
  113.  *              PerFORM will assume that no valid calculation data exists
  114.  *              if a return code of 1 is received
  115.  *
  116.  **********************************************************************/
  117. int FAR PASCAL PerformNumFunc (double far *result, LPSTR parm1, 
  118.                 LPSTR parm2, LPSTR parm3, LPSTR parm4)
  119. {
  120.     *result = lstrlen(parm1) + lstrlen(parm2);
  121.     return (0);
  122. }
  123.  
  124.