11 "HIPC_SUCCESS: No error",
13 "HIPC_ERR_S_INV_UDATA: Invalid user data",
14 "HIPC_ERR_S_INV_MSG_TYPE: Invalid message type",
15 "HIPC_ERR_S_INV_STRUNO: Invalid structure number",
16 "HIPC_ERR_S_INV_RW_RANGE: Invalid read/write range",
17 "HIPC_ERR_S_V_UNINIT_MSG: Virtually uninitialized HIPC message",
18 "HIPC_ERR_S_IO_READ: I/O read error",
19 "HIPC_ERR_S_IO_WRITE: I/O write error",
20 "HIPC_ERR_S_INV_CFG: Invalid Configuration",
21 "HIPC_ERR_S_INV_NULL: Invalid NULL value",
22 "HIPC_ERR_S_BUF_SHTG: Buffer shortage",
23 "HIPC_ERR_S_OVERSIZED_STRU: Oversized structure size",
24 "HIPC_ERR_S_PBANK_STAT_MISMATCH: pbank status mismatch",
26 "HIPC_ERR_C_STD: C standard library error",
27 "HIPC_ERR_INTERNAL_ERROR: Internal error in HIPC library",
28 "HIPC_ERR_IO_READ: I/O read error",
29 "HIPC_ERR_IO_WRITE: I/O write error",
30 "HIPC_ERR_PROTOCOL_VIOLATION: Protocol violation",
31 "HIPC_ERR_INV_ENDIAN: Invalid endian",
32 "HIPC_ERR_INV_ID_STR: Invalid ID string",
33 "HIPC_ERR_INV_BASE_CLIENT: Invalid base client",
34 "HIPC_ERR_MBR_SIZE_MISMATCH: Structure member size mismatch",
35 "HIPC_ERR_SESS_STATE_MISMATCH: Session state mismatch",
37 "HIPC_ERR_FOR_TESTING: Error only for testing",
38 "HIPC_ERR_TEST_LIB_INTERNAL: Internal error in a library only for testing",
62 if (NULL == pllist_p) {
68 pllist_p->
ptr = tmp_p;
90 tmp_p = calloc(nmemb, size);
98 if (NULL == pllist_p) {
104 pllist_p->
ptr = tmp_p;
160 return "Unknown HIPC errorno value";
197 char const *
const str0,
198 char const *
const str1,
size_t ls1)
242 char const *
const str)
261 const unsigned char struno,
void *cimg_p)
264 cl_p->
cimg_pp[struno] = cimg_p;
280 const unsigned char struno,
283 void *),
void *
const arg)
304 const unsigned char struno,
const hipc_msg msgR)
312 if (NULL != cl_p->
hndlr_pp[struno]) {
345 if (NULL == clbase_p) {
358 if (NULL == cl_p->
indp_p) {
360 "cl_p->indp_p is NULL");
362 if (NULL == cl_p->
cmdp_p) {
364 "cl_p->cmdp_p is NULL");
369 "cl_p->cmdp_p->endian is 'o'");
401 if (NULL == clbase_p->
smdp_p) {
404 if (NULL == cl_p->
smdp_p) {
468 for (i = 0; i < mis_p->
n_member; ++i) {
476 "MBR_SIZE_MISMATCH: "
478 "struno/mbrnum %d/%d; "
479 "client-side size/server-side size %d/%d\n",
487 "The member size in server is not the same as the size in client; member name: ",
510 const unsigned char struno,
511 const size_t offset,
const size_t rngsize)
516 "INV_STRUNO: (struno=)%d >= %d(=cl_p->indp_p->n_struct)\n",
521 "INV_STRUNO: The structure number is equal to or more than cl_p->indp_p->n_struct");
526 "INV_OFFSET: (offset=)%ld >= %d(=cl_p->smdp_p->struct_size_p[struno])\n",
530 "INV_OFFSET: The offest value is equal to or more than cl_p->smdp_p->struct_size_p[struno]");
535 "INV_SIZE: (rngsize=)%ld > %d(=cl_p->smdp_p->struct_size_p[struno])\n",
539 "INV_RNGSIZE: The rngsize is more than cl_p->smdp_p->struct_size_p[struno]");
544 "INV_OFFSET_RNGSIZE: (offset=)%ld+(rngsize=)%ld > %d(=ccl_p->smdp_p->struct_size_p[struno])\n",
548 "INV_OFFSET_SIZE: The sum of offset and rngsizeis is more than cl_p->smdp_p->struct_size_p[struno]");
567 const *
const mbr_p,
size_t * offset_p,
size_t * size_p)
570 unsigned long ary_idx;
578 switch (mbr_p->
type) {
587 "No period before the member name: ",
593 n = strcspn(str + 1,
".[");
604 if (0 == strncmp(str + 1, indstc_p->
mbr_p[i].
name, n)) {
610 *size_p = rmdstc_p->
size_p[i];
611 if (
'\0' == str[n + 1]) {
625 "No left bracket following the array name: ",
630 ary_idx = strtoul(&str[1], &end_p, 10);
631 if (ULONG_MAX == ary_idx || &str[1] == end_p) {
633 "Failed to extract index from: ",
640 "No right bracket following the index number: ",
648 "Number of dimensions is zero: mbr_p->ary_dim is zero");
652 "The index is out of range: ", str, 0);
658 *offset_p += (*size_p) * ary_idx;
659 if (
'\0' == *(end_p + 1)) {
680 "Invalid member type: invalid value in mbr_p->type");
699 char const *
const str,
700 unsigned char *struno_p,
701 size_t * offset_p,
size_t * size_p)
708 n = strcspn(str,
".");
723 if (
'\0' == str[n]) {
759 unsigned char *
const begin,
unsigned char *
const end,
760 unsigned char *
const scur_p,
unsigned char *
const ccur_p,
761 const size_t ssize,
const size_t csize,
762 void (*fnc_p) (
void *
const ccur_p,
void *
const scur_p,
770 unsigned char *stmp_p;
771 unsigned char *ctmp_p;
776 switch (mbr_p->
type) {
778 if ((begin <= scur_p) && (end >= scur_p + ssize)) {
779 fnc_p(scur_p, ccur_p, ssize);
786 for (i = 0; i < indstc_p->
n_member; ++i) {
787 if (end <= scur_p + rmdstc_p->offset_p[i]) {
790 if ((end > scur_p + rmdstc_p->
offset_p[i]) &&
799 lmdstc_p->
size_p[i], fnc_p);
809 for (i = 0; i < mbr_p->
ary_dim; ++i) {
813 if (0 == celm_size) {
815 "ZERO_SIZE: celm_size is zero");
817 if (0 == selm_size) {
819 "ZERO_SIZE: selm_size is zero");
824 if (begin <= scur_p) {
828 stmp_p = begin - ((begin - scur_p) % selm_size);
830 ccur_p + (((stmp_p - scur_p) / selm_size) * celm_size);
832 while (end > stmp_p && scur_p + ssize > stmp_p) {
834 stmp_p, ctmp_p, selm_size,
845 "Invalid member type: invalid value in mbr_p->type");
855 memcpy(scur_p, ccur_p, n);
862 memcpy(ccur_p, scur_p, n);
871 for (i = 0; i < n; ++i) {
872 ((
unsigned char *) scur_p)[i] =
873 ((
unsigned char *) ccur_p)[n - 1 - i];
884 for (i = 0; i < n; ++i) {
885 ((
unsigned char *) ccur_p)[i] =
886 ((
unsigned char *) scur_p)[n - 1 - i];
909 const unsigned char struno,
const size_t offset,
910 const size_t size,
void *simg,
void *cimg)
913 void (*fnc_p) (
void *
const ccur_p,
void *
const scur_p,
const size_t n);
922 if (NULL == cl_p->
cimg_pp[struno]) {
941 (
unsigned char *) simg + offset,
942 (
unsigned char *) simg + offset + size,
943 simg, cimg, 0, 0, fnc_p);
963 const unsigned char struno,
964 const size_t offset,
const size_t size,
965 void *simg,
void *cimg)
968 void (*fnc_p) (
void *
const scur_p,
void *
const ccur_p,
const size_t n);
977 if (NULL == cl_p->
cimg_pp[struno]) {
996 (
unsigned char *) simg + offset,
997 (
unsigned char *) simg + offset + size,
998 simg, cimg, 0, 0, fnc_p);
1017 "INVALID_MSGBDY_TYPE: A message fed to hipcClientFeedUnstrumsgAsError() must have an unstructured body");
1039 const hipc_msg msg,
unsigned char **
const tgtadr)
1048 "INV_STRUNO: (cl_p->indp_p->n_struct=)%d <= %d(=struno)\n",
1052 "INV_STRUNO: The structure number in the system message is over cl_p->indp_p->n_struct");
1058 "INV_N_MEMBER: (cl_p->indp_p->struct_p[struno].n_member=)%d != %d(=bdysz)\n",
1062 "INV_N_MEMBER: The number of members in the system message is not same as the number in cl_p");
1066 if (NULL == tmp_p) {
1070 if (NULL != *tgtadr) {
1072 "INVALID_SYSMSG: The information has been already set in cl_p");
1092 unsigned char **tgtadr;
1099 "INVALID_MSG_TYPE: Type must be SYS or QUIT");
1108 "cl_p->smdp_p->endian is not 'B' nor 'l'");
1119 "UNMATCHED_SYSMSG: (cl_p->indp_p->n_struct=)%d != %d(=bdysz)\n",
1123 "UNMATCHED_SYSMSG: cl_p->indp_p->n_struct is not the same as the number in the system message");
1127 sizeof(
unsigned char) *
1129 if (NULL == tmp_p) {
1136 if (NULL == tmp_p) {
1158 "Invalid system message");
1185 if (0 != msgR[HIPC_MSGHDR_BYTE_BDYSZ]) {
1186 memcpy(cl_p->
simg_pp[msgR[HIPC_MSGHDR_BYTE_STRUNO]] +
1187 msgR[HIPC_MSGHDR_BYTE_OFFSET],
1224 const unsigned char struno,
1225 const size_t offset,
const size_t size)
1254 const unsigned char struno,
1255 const size_t offset,
const size_t size)
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.
static void contra_convert_endian(void *const scur_p, void *const ccur_p, const size_t n)
Machine-dependent information of a structure used in a client.
unsigned char hipc_msg[HIPC_MSG_ALLOCSIZE]
Machine-independent information of a member of a structure used in a client.
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.
void ** hdarg_pp
Handler's arguments.
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.
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.
#define HIPC_IMG_ALLOCSIZE
static const char * hipc_errstr[HIPC_N_ERR]
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.
struct HIPC_cl_dp * cmdp_p
Client Machine DePendent data.
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.
char err_detail_str[HIPC_IMG_ALLOCSIZE]
enum HIPC_errno hipcClientGetHipcErrno(const struct HIPC_client *const cl_p)
Gets a HIPC error number that has been set.
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.
static enum HIPC_errno GetStrutpl_mbr(struct HIPC_client *const cl_p, char const *const str, struct HIPC_cl_indp_mbr const *const mbr_p, size_t *offset_p, size_t *size_p)
Gets offset, and size from member structure and a string that specify further.
void hipcClientTerminate(struct HIPC_client *const cl_p)
Terminates a HIPC client with releasing the memory space that the client has.
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.
unsigned char hipcClientGetNsysmsg(struct HIPC_client const *const cl_p)
Gets the number of system messages.
int hipcClientGetStdErrno(const struct HIPC_client *const cl_p)
Gets an errno value saved by hipcClientSetStdErrno().
static void * hipcClientCalloc(struct HIPC_client *const cl_p, size_t nmemb, size_t size)
Allocates memory by using calloc.
size_t const * ary_max_idxs
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...
static void * hipcClientMalloc(struct HIPC_client *const cl_p, size_t size)
Allocates memory by using malloc.
Machine-independent information of a structure used in a client.
void hipcGenmsgBye(hipc_msg msg)
Initializes a HIPC message as a BYE message.
void hipcGenmsgHello(hipc_msg msg, const struct HIPC_client *const cl_p)
Generates HELLO message.
struct HIPC_ptr_link_list * pllist_p
struct HIPC_cl_indp_mbr const * mbr_p
static void hipcClientSetErrDtlStr(struct HIPC_client *const cl_p, char const *const str0, char const *const str1, size_t ls1)
Sets a string describing details of an error, which will be a concatenation of str0 and str1...
static void memcpy_wrapper(void *const scur_p, void *const ccur_p, const size_t n)
enum HIPC_errno hipcClientSetError(struct HIPC_client *const cl_p, enum HIPC_errno hipc_errno, char const *const str)
Sets an error to a client with error detail.
enum HIPC_errno(** hndlr_pp)(struct HIPC_client *, const hipc_msg, void *, void *)
enum HIPC_member_type elm_type
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.
enum HIPC_member_type type
unsigned char const * struct_size_p
struct HIPC_cl_indp_stru const * struct_p
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.
enum HIPC_errno hipc_errno
static enum HIPC_errno FeedSysmsg_OFFSET_SIZE(struct HIPC_client *const cl_p, const hipc_msg msg, unsigned char **const tgtadr)
Feeds a system message whose type is HIPC_SYSMSG_TYPE_OFFSET or HIPC_SYSMSG_TYPE_SIZE.
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.
static void contra_memcpy(void *const scur_p, void *const ccur_p, const size_t n)
const unsigned char * cfgid
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.
unsigned char ** simg_pp
Server-side images of structures.
struct HIPC_ptr_link_list * next
struct HIPC_cl_indp const * indp_p
Machine-dependent information of a client.
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.
unsigned char hipcEndian(void)
Returns endian of the system.
struct HIPC_cl_dp_stru * struct_p
struct HIPC_cl_dp * smdp_p
Server Machine DePendent data.
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.
unsigned char ** cimg_pp
Client-side images of structures.
static void convert_endian(void *const scur_p, void *const ccur_p, const size_t n)
enum HIPC_errno hipcClientCheckStrutpl(struct HIPC_client *const cl_p, const unsigned char struno, const size_t offset, const size_t rngsize)
Checks a combination of a structure number, an offset, and a size for a HIPC message.
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.
void hipcClientSetStdErrno(struct HIPC_client *const cl_p)
Sets errno value to a HIPC client.