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

  1. /*
  2.  
  3. These routines build slots for the cmm.  These slots are placed into a
  4. msg structure and sent to the user.
  5.  
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <sys/time.h>
  10. #include "cm_constants.h"
  11. #include "cm_sd.h"
  12. #include "cm_slot.h"    /* definitions of slot structures */
  13. #include "cm_bytestuff.h"
  14.  
  15. extern struct msg *omsg;    /* this is soooo... messy */
  16.  
  17. put_slot_read_response(m,name,count,timestamp,cmd,data)
  18. struct msg *m;
  19. char *name;
  20. unsigned long count;
  21. struct timeval *timestamp;
  22. int cmd;
  23. cm_value *data;
  24. {
  25.     struct big_slot s;
  26.     unsigned int size;
  27.  
  28.     init_slot(&s,name,CM_SLOT_READ_RESPONSE);
  29.     size = align(sizeof(struct slot_hdr));
  30.     size += align(sizeof(struct slot_read_response_hdr));
  31.     s.subslot.read_response.srr_count = count;
  32.     cm_time_copy(timestamp,&s.subslot.read_response.srr_timestamp);
  33.     s.subslot.read_response.srr_command_association = cmd;
  34.     size += cm_sd_to_flat(data,&s.subslot.read_response.fdata);
  35.     finish_slot(m,&s,size);
  36. }
  37.  
  38. /* error slots should never be generated by the user since infinite loops */
  39. /* could result between the user and cmm sending each other back error slots */
  40. put_slot_error(m,name,type,string)
  41. struct msg *m;
  42. char *name;
  43. int type;
  44. char *string;
  45. {
  46.     struct big_slot s;
  47.     unsigned int size;
  48.  
  49.     fprintf(stdout,"slot error in <%s>  type %d - %s\n",name,type,string);
  50.     
  51.     init_slot(&s,name,CM_SLOT_ERROR);
  52.     size = align(sizeof(struct slot_hdr));
  53.     size += align(sizeof(struct slot_error_hdr));
  54.     size += strlen(string) + 1;
  55.     s.subslot.error.se_type = type;
  56.     strcpy(s.subslot.error.msg,string);
  57.     finish_slot(m,&s,size);
  58. }
  59.