d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL;
d_tio.c_cflag = VAL_LINE_SPEED|CS8|CREAD|PARENB|HUPCL;
main (int argc, char *argv[]){	Widget form_top, menu_top;	register TScreen *screen;	int mode;	/* Do these first, since we may not be able to open the display */	ProgramName = argv[0];	if (argc > 1) {		if (abbrev(argv[1], "-version"))			Version();		if (abbrev(argv[1], "-help"))			Help();	}	/* This dumps core on HP-UX 9.05 with X11R5 */#if OPT_I18N_SUPPORT	XtSetLanguageProc (NULL, NULL, NULL);#endif#ifndef AMOEBA	/* +2 in case longer tty name like /dev/ttyq255 */	ttydev = (char *) malloc (sizeof(TTYDEV) + 2);#ifndef __osf__	ptydev = (char *) malloc (sizeof(PTYDEV) + 2);	if (!ttydev || !ptydev)#else	if (!ttydev)#endif	{	    fprintf (stderr,		     "%s:  unable to allocate memory for ttydev or ptydev\n",		     ProgramName);	    exit (1);	}	strcpy (ttydev, TTYDEV);#ifndef __osf__	strcpy (ptydev, PTYDEV);#endif#ifdef MINIX	d_tio.c_iflag= TINPUT_DEF;	d_tio.c_oflag= TOUTPUT_DEF;	d_tio.c_cflag= TCTRL_DEF;	d_tio.c_lflag= TLOCAL_DEF;	cfsetispeed(&d_tio, TSPEED_DEF);	cfsetispeed(&d_tio, TSPEED_DEF);	d_tio.c_cc[VEOF]= TEOF_DEF;	d_tio.c_cc[VEOL]= TEOL_DEF;	d_tio.c_cc[VERASE]= TERASE_DEF;	d_tio.c_cc[VINTR]= TINTR_DEF;	d_tio.c_cc[VKILL]= TKILL_DEF;	d_tio.c_cc[VMIN]= TMIN_DEF;	d_tio.c_cc[VQUIT]= TQUIT_DEF;	d_tio.c_cc[VTIME]= TTIME_DEF;	d_tio.c_cc[VSUSP]= TSUSP_DEF;	d_tio.c_cc[VSTART]= TSTART_DEF;	d_tio.c_cc[VSTOP]= TSTOP_DEF;	d_tio.c_cc[VREPRINT]= TREPRINT_DEF;	d_tio.c_cc[VLNEXT]= TLNEXT_DEF;	d_tio.c_cc[VDISCARD]= TDISCARD_DEF;#elif defined(USE_SYSV_TERMIO) || defined(USE_POSIX_TERMIOS) /* { */	/* Initialization is done here rather than above in order	** to prevent any assumptions about the order of the contents	** of the various terminal structures (which may change from	** implementation to implementation).	*/	d_tio.c_iflag = ICRNL|IXON;#ifdef TAB3	d_tio.c_oflag = OPOST|ONLCR|TAB3;#else#ifdef ONLCR	d_tio.c_oflag = OPOST|ONLCR;#else	d_tio.c_oflag = OPOST;#endif#endif#if defined(macII) || defined(ATT) || defined(CRAY) /* { */	d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL;	d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;#ifdef ECHOKE	d_tio.c_lflag |= ECHOKE|IEXTEN;#endif#ifdef ECHOCTL	d_tio.c_lflag |= ECHOCTL|IEXTEN;#endif#ifndef USE_TERMIOS /* { */	d_tio.c_line = 0;#endif /* } */	d_tio.c_cc[VINTR] = CINTR;	d_tio.c_cc[VQUIT] = CQUIT;	d_tio.c_cc[VERASE] = CERASE;	d_tio.c_cc[VKILL] = CKILL;	d_tio.c_cc[VEOF] = CEOF;	d_tio.c_cc[VEOL] = CNUL;	d_tio.c_cc[VEOL2] = CNUL;#ifdef VSWTCH	d_tio.c_cc[VSWTCH] = CNUL;#endif#if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */	d_tio.c_cc[VSUSP] = CSUSP;#ifdef VDSUSP	d_tio.c_cc[VDSUSP] = CDSUSP;#endif	d_tio.c_cc[VREPRINT] = CRPRNT;	d_tio.c_cc[VDISCARD] = CFLUSH;	d_tio.c_cc[VWERASE] = CWERASE;	d_tio.c_cc[VLNEXT] = CLNEXT;	d_tio.c_cc[VMIN] = 1;	d_tio.c_cc[VTIME] = 0;#endif /* } */#ifdef HAS_LTCHARS /* { */	d_ltc.t_suspc = CSUSP;		/* t_suspc */	d_ltc.t_dsuspc = CDSUSP;	/* t_dsuspc */	d_ltc.t_rprntc = CRPRNT;	d_ltc.t_flushc = CFLUSH;	d_ltc.t_werasc = CWERASE;	d_ltc.t_lnextc = CLNEXT;#endif /* } HAS_LTCHARS */#ifdef TIOCLSET /* { */	d_lmode = 0;#endif /* } TIOCLSET */#else  /* }{ else !macII, ATT, CRAY */#ifndef USE_POSIX_TERMIOS#ifdef BAUD_0 /* { */	d_tio.c_cflag = CS8|CREAD|PARENB|HUPCL;#else	/* }{ !BAUD_0 */	d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL;#endif	/* } !BAUD_0 */#else /* USE_POSIX_TERMIOS */	d_tio.c_cflag = CS8|CREAD|PARENB|HUPCL;	cfsetispeed(&d_tio, B9600);	cfsetospeed(&d_tio, B9600);#endif	d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;#ifdef ECHOKE	d_tio.c_lflag |= ECHOKE|IEXTEN;#endif#ifdef ECHOCTL	d_tio.c_lflag |= ECHOCTL|IEXTEN;#endif#ifndef USE_POSIX_TERMIOS#ifdef NTTYDISC	d_tio.c_line = NTTYDISC;#else	d_tio.c_line = 0;#endif#endif /* USE_POSIX_TERMIOS */#ifdef __sgi	d_tio.c_cflag &= ~(HUPCL|PARENB);	d_tio.c_iflag |= BRKINT|ISTRIP|IGNPAR;#endif	d_tio.c_cc[VINTR] = CONTROL('C');	/* '^C'	*/	d_tio.c_cc[VERASE] = 0x7f;		/* DEL	*/	d_tio.c_cc[VKILL] = CONTROL('U');	/* '^U'	*/	d_tio.c_cc[VQUIT] = CQUIT;		/* '^\'	*/	d_tio.c_cc[VEOF] = CEOF;		/* '^D' */	d_tio.c_cc[VEOL] = CEOL;		/* '^@'	*/	d_tio.c_cc[VMIN] = 1;	d_tio.c_cc[VTIME] = 0;#ifdef VSWTCH	d_tio.c_cc[VSWTCH] = CSWTCH;            /* usually '^Z' */#endif#ifdef VLNEXT	d_tio.c_cc[VLNEXT] = CLNEXT;#endif#ifdef VWERASE	d_tio.c_cc[VWERASE] = CWERASE;#endif#ifdef VREPRINT	d_tio.c_cc[VREPRINT] = CRPRNT;#endif#ifdef VRPRNT	d_tio.c_cc[VRPRNT] = CRPRNT;#endif#ifdef VDISCARD	d_tio.c_cc[VDISCARD] = CFLUSH;#endif#ifdef VFLUSHO	d_tio.c_cc[VFLUSHO] = CFLUSH;#endif#ifdef VSTOP	d_tio.c_cc[VSTOP] = CSTOP;#endif#ifdef VSTART	d_tio.c_cc[VSTART] = CSTART;#endif#ifdef VSUSP	d_tio.c_cc[VSUSP] = CSUSP;#endif#ifdef VDSUSP	d_tio.c_cc[VDSUSP] = CDSUSP;#endif#ifdef VSTATUS	d_tio.c_cc[VSTATUS] = CSTATUS;#endif	/* now, try to inherit tty settings */	{	    int i;	    for (i = 0; i <= 2; i++) {#ifndef USE_POSIX_TERMIOS		struct termio deftio;		if (ioctl (i, TCGETA, &deftio) == 0)#else		struct termios deftio;		if (tcgetattr(i, &deftio) == 0)#endif		{		    d_tio.c_cc[VINTR] = deftio.c_cc[VINTR];		    d_tio.c_cc[VQUIT] = deftio.c_cc[VQUIT];		    d_tio.c_cc[VERASE] = deftio.c_cc[VERASE];		    d_tio.c_cc[VKILL] = deftio.c_cc[VKILL];		    d_tio.c_cc[VEOF] = deftio.c_cc[VEOF];		    d_tio.c_cc[VEOL] = deftio.c_cc[VEOL];#ifdef VSWTCH		    d_tio.c_cc[VSWTCH] = deftio.c_cc[VSWTCH];#endif#ifdef VEOL2		    d_tio.c_cc[VEOL2] = deftio.c_cc[VEOL2];#endif#ifdef VLNEXT		    d_tio.c_cc[VLNEXT] = deftio.c_cc[VLNEXT];#endif#ifdef VWERASE		    d_tio.c_cc[VWERASE] = deftio.c_cc[VWERASE];#endif#ifdef VREPRINT		    d_tio.c_cc[VREPRINT] = deftio.c_cc[VREPRINT];#endif#ifdef VRPRNT		    d_tio.c_cc[VRPRNT] = deftio.c_cc[VRPRNT];#endif#ifdef VDISCARD		    d_tio.c_cc[VDISCARD] = deftio.c_cc[VDISCARD];#endif#ifdef VFLUSHO		    d_tio.c_cc[VFLUSHO] = deftio.c_cc[VFLUSHO];#endif#ifdef VSTOP		    d_tio.c_cc[VSTOP] = deftio.c_cc[VSTOP];#endif#ifdef VSTART		    d_tio.c_cc[VSTART] = deftio.c_cc[VSTART];#endif#ifdef VSUSP		    d_tio.c_cc[VSUSP] = deftio.c_cc[VSUSP];#endif#ifdef VDSUSP		    d_tio.c_cc[VDSUSP] = deftio.c_cc[VDSUSP];#endif#ifdef VSTATUS		    d_tio.c_cc[VSTATUS] = deftio.c_cc[VSTATUS];#endif		    break;		}	    }	}#ifdef HAS_LTCHARS /* { */	d_ltc.t_suspc = '\000';		/* t_suspc */	d_ltc.t_dsuspc = '\000';	/* t_dsuspc */	d_ltc.t_rprntc = '\377';	/* reserved...*/	d_ltc.t_flushc = '\377';	d_ltc.t_werasc = '\377';	d_ltc.t_lnextc = '\377';#endif	/* } HAS_LTCHARS */#if defined(USE_TERMIOS) || defined(USE_POSIX_TERMIOS) /* { */	d_tio.c_cc[VSUSP] = CSUSP;#ifdef VDSUSP	d_tio.c_cc[VDSUSP] = '\000';#endif#ifdef VSTATUS	d_tio.c_cc[VSTATUS] = '\377';#endif#ifdef VREPRINT	d_tio.c_cc[VREPRINT] = '\377';#endif#ifdef VDISCARD	d_tio.c_cc[VDISCARD] = '\377';#endif#ifdef VWERASE	d_tio.c_cc[VWERASE] = '\377';#endif#ifdef VLNEXT	d_tio.c_cc[VLNEXT] = '\377';#endif#endif /* } USE_TERMIOS */#ifdef TIOCLSET /* { */	d_lmode = 0;#endif	/* } TIOCLSET */#endif  /* } macII, ATT, CRAY */#endif	/* } MINIX, etc */#endif  /* AMOEBA */	/* Init the Toolkit. */	{#ifdef HAS_SAVED_IDS_AND_SETEUID	    uid_t euid = geteuid();	    gid_t egid = getegid();	    uid_t ruid = getuid();	    gid_t rgid = getgid();	    if (setegid(rgid) == -1)#ifdef __MVS__	       if (!(errno == EMVSERR)) /* could happen if _BPX_SHAREAS=REUSE */#endif		(void) fprintf(stderr, "setegid(%d): %s\n",			       (int) rgid, strerror(errno));	    if (seteuid(ruid) == -1)#ifdef __MVS__	       if (!(errno == EMVSERR))#endif		(void) fprintf(stderr, "seteuid(%d): %s\n",			       (int) ruid, strerror(errno));#endif	    XtSetErrorHandler(xt_error);	    toplevel = XtAppInitialize (&app_con, "XTerm",					optionDescList,					XtNumber(optionDescList),					&argc, argv, fallback_resources,					NULL, 0);	    XtSetErrorHandler((XtErrorHandler)0);	    XtGetApplicationResources(toplevel, (XtPointer) &resource,				      application_resources,				      XtNumber(application_resources), NULL, 0);#ifdef HAS_SAVED_IDS_AND_SETEUID	    if (seteuid(euid) == -1)#ifdef __MVS__	       if (!(errno == EMVSERR))#endif		(void) fprintf(stderr, "seteuid(%d): %s\n",			       (int) euid, strerror(errno));	    if (setegid(egid) == -1)#ifdef __MVS__	       if (!(errno == EMVSERR))#endif		(void) fprintf(stderr, "setegid(%d): %s\n",			       (int) egid, strerror(errno));#endif	}	waiting_for_initial_map = resource.wait_for_map;	/*	 * ICCCM delete_window.	 */	XtAppAddActions(app_con, actionProcs, XtNumber(actionProcs));	/*	 * fill in terminal modes	 */	if (resource.tty_modes) {	    int n = parse_tty_modes (resource.tty_modes, ttymodelist);	    if (n < 0) {		fprintf (stderr, "%s:  bad tty modes \"%s\"\n",			 ProgramName, resource.tty_modes);	    } else if (n > 0) {		override_tty_modes = 1;	    }	}#if OPT_ZICONBEEP	zIconBeep = resource.zIconBeep;	zIconBeep_flagged = False;	if ( zIconBeep > 100 || zIconBeep < -100 ) {	    zIconBeep = 0;	/* was 100, but I prefer to defaulting off. */	    fprintf( stderr, "a number between -100 and 100 is required for zIconBeep.  0 used by default\n");	}#endif /* OPT_ZICONBEEP */#if OPT_SAME_NAME	sameName = resource.sameName;#endif	hold_screen = resource.hold_screen ? 1 : 0;	xterm_name = resource.xterm_name;	if (strcmp(xterm_name, "-") == 0) xterm_name = DFT_TERMTYPE;	if (resource.icon_geometry != NULL) {	    int scr, junk;	    int ix, iy;	    Arg args[2];	    for(scr = 0;	/* yyuucchh */		XtScreen(toplevel) != ScreenOfDisplay(XtDisplay(toplevel),scr);		scr++);	    args[0].name = XtNiconX;	    args[1].name = XtNiconY;	    XGeometry(XtDisplay(toplevel), scr, resource.icon_geometry, "",		      0, 0, 0, 0, 0, &ix, &iy, &junk, &junk);	    args[0].value = (XtArgVal) ix;	    args[1].value = (XtArgVal) iy;	    XtSetValues( toplevel, args, 2);	}	XtSetValues (toplevel, ourTopLevelShellArgs,		     number_ourTopLevelShellArgs);	/* Parse the rest of the command line */	for (argc--, argv++ ; argc > 0 ; argc--, argv++) {	    if(**argv != '-') Syntax (*argv);	    switch(argv[0][1]) {	     case 'h':		Help ();		/* NOTREACHED */	     case 'C':#if defined(TIOCCONS) || defined(SRIOCSREDIR)#ifndef __sgi		{		    struct stat sbuf;		    /* Must be owner and have read/write permission.		       xdm cooperates to give the console the right user. */		    if ( !stat("/dev/console", &sbuf) &&			 (sbuf.st_uid == getuid()) &&			 !access("/dev/console", R_OK|W_OK))		    {			Console = TRUE;		    } else			Console = FALSE;		}#else /* __sgi */		Console = TRUE;#endif /* __sgi */#endif	/* TIOCCONS */		continue;	     case 'S':		if (sscanf(*argv + 2, "%c%c%d", passedPty, passedPty+1,			   &am_slave) != 3)		    Syntax(*argv);		continue;#ifdef DEBUG	     case 'D':		debug = TRUE;		continue;#endif	/* DEBUG */	     case 'e':		if (argc <= 1) Syntax (*argv);		command_to_exec = ++argv;		break;	     default:		Syntax (*argv);	    }	    break;	}#if OPT_WIDE_CHARS	/* Test whether UTF-8 mode should be active by default */	{	    char *s;	    if ((s = getenv("LC_ALL")) ||		(s = getenv("LC_CTYPE")) ||		(s = getenv("LANG"))) {		if (strstr(s, "UTF-8"))		    defaultUTF8[0] = '2';	    }	}#endif	SetupMenus(toplevel, &form_top, &menu_top);	term = (XtermWidget) XtVaCreateManagedWidget(		"vt100", xtermWidgetClass, form_top,#if OPT_TOOLBAR		XtNmenuBar,	menu_top,		XtNresizable,	True,		XtNfromVert,	menu_top,		XtNleft,	XawChainLeft,		XtNright,	XawChainRight,		XtNbottom,	XawChainBottom,#endif		0);	    /* this causes the initialize method to be called */#if OPT_HP_FUNC_KEYS	init_keyboard_type(keyboardIsHP, resource.hpFunctionKeys);#endif	init_keyboard_type(keyboardIsSun, resource.sunFunctionKeys);#if OPT_SUNPC_KBD	init_keyboard_type(keyboardIsVT220, resource.sunKeyboard);#endif	screen = &term->screen;	inhibit = 0;#ifdef ALLOWLOGGING	if (term->misc.logInhibit)		inhibit |= I_LOG;#endif	if (term->misc.signalInhibit)		inhibit |= I_SIGNAL;#if OPT_TEK4014	if (term->misc.tekInhibit)		inhibit |= I_TEK;#endif/* * Set title and icon name if not specified */	if (command_to_exec) {	    Arg args[2];	    if (!resource.title) {		if (command_to_exec) {		    resource.title = base_name (command_to_exec[0]);		} /* else not reached */	    }	    if (!resource.icon_name)	      resource.icon_name = resource.title;	    XtSetArg (args[0], XtNtitle, resource.title);	    XtSetArg (args[1], XtNiconName, resource.icon_name);	    XtSetValues (toplevel, args, 2);	}#if OPT_TEK4014	if(inhibit & I_TEK)		screen->TekEmu = FALSE;	if(screen->TekEmu && !TekInit())		exit(ERROR_INIT);#endif#ifndef MINIX#ifdef DEBUG    {	/* Set up stderr properly.  Opening this log file cannot be	 done securely by a privileged xterm process (although we try),	 so the debug feature is disabled by default. */	int i = -1;	if(debug) {		creat_as (getuid(), getgid(), "xterm.debug.log", 0666);		i = open ("xterm.debug.log", O_WRONLY | O_TRUNC, 0666);	}	if(i >= 0) {#if defined(USE_SYSV_TERMIO) && !defined(SVR4) && !defined(linux)		/* SYSV has another pointer which should be part of the		** FILE structure but is actually a separate array.		*/		unsigned char *old_bufend;		old_bufend = (unsigned char *) _bufend(stderr);#ifdef __hpux		stderr->__fileH = (i >> 8);		stderr->__fileL = i;#else		stderr->_file = i;#endif		_bufend(stderr) = old_bufend;#else	/* USE_SYSV_TERMIO */#ifndef linux		stderr->_file = i;#else		setfileno(stderr, i);#endif#endif	/* USE_SYSV_TERMIO */		/* mark this file as close on exec */		(void) fcntl(i, F_SETFD, 1);	}    }#endif	/* DEBUG */#endif /* MINIX */	/* open a terminal for client */	get_terminal ();	spawn ();#ifndef VMS	/* Child process is out there, let's catch its termination */	(void) signal (SIGCHLD, reapchild);	/* Realize procs have now been executed */#ifndef AMOEBA	if (am_slave) { /* Write window id so master end can read and use */	    char buf[80];	    buf[0] = '\0';	    sprintf (buf, "%lx\n", XtWindow (XtParent (CURRENT_EMU(screen))));	    write (screen->respond, buf, strlen (buf));	}#endif /* !AMOEBA */	screen->inhibit = inhibit;#ifdef AIXV3#if (OSMAJORVERSION < 4)	/* In AIXV3, xterms started from /dev/console have CLOCAL set.	 * This means we need to clear CLOCAL so that SIGHUP gets sent	 * to the slave-pty process when xterm exits.	 */	{	    struct termio tio;	    if(ioctl(screen->respond, TCGETA, &tio) == -1)		SysError(ERROR_TIOCGETP);	    tio.c_cflag &= ~(CLOCAL);	    if (ioctl (screen->respond, TCSETA, &tio) == -1)		SysError(ERROR_TIOCSETP);	}#endif#endif#ifndef AMOEBA#ifdef MINIX	if ((mode = fcntl(screen->respond, F_GETFD, 0)) == -1)		Error(1);	mode |= FD_ASYNCHIO;	if (fcntl(screen->respond, F_SETFD, mode) == -1)		Error(1);	nbio_register(screen->respond);#elif defined(USE_SYSV_TERMIO) || defined(__MVS__)	if (0 > (mode = fcntl(screen->respond, F_GETFL, 0)))		Error(1);#ifdef O_NDELAY	mode |= O_NDELAY;#else	mode |= O_NONBLOCK;#endif /* O_NDELAY */	if (fcntl(screen->respond, F_SETFL, mode))		Error(1);#else	/* !MINIX && !USE_SYSV_TERMIO */	mode = 1;	if (ioctl (screen->respond, FIONBIO, (char *)&mode) == -1) SysError (ERROR_FIONBIO);#endif	/* MINIX, etc */#endif  /* AMOEBA */	FD_ZERO (&pty_mask);	FD_ZERO (&X_mask);	FD_ZERO (&Select_mask);	FD_SET (screen->respond, &pty_mask);	FD_SET (ConnectionNumber(screen->display), &X_mask);	FD_SET (screen->respond, &Select_mask);	FD_SET (ConnectionNumber(screen->display), &Select_mask);	max_plus1 = (screen->respond < ConnectionNumber(screen->display)) ?		(1 + ConnectionNumber(screen->display)) :		(1 + screen->respond);#endif /* !VMS */#ifdef DEBUG	if (debug) printf ("debugging on\n");#endif	/* DEBUG */	XSetErrorHandler(xerror);	XSetIOErrorHandler(xioerror);#ifdef ALLOWLOGGING	if (term->misc.log_on) {		StartLog(screen);	}#endif	for( ; ; ) {#if OPT_TEK4014		if(screen->TekEmu)			TekRun();		else#endif			VTRun();	}}