home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / Chapter9 / cmd32 / Prompt.c < prev    next >
C/C++ Source or Header  |  2000-05-07  |  2KB  |  94 lines

  1. /****************************************************************/
  2. /*                                */
  3. /*                 prompt.c                */
  4. /*                                */
  5. /*              command.com prompt command        */
  6. /*                                */
  7. /*            Copyright (c) 1995            */
  8. /*            Pasquale J. Villani            */
  9. /*            All Rights Reserved            */
  10. /*                                */
  11. /* This file is part of CMD32.                    */
  12. /*                                */
  13. /* CMD32 is free software; you can redistribute it and/or    */
  14. /* modify it under the terms of the GNU General Public License    */
  15. /* as published by the Free Software Foundation; either version    */
  16. /* 2, or (at your option) any later version.            */
  17. /*                                */
  18. /* CMD32 is distributed in the hope that it will be useful, but    */
  19. /* WITHOUT ANY WARRANTY; without even the implied warranty of    */
  20. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See    */
  21. /* the GNU General Public License for more details.        */
  22. /*                                */
  23. /* You should have received a copy of the GNU General Public    */
  24. /* License along with CMD32; see the file COPYING.  If not,    */
  25. /* write to the Free Software Foundation, 675 Mass Ave,        */
  26. /* Cambridge, MA 02139, USA.                    */
  27. /****************************************************************/
  28.  
  29. /* $Logfile$ */
  30.  
  31. /* $Log$ 
  32.  */
  33. /* $EndLog$ */
  34.  
  35. #ifdef VERSION_STRINGS
  36. static char *RcsId = "$Header$";
  37. #endif
  38.  
  39. #include <windows.h>
  40. #include "globals.h"
  41.  
  42. /* put_prompt - print prompt obeying $x commands */
  43. void put_prompt(BYTE *fmt)
  44. {
  45.     BYTE c;
  46.     BYTE *s;
  47.     BYTE directory[NAMEMAX];
  48.  
  49.     while ((c = *fmt++) != '\0')
  50.     {
  51.         if (c != '$')
  52.         {
  53.             if(c != '\n' && c != '\r')
  54.                 HandleChar(0, c);
  55.             continue;
  56.         }
  57.         c = *fmt++;
  58.         switch (toupper(c))
  59.         {
  60.         case 'P':
  61.             GetCurrentDirectory(NAMEMAX, directory);
  62.             printf("%s", directory);
  63.             continue;
  64.  
  65.         case 'N':
  66.             GetCurrentDirectory(NAMEMAX, directory);
  67.             HandleChar(0, directory[0]);
  68.             continue;
  69.  
  70.         case 'G':
  71.             HandleChar(0, '>');
  72.             continue;
  73.  
  74.         case 'L':
  75.             HandleChar(0, '<');
  76.             continue;
  77.  
  78.         case 'B':
  79.             HandleChar(0, '|');
  80.             continue;
  81.  
  82.         case 'E':
  83.             HandleChar(0, '=');
  84.             continue;
  85.  
  86.         default:
  87.             HandleChar(0, c);
  88.             continue;
  89.         }
  90.     }
  91. }
  92.  
  93.  
  94.