home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / TEKST / GROFFSRC / SRC / LIBGROFF / EXECPATH.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-24  |  713 b   |  38 lines

  1. #define INCL_DOSPROCESS
  2. #include <os2.h>
  3. #include <string.h>
  4.  
  5. char *loadpath(void)
  6. {
  7.   PTIB pptib;
  8.   PPIB pppib;
  9.   char *szPath;
  10.  
  11.   DosGetInfoBlocks(&pptib, &pppib);
  12.   szPath = pppib -> pib_pchenv;
  13.  
  14.   while (*szPath)
  15.     szPath = strchr(szPath, 0) + 1;
  16.  
  17.   return szPath + 1;
  18. }
  19.  
  20. char *execpath(char *szProg)
  21. {
  22.   static char *szLpath;
  23.   static char szPath[CCHMAXPATH];
  24.   char *szPtr;
  25.  
  26.   if (!szLpath)
  27.     szLpath = loadpath();
  28.  
  29.   strcpy(szPath, szLpath);
  30.   szPtr = strrchr(szPath, '\\');
  31.   strcpy(szPtr + 1, szProg);
  32.   szPtr = strrchr(szPath, '.');
  33.   if (szPtr == NULL || stricmp(szPtr, ".exe"))
  34.     strcat(szPath, ".exe");
  35.  
  36.   return access(szPath, 0) == 0 ? szPath : szProg;
  37. }
  38.