1*33685Sbostic /* 2*33685Sbostic * Copyright (c) 1988 Regents of the University of California. 3*33685Sbostic * All rights reserved. 4*33685Sbostic * 5*33685Sbostic * Redistribution and use in source and binary forms are permitted 6*33685Sbostic * provided that this notice is preserved and that due credit is given 7*33685Sbostic * to the University of California at Berkeley. The name of the University 8*33685Sbostic * may not be used to endorse or promote products derived from this 9*33685Sbostic * software without specific prior written permission. This software 10*33685Sbostic * is provided ``as is'' without express or implied warranty. 11*33685Sbostic */ 12*33685Sbostic 13*33685Sbostic #ifndef lint 14*33685Sbostic char copyright[] = 15*33685Sbostic "@(#) Copyright (c) 1988 Regents of the University of California.\n\ 16*33685Sbostic All rights reserved.\n"; 17*33685Sbostic #endif /* not lint */ 18*33685Sbostic 19*33685Sbostic #ifndef lint 20*33685Sbostic static char sccsid[] = "@(#)main.c 1.5 (Berkeley) 03/08/88"; 21*33685Sbostic #endif /* not lint */ 22*33685Sbostic 2332381Sminshall #include <sys/types.h> 2432381Sminshall 2532381Sminshall #include "ring.h" 2632381Sminshall 2732145Sminshall #include "externs.h" 2832145Sminshall #include "defines.h" 2932145Sminshall 3032145Sminshall /* 3132145Sminshall * Initialize variables. 3232145Sminshall */ 3332145Sminshall 3432145Sminshall void 3532145Sminshall tninit() 3632145Sminshall { 3732145Sminshall init_terminal(); 3832145Sminshall 3932145Sminshall init_network(); 4032145Sminshall 4132145Sminshall init_telnet(); 4232531Sminshall 4332531Sminshall init_sys(); 4432145Sminshall } 4532145Sminshall 4632145Sminshall 4732145Sminshall /* 4832145Sminshall * main. Parse arguments, invoke the protocol or command parser. 4932145Sminshall */ 5032145Sminshall 5132145Sminshall 5232145Sminshall void 5332145Sminshall main(argc, argv) 5432145Sminshall int argc; 5532145Sminshall char *argv[]; 5632145Sminshall { 5732145Sminshall tninit(); /* Clear out things */ 5832145Sminshall 5932145Sminshall TerminalSaveState(); 6032145Sminshall 6132145Sminshall prompt = argv[0]; 6232145Sminshall while ((argc > 1) && (argv[1][0] == '-')) { 6332145Sminshall if (!strcmp(argv[1], "-d")) { 6432145Sminshall debug = 1; 6532145Sminshall } else if (!strcmp(argv[1], "-n")) { 6632145Sminshall if ((argc > 1) && (argv[2][0] != '-')) { /* get file name */ 6732145Sminshall NetTrace = fopen(argv[2], "w"); 6832145Sminshall argv++; 6932145Sminshall argc--; 7032145Sminshall if (NetTrace == NULL) { 7132145Sminshall NetTrace = stdout; 7232145Sminshall } 7332145Sminshall } 7432145Sminshall } else { 7532145Sminshall #if defined(TN3270) && defined(unix) 7632145Sminshall if (!strcmp(argv[1], "-t")) { 7732145Sminshall if ((argc > 1) && (argv[2][0] != '-')) { /* get file name */ 7832145Sminshall transcom = tline; 7932145Sminshall (void) strcpy(transcom, argv[1]); 8032145Sminshall argv++; 8132145Sminshall argc--; 8232145Sminshall } 8332145Sminshall } else if (!strcmp(argv[1], "-noasynch")) { 8432145Sminshall noasynch = 1; 8532145Sminshall } else 8632145Sminshall #endif /* defined(TN3270) && defined(unix) */ 8732145Sminshall if (argv[1][1] != '\0') { 8832145Sminshall fprintf(stderr, "Unknown option *%s*.\n", argv[1]); 8932145Sminshall } 9032145Sminshall } 9132145Sminshall argc--; 9232145Sminshall argv++; 9332145Sminshall } 9432145Sminshall if (argc != 1) { 9532145Sminshall if (setjmp(toplevel) != 0) 9632145Sminshall Exit(0); 9732145Sminshall tn(argc, argv); 9832145Sminshall } 9932145Sminshall setjmp(toplevel); 10032145Sminshall for (;;) { 10132145Sminshall #if !defined(TN3270) 10232145Sminshall command(1); 10332145Sminshall #else /* !defined(TN3270) */ 10432145Sminshall if (!shell_active) { 10532145Sminshall command(1); 10632145Sminshall } else { 10732145Sminshall #if defined(TN3270) 10832145Sminshall shell_continue(); 10932145Sminshall #endif /* defined(TN3270) */ 11032145Sminshall } 11132145Sminshall #endif /* !defined(TN3270) */ 11232145Sminshall } 11332145Sminshall } 114