home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 344_01 / pcon.c < prev    next >
Text File  |  1989-06-08  |  2KB  |  69 lines

  1. /* HEADER:       (cat #);
  2.    TITLE:        Utility to send multiple printer control codes;
  3.    DATE:         06/08/1989;
  4.    DESCRIPTION:  "Sends a series of printer control codes (entered on the
  5.                  command line). Initially set up for Epson type printers,
  6.                  the control codes can be easily modified by changing 2
  7.                  tables in the header file pcon.h. One table is for control 
  8.                  code data, the other is for on-screen help";
  9.    KEYWORDS:     escape sequences, printer control, pcon.;
  10.    SYSTEM:       MS-DOS;
  11.    FILENAME:     PCON.C;
  12.    SEE-ALSO:     pcon.h;
  13.    AUTHOR:       Eric Horner;
  14.    COMPILERS:    Turbo C 2.0;
  15. */
  16.  
  17.  
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include "pcon.h"
  21.  
  22. main(int argc, char *argv[])
  23. {
  24.     int parm, pcnt, flts, codenum;
  25.  
  26.     if (argc > (MAXPARMS + 1))
  27.     {
  28.     fprintf(stderr, "%s", ers[1]);
  29.     exit(1);
  30.     }
  31.     if (argc > 1)
  32.     {
  33.     for (parm = 1, pcnt = 0; parm <= (argc - 1); parm++)
  34.     {
  35.             strtoupper(argv[parm]);
  36.         for (codenum = 0; codenum < MAXCODES; codenum++)
  37.         {
  38.         if (strcmp(argv[parm], codes[codenum * 2]) == 0)
  39.         {
  40.             fprintf(stdprn, "%s", codes[(codenum * 2) + 1]);
  41.             fputc(0, stdprn); /* for sequences awaiting null */
  42.             pcnt++;
  43.         }
  44.         }
  45.     }
  46.     if((flts =(argc - pcnt -1)) != 0) fprintf(stderr, "\n%d %s", flts, ers[0]);
  47.     }
  48.     else print_instructions();
  49.  
  50.     exit(0);
  51. }
  52.  
  53.     /***** print instructions, if no commands given *****/
  54. void print_instructions()
  55. {
  56.     int i;
  57.     for (i = 0; i < TEXTLEN; ++i)
  58.     {
  59.     fprintf(stderr, "%s", explain[i]);
  60.     }
  61. }
  62.  
  63.     /***** convert a string to all upper case *****/
  64. void strtoupper(char *strptr)
  65. {
  66.     for (; *strptr != '\0'; strptr++)
  67.     if ((*strptr >= 'a') && (*strptr <= 'z')) *strptr -= 32;
  68. }
  69.