home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / sharedmem / part01 / src / msg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-17  |  966 b   |  48 lines

  1. /* msg.c */
  2.  
  3. #include <sys/time.h>
  4. #include "cm_constants.h"
  5. #include "cm_sd.h"
  6. #include "cm_slot.h"
  7. #include "cm_msg.h"
  8. #include "cm_bytestuff.h"
  9.  
  10. extern int cm_debug_level;
  11.  
  12. /* returns NULL if no more slots */
  13. struct slot *
  14. nextslot(m,s)
  15. struct msg *m;
  16. struct slot *s;
  17. {
  18.     struct slot *next;
  19.  
  20.     next = (struct slot *)byteadd(s,s->s_size);
  21.     if (next >= (struct slot *)byteadd(m,m->size))
  22.         return((struct slot *)0);
  23.     return(next);
  24. }
  25.  
  26. print_msg(m)
  27. struct msg *m;
  28. {
  29.     struct slot *s;
  30.  
  31.     eprintf(3,"msg header:");
  32.     eprintf(3," size = %d",m->size);
  33.     eprintf(3," slots = %d",m->slots);
  34.     eprintf(3," name = %s",m->name);
  35.     eprintf(3," read_wait = %d\n",m->read_wait);
  36.     for (s=m->data;s;s=nextslot(m,s)) {
  37.         eprintf(5,"slot: name = %s",s->s_name);
  38.         eprintf(5," &slot = %x",s);
  39.         eprintf(5," size = %d\n",s->s_size);
  40.         if (s->s_size == 0) {
  41.             eprintf(5,"0 length slot encountered in print_msg\n");
  42.             break;
  43.         }
  44.     }
  45.     if (cm_debug_level >= 10) ascii_dump((char *)m,m->size);
  46. }
  47.  
  48.