home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_06_04 / v6n4053c.txt < prev    next >
Text File  |  1989-09-28  |  757b  |  41 lines

  1. #include "q2.h"
  2.  
  3. #define TEST 1
  4.  
  5. #ifdef TEST
  6. #define cksig(x) if(qpt->sigword!=0x756)exit();
  7. #else
  8. #define chsig(x)
  9. #endif
  10.  
  11. static struct q_strct {
  12.    qele_type queue[q_MAX]; 
  13.    int next_in ;
  14.    int next_out;
  15.    int sigword ;
  16.    } q1, q2;
  17.  
  18. /* now initialization must be explicit */ 
  19. void q_init(qpt)
  20. struct q_strct *qpt;
  21. {
  22. qpt->next_in = 0;
  23. qpt->next_out = 0;
  24. qpt->sigword = 0x576;
  25. }
  26.  
  27. /* fetch an item from the queue */
  28.  
  29. qele_type q_get(qpt)
  30. struct q_strct *qpt;
  31. {
  32.       qele_type rval;
  33.       cksig(qpt);
  34.       /* first test to see if there is an item */
  35.       if (qpt->next_in == qpt->next_out) return EMPTY;
  36.       qele_cpy(rval, qpt->queue[qpt->next_out++]);
  37.       (qpt->next_out) &= q_WRAP;
  38.       return rval;
  39. }
  40.  
  41.