onoff.c
来自「中科院徐志伟老师一书《操作系统 原理·技术与编程》的源代码和习题接」· C语言 代码 · 共 29 行
C
29 行
#include <fcntl.h>#include <unistd.h>#include <stdio.h>#include <string.h>#include <linux/ioport.h>#include "trlight.h"#include <asm/io.h>int value=0;void main (int argc, char** argv){ int fd; if (argc<2){ printf("usage: onoff [1/0]\n"); exit(0); } fd=open("/dev/trlight",0); sscanf(argv[1],"%d",&value); printf("%d",value); if (value==1) value=TRLIGHT_START; else if (value==0) value=TRLIGHT_STOP; ioctl(fd,value,0); close(fd); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?