1 /* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 char copyright[] = 20 "@(#) Copyright (c) 1988 Regents of the University of California.\n\ 21 All rights reserved.\n"; 22 #endif /* not lint */ 23 24 #ifndef lint 25 static char sccsid[] = "@(#)main.c 1.10 (Berkeley) 11/18/88"; 26 #endif /* not lint */ 27 28 #include <sys/types.h> 29 30 #include "ring.h" 31 32 #include "externs.h" 33 #include "defines.h" 34 35 /* 36 * Initialize variables. 37 */ 38 39 void 40 tninit() 41 { 42 init_terminal(); 43 44 init_network(); 45 46 init_telnet(); 47 48 init_sys(); 49 50 init_3270(); 51 } 52 53 54 /* 55 * main. Parse arguments, invoke the protocol or command parser. 56 */ 57 58 59 int 60 main(argc, argv) 61 int argc; 62 char *argv[]; 63 { 64 tninit(); /* Clear out things */ 65 66 TerminalSaveState(); 67 68 prompt = argv[0]; 69 while ((argc > 1) && (argv[1][0] == '-')) { 70 if (!strcmp(argv[1], "-d")) { 71 debug = 1; 72 } else if (!strcmp(argv[1], "-n")) { 73 if ((argc > 1) && (argv[2][0] != '-')) { /* get file name */ 74 NetTrace = fopen(argv[2], "w"); 75 argv++; 76 argc--; 77 if (NetTrace == NULL) { 78 NetTrace = stdout; 79 } 80 } 81 } else { 82 #if defined(TN3270) && defined(unix) 83 if (!strcmp(argv[1], "-t")) { 84 if ((argc > 1) && (argv[2][0] != '-')) { /* get file name */ 85 transcom = tline; 86 (void) strcpy(transcom, argv[2]); 87 argv++; 88 argc--; 89 } 90 } else if (!strcmp(argv[1], "-noasynch")) { 91 noasynchtty = 1; 92 noasynchnet = 1; 93 } else if (!strcmp(argv[1], "-noasynchtty")) { 94 noasynchtty = 1; 95 } else if (!strcmp(argv[1], "-noasynchnet")) { 96 noasynchnet = 1; 97 } else 98 #endif /* defined(TN3270) && defined(unix) */ 99 if (argv[1][1] != '\0') { 100 fprintf(stderr, "Unknown option *%s*.\n", argv[1]); 101 } 102 } 103 argc--; 104 argv++; 105 } 106 if (argc != 1) { 107 if (setjmp(toplevel) != 0) 108 Exit(0); 109 if (tn(argc, argv) == 1) { 110 return 0; 111 } else { 112 return 1; 113 } 114 } 115 (void) setjmp(toplevel); 116 for (;;) { 117 #if !defined(TN3270) 118 command(1); 119 #else /* !defined(TN3270) */ 120 if (!shell_active) { 121 command(1); 122 } else { 123 #if defined(TN3270) 124 shell_continue(); 125 #endif /* defined(TN3270) */ 126 } 127 #endif /* !defined(TN3270) */ 128 } 129 } 130