SCO OpenServer在硬件检测完毕后自动Numlock ON
发表于:2007-05-26来源:作者:点击数:
标签:
该程序可以实现SCOOpenServer在硬件检测完毕后自动Numlock lockkeys编译方法:cc-olockkeyslockkeys.c 实现步骤: 1、将lockkeys执行程序拷贝到/etc目录下,并赋予执行权限; 2、把numlock.init.string中的代码加入到/etc/inittab文件中指令行的第一行。 num
该程序可以实现SCO OpenServer在硬件检测完毕后自动Numlock
lockkeys编译方法:cc -o lockkeys lockkeys.c
实现步骤:
1、将lockkeys执行程序拷贝到/etc目录下,并赋予执行权限;
2、把numlock.init.string中的代码加入到/etc/inittab文件中指令行的第一行。
numlock.init.string代码内容:
snum::sysinit:/etc/lockkeys numlock on < /dev/console >/dev/console 2>&1
lockkeys源代码:
/*
* Program to control the console lock keys states
*
* Build with
"cc -o lockkeys lockkeys.c
" */
#include
#include
#include
#include
#define RDFD 0
#define CAPSLOCK 0x01
#define N
UMLOCK 0x02
#define SCROLLLOCK 0x04
void main( argc, argv )
int argc;
char *argv[];
{
char c;
int function, key;
if ( argc != 3 ) {
fprintf( stderr,
"Usage: lockkeys key on | off | toggle
" );
exit( 1 );
}
if ( !strcmp( argv[2],
"off
" ))
function=0;
else if ( !strcmp( argv[2],
"on
" ))
function=1;
else if ( !strcmp( argv[2],
"toggle
" ))
function=2;
else {
fprintf( stderr,
"lockkeys: function must be on, off, or toggle
" );
exit( 1 );
}
if ( !strcmp( argv[1],
"numlock
" ))
key=NUMLOCK;
else if ( !strcmp( argv[1],
"capslock
" ))
key=CAPSLOCK;
else if ( !strcmp( argv[1],
"scrolllock
" ))
key=SCROLLLOCK;
else {
fprintf( stderr,
"lockkeys: key must be numlock, capslock, or scrolllock
" );
exit( 1 );
}
if ( ioctl( RDFD, KDGETLED, &c ) != 0 ) {
perror(
"lockkeys: can
't get current lock state
" );
exit( 2 );
}
if ( function == 0 )
c &= ~key;
else if ( function == 1 )
c |= key;
else
c ^= key;
if ( ioctl( RDFD, KDSETLED, c ) != 0 ) {
perror(
"lockkeys: error setting lock state
" );
exit( 2 );
}
exit( 0 );
}
注:该程序非我原创,来自SCO网站,该程序不能在Xwindow中使用仅支持控制台模式。
原文转自:http://www.ltesting.net
|