home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / siod-29.zip / SIOD-29.SHA / siodm.c < prev    next >
C/C++ Source or Header  |  1993-01-09  |  1KB  |  40 lines

  1. /* Code specific to Lightspeed C on MacIntosh.
  2.    This detects that the character APPLE-DOT is depressed,
  3.    and then expects that sending a newline to the console
  4.    will invoke the proper signal handling code. 
  5.  
  6.    See the file "THINK C 5.0 FOLDER/C LIBRARIES/SOURCES/CONSOLE.C"
  7.  
  8.    It would be a good thing to have some code in here that would call
  9.    the proper inside-mac OS routines to determine allowable machine
  10.    stack size, because of lack of protection against stack
  11.    overflow bashing another program.
  12.  
  13.  */
  14.   
  15.  
  16. #include <stdio.h>
  17. #include <console.h>
  18.  
  19. #include <MacHeaders>
  20.  
  21. static int interrupt_key_down(void);
  22. void full_interrupt_poll(int *counter);
  23.  
  24. void full_interrupt_poll(int *counter)
  25. {SystemTask();
  26.  if (interrupt_key_down())
  27.      putc('\n',stdout);
  28.   /* 200 seems to be a good compromise here between
  29.      interrupt latency and cpu-bound performance */   
  30.  *counter = 200;}
  31.  
  32. static int interrupt_key_down(void)
  33. {EvQElPtr l;
  34.  for(l = (EvQElPtr) EventQueue.qHead; l; l = (EvQElPtr) l->qLink)
  35.    if ((l->evtQWhat == keyDown) &&
  36.        ((char) l->evtQMessage == '.') &&
  37.        (l->evtQModifiers & cmdKey))
  38.      return(1);
  39.  return(0);}
  40.