1 /* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 char copyright[] = 10 "@(#) Copyright (c) 1988 Regents of the University of California.\n\ 11 All rights reserved.\n"; 12 #endif /* not lint */ 13 14 #ifndef lint 15 static char sccsid[] = "@(#)main.c 1.13 (Berkeley) 06/01/90"; 16 #endif /* not lint */ 17 18 #include <sys/types.h> 19 20 #include "ring.h" 21 22 #include "externs.h" 23 #include "defines.h" 24 25 /* 26 * Initialize variables. 27 */ 28 29 void 30 tninit() 31 { 32 init_terminal(); 33 34 init_network(); 35 36 init_telnet(); 37 38 init_sys(); 39 40 init_3270(); 41 } 42 43 44 /* 45 * main. Parse arguments, invoke the protocol or command parser. 46 */ 47 48 49 int 50 main(argc, argv) 51 int argc; 52 char *argv[]; 53 { 54 tninit(); /* Clear out things */ 55 #ifdef CRAY 56 _setlist_init(); /* Work around compiler bug */ 57 #endif 58 59 TerminalSaveState(); 60 61 prompt = (unsigned char *)argv[0]; 62 while ((argc > 1) && (argv[1][0] == '-')) { 63 if (!strcmp(argv[1], "-d")) { 64 debug = 1; 65 } else if (!strcmp(argv[1], "-n")) { 66 if ((argc > 1) && (argv[2][0] != '-')) { /* get file name */ 67 SetNetTrace(argv[2]); 68 argv++; 69 argc--; 70 } 71 } else { 72 #if defined(TN3270) && defined(unix) 73 if (!strcmp(argv[1], "-t")) { 74 if ((argc > 1) && (argv[2][0] != '-')) { /* get file name */ 75 transcom = tline; 76 (void) strcpy(transcom, argv[2]); 77 argv++; 78 argc--; 79 } 80 } else if (!strcmp(argv[1], "-noasynch")) { 81 noasynchtty = 1; 82 noasynchnet = 1; 83 } else if (!strcmp(argv[1], "-noasynchtty")) { 84 noasynchtty = 1; 85 } else if (!strcmp(argv[1], "-noasynchnet")) { 86 noasynchnet = 1; 87 } else 88 #endif /* defined(TN3270) && defined(unix) */ 89 if (argv[1][1] != '\0') { 90 fprintf(stderr, "Unknown option *%s*.\n", argv[1]); 91 } 92 } 93 argc--; 94 argv++; 95 } 96 if (argc != 1) { 97 if (setjmp(toplevel) != 0) 98 Exit(0); 99 if (tn(argc, argv) == 1) { 100 return 0; 101 } else { 102 return 1; 103 } 104 } 105 (void) setjmp(toplevel); 106 for (;;) { 107 #if !defined(TN3270) 108 command(1, 0, 0); 109 #else /* !defined(TN3270) */ 110 if (!shell_active) { 111 command(1, 0, 0); 112 } else { 113 #if defined(TN3270) 114 shell_continue(); 115 #endif /* defined(TN3270) */ 116 } 117 #endif /* !defined(TN3270) */ 118 } 119 } 120