Commit | Line | Data |
---|---|---|
6f6e51bd GM |
1 | #include "externs.h" |
2 | #include "defines.h" | |
3 | ||
4 | /* | |
5 | * Initialize variables. | |
6 | */ | |
7 | ||
8 | void | |
9 | tninit() | |
10 | { | |
6f6e51bd GM |
11 | init_terminal(); |
12 | ||
13 | init_network(); | |
14 | ||
15 | init_telnet(); | |
6f6e51bd GM |
16 | } |
17 | ||
18 | ||
19 | /* | |
20 | * main. Parse arguments, invoke the protocol or command parser. | |
21 | */ | |
22 | ||
23 | ||
24 | void | |
25 | main(argc, argv) | |
26 | int argc; | |
27 | char *argv[]; | |
28 | { | |
29 | tninit(); /* Clear out things */ | |
30 | ||
31 | TerminalSaveState(); | |
32 | ||
33 | prompt = argv[0]; | |
34 | while ((argc > 1) && (argv[1][0] == '-')) { | |
35 | if (!strcmp(argv[1], "-d")) { | |
36 | debug = 1; | |
37 | } else if (!strcmp(argv[1], "-n")) { | |
38 | if ((argc > 1) && (argv[2][0] != '-')) { /* get file name */ | |
39 | NetTrace = fopen(argv[2], "w"); | |
40 | argv++; | |
41 | argc--; | |
42 | if (NetTrace == NULL) { | |
43 | NetTrace = stdout; | |
44 | } | |
45 | } | |
46 | } else { | |
47 | #if defined(TN3270) && defined(unix) | |
48 | if (!strcmp(argv[1], "-t")) { | |
49 | if ((argc > 1) && (argv[2][0] != '-')) { /* get file name */ | |
50 | transcom = tline; | |
51 | (void) strcpy(transcom, argv[1]); | |
52 | argv++; | |
53 | argc--; | |
54 | } | |
55 | } else if (!strcmp(argv[1], "-noasynch")) { | |
56 | noasynch = 1; | |
57 | } else | |
58 | #endif /* defined(TN3270) && defined(unix) */ | |
59 | if (argv[1][1] != '\0') { | |
60 | fprintf(stderr, "Unknown option *%s*.\n", argv[1]); | |
61 | } | |
62 | } | |
63 | argc--; | |
64 | argv++; | |
65 | } | |
66 | if (argc != 1) { | |
67 | if (setjmp(toplevel) != 0) | |
68 | Exit(0); | |
69 | tn(argc, argv); | |
70 | } | |
71 | setjmp(toplevel); | |
72 | for (;;) { | |
73 | #if !defined(TN3270) | |
74 | command(1); | |
75 | #else /* !defined(TN3270) */ | |
76 | if (!shell_active) { | |
77 | command(1); | |
78 | } else { | |
79 | #if defined(TN3270) | |
80 | shell_continue(); | |
81 | #endif /* defined(TN3270) */ | |
82 | } | |
83 | #endif /* !defined(TN3270) */ | |
84 | } | |
85 | } |