ftp.nice.ch/pub/next/developer/objc/screen/ScreenMunger.2.0.N.bs.tar.gz#/ScreenMunger/flash.c

This is flash.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>

#define DELAY 10000

/* flash.c -- flash the screen at a rather annoying rate.
 *
 * 5/92, CWS -- modified to use the evs driver, added support for signal
 * trapping.  This now runs forever until the user kills it.
 */

int fd = 0;

// handle general signals
void handle(sig)
   int sig;
{
  int j = 40;
  (void) ioctl(fd, EVSIOSB, &j);
  close(fd);
  exit(0);
}

// handle a Cntl-Z, TSTP
void pause(sig)
   int sig;
{
  int j = 40;
  (void) ioctl(fd, EVSIOSB, &j);
  raise(SIGSTOP);
}


main() {
  int j, k;

// 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(1);
  }

  if (signal(SIGTSTP, &pause)) {
      fprintf(stdout, "Couldn't establish new errorhandler for SIGTSTP.\n");
      exit(1);
  }

  fd = open("/dev/evs0", O_RDONLY, NULL);
  
  if (fd <= 0) {
    fprintf(stdout,"Error, openning /dev/evs0: %d.\n", errno);
    exit(1);
  }
  
  for(;;) {
    j=0;
    (void) ioctl(fd, EVSIOSB, &j);
    for(k=0;k<DELAY;k++);
    
    j=61;
    (void) ioctl(fd, EVSIOSB, &j);
    for(k=0;k<DELAY;k++);
  }
  
  j = 40;
  (void) ioctl(fd, EVSIOSB, &j);
  close(fd);
  exit(0);
}






These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.