aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China/*
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * CDDL HEADER START
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China *
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * The contents of this file are subject to the terms of the
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * Common Development and Distribution License (the "License").
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * You may not use this file except in compliance with the License.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China *
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * or http://www.opensolaris.org/os/licensing.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * See the License for the specific language governing permissions
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * and limitations under the License.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China *
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * When distributing Covered Code, include this CDDL HEADER in each
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * If applicable, add the following below this CDDL HEADER, with the
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * fields enclosed by brackets "[]" replaced with your own identifying
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * information: Portions Copyright [yyyy] [name of copyright owner]
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China *
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * CDDL HEADER END
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China/*
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * Use is subject to license terms.
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#include <sys/types.h>
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#include <sys/stat.h>
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#include <fcntl.h>
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#include <unistd.h>
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#include <stropts.h>
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China#include <sys/vt.h>
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China/*
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * return value:
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * 0: disabled
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * 1: enabled
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China * 2: An error occured
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinaint
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing Chinamain(void)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China{
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China int result;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China int fd;
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if ((fd = open("/dev/vt/0", O_RDONLY)) < 0)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China return (2);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (ioctl(fd, VT_ENABLED, &result) != 0) {
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China (void) close(fd);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China return (2);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China }
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China (void) close(fd);
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China if (result == 0)
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China return (0); /* disabled */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China return (1); /* enabled */
aecfc01d1bad84e66649703f7fc2926ef70b34barui zang - Sun Microsystems - Beijing China}