home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / 18 / commscmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  2.4 KB  |  64 lines

  1. /***********************************************************************
  2. *                                                                      *
  3. *  COMMSCMD                                                            *
  4. *                                                                      *
  5. *  This routine controls the COMMSCOP program that has been in-        *
  6. *  stalled as a resident routine.  The operation performed is de-      *
  7. *  termined by the command line.  The COMMSCMD program is invoked      *
  8. *  as follows:                                                         *
  9. *                                                                      *
  10. *                COMMSCMD [[cmd][ port]]                               *
  11. *                                                                      *
  12. *  where cmd is the command to be executed                             *
  13. *            STOP   -- stop trace                                      *
  14. *            START  -- flush trace buffer and start trace              *
  15. *            RESUME -- resume a stopped trace                          *
  16. *        port is the COMM port to be traced (1=COM1, 2=COM2, etc.)     *
  17. *                                                                      *
  18. *  If cmd is omitted, STOP is assumed.  If port is omitted, 1 is       *
  19. *  assumed.                                                            *
  20. *                                                                      *
  21. ***********************************************************************/
  22.  
  23. #include <stdlib.h>
  24. #include <stdio.h>
  25. #include <dos.h>
  26. #define COMMCMD 0x60
  27.  
  28. main(argc, argv)
  29. int argc;
  30. char *argv[];
  31. {
  32.     int cmd, port, result;
  33.     static char commands[3] [10] = {"STOPPED", "STARTED", "RESUMED"};
  34.     union REGS inregs, outregs;
  35.  
  36.     cmd = 0;
  37.     port = 0;
  38.  
  39.     if (argc > 1)
  40.         {
  41.         if (0 == stricmp(argv[1], "STOP"))
  42.             cmd = 0;
  43.         else if (0 == stricmp(argv[1], "START"))
  44.             cmd = 1;
  45.         else if (0 == stricmp(argv[1], "RESUME"))
  46.             cmd = 2;
  47.         }
  48.  
  49.     if (argc == 3)
  50.         {
  51.         port = atoi(argv[2]);
  52.         if (port > 0)
  53.             port = port - 1;
  54.         }
  55.  
  56.     inregs.h.ah = cmd;
  57.     inregs.x.dx = port;
  58.     result = int86(COMMCMD, &inregs, &outregs);
  59.  
  60.  
  61.     printf("\nCommunications tracing %s for port COM%1d:\n",
  62.             commands[cmd], port + 1);
  63. }
  64.