home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / fileutil / tcggrep2.arj / MSDOSMAC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-25  |  862 b   |  35 lines

  1. /*
  2.  * The macro EXTRACT_PROGRAM_NAME(p) converts an MSDOS style argument 0
  3.  * full path program name to a nice, Un*x style argument 0 program name.
  4.  */
  5. /* fix for '/' directory separator Jim Segrave 21:59:55 Sun Nov 25 1990    */
  6.  
  7. #include <string.h>
  8. #define EXTRACT_PROGRAM_NAME(p)        \
  9.     {                    \
  10.         char    *q;            \
  11.     if ((q = strrchr(p, '\\')) != NULL)    \
  12.         p = q + 1;            \
  13.     if ((q = strrchr(p, '/')) != NULL)    \
  14.         p = q + 1;            \
  15.     if ((q = strchr(p, '.')) != NULL)        \
  16.         *q = '\0';            \
  17.     strlwr(p);            \
  18.     }
  19.  
  20.  
  21.  
  22. /*
  23.  * The macro CONVERT_TO_SLASHES(p) converts all backslashes in a pathname
  24.  * to forward slashes.  As a nice extra effect, it converts upper case to
  25.  * lower case.
  26.  */
  27. #define CONVERT_TO_SLASHES(p)        \
  28.     {                    \
  29.     char    *q;            \
  30.     for (q = p; *q; ++q)        \
  31.         if (*q == '\\')        \
  32.         *q = '/';        \
  33.     strlwr(p);            \
  34.     }
  35.