This is bright.c in view mode; [Download] [Up]
#import <stdio.h> #import <nextdev/evsio.h> #import <sys/file.h> #import <sys/ioctl.h> #import <sys/signal.h> /* bright.c -- smoothly alter the screen brightness. * * 5/92, CWS -- modified to use the evs driver, added support for signal * trapping. This now runs forever until the user kills it. */ #define DELAY 100000 int fd = 0; void handle(sig) int sig; { int i = 40; (void) ioctl(fd, EVSIOSB, &i); close(fd); fprintf(stdout, "\nCaught signal %d...\n", sig); exit(0); } void pause(sig) int sig; { int i = 40; (void) ioctl(fd, EVSIOSB, &i); raise(SIGSTOP); } main() { int i,j; // do the signal trapping stuff if (signal(SIGINT, &handle)) { fprintf(stdout, "Couldn't establish new error handler for SIGINT.\n"); exit(1); } if (signal(SIGTERM, &handle)) { fprintf(stdout, "Couldn't establish new error handler for SIGTERM.\n"); exit(2); } if (signal(SIGTSTP, &pause)) { fprintf(stdout, "Couldn't establish new errorhandler for SIGTSTP.\n"); exit(3); } fd = open("/dev/evs0", O_RDONLY, NULL); if (fd <= 0) { fprintf(stdout,"Error, openning /dev/evs0: %d.\n", errno); exit(4); } for(;;) { for (i=0; i < 61; i++) { (void) ioctl(fd, EVSIOSB, &i); for(j=0;j<DELAY;j++); } for (i=61; i > 0; i--) { (void) ioctl(fd, EVSIOSB, &i); for(j=0;j<DELAY;j++); } } // if we exit, do this i = 40; (void) ioctl(fd, EVSIOSB, &i); close(fd); exit(0); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.