|
|
1.1 root 1: /*
2: * Copyright (c) 1988, 1990 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted provided
6: * that: (1) source distributions retain this entire copyright notice and
7: * comment, and (2) distributions including binaries display the following
8: * acknowledgement: ``This product includes software developed by the
9: * University of California, Berkeley and its contributors'' in the
10: * documentation or other materials provided with the distribution and in
11: * all advertising materials mentioning features or use of this software.
12: * Neither the name of the University nor the names of its contributors may
13: * be used to endorse or promote products derived from this software without
14: * specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
16: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: */
19:
20: #ifndef lint
21: char copyright[] =
22: "@(#) Copyright (c) 1988, 1990 Regents of the University of California.\n\
23: All rights reserved.\n";
24: #endif /* not lint */
25:
26: #ifndef lint
27: static char sccsid[] = "@(#)main.c 1.15 (Berkeley) 7/27/90";
28: #endif /* not lint */
29:
30: #include <sys/types.h>
31: #include <string.h>
32:
33: #include "ring.h"
34: #include "externs.h"
35: #include "defines.h"
36:
37: /*
38: * Initialize variables.
39: */
40: void
41: tninit()
42: {
43: init_terminal();
44: init_network();
45: init_telnet();
46: init_sys();
47: init_3270();
48: }
49:
50: int autologin;
51:
52: /*
53: * main. Parse arguments, invoke the protocol or command parser.
54: */
55: main(argc, argv)
56: int argc;
57: char *argv[];
58: {
59: extern char *optarg;
60: extern int optind;
61: int ch;
62: char *user;
63:
64: tninit(); /* Clear out things */
65: #ifdef CRAY
66: _setlist_init(); /* Work around compiler bug */
67: #endif
68: TerminalSaveState();
69:
70: if (prompt = rindex(argv[0], '/'))
71: ++prompt;
72: else
73: prompt = argv[0];
74:
75: user = NULL;
76: autologin = 0;
77: while ((ch = getopt(argc, argv, "ade:l:n:")) != EOF)
78: switch(ch) {
79: case 'a':
80: autologin = 1;
81: break;
82: case 'd':
83: debug = 1;
84: break;
85: case 'e':
86: set_escape_char(optarg);
87: break;
88: case 'l':
89: autologin = 1;
90: user = optarg;
91: break;
92: case 'n':
93: #if defined(TN3270) && defined(unix)
94: /* distinguish between "-n oasynch" and "-noasynch" */
95: if (argv[optind - 1][0] == '-' && argv[optind - 1][1]
96: == 'n' && argv[optind - 1][2] == 'o') {
97: if (!strcmp(optarg, "oasynch")) {
98: noasynchtty = 1;
99: noasynchnet = 1;
100: } else if (!strcmp(optarg, "oasynchtty"))
101: noasynchtty = 1;
102: } else if (!strcmp(optarg, "oasynchnet"))
103: noasynchnet = 1;
104: }
105: } else
106: #endif /* defined(TN3270) && defined(unix) */
107: SetNetTrace(optarg);
108: break;
109: #if defined(TN3270) && defined(unix)
110: case 't':
111: transcom = tline;
112: (void)strcpy(transcom, optarg);
113: break;
114: #endif
115: case '?':
116: default:
117: usage();
118: /* NOTREACHED */
119: }
120: argc -= optind;
121: argv += optind;
122:
123: if (argc) {
124: char *args[7], **argp = args;
125:
126: if (argc > 2)
127: usage();
128: *argp++ = prompt;
129: if (user) {
130: *argp++ = "-l";
131: *argp++ = user;
132: }
133: *argp++ = argv[0]; /* host */
134: if (argc > 1)
135: *argp++ = argv[1]; /* port */
136: *argp = 0;
137:
138: if (setjmp(toplevel) != 0)
139: Exit(0);
140: if (tn(argp - args, args) == 1)
141: return (0);
142: else
143: return (1);
144: }
145: (void)setjmp(toplevel);
146: for (;;)
147: #ifdef TN3270
148: if (shell_active)
149: shell_continue();
150: else
151: #endif
152: command(1, 0, 0);
153: }
154:
155: usage()
156: {
157: fprintf(stderr, "usage: %s [-a] [ [-l user] host-name [port] ]\n",
158: prompt);
159: exit(1);
160: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.