XawSimpleMenuAddGlobalActions (app_con); XtRegisterGrabAction (HandlePopupMenu, True, (ButtonPressMask|ButtonReleaseMask), GrabModeAsync, GrabModeAsync);  term = (XtermWidget) XtCreateManagedWidget( "vt100", xtermWidgetClass, toplevel, NULL, 0);
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);
main (int argc, char **argv, char **envp){	register TScreen *screen;	int mode;	extern char **environ;	/* 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();	}	/* XXX: for some obscure reason EMX seems to lose the value of	 * the environ variable, don't understand why, so save it recently	 */	gblenvp = envp;#ifdef I18N	setlocale(LC_ALL, NULL);#endif/*debug	opencons();*/	ttydev = (char *) malloc (PTMS_BUFSZ);	ptydev = (char *) malloc (PTMS_BUFSZ);	if (!ttydev || !ptydev) {	    fprintf (stderr,	    	     "%s:  unable to allocate memory for ttydev or ptydev\n",		     ProgramName);	    exit (1);	}	strcpy (ttydev, TTYDEV);	strcpy (ptydev, PTYDEV);	/* 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;	d_tio.c_oflag = OPOST|ONLCR|TAB3;    	d_tio.c_cflag = B9600|CS8|CREAD|PARENB|HUPCL;    	d_tio.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;	d_tio.c_line = 0;	d_tio.c_cc[VINTR] = CTRL('C');		/* '^C'	*/	d_tio.c_cc[VERASE] = 0x7f;		/* DEL	*/	d_tio.c_cc[VKILL] = CTRL('U');		/* '^U'	*/	d_tio.c_cc[VQUIT] = CQUIT;		/* '^\'	*/    	d_tio.c_cc[VEOF] = CEOF;		/* '^D'	*/	d_tio.c_cc[VEOL] = CEOL;		/* '^@'	*/	/* Init the Toolkit. */	{	    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);	}	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	xterm_name = resource.xterm_name;	sunFunctionKeys = resource.sunFunctionKeys;#if OPT_SUNPC_KBD	sunKeyboard = resource.sunKeyboard;#endif	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':		{		    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;		}		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;	}	XawSimpleMenuAddGlobalActions (app_con);	XtRegisterGrabAction (HandlePopupMenu, True,			      (ButtonPressMask|ButtonReleaseMask),			      GrabModeAsync, GrabModeAsync);        term = (XtermWidget) XtCreateManagedWidget(	    "vt100", xtermWidgetClass, toplevel, NULL, 0);	    /* this causes the initialize method to be called */        screen = &term->screen;	if (screen->savelines < 0) screen->savelines = 0;	term->flags = 0;	if (!screen->jumpscroll) {	    term->flags |= SMOOTHSCROLL;	    update_jumpscroll();	}	if (term->misc.reverseWrap) {	    term->flags |= REVERSEWRAP;	    update_reversewrap();	}	if (term->misc.autoWrap) {	    term->flags |= WRAPAROUND;	    update_autowrap();	}	if (term->misc.re_verse) {	    term->flags |= REVERSE_VIDEO;	    update_reversevideo();	}	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	term->initflags = term->flags;	if (term->misc.appcursorDefault) {	    term->keyboard.flags |= MODE_DECCKM;	    update_appcursor();	}	if (term->misc.appkeypadDefault) {	    term->keyboard.flags |= MODE_DECKPAM;	    update_appkeypad();	}/* * 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#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) {		dup2(i,2);		/* mark this file as close on exec */		(void) fcntl(i, F_SETFD, 1);	}    }#endif	/* DEBUG */	/* open a terminal for client */	get_terminal ();	spawn ();	/* Child process is out there, let's catch its termination */	(void) signal (SIGCHLD, reapchild);	/* Realize procs have now been executed */	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));	}	screen->inhibit = inhibit;	if (0 > (mode = fcntl(screen->respond, F_GETFL, 0)))		Error(1);	mode |= O_NDELAY;	if (fcntl(screen->respond, F_SETFL, mode))		Error(1);	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);#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();	}	return 0;}