HIPC  0.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
client.h
Go to the documentation of this file.
1 #ifndef HIPC_CLIENT_H
2 #define HIPC_CLIENT_H
3 
4 #include <stddef.h>
5 
6 #include <hipc.h>
7 #include <hipc/msg.h>
8 
10  HIPC_MBR_SIMPLE, /* simple variable */
13 };
14 
20  char const *name;
21 
22  /* for HIPC_MEMBER_STRUCT */
23  unsigned char struno;
24 
25  /* for HIPC_MEMBER_ARRAY */
26  size_t ary_dim;
27  size_t const *ary_max_idxs;
29  unsigned char elm_struno; /* used when elem of array is struct */
30 };
31 
36  unsigned int n_member;
37  char const *name;
38  struct HIPC_cl_indp_mbr const *mbr_p;
39 };
40 
44 struct HIPC_cl_indp {
45  const unsigned char *cfgid;
46  unsigned int cfgid_size;
47  unsigned int n_sysmsg;
48  unsigned int n_struct;
49  struct HIPC_cl_indp_stru const *struct_p;
50 };
51 
56  unsigned char *offset_p;
57  unsigned char *size_p;
58 };
59 
63 struct HIPC_cl_dp {
64  unsigned char endian;
65  unsigned char const *struct_size_p;
67 };
68 
71  void *ptr;
72 };
73 
74 struct HIPC_client {
76  struct HIPC_cl_indp const *indp_p;
77  struct HIPC_cl_dp *cmdp_p;
78  struct HIPC_cl_dp *smdp_p;
79  unsigned char **simg_pp;
80  unsigned char **cimg_pp;
81  enum HIPC_errno (**hndlr_pp) (struct HIPC_client *, const hipc_msg,
82  void *, void *);
83  void **hdarg_pp;
84  int std_errno;
88 };
89 
90 #ifdef __cplusplus
91 extern "C" {
92 #endif
93 
94  extern void hipcClientSetStdErrno(struct HIPC_client *const cl_p);
95  extern int hipcClientGetStdErrno(const struct HIPC_client *const cl_p);
96  extern enum HIPC_errno
97  hipcClientGetHipcErrno(const struct HIPC_client *const cl_p);
98  extern const char *hipcClientGetErrStr(const struct HIPC_client *const
99  cl_p);
100  extern const char *hipcClientGetErrDtlStr(const struct HIPC_client
101  *const cl_p);
102  extern enum HIPC_errno
103  hipcClientSetError(struct HIPC_client *const cl_p,
104  enum HIPC_errno hipc_errno, const char *const str);
105 
106  extern void hipcClientSetCimg(struct HIPC_client *const cl_p,
107  const unsigned char struno,
108  void *cimg_p);
109  extern void
110  hipcClientSetHandler(struct HIPC_client *const cl_p,
111  const unsigned char struno,
112  enum HIPC_errno (*hndlr_p) (struct HIPC_client *,
113  const hipc_msg,
114  void *, void *),
115  void *const arg);
116  enum HIPC_errno
117  hipcClientCallHandler(struct HIPC_client *const cl_p,
118  const unsigned char struno,
119  const hipc_msg msgR);
120 
121  extern unsigned char
122  hipcClientGetNsysmsg(struct HIPC_client const *const cl_p);
123 
124  extern enum HIPC_errno
125  hipcClientInit(struct HIPC_client *const cl_p,
126  struct HIPC_client const *const clbase_p);
127  extern void hipcClientTerminate(struct HIPC_client *const cl_p);
128 
129  extern enum HIPC_errno
130  hipcClientCheckMbrSize(struct HIPC_client *const cl_p);
131 
132  enum HIPC_errno
133  hipcClientCheckStrutpl(struct HIPC_client *const cl_p,
134  const unsigned char struno,
135  const size_t offset, const size_t size);
136  extern enum HIPC_errno
137  hipcClientGetStrutpl(struct HIPC_client *const cl_p,
138  char const *const str,
139  unsigned char *struno_p,
140  size_t * offset_p, size_t * size_p);
141  enum HIPC_errno
142  hipcClientEachMbr(struct HIPC_client *const cl_p,
143  struct HIPC_cl_indp_mbr const *const mbr_p,
144  unsigned char *const begin,
145  unsigned char *const end,
146  unsigned char *const scur_p,
147  unsigned char *const ccur_p, const size_t ssize,
148  const size_t csize,
149  void (*fnc_p) (void *const ccur_p,
150  void *const scur_p, const size_t n));
151  extern enum HIPC_errno
152  hipcClientUnpack(struct HIPC_client *const cl_p,
153  const unsigned char struno,
154  const size_t offset, const size_t size,
155  void *simg, void *cimg);
156  extern enum HIPC_errno
157  hipcClientPack(struct HIPC_client *const cl_p,
158  const unsigned char struno,
159  const size_t offset, const size_t size,
160  void *simg, void *cimg);
161 
162  enum HIPC_errno
163  hipcClientFeedUnstrumsgAsError(struct HIPC_client *const cl_p,
164  const hipc_msg msgR);
165  extern enum HIPC_errno
166  hipcClientFeedSysmsg(struct HIPC_client *const cl_p,
167  const hipc_msg msgR);
168  extern enum HIPC_errno
169  hipcClientFeedStrumsg(struct HIPC_client *const cl_p,
170  const hipc_msg msgR);
171 
172  extern void
173  hipcGenmsgHello(hipc_msg msg, const struct HIPC_client *const cl_p);
174  extern enum HIPC_errno
175  hipcGenmsgGet(hipc_msg msg, struct HIPC_client *const cl_p,
176  const unsigned char struno,
177  const size_t offset, const size_t size);
178  extern enum HIPC_errno
179  hipcGenmsgPut(hipc_msg msg, struct HIPC_client *const cl_p,
180  const unsigned char struno,
181  const size_t offset, const size_t size);
182  extern void hipcGenmsgBye(hipc_msg msg);
183 
184 #ifdef __cplusplus
185 }
186 #endif
187 #endif
enum HIPC_errno hipcClientPack(struct HIPC_client *const cl_p, const unsigned char struno, const size_t offset, const size_t size, void *simg, void *cimg)
Packs a range of contents of cimg into simg.
Definition: client.c:962
Machine-dependent information of a structure used in a client.
Definition: client.h:55
unsigned char hipc_msg[HIPC_MSG_ALLOCSIZE]
Definition: msg.h:8
Machine-independent information of a member of a structure used in a client.
Definition: client.h:18
enum HIPC_errno hipcClientFeedUnstrumsgAsError(struct HIPC_client *const cl_p, const hipc_msg msgR)
Feeds a message and sets an error specified by the message.
Definition: client.c:1011
Machine-independent information of a client.
Definition: client.h:44
enum HIPC_errno hipcClientGetHipcErrno(const struct HIPC_client *const cl_p)
Gets a HIPC error number that has been set.
Definition: client.c:143
void ** hdarg_pp
Handler's arguments.
Definition: client.h:83
int std_errno
Definition: client.h:84
#define HIPC_IMG_ALLOCSIZE
Definition: hipc.h:46
struct HIPC_cl_dp * cmdp_p
Client Machine DePendent data.
Definition: client.h:77
unsigned char hipcClientGetNsysmsg(struct HIPC_client const *const cl_p)
Gets the number of system messages.
Definition: client.c:326
void hipcGenmsgHello(hipc_msg msg, const struct HIPC_client *const cl_p)
Generates HELLO message.
Definition: client.c:1201
char err_detail_str[HIPC_IMG_ALLOCSIZE]
Definition: client.h:86
enum HIPC_errno hipcClientFeedSysmsg(struct HIPC_client *const cl_p, const hipc_msg msgR)
Feeds a system message and incorporates it to the internal data of the client.
Definition: client.c:1087
enum HIPC_errno hipcClientCallHandler(struct HIPC_client *const cl_p, const unsigned char struno, const hipc_msg msgR)
Calls a handler that corresponds to struno.
Definition: client.c:303
char const * name
Definition: client.h:37
unsigned int n_member
Definition: client.h:36
enum HIPC_errno hipcClientFeedStrumsg(struct HIPC_client *const cl_p, const hipc_msg msgR)
Feeds a message and incorporates it to the internal data of a client.
Definition: client.c:1174
int endian_convert
Definition: client.h:75
HIPC_errno
Definition: hipc.h:4
size_t const * ary_max_idxs
Definition: client.h:27
unsigned char struno
Definition: client.h:23
Machine-independent information of a structure used in a client.
Definition: client.h:35
enum HIPC_errno hipcGenmsgGet(hipc_msg msg, struct HIPC_client *const cl_p, const unsigned char struno, const size_t offset, const size_t size)
Generates GET message.
Definition: client.c:1223
enum HIPC_errno hipcGenmsgPut(hipc_msg msg, struct HIPC_client *const cl_p, const unsigned char struno, const size_t offset, const size_t size)
Generates PUT message.
Definition: client.c:1253
int hipcClientGetStdErrno(const struct HIPC_client *const cl_p)
Gets an errno value saved by hipcClientSetStdErrno().
Definition: client.c:131
struct HIPC_ptr_link_list * pllist_p
Definition: client.h:87
struct HIPC_cl_indp_mbr const * mbr_p
Definition: client.h:38
enum HIPC_errno(** hndlr_pp)(struct HIPC_client *, const hipc_msg, void *, void *)
Definition: client.h:81
enum HIPC_errno hipcClientGetStrutpl(struct HIPC_client *const cl_p, char const *const str, unsigned char *struno_p, size_t *offset_p, size_t *size_p)
Gets structure number, offset, and size from ID string.
Definition: client.c:698
enum HIPC_errno hipcClientCheckStrutpl(struct HIPC_client *const cl_p, const unsigned char struno, const size_t offset, const size_t size)
Checks a combination of a structure number, an offset, and a size for a HIPC message.
Definition: client.c:509
enum HIPC_errno hipcClientEachMbr(struct HIPC_client *const cl_p, struct HIPC_cl_indp_mbr const *const mbr_p, unsigned char *const begin, unsigned char *const end, unsigned char *const scur_p, unsigned char *const ccur_p, const size_t ssize, const size_t csize, void(*fnc_p)(void *const ccur_p, void *const scur_p, const size_t n))
Calls the function specified by fnc_p with each member between begin and end.
Definition: client.c:756
unsigned int n_struct
Definition: client.h:48
enum HIPC_member_type elm_type
Definition: client.h:28
void hipcClientSetHandler(struct HIPC_client *const cl_p, const unsigned char struno, enum HIPC_errno(*hndlr_p)(struct HIPC_client *, const hipc_msg, void *, void *), void *const arg)
Sets an handler hndlr_p to a structure number struno.
Definition: client.c:279
void hipcClientSetCimg(struct HIPC_client *const cl_p, const unsigned char struno, void *cimg_p)
Sets a client-side image that is a structure instance of a structure.
Definition: client.c:260
void hipcClientSetStdErrno(struct HIPC_client *const cl_p)
Sets errno value to a HIPC client.
Definition: client.c:119
char const * name
Definition: client.h:20
enum HIPC_member_type type
Definition: client.h:19
size_t ary_dim
Definition: client.h:26
unsigned char const * struct_size_p
Definition: client.h:65
enum HIPC_errno hipcClientCheckMbrSize(struct HIPC_client *const cl_p)
Checks whether sizes of members in structures in a server are the same as sizes in a client...
Definition: client.c:458
struct HIPC_cl_indp_stru const * struct_p
Definition: client.h:49
unsigned char elm_struno
Definition: client.h:29
enum HIPC_errno hipc_errno
Definition: client.h:85
unsigned int n_sysmsg
Definition: client.h:47
unsigned char endian
Definition: client.h:64
const unsigned char * cfgid
Definition: client.h:45
const char * hipcClientGetErrStr(const struct HIPC_client *const cl_p)
Gets a string describing a HIPC error number that has been set to a HIPC client.
Definition: client.c:155
enum HIPC_errno hipcClientSetError(struct HIPC_client *const cl_p, enum HIPC_errno hipc_errno, const char *const str)
Sets an error to a client with error detail.
Definition: client.c:240
enum HIPC_errno hipcClientUnpack(struct HIPC_client *const cl_p, const unsigned char struno, const size_t offset, const size_t size, void *simg, void *cimg)
Unpacks a range of contents of simg into cimg.
Definition: client.c:908
unsigned char ** simg_pp
Server-side images of structures.
Definition: client.h:79
const char * hipcClientGetErrDtlStr(const struct HIPC_client *const cl_p)
Gets a string describing details of an error that has been set to a HIPC client.
Definition: client.c:171
unsigned int cfgid_size
Definition: client.h:46
struct HIPC_cl_indp const * indp_p
Definition: client.h:76
Machine-dependent information of a client.
Definition: client.h:63
HIPC_member_type
Definition: client.h:9
struct HIPC_cl_dp_stru * struct_p
Definition: client.h:66
struct HIPC_cl_dp * smdp_p
Server Machine DePendent data.
Definition: client.h:78
enum HIPC_errno hipcClientInit(struct HIPC_client *const cl_p, struct HIPC_client const *const clbase_p)
Initializes a HIPC client with allocating memory space if necessary.
Definition: client.c:339
unsigned char * size_p
Definition: client.h:57
unsigned char * offset_p
Definition: client.h:56
unsigned char ** cimg_pp
Client-side images of structures.
Definition: client.h:80
void hipcClientTerminate(struct HIPC_client *const cl_p)
Terminates a HIPC client with releasing the memory space that the client has.
Definition: client.c:438
void hipcGenmsgBye(hipc_msg msg)
Initializes a HIPC message as a BYE message.
Definition: client.c:1279