133685Sbostic /* 233685Sbostic * Copyright (c) 1988 Regents of the University of California. 333685Sbostic * All rights reserved. 433685Sbostic * 533685Sbostic * Redistribution and use in source and binary forms are permitted 634898Sbostic * provided that the above copyright notice and this paragraph are 734898Sbostic * duplicated in all such forms and that any documentation, 834898Sbostic * advertising materials, and other materials related to such 934898Sbostic * distribution and use acknowledge that the software was developed 1034898Sbostic * by the University of California, Berkeley. The name of the 1134898Sbostic * University may not be used to endorse or promote products derived 1234898Sbostic * from this software without specific prior written permission. 1334898Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 1434898Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 1534898Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1633685Sbostic */ 1733685Sbostic 1833685Sbostic #ifndef lint 1933685Sbostic char copyright[] = 2033685Sbostic "@(#) Copyright (c) 1988 Regents of the University of California.\n\ 2133685Sbostic All rights reserved.\n"; 2233685Sbostic #endif /* not lint */ 2333685Sbostic 2433685Sbostic #ifndef lint 25*38689Sborman static char sccsid[] = "@(#)main.c 1.11 (Berkeley) 08/21/89"; 2633685Sbostic #endif /* not lint */ 2733685Sbostic 2832381Sminshall #include <sys/types.h> 2932381Sminshall 3032381Sminshall #include "ring.h" 3132381Sminshall 3232145Sminshall #include "externs.h" 3332145Sminshall #include "defines.h" 3432145Sminshall 3532145Sminshall /* 3632145Sminshall * Initialize variables. 3732145Sminshall */ 3832145Sminshall 3932145Sminshall void 4032145Sminshall tninit() 4132145Sminshall { 4232145Sminshall init_terminal(); 4332145Sminshall 4432145Sminshall init_network(); 4532145Sminshall 4632145Sminshall init_telnet(); 4732531Sminshall 4832531Sminshall init_sys(); 4934302Sminshall 5034302Sminshall init_3270(); 5132145Sminshall } 5232145Sminshall 5332145Sminshall 5432145Sminshall /* 5532145Sminshall * main. Parse arguments, invoke the protocol or command parser. 5632145Sminshall */ 5732145Sminshall 5832145Sminshall 5934849Sminshall int 6032145Sminshall main(argc, argv) 6132145Sminshall int argc; 6232145Sminshall char *argv[]; 6332145Sminshall { 6432145Sminshall tninit(); /* Clear out things */ 65*38689Sborman #ifdef CRAY 66*38689Sborman _setlist_init(); /* Work around compiler bug */ 67*38689Sborman #endif 6832145Sminshall 6932145Sminshall TerminalSaveState(); 7032145Sminshall 7132145Sminshall prompt = argv[0]; 7232145Sminshall while ((argc > 1) && (argv[1][0] == '-')) { 7332145Sminshall if (!strcmp(argv[1], "-d")) { 7432145Sminshall debug = 1; 7532145Sminshall } else if (!strcmp(argv[1], "-n")) { 7632145Sminshall if ((argc > 1) && (argv[2][0] != '-')) { /* get file name */ 77*38689Sborman SetNetTrace(argv[2]); 7832145Sminshall argv++; 7932145Sminshall argc--; 8032145Sminshall } 8132145Sminshall } else { 8232145Sminshall #if defined(TN3270) && defined(unix) 8332145Sminshall if (!strcmp(argv[1], "-t")) { 8432145Sminshall if ((argc > 1) && (argv[2][0] != '-')) { /* get file name */ 8532145Sminshall transcom = tline; 8635717Smckusick (void) strcpy(transcom, argv[2]); 8732145Sminshall argv++; 8832145Sminshall argc--; 8932145Sminshall } 9032145Sminshall } else if (!strcmp(argv[1], "-noasynch")) { 9136242Sminshall noasynchtty = 1; 9236242Sminshall noasynchnet = 1; 9336242Sminshall } else if (!strcmp(argv[1], "-noasynchtty")) { 9436242Sminshall noasynchtty = 1; 9536242Sminshall } else if (!strcmp(argv[1], "-noasynchnet")) { 9636242Sminshall noasynchnet = 1; 9732145Sminshall } else 9832145Sminshall #endif /* defined(TN3270) && defined(unix) */ 9932145Sminshall if (argv[1][1] != '\0') { 10032145Sminshall fprintf(stderr, "Unknown option *%s*.\n", argv[1]); 10132145Sminshall } 10232145Sminshall } 10332145Sminshall argc--; 10432145Sminshall argv++; 10532145Sminshall } 10632145Sminshall if (argc != 1) { 10732145Sminshall if (setjmp(toplevel) != 0) 10832145Sminshall Exit(0); 10934849Sminshall if (tn(argc, argv) == 1) { 11034849Sminshall return 0; 11134849Sminshall } else { 11234849Sminshall return 1; 11334849Sminshall } 11432145Sminshall } 11534849Sminshall (void) setjmp(toplevel); 11632145Sminshall for (;;) { 11732145Sminshall #if !defined(TN3270) 118*38689Sborman command(1, 0, 0); 11932145Sminshall #else /* !defined(TN3270) */ 12032145Sminshall if (!shell_active) { 121*38689Sborman command(1, 0, 0); 12232145Sminshall } else { 12332145Sminshall #if defined(TN3270) 12432145Sminshall shell_continue(); 12532145Sminshall #endif /* defined(TN3270) */ 12632145Sminshall } 12732145Sminshall #endif /* !defined(TN3270) */ 12832145Sminshall } 12932145Sminshall } 130