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

  1.  
  2. /*
  3.  
  4. These routines build slots for the user.  These slots are placed into a
  5. msg structure and sent to the cmm.  The all return 0 for failure, or a
  6. positive number indicating the number of bytes in the slot.
  7.  
  8. */
  9.  
  10. #include <stdio.h>
  11. #include <sys/time.h>
  12. #include "cm_constants.h"
  13. #include "cm_sd.h"
  14. #include "cm_slot.h"
  15. #include "cm_msg.h"
  16. #include "cm_bytestuff.h"
  17. #include "cm_interface.h"
  18.  
  19. /* this indicates that the user wants the cmm to send back the latest value */
  20. /* of all variables */
  21. put_slot_read(m)
  22. struct msg *m;
  23. {
  24.     struct slot s;
  25.     unsigned int size;
  26.  
  27.     init_slot(&s,"read all",CM_SLOT_READ);
  28.     size = align(sizeof(struct slot_hdr));
  29. /*    size += align(sizeof(struct slot_read));*/
  30.     return(finish_slot(m,&s,size));
  31. }
  32.  
  33. int    /* returns size of data written in msg */
  34. put_slot_write(m,name,data,cmd)
  35. struct msg *m;
  36. char *name;
  37. cm_value *data;
  38. int cmd;
  39. {
  40.     struct big_slot s;
  41.     unsigned int size;
  42.  
  43.     init_slot((struct slot *)&s,name,CM_SLOT_WRITE);
  44.     size = align(sizeof(struct slot_hdr));
  45.     size += align(sizeof(struct slot_write_hdr));
  46.     s.subslot.write.sw_command_association = cmd;
  47.     size += cm_sd_to_flat(data,&s.subslot.write.fdata);
  48.     return(finish_slot(m,(struct slot *)&s,size));
  49. }
  50.  
  51. int
  52. put_slot_declare(m,name,role,cmd_assoc)
  53. struct msg *m;
  54. char *name;
  55. struct usr_var_role *role;
  56. int cmd_assoc;
  57. {
  58.     struct slot s;
  59.     unsigned int size;
  60.  
  61.     init_slot(&s,name,CM_SLOT_DECLARE);
  62.     size = align(sizeof(struct slot_hdr));
  63.     size += align(sizeof(struct slot_declare));
  64.     /* could do some checking on the following */
  65.     s.subslot.declare.role.reader = role->reader;
  66.     s.subslot.declare.role.wakeup = role->wakeup;
  67.     s.subslot.declare.role.xwriter = role->xwriter;
  68.     s.subslot.declare.role.nonxwriter = role->nonxwriter;
  69.     s.subslot.declare.command_association = cmd_assoc;
  70.     return(finish_slot(m,&s,size));
  71. }
  72.  
  73. int
  74. put_slot_undeclare(m,name)
  75. struct msg *m;
  76. char *name;
  77. {
  78.     struct slot s;
  79.     unsigned int size;
  80.  
  81.     init_slot(&s,name,CM_SLOT_UNDECLARE);
  82.     size = align(sizeof(struct slot_hdr));
  83. /*    size += align(sizeof(struct slot_undeclare));*/
  84.     return(finish_slot(m,&s,size));
  85. }
  86.