home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / SYSTEM / SLASH2.ZIP / SWITCH.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-22  |  1.3 KB  |  57 lines

  1. #include <stdio.h>        /* display/set command line switch char */
  2. #include <dos.h>        /* compliments of Anthony LiCausi c/o    */
  3.                 /* Allen Holub (DDJ).            */
  4.  
  5.                 /*****************************************
  6.                 * if c == 0, return current switch char, *
  7.                 * else change the switch char to c and     *
  8.                 * return the old switch character.     *
  9.                 * Note mild recursion.
  10.                 *****************************************/
  11. int switchar(c)
  12. int c;
  13. {
  14.     union REGS regs;
  15.     int rval = 0;
  16.  
  17.     if (c)
  18.     rval = switchar(0);
  19.     regs.x.dx = c;
  20.     regs.x.ax = c ? 0x3701 : 0x3700;
  21.     int86(0x21, ®s, ®s);
  22.     return(rval ? rval : regs.h.dl);
  23. }
  24.  
  25. void pscscs(char *s1, char c1, char *s2, char c2, char *s3)
  26. {
  27.     write(1,  s1, strlen(s1));
  28.     write(1, &c1, 1);
  29.     write(1,  s2, strlen(s2));
  30.     write(1, &c2, 1);
  31.     write(1,  s3, strlen(s3));
  32. }
  33.  
  34. void pscs(char *s1, char c1, char *s2)
  35. {
  36.     write(1,  s1, strlen(s1));
  37.     write(1, &c1, 1);
  38.     write(1,  s2, strlen(s2));
  39. }
  40.  
  41.                 /*****************************************
  42.                 * main                     *
  43.                 *****************************************/
  44. main( argc, argv )
  45. int argc;
  46. char **argv;
  47. {
  48.     argv++;
  49.     if ( argc > 1 )
  50.     pscscs( "Changing switch character from <", switchar( **argv ),
  51.         "> to <", **argv, ">\n");
  52.     else
  53.     pscs( " Switch character is <", switchar( 0 ), ">\n");
  54.     exit(0);
  55. }
  56.  
  57.