&& (CONS_fd = open(CONSOLE_DEVICE, O_RDWR, 0)) < 0)
&& (CONS_fd = open(CONSOLE_DEVICE, O_RDWR, 0)) < 0 #ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV && (CONS_fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, O_RDWR, 0)) < 0 #endif )
int OpenVideo(){	if (geteuid() != 0)	{		fprintf(stderr, 			"%s: Must be run as root\n", 			MyName);		return(-1);	}	/*	 * Attempt to open /dev/kbd.  If this fails, the driver is either	 * pccons, or it is codrv and something else has it open.  errno	 * will tell us which case it is.	 */	if ((CONS_fd = open("/dev/kbd", O_RDONLY|O_NDELAY, 0)) < 0)	{		if (errno == EBUSY)		{			/*			 * Codrv, but something else is using the console			 * in "X" mode			 */			fprintf(stderr,			    "%s: Cannot be run while an X server is running\n",			    MyName);			return(-1);		}#ifndef __bsdi__		/*		 * pccons.  To guess if we're being run from within an		 * X session, check $DISPLAY, and fail if it is set.		 * This check is not foolproof -- just a guide.		 */		if (getenv("DISPLAY"))		{			fprintf(stderr,			    "%s: Cannot be run while an X server is running\n",			    MyName);			fprintf(stderr,			    "%s: If an X server is not running, unset $DISPLAY",			    MyName);			fprintf(stderr,			    " and try again\n");			return(-1);		}		if ((CONS_fd = open("/dev/vga", O_RDWR, 0)) < 0		    && (CONS_fd = open(CONSOLE_DEVICE, O_RDWR, 0)) < 0)		{			fprintf(stderr,				"%s: Cannot open /dev/vga nor %s\n", 				MyName, CONSOLE_DEVICE);			return(-1);		}#endif	}	else	{#ifndef __bsdi__#ifdef CODRV_SUPPORT		struct oldconsinfo tmp;		if (ioctl(CONS_fd, OLDCONSGINFO, &tmp) < 0)		{			fprintf(stderr, "%s: Unknown console driver\n",				MyName);			return(-1);		}		HasCodrv = TRUE;#endif#endif	}#ifndef __bsdi__	if (HasCodrv)	{#ifdef CODRV_SUPPORT		int onoff = X_MODE_ON;		if (ioctl(CONS_fd, CONSOLE_X_MODE, &onoff) < 0)		{			fprintf(stderr, "%s: CONSOLE_X_MODE ON failed\n",				MyName);			return(-1);		}		ioctl(CONS_fd, VGATAKECTRL, 0);#endif	}	else	{#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)		/*		 * not codrv and not BSDI; first look if we have a console		 * driver that understands USL-style VT commands		 */		int vt_num;				if (ioctl(CONS_fd, VT_GETACTIVE, &vt_num) == 0)		{			/* yes, so we don't use the old stuff */			HasUslVt = TRUE;			if (ioctl(CONS_fd, KDENABIO, 0) < 0)			{				fprintf(stderr, "%s: KDENABIO failed\n",					MyName);				return(-1);			}		}		else#endif#endif		if (ioctl(CONS_fd, CONSOLE_X_MODE_ON, 0) < 0)		{			fprintf(stderr, "%s: CONSOLE_X_MODE_ON failed\n",				MyName);			return(-1);		}#ifdef __bsdi__	ioctl(CONS_fd, PCCONENABIOPL, 0);#else	}#endif	return(CONS_fd);}