home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / pmode_392.lzh / Pmode / pmode.c < prev    next >
C/C++ Source or Header  |  1990-10-27  |  4KB  |  144 lines

  1. echo ; /*  Note that this declares an int available externally
  2.  lc:lc -cwusf -v -y pmode.c
  3.  lc:blink lib:c.o pmode.o TO pmode LIB lib:amiga.lib,lib:lc.lib SD SC ND VERBOSE
  4.  quit
  5. */
  6. /*
  7.  *  Created on 88/07/27           by  Dario de Judicibus
  8.  *                                    via Canton 101, Rome I 00144, ITALY
  9.  *
  10.  *  Module:    pmode (Printer MODE)
  11.  *
  12.  *  Purpose:   select different printer modes
  13.  *
  14.  *  Syntax:    pmode { [op]flag }
  15.  *
  16.  *  ParmList:  flag             one of the following characters:
  17.  *                                l : Near Letter Quality
  18.  *                                d : Double Strike
  19.  *                                s : Shadow
  20.  *                                e : Enlarged
  21.  *                                c : Condensed
  22.  *                                p : Proportional
  23.  *                              where [op] is
  24.  *                                +  : to set style on
  25.  *                                -  : to set style off
  26.  *                                x  : to reset styles
  27.  *
  28.  *  Syntax Guideline (BNF):
  29.  *
  30.  *    arglist   ::= "arg" | "arglist | arg"
  31.  *    {arglist}   argument is required
  32.  *    [arglist]   argument is optional
  33.  *    arg | arg   OR indicator: choose one
  34.  *    arg ...     repeat argument
  35.  *
  36.  *  =========================================================================
  37.  *  @Mod |   on   | by  |  reason
  38.  *  -----+--------+-----+----------------------------------------------------
  39.  *  @001 | 880727 | DdJ | Version 1 Release 0 Modification 0
  40.  *
  41.  */
  42.  
  43.  #include "exec/types.h"
  44.  #include "libraries/dos.h"
  45.  #include "libraries/dosextens.h"
  46.  #include "proto/exec.h"
  47.  #include "proto/dos.h"
  48.  #include "stdio.h"
  49.  #include "ctype.h"
  50.  #include "string.h"
  51.  
  52.  #define A_BANNER "\x9B4;33mPrint Mode\x9B0;33m Version 1\x9B0m by Dario de Judicibus - Copyright © 1988\n"
  53.  #define H0_BANNER "\x9B33mSyntax:\x9B0m pmode { [op]flag }\n"
  54.  #define H1_BANNER "Operators are:\n \x9B33m+\x9B0m to switch on style\n \x9B33m-\x9B0m to switch off style\n \x9B33mx\x9B0m to reset all styles\n"
  55.  #define H2_BANNER "Flags are:\n \x9B33ml\x9B0metter quality \x9B33md\x9B0mouble strike \x9B33ms\x9B0mhadow\n \x9B33me\x9B0mnlarged       \x9B33mc\x9B0mondensed     \x9B33mp\x9B0mroportional\n"
  56.  
  57.  #define B_T_N(c)   ( (c == ' ') || (c == '\t') || (c == '\n') )
  58.  
  59.  #define  NLQ_ON     "\x1B[2\x22z"
  60.  #define  NLQ_OFF    "\x1B[1\x22z"
  61.  #define  DBS_ON     "\x1B[4\x22z"
  62.  #define  DBS_OFF    "\x1B[3\x22z"
  63.  #define  SHD_ON     "\x1B[6\x22z"
  64.  #define  SHD_OFF    "\x1B[5\x22z"
  65.  #define  ENL_ON     "\x1B[6w"
  66.  #define  ENL_OFF    "\x1B[5w"
  67.  #define  CMP_ON     "\x1B[4w"
  68.  #define  CMP_OFF    "\x1B[3w"
  69.  #define  PRO_ON     "\x1B[2p"
  70.  #define  PRO_OFF    "\x1B[1p"
  71.  #define  RESET_ALL  "\x1B[1\x22z\x1B[3\x22z\x1B[5\x22z\x1B[0w\x1B[1p"
  72.  
  73.  struct FileHandle *prt;
  74.  
  75.  extern VOID PrintIt(int, char *);
  76.  
  77.  VOID PrintIt(out,msg)
  78.  int out;
  79.  char *msg;
  80.  {
  81.    Write(out,msg,strlen(msg));
  82.  }
  83.  
  84.  VOID _main(cmd)
  85.  char *cmd;
  86.  {
  87.  
  88.    char style;
  89.    int toggle;
  90.  
  91.    echo = Output();
  92.  
  93.    if (!(cmd)) Exit(RETURN_WARN); /* Must be called from CLI */
  94.    while (*cmd != ' ') cmd++;  /* Skip over command name   */
  95.    while (B_T_N(*cmd)) cmd++; /* Skip over leading blanks */
  96.    if (*cmd == '\0')
  97.    {
  98.       PrintIt(echo,A_BANNER);
  99.       Exit(RETURN_OK);
  100.    }
  101.  
  102.    if (*cmd == '+')
  103.    {
  104.      toggle = TRUE;
  105.      ++cmd;
  106.    }
  107.    else if (*cmd == '-')
  108.    {
  109.      toggle = FALSE;
  110.      ++cmd;
  111.    }
  112.    else if (*cmd == 'x')
  113.      ;
  114.    else
  115.    {
  116.       PrintIt(echo,H0_BANNER);
  117.       PrintIt(echo,H1_BANNER);
  118.       PrintIt(echo,H2_BANNER);
  119.       Exit(RETURN_OK);
  120.    }
  121.  
  122.    style = *cmd;
  123.  
  124.    if((BOOL)(prt = Open("PRT:",MODE_NEWFILE)))
  125.    {
  126.      switch(style)
  127.      {
  128.        case 'l': PrintIt(prt,(toggle? NLQ_ON : NLQ_OFF)); break;
  129.        case 'd': PrintIt(prt,(toggle? DBS_ON : DBS_OFF)); break;
  130.        case 's': PrintIt(prt,(toggle? SHD_ON : SHD_OFF)); break;
  131.        case 'e': PrintIt(prt,(toggle? ENL_ON : ENL_OFF)); break;
  132.        case 'c': PrintIt(prt,(toggle? CMP_ON : CMP_OFF)); break;
  133.        case 'p': PrintIt(prt,(toggle? PRO_ON : PRO_OFF)); break;
  134.        case 'x': PrintIt(prt,RESET_ALL);                  break;
  135.        default : PrintIt(echo,H0_BANNER);
  136.                  PrintIt(echo,H1_BANNER);
  137.                  PrintIt(echo,H2_BANNER);
  138.                  Close(prt);
  139.                  Exit(RETURN_WARN);
  140.      }
  141.      Close(prt);
  142.    }
  143.  }
  144.