home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / Chapter9 / cmd32 / ECHO.C < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-29  |  2.1 KB  |  91 lines

  1. /****************************************************************/
  2. /*                                */
  3. /*                  echo.c                */
  4. /*                                */
  5. /*                Copyright (c) 2000            */
  6. /*            Pasquale J. Villani            */
  7. /*            All Rights Reserved            */
  8. /*                                */
  9. /* This file is part of CMD32.                    */
  10. /*                                */
  11. /* CMD32 is free software; you can redistribute it and/or    */
  12. /* modify it under the terms of the GNU General Public License    */
  13. /* as published by the Free Software Foundation; either version    */
  14. /* 2, or (at your option) any later version.            */
  15. /*                                */
  16. /* CMD32 is distributed in the hope that it will be useful, but    */
  17. /* WITHOUT ANY WARRANTY; without even the implied warranty of    */
  18. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See    */
  19. /* the GNU General Public License for more details.        */
  20. /*                                */
  21. /* You should have received a copy of the GNU General Public    */
  22. /* License along with CMD32; see the file COPYING.  If not,    */
  23. /* write to the Free Software Foundation, 675 Mass Ave,        */
  24. /* Cambridge, MA 02139, USA.                    */
  25. /****************************************************************/
  26.  
  27.  
  28. /* $Logfile$*/
  29.  
  30. /* $Log$ 
  31.  * $EndLog$ */
  32.  
  33. #include <windows.h>
  34. #include "globals.h"
  35. #include "proto.h"
  36.  
  37. #ifdef VERSION_STRINGS
  38. static BYTE *RcsId = "$Header$";
  39. #endif
  40.  
  41. extern BOOL batch_FLAG;
  42. extern BOOL echo_FLAG;
  43.  
  44. BOOL echo_bat(INT argc, BYTE *argv[])
  45. {
  46.     BYTE *lp, idx;
  47.  
  48.     if (argc == 1)
  49.     {
  50.         printf("ECHO is %s\n", echo_FLAG ? "ON" : "OFF");
  51.         return TRUE;
  52.     }
  53.     else if (argc == 2)
  54.     {
  55.         BYTE *p;
  56.  
  57.         for(p = argv[1]; *p ; p++)
  58.             *p = tolower(*p);
  59.  
  60.         if (strcmp(argv[1], "on") == 0)
  61.         {
  62.             echo_FLAG = TRUE;
  63.             printf("ECHO is ON\n");
  64.             return TRUE;
  65.         }
  66.         else if (strcmp(argv[1], "off") == 0)
  67.         {
  68.             echo_FLAG = FALSE;
  69.             return TRUE;
  70.         }
  71.     }
  72.     /* its user data                        */
  73.  
  74.     /* First trim leading white and trailing new line        */
  75.     lp = skipwh(tail);
  76.     if(lp[(idx = strlen(lp))] == '\n')
  77.         lp[idx] = '\0';
  78.  
  79.     /* Finally, print the user's data                */
  80.     printf("%s\n", lp);
  81.     return TRUE;
  82. }
  83.  
  84. BOOL echo_dot_bat(INT argc, BYTE *argv[])
  85. {
  86.     if (echo_FLAG)
  87.         printf("\n");
  88.     return TRUE;
  89. }
  90.  
  91.