home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / tn3270 / ctlr / options.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-26  |  4.3 KB  |  182 lines

  1. /*-
  2.  * Copyright (c) 1988 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  */
  33.  
  34. #ifndef lint
  35. static char sccsid[] = "@(#)options.c    4.2 (Berkeley) 4/26/91";
  36. #endif /* not lint */
  37.  
  38. /*
  39.  * this file contains the definitions, initialization, and processing of
  40.  *    commands to handle the various local options (APL ON, etc.)
  41.  */
  42.  
  43. #include "options.h"
  44.  
  45. #include "../general/globals.h"
  46. #include "declare.h"
  47.  
  48. void
  49. OptInit()
  50. {
  51.     register int i;
  52.  
  53.     OptAPLmode = 0;
  54.     OptNullProcessing = 1;        /* improved null processing */
  55.     OptZonesMode = 0;        /* zones mode off */
  56.     OptEnterNL = 0;        /* regular enter/new line keys */
  57.     OptColFieldTab = 0;        /* regular column/field tab keys */
  58.     OptPacing = 1;            /* do pacing */
  59.     OptAlphaInNumeric = 0;        /* allow alpha in numeric fields */
  60.     for (i = 0; i < sizeof OptColTabs; i++) {
  61.     OptColTabs[i] = ((i%8) == 0);    /* every 8 columns */
  62.     }
  63.     OptHome = 0;
  64.     OptLeftMargin = 0;
  65.     OptWordWrap = 0;
  66. }
  67.  
  68. OptOrder(pointer, count, control)
  69. unsigned char *pointer;
  70. int count;
  71. int control;
  72. {
  73.     int i, j, character, origCount;
  74.  
  75.     origCount = count;
  76.  
  77.     if (count == 0) {
  78.     return(0);
  79.     }
  80.     character = *pointer&0xff;
  81.     pointer++;
  82.     count--;
  83.     switch (character) {
  84.     case 0xa0:
  85.     OptAPLmode = 1;
  86.     break;
  87.     case 0x61:
  88.     OptAPLmode = 0;
  89.     break;
  90.     case 0x95:
  91.     OptNullProcessing = 0;
  92.     break;
  93.     case 0xd5:
  94.     OptNullProcessing = 1;
  95.     break;
  96.     case 0xa9:
  97.     OptZonesMode = 1;
  98.     break;
  99.     case 0xe9:
  100.     OptZonesMode = 0;
  101.     break;
  102.     case 0x85:
  103.     OptEnterNL = 1;
  104.     break;
  105.     case 0xc5:
  106.     OptEnterNL = 0;
  107.     break;
  108.     case 0x83:
  109.     OptColFieldTab = 1;
  110.     break;
  111.     case 0xc3:
  112.     OptColFieldTab = 0;
  113.     break;
  114.     case 0x97:
  115.     OptPacing = 0;
  116.     break;
  117.     case 0xd7:
  118.     OptPacing = 1;
  119.     break;
  120.     case 0xa5:
  121.     OptAlphaInNumeric = 1;
  122.     break;
  123.     case 0xe5:
  124.     OptAlphaInNumeric = 0;
  125.     break;
  126.     case 0xe3:
  127.     if (!control && count < 30) {
  128.         return(0);        /* want more! */
  129.     }
  130.     for (i = 0; i < sizeof OptColTabs; i++) {
  131.         OptColTabs[i] = 0;
  132.     }
  133.     if (!count) {
  134.         break;
  135.     }
  136.     j = (*pointer&0xff)-0x40;
  137.     count--;
  138.     pointer++;
  139.     if (j < 0 || j >= 24) {
  140.         break;
  141.     }
  142.     OptHome = j;
  143.     if (!count) {
  144.         break;
  145.     }
  146.     j = (*pointer&0xff)-0x40;
  147.     count--;
  148.     pointer++;
  149.     if (j < 0 || j >= 80) {
  150.         break;
  151.     }
  152.     OptLeftMargin = j;
  153.     if (!count) {
  154.         break;
  155.     }
  156.     i = count;
  157.     if (i > 28) {
  158.         i = 28;
  159.     }
  160.     while (i) {
  161.         j = (*pointer&0xff)-0x40;
  162.         if (j < 0 || j >= sizeof OptColTabs) {
  163.         break;
  164.         }
  165.         OptColTabs[j] = 1;
  166.         i --;
  167.         pointer++;
  168.         count--;
  169.     }
  170.     break;
  171.     case 0xa6:
  172.     OptWordWrap = 1;
  173.     break;
  174.     case 0xe6:
  175.     OptWordWrap = 0;
  176.     break;
  177.     default:
  178.     break;
  179.     }
  180.     return(origCount - count);
  181. }
  182.