home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************
- /*
- /* File FAXEXIT2.C
- /*
- /* Description This file is a sample for the RECEIVEDFAX function. This
- /* function is run when a fax has just been received, and is
- /* located in the FAXEXIT2.DLL file.
- /* This program describes how to use the RECEIVEDFAX function.
- /* This function just calls the Fax/PM Viewer to display the
- /* received fax.
- /*
- /* Functions RECEIVEDFAX
- /* GetFaxPMPath [static]
- /*
- /* Last modif March 15, 1993
- /*
- /* Copyright (c) Microformatic S.A. 1993
- /*
- /*****************************************************************************/
-
-
- /*****************************************************************************
- /* Includes
- /*****************************************************************************/
-
- #define INCL_DOS
- #define INCL_WIN
- #define INCL_GPI
- #include <os2.h>
-
- #include <memory.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
-
-
- /*****************************************************************************
- /* Defines
- /*****************************************************************************/
-
- #define MEMORY_4K 4096
- #define PAG_RWC PAG_READ | PAG_WRITE | PAG_COMMIT
- #define PROGRAM_NAME "FaxView.Exe"
- #define FAXPM_ENV_VAR "FAXPM"
-
-
- /*****************************************************************************
- /* Prototypes
- /*****************************************************************************/
-
- static APIRET APIENTRY GetFaxPMPath (PSZ pszPath) ;
-
-
- /*****************************************************************************
- /*
- /* Function RECEIVEDFAX
- /*
- /* Description Called when a fax has been received.
- /*
- /* Parameters PSZ pszFile : complete name of the received fax.
- /* PSZ pszId : remote fax identifier. This may be a NULL string.
- /* ULONG ulChannel : channel. For Fax/PM 2.0 standalone, this
- /* number is always 1.
- /*
- /* Return code APIRET. In Fax/PM 2.0 standalone, the return code is ignored.
- /*
- /****************************************************************************/
-
- APIRET APIENTRY RECEIVEDFAX ( PSZ pszFile, PSZ pszId, ULONG ulChannel ) {
-
- ULONG ulRc ; /* return code for function calls */
- PSZ pszProgram ; /* program name */
- PSZ pszArgument0 ; /* 1st argument = program name */
- PSZ pszArguments ; /* program arguments */
- RESULTCODES RcExec ; /* result codes of the program */
-
-
- /***************************************************************************
- /* Allocate memory for the environment
- /**************************************************************************/
- ulRc = DosAllocMem ((PPVOID)&pszProgram, MEMORY_4K, PAG_RWC) ;
- if (ulRc) {
- return 1L ;
- }
- pszArgument0 = &pszProgram [1024] ;
-
-
- /***************************************************************************
- /* Get the Fax/PM path
- /**************************************************************************/
- GetFaxPMPath (pszProgram) ;
-
-
- /***************************************************************************
- /* Build the program name and the arguments list.
- /**************************************************************************/
- strcat (pszProgram, PROGRAM_NAME) ;
- strcpy (pszArgument0, pszProgram) ;
- pszArguments = &pszArgument0[strlen(pszArgument0)+1] ;
- strcpy (pszArguments, pszFile) ;
-
-
- /***************************************************************************
- /* Run the program
- /**************************************************************************/
- ulRc = DosExecPgm (NULL, 0L, EXEC_ASYNC, pszArgument0, NULL, &RcExec,
- pszProgram) ;
-
-
- /***************************************************************************
- /* Terminate
- /**************************************************************************/
- DosFreeMem ((PVOID)pszProgram) ;
-
- return ulRc ;
-
- }
-
-
- /*****************************************************************************
- /*
- /* Function GetFaxPMPath [static]
- /*
- /* Description This function returns the Fax/PM path. The path is retrieved
- /* from the FAXPM environment variable path. It is returned with
- /* a terminating backslash. If no path is found, the current
- /* directory is assumed.
- /*
- /* Parameters PSZ pszPath : receives the Fax/PM path.
- /*
- /* Return code 0
- /*
- /****************************************************************************/
-
- static APIRET APIENTRY GetFaxPMPath ( PSZ pszPath ) {
-
- ULONG ulRc ; /* return code for function calls */
- PSZ pszEnvVar ; /* environment variable */
- PCHAR pchLast ; /* last character in the string */
-
-
- /***************************************************************************
- /* Query the environment variable
- /**************************************************************************/
- ulRc = DosScanEnv (FAXPM_ENV_VAR, &pszEnvVar) ;
- if (ulRc) {
- strcpy (pszPath, ".\\") ;
- return 0L ;
- }
- else {
- strcpy (pszPath, pszEnvVar) ;
- }
-
-
- /***************************************************************************
- /* Removes terminating '\' or ';' and adds a '\'
- /**************************************************************************/
- pchLast = &pszPath [strlen(pszPath)-1] ;
- if (*pchLast=='\\' || *pchLast==';') {
- *pchLast='\\' ;
- }
- else {
- strcat (pszPath, "\\") ;
- }
-
- return 0l ;
-
- }