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*36242Sminshall static char sccsid[] = "@(#)main.c 1.10 (Berkeley) 11/18/88"; 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 */ 6532145Sminshall 6632145Sminshall TerminalSaveState(); 6732145Sminshall 6832145Sminshall prompt = argv[0]; 6932145Sminshall while ((argc > 1) && (argv[1][0] == '-')) { 7032145Sminshall if (!strcmp(argv[1], "-d")) { 7132145Sminshall debug = 1; 7232145Sminshall } else if (!strcmp(argv[1], "-n")) { 7332145Sminshall if ((argc > 1) && (argv[2][0] != '-')) { /* get file name */ 7432145Sminshall NetTrace = fopen(argv[2], "w"); 7532145Sminshall argv++; 7632145Sminshall argc--; 7732145Sminshall if (NetTrace == NULL) { 7832145Sminshall NetTrace = stdout; 7932145Sminshall } 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")) { 91*36242Sminshall noasynchtty = 1; 92*36242Sminshall noasynchnet = 1; 93*36242Sminshall } else if (!strcmp(argv[1], "-noasynchtty")) { 94*36242Sminshall noasynchtty = 1; 95*36242Sminshall } else if (!strcmp(argv[1], "-noasynchnet")) { 96*36242Sminshall 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) 11832145Sminshall command(1); 11932145Sminshall #else /* !defined(TN3270) */ 12032145Sminshall if (!shell_active) { 12132145Sminshall command(1); 12232145Sminshall } else { 12332145Sminshall #if defined(TN3270) 12432145Sminshall shell_continue(); 12532145Sminshall #endif /* defined(TN3270) */ 12632145Sminshall } 12732145Sminshall #endif /* !defined(TN3270) */ 12832145Sminshall } 12932145Sminshall } 130