HIPC  0.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
msgd.c
Go to the documentation of this file.
1 #include <hipc/msgd.h>
2 
9 unsigned char hipcMsgdBdySize(hipc_msgd const *const md_p)
10 {
11  return hipcMsghdrBdysize(md_p->header);
12 }
13 
20 unsigned char hipcMsgdType(hipc_msgd const *const md_p)
21 {
22  return md_p->header[HIPC_MSGHDR_BYTE_TYPE];
23 }
24 
31 unsigned char hipcMsgdStruno(hipc_msgd const *const md_p)
32 {
33  return md_p->header[HIPC_MSGHDR_BYTE_STRUNO];
34 }
35 
42 unsigned char hipcMsgdOffset(hipc_msgd const *const md_p)
43 {
44  return md_p->header[HIPC_MSGHDR_BYTE_OFFSET];
45 }
46 
53 unsigned char hipcMsgdRngsize(hipc_msgd const *const md_p)
54 {
55  return md_p->header[HIPC_MSGHDR_BYTE_BDYSZ];
56 }
57 
69  const unsigned char type,
70  const enum HIPC_errno hipc_errno,
71  char *const errdtlstr,
72  size_t errdtlstr_size)
73 {
74  md_p->header[HIPC_MSGHDR_BYTE_TYPE] = type;
75  md_p->header[HIPC_MSGHDR_BYTE_OFFSET] = hipc_errno;
77  md_p->body_p = errdtlstr;
78 
79  if (NULL == errdtlstr) {
80  md_p->header[HIPC_MSGHDR_BYTE_BDYSZ] = 0;
81  } else {
82  if (255 < errdtlstr_size) {
83  md_p->header[HIPC_MSGHDR_BYTE_BDYSZ] = 255;
84  } else {
85  md_p->header[HIPC_MSGHDR_BYTE_BDYSZ] = errdtlstr_size;
86  }
87  }
88 
89  return hipc_errno;
90 }
91 
103  hipc_msgd const *const mdr_p,
104  void *const stru_p,
105  const size_t stru_size)
106 {
107  if (stru_size < (size_t) mdr_p->header[HIPC_MSGHDR_BYTE_OFFSET] +
108  mdr_p->header[HIPC_MSGHDR_BYTE_BDYSZ]) {
110  }
111 
119  mds_p->body_p =
120  ((unsigned char *const) stru_p) +
122 
123  return HIPC_SUCCESS;
124 }
125 
141  void *const stru_p,
142  const size_t stru_size)
143 {
144  if (stru_size < (size_t) mdr_p->header[HIPC_MSGHDR_BYTE_OFFSET] +
145  mdr_p->header[HIPC_MSGHDR_BYTE_BDYSZ]) {
147  }
148 
149  mdr_p->body_p =
150  ((unsigned char *) stru_p) +
152 
153  return HIPC_SUCCESS;
154 }
unsigned char header[HIPC_MSGHDR_SIZE]
Definition: msgd.h:9
enum HIPC_errno hipcGenmdSuccessToGet(hipc_msgd *const mds_p, hipc_msgd const *const mdr_p, void *const stru_p, const size_t stru_size)
Initializes mds_p as a response to mdr_p whose type must be GET.
Definition: msgd.c:102
enum HIPC_errno hipcMsgdSetBdyForPut(hipc_msgd *const mdr_p, void *const stru_p, const size_t stru_size)
Sets a body to a HIPC message data that contains a header of a PUT message.
Definition: msgd.c:140
enum HIPC_errno hipcGenmdUnstru(hipc_msgd *const md_p, const unsigned char type, const enum HIPC_errno hipc_errno, char *const errdtlstr, size_t errdtlstr_size)
Initializes a HIPC message data as a unstructured type message.
Definition: msgd.c:68
HIPC_errno
Definition: hipc.h:4
unsigned char hipcMsgdBdySize(hipc_msgd const *const md_p)
Returns body size of a HIPC message data.
Definition: msgd.c:9
unsigned char hipcMsgdStruno(hipc_msgd const *const md_p)
Returns structure number of a HIPC message data.
Definition: msgd.c:31
unsigned char hipcMsgdRngsize(hipc_msgd const *const md_p)
Returns range size of a HIPC message data.
Definition: msgd.c:53
unsigned char hipcMsghdrBdysize(unsigned char const *const msghdr)
Returns message size determined by a message header.
Definition: hipc.c:12
unsigned char hipcMsgdType(hipc_msgd const *const md_p)
Returns type of a HIPC message data.
Definition: msgd.c:20
unsigned char hipcMsgdOffset(hipc_msgd const *const md_p)
Returns offset of a HIPC message data.
Definition: msgd.c:42
void * body_p
Definition: msgd.h:10
#define HIPC_UNSTRU
Definition: hipc.h:44