summaryrefslogtreecommitdiff
path: root/usr.bin/tn3270/general
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
commitd6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch)
treeece253b876159b39c620e62b6c9b1174642e070e /usr.bin/tn3270/general
initial import of NetBSD tree
Diffstat (limited to 'usr.bin/tn3270/general')
-rw-r--r--usr.bin/tn3270/general/genbsubs.c126
-rw-r--r--usr.bin/tn3270/general/general.h66
-rw-r--r--usr.bin/tn3270/general/general.order2
-rw-r--r--usr.bin/tn3270/general/globals.c75
-rw-r--r--usr.bin/tn3270/general/globals.h131
-rw-r--r--usr.bin/tn3270/general/vaxbsubs.s102
6 files changed, 502 insertions, 0 deletions
diff --git a/usr.bin/tn3270/general/genbsubs.c b/usr.bin/tn3270/general/genbsubs.c
new file mode 100644
index 00000000000..a20c6cffcbf
--- /dev/null
+++ b/usr.bin/tn3270/general/genbsubs.c
@@ -0,0 +1,126 @@
+/*-
+ * Copyright (c) 1988 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+/*static char sccsid[] = "from: @(#)genbsubs.c 4.2 (Berkeley) 4/26/91";*/
+static char rcsid[] = "$Id: genbsubs.c,v 1.1 1995/10/18 08:46:21 deraadt Exp $";
+#endif /* not lint */
+
+/* The output of bunequal is the offset of the byte which didn't match;
+ * if all the bytes match, then we return n.
+ * bunequal(s1, s2, n) */
+
+int
+bunequal(s1, s2, n)
+register char *s1, *s2;
+register n;
+{
+ register int i = 0;
+
+ while (i++ < n) {
+ if (*s1++ != *s2++) {
+ break;
+ }
+ }
+ return(i-1);
+}
+
+/* bskip(s1, n, b) : finds the first occurrence of any byte != 'b' in the 'n'
+ * bytes beginning at 's1'.
+ */
+
+int
+bskip(s1, n, b)
+register char *s1;
+register int n;
+register int b;
+{
+ register int i = 0;
+
+ while (i++ < n) {
+ if (*s1++ != b) {
+ break;
+ }
+ }
+ return(i-1);
+}
+
+/*
+ * memNSchr(const void *s, int c, size_t n, int and)
+ *
+ * Like memchr, but the comparison is '((*s)&and) == c',
+ * and we increment our way through s by "stride" ('s += stride').
+ *
+ * We optimize for the most used strides of +1 and -1.
+ */
+
+unsigned char *
+memNSchr(s, c, n, and, stride)
+char *s;
+int c;
+unsigned int n;
+int and;
+int stride;
+{
+ register unsigned char _c, *_s, _and;
+
+ _and = and;
+ _c = (c&_and);
+ _s = (unsigned char *)s;
+ switch (stride) {
+ case 1:
+ while (n--) {
+ if (((*_s)&_and) == _c) {
+ return _s;
+ }
+ _s++;
+ }
+ break;
+ case -1:
+ while (n--) {
+ if (((*_s)&_and) == _c) {
+ return _s;
+ }
+ _s--;
+ }
+ break;
+ default:
+ while (n--) {
+ if (((*_s)&_and) == _c) {
+ return _s;
+ }
+ _s += stride;
+ }
+ }
+ return 0;
+}
diff --git a/usr.bin/tn3270/general/general.h b/usr.bin/tn3270/general/general.h
new file mode 100644
index 00000000000..49146364d14
--- /dev/null
+++ b/usr.bin/tn3270/general/general.h
@@ -0,0 +1,66 @@
+/*-
+ * Copyright (c) 1988 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)general.h 4.2 (Berkeley) 4/26/91
+ * $Id: general.h,v 1.1 1995/10/18 08:46:22 deraadt Exp $
+ */
+
+/*
+ * Some general definitions.
+ */
+
+#define numberof(x) (sizeof x/sizeof x[0])
+#define highestof(x) (numberof(x)-1)
+
+#if defined(unix)
+#define ClearElement(x) bzero((char *)&x, sizeof x)
+#define ClearArray(x) bzero((char *)x, sizeof x)
+#else /* defined(unix) */
+#define ClearElement(x) memset((char *)&x, 0, sizeof x)
+#define ClearArray(x) memset((char *)x, 0, sizeof x)
+#endif /* defined(unix) */
+
+#if defined(unix) /* Define BSD equivalent mem* functions */
+#define memcpy(dest,src,n) bcopy(src,dest,n)
+#define memmove(dest,src,n) bcopy(src,dest,n)
+#define memset(s,c,n) if (c == 0) { \
+ bzero(s,n); \
+ } else { \
+ register char *src = s; \
+ register int count = n; \
+ \
+ while (count--) { \
+ *src++ = c; \
+ } \
+ }
+#define memcmp(s1,s2,n) bcmp(s1,s2,n)
+#endif /* defined(unix) */
diff --git a/usr.bin/tn3270/general/general.order b/usr.bin/tn3270/general/general.order
new file mode 100644
index 00000000000..6f4d233b010
--- /dev/null
+++ b/usr.bin/tn3270/general/general.order
@@ -0,0 +1,2 @@
+globals.o
+genbsubs.o
diff --git a/usr.bin/tn3270/general/globals.c b/usr.bin/tn3270/general/globals.c
new file mode 100644
index 00000000000..31434759222
--- /dev/null
+++ b/usr.bin/tn3270/general/globals.c
@@ -0,0 +1,75 @@
+/*-
+ * Copyright (c) 1988 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+/*static char sccsid[] = "from: @(#)globals.c 4.2 (Berkeley) 4/26/91";*/
+static char rcsid[] = "$Id: globals.c,v 1.1 1995/10/18 08:46:22 deraadt Exp $";
+#endif /* not lint */
+
+/*
+ * Do the defining instances for the globals of tn3270.
+ */
+
+#include "../ctlr/hostctlr.h"
+#include "../ctlr/oia.h"
+#include "../ctlr/options.h"
+#include "../ctlr/screen.h"
+
+
+#define DEFINING_INSTANCES
+
+#include "globals.h"
+
+#include "../general/general.h"
+
+/*
+ * init_system()
+ *
+ * Initialize the global values in case of a restart.
+ */
+
+void
+init_system()
+{
+ OptHome = OptLeftMargin = OptAPLmode = OptNullProcessing = 0;
+ OptZonesMode = OptEnterNL = OptColFieldTab = OptPacing = 0;
+ OptAlphaInNumeric = OptHome = OptLeftMargin = OptWordWrap = 0;
+
+ ClearArray(Host);
+ CursorAddress = BufferAddress = 0;
+
+ Lowest = Highest = 0;
+
+ UnLocked = AidByte = 0;
+
+}
diff --git a/usr.bin/tn3270/general/globals.h b/usr.bin/tn3270/general/globals.h
new file mode 100644
index 00000000000..81d393197ae
--- /dev/null
+++ b/usr.bin/tn3270/general/globals.h
@@ -0,0 +1,131 @@
+/*-
+ * Copyright (c) 1988 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)globals.h 4.2 (Berkeley) 4/26/91
+ * $Id: globals.h,v 1.1 1995/10/18 08:46:22 deraadt Exp $
+ */
+
+/*
+ * This file contains all the globals used by tn3270.
+ *
+ * Since various files may want to reference this file,
+ * and since they may only want subsets of the globals,
+ * we assume they have #include'd all the other .h files
+ * first, and we only give those globals relevant to
+ * the #include'd .h files.
+ *
+ */
+
+#if defined(DEFINING_INSTANCES)
+#define EXTERN
+#else
+#define EXTERN extern
+#endif
+
+
+EXTERN int
+ /*
+ * shell_active ==>
+ * 1. Don't do input.
+ * 2. Don't do output.
+ * 3. Don't block in select.
+ * 4. When nothing to do, call shell_continue()
+ */
+ shell_active;
+
+
+#if defined(INCLUDED_OPTIONS)
+EXTERN int OptHome; /* where home should send us */
+
+EXTERN int OptLeftMargin; /* where new line should send us */
+
+EXTERN char OptColTabs[80]; /* local tab stops */
+
+EXTERN int OptAPLmode;
+
+EXTERN int OptNullProcessing; /* improved null processing */
+
+EXTERN int OptZonesMode; /* zones mode off */
+
+EXTERN int OptEnterNL; /* regular enter/new line keys */
+
+EXTERN int OptColFieldTab; /* regular column/field tab keys */
+
+EXTERN int OptPacing; /* do pacing */
+
+EXTERN int OptAlphaInNumeric; /* allow alpha in numeric fields */
+
+EXTERN int OptHome;
+
+EXTERN int OptLeftMargin;
+
+EXTERN int OptWordWrap;
+#endif
+
+#if defined(INCLUDED_SCREEN)
+EXTERN ScreenImage
+ Host[MAXSCREENSIZE]; /* host view of screen */
+
+EXTERN char Orders[256]; /* Non-zero for orders */
+
+ /* Run-time screen geometry */
+EXTERN int
+ MaxNumberLines, /* How many rows the 3270 COULD have */
+ MaxNumberColumns, /* How many columns the 3270 COULD have */
+ NumberLines, /* How many lines the 3270 screen contains */
+ NumberColumns, /* How many columns the 3270 screen contains */
+ ScreenSize;
+
+EXTERN int CursorAddress; /* where cursor is */
+EXTERN int BufferAddress; /* where writes are going */
+
+EXTERN int Lowest, Highest;
+
+extern char CIABuffer[];
+
+EXTERN int UnLocked; /* is the keyboard unlocked */
+EXTERN int AidByte;
+
+#endif
+
+#if defined(INCLUDED_STATE)
+#endif
+
+#if defined(INCLUDED_OIA)
+
+EXTERN OIA OperatorInformationArea;
+
+EXTERN int
+ oia_modified, /* Has the oia been modified */
+ ps_modified; /* Has the presentation space been modified */
+
+#endif /* defined(INCLUDED_OIA) */
diff --git a/usr.bin/tn3270/general/vaxbsubs.s b/usr.bin/tn3270/general/vaxbsubs.s
new file mode 100644
index 00000000000..ddbe516c4ca
--- /dev/null
+++ b/usr.bin/tn3270/general/vaxbsubs.s
@@ -0,0 +1,102 @@
+/*-
+ * Copyright (c) 1988 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: @(#)vaxbsubs.s 4.2 (Berkeley) 4/26/91
+ * $Id: vaxbsubs.s,v 1.1 1995/10/18 08:46:22 deraadt Exp $
+ */
+
+/* This is taken from bcmp.s from 4.2.
+ * The output of bunequal is the offset of the byte which didn't match;
+ * if all the bytes match, then we return n.
+ *
+ * BUGNOTE: This has no chance of working for lengths greater than 64K.
+ * (so, if you use this somewhere else, you may need to
+ * fix it...)
+ */
+
+/* bunequal(s1, s2, n) */
+
+#include "defs.h"
+
+ENTRY(bunequal)
+ movl 4(ap),r1
+ movl 8(ap),r3
+ movl 12(ap),r4
+1:
+ movzwl $65535,r0
+ cmpl r4,r0
+ jleq 2f
+ subl2 r0,r4
+ cmpc3 r0,(r1),(r3)
+ jeql 1b
+ addl2 r4,r0
+ /* changes... */
+ subl3 r0,12(ap),r0
+ /* end of changes for bunequal... */
+ ret
+2:
+ cmpc3 r4,(r1),(r3)
+ /* changes... */
+ subl3 r0,12(ap),r0
+ /* end of changes for bunequal... */
+ ret
+
+
+
+
+/* brand new code, using the above as base... */
+/* bskip(s1, n, b) : finds the first occurrence of any byte != 'b' in the 'n'
+ * bytes beginning at 's1'.
+ *
+ * BUGNOTE: This has no chance of working for lengths greater than 64K.
+ * (so, if you use this somewhere else, you may need to
+ * fix it...)
+ */
+
+ENTRY(bskip)
+ movl 4(ap),r1
+ movl 8(ap),r3
+ movl 12(ap),r4
+1:
+ movzwl $65535,r0
+ cmpl r3,r0
+ jleq 2f
+ subl2 r0,r3
+ skpc r4,r0,(r1)
+ jeql 1b
+ addl2 r3,r0
+ subl3 r0,8(ap),r0
+ ret
+2:
+ skpc r4,r3,(r1)
+ subl3 r0,8(ap),r0
+ ret