home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / Chapter9 / cmd32 / Path.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-14  |  1.8 KB  |  73 lines

  1. /****************************************************************/
  2. /*                                */
  3. /*                 path.c                */
  4. /*                                */
  5. /*            Copyright (c) 2000            */
  6. /*            Pasquale J. Villani            */
  7. /*            All Rights Reserved            */
  8. /*                                */
  9. /* CMD32 is free software; you can redistribute it and/or    */
  10. /* modify it under the terms of the GNU General Public License    */
  11. /* as published by the Free Software Foundation; either version    */
  12. /* 2, or (at your option) any later version.            */
  13. /*                                */
  14. /* CMD32 is distributed in the hope that it will be useful, but    */
  15. /* WITHOUT ANY WARRANTY; without even the implied warranty of    */
  16. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See    */
  17. /* the GNU General Public License for more details.        */
  18. /*                                */
  19. /* You should have received a copy of the GNU General Public    */
  20. /* License along with CMD32; see the file COPYING.  If not,    */
  21. /* write to the Free Software Foundation, 675 Mass Ave,        */
  22. /* Cambridge, MA 02139, USA.                    */
  23. /****************************************************************/
  24.  
  25. /* $Logfile$ */
  26.  
  27. /* $Log$ 
  28.  * $EndLog$ */
  29.  
  30. #ifdef VERSION_STRINGS
  31. static char *RcsId = "$Header$";
  32. #endif
  33.  
  34. #include <windows.h>
  35. #include "globals.h"
  36. #include "proto.h"
  37.  
  38. #define SIZE 2048
  39.  
  40. BOOL cmd_path(INT argc, BYTE *argv[])
  41. {
  42.     BYTE szPath[SIZE];
  43.     BYTE *lp;
  44.     BYTE *ptr;
  45.     BYTE *p;
  46.  
  47.     lp = skipwh(tail);
  48.     if(*lp == ';')
  49.         SetEnvironmentVariable("PATH", NULL);
  50.     else if(*lp == '\0' || *lp == '\r' || *lp == '\n')
  51.     {
  52.         GetEnvironmentVariable("PATH", szPath, SIZE);
  53.         ptr = skipwh(szPath);
  54.         if(*ptr == '\0')
  55.             printf("No Path\n\n");
  56.         else
  57.             printf("PATH=%s\n\n", ptr);
  58.     }
  59.     else
  60.     {
  61.         /* Trim trailing newline                */
  62.  
  63.         for(p = lp; (*p != '\r') && (*p != '\n'); p++)
  64.             ;
  65.         *p = '\0';
  66.         SetEnvironmentVariable("PATH", lp);
  67.     }
  68.     return TRUE;
  69. }
  70.  
  71.  
  72.  
  73.