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