#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hipc/client.h>
Go to the source code of this file.
Functions | |
void | hipcClientSetStdErrno (struct HIPC_client *const cl_p) |
Sets errno value to a HIPC client. More... | |
int | hipcClientGetStdErrno (const struct HIPC_client *const cl_p) |
Gets an errno value saved by hipcClientSetStdErrno(). More... | |
enum HIPC_errno | hipcClientGetHipcErrno (const struct HIPC_client *const cl_p) |
Gets a HIPC error number that has been set. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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 . More... | |
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 . More... | |
unsigned char | hipcClientGetNsysmsg (struct HIPC_client const *const cl_p) |
Gets the number of system messages. More... | |
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. More... | |
void | hipcClientTerminate (struct HIPC_client *const cl_p) |
Terminates a HIPC client with releasing the memory space that the client has. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | hipcGenmsgHello (hipc_msg msg, const struct HIPC_client *const cl_p) |
Generates HELLO message. More... | |
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. More... | |
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. More... | |
void | hipcGenmsgBye (hipc_msg msg) |
Initializes a HIPC message as a BYE message. More... | |
void hipcClientSetStdErrno | ( | struct HIPC_client *const | cl_p | ) |
Sets errno value to a HIPC client.
The value comes from errno
in the C standard library, so this function takes no arguments.
cl_p | pointer to the HIPC client |
Definition at line 119 of file client.c.
References HIPC_client::std_errno.
Referenced by hipcRecvMsg(), and hipcSendMsg().
int hipcClientGetStdErrno | ( | const struct HIPC_client *const | cl_p | ) |
Gets an errno value saved by hipcClientSetStdErrno().
cl_p | pointer to a HIPC client |
Definition at line 131 of file client.c.
References HIPC_client::std_errno.
Referenced by hipcERRCHECK().
enum HIPC_errno hipcClientGetHipcErrno | ( | const struct HIPC_client *const | cl_p | ) |
Gets a HIPC error number that has been set.
cl_p | pointer to a HIPC client |
Definition at line 143 of file client.c.
References HIPC_client::hipc_errno.
Referenced by hipcERRCHECK(), and hipcWaitReturn().
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.
cl_p | pointer to the HIPC client |
Definition at line 155 of file client.c.
References HIPC_client::hipc_errno, and HIPC_N_ERR.
Referenced by hipcERRCHECK().
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.
cl_p | pointer to the HIPC client |
Definition at line 171 of file client.c.
References HIPC_client::err_detail_str.
Referenced by hipcERRCHECK().
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.
cl_p | pointer to the HIPC client |
hipc_errno | HIPC error number to be set |
str | string of the error detail |
hipc_errno
. Definition at line 240 of file client.c.
References HIPC_client::hipc_errno.
Referenced by hipcClientCheckStrutpl(), hipcClientEachMbr(), hipcClientFeedSysmsg(), hipcClientFeedUnstrumsgAsError(), hipcClientInit(), hipcGet(), hipcPut(), hipcRecvMsg(), hipcSendMsg(), hipcSetHandler(), and hipcWaitReturn().
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.
cimg_p
points the client-side image. struno
must correspond to the type of the client-side image.
cl_p | pointer to a HIPC client |
struno | structure number |
cimg_p | address that points the structure instance |
Definition at line 260 of file client.c.
References HIPC_client::cimg_pp.
Referenced by hipcSetHandler().
void hipcClientSetHandler | ( | struct HIPC_client *const | cl_p, |
const unsigned char | struno, | ||
enum HIPC_errno(*)(struct HIPC_client *, const hipc_msg, void *, void *) | hndlr_p, | ||
void *const | arg | ||
) |
Sets an handler hndlr_p
to a structure number struno
.
arg
will be passed to the handler when the handler is called.
cl_p | pointer to a HIPC client |
struno | structure number |
hndlr_p | function pointer, which is the handler. |
arg | argument for the handler |
Definition at line 279 of file client.c.
References HIPC_client::hdarg_pp, and HIPC_client::hndlr_pp.
Referenced by hipcSetHandler().
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
.
msgR
is passed to the handler as an argument.
cl_p | pointer to a HIPC client |
struno | structure number |
msgR | HIPC message to be passed to the handler |
Definition at line 303 of file client.c.
References HIPC_client::cimg_pp, HIPC_client::hdarg_pp, HIPC_SUCCESS, and HIPC_client::hndlr_pp.
Referenced by hipcWaitReturn().
unsigned char hipcClientGetNsysmsg | ( | struct HIPC_client const *const | cl_p | ) |
Gets the number of system messages.
cl_p | Pointer to a HIPC client |
Definition at line 326 of file client.c.
References HIPC_client::indp_p, and HIPC_cl_indp::n_sysmsg.
Referenced by hipcOpen().
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.
cl_p | pointer to a HIPC client to be initialized. This must not be NULL. |
clbase_p | pointer to a HIPC client with which cl_p is initialized. |
Definition at line 339 of file client.c.
References HIPC_client::cimg_pp, HIPC_client::cmdp_p, HIPC_cl_dp::endian, HIPC_client::endian_convert, HIPC_client::err_detail_str, HIPC_client::hdarg_pp, HIPC_ERR_INV_BASE_CLIENT, HIPC_ERR_INV_ENDIAN, HIPC_client::hipc_errno, HIPC_SUCCESS, hipcClientSetError(), hipcEndian(), HIPC_client::hndlr_pp, HIPC_client::indp_p, HIPC_cl_indp::n_struct, HIPC_client::pllist_p, HIPC_client::simg_pp, HIPC_client::smdp_p, HIPC_client::std_errno, HIPC_cl_dp::struct_p, and HIPC_cl_dp::struct_size_p.
Referenced by hipcOpen().
void hipcClientTerminate | ( | struct HIPC_client *const | cl_p | ) |
Terminates a HIPC client with releasing the memory space that the client has.
cl_p | pointer to a HIPC client |
Definition at line 438 of file client.c.
References HIPC_ptr_link_list::next, HIPC_client::pllist_p, and HIPC_ptr_link_list::ptr.
Referenced by hipcClose().
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.
Only sizes of structures may differ.
cl_p | pointer to a HIPC client |
Definition at line 458 of file client.c.
References HIPC_client::cmdp_p, HIPC_cl_indp_mbr::elm_type, HIPC_ERR_MBR_SIZE_MISMATCH, HIPC_client::hipc_errno, HIPC_MBR_ARRAY, HIPC_MBR_SIMPLE, HIPC_SUCCESS, HIPC_client::indp_p, HIPC_cl_indp_stru::mbr_p, HIPC_cl_indp_stru::n_member, HIPC_cl_indp::n_struct, HIPC_cl_indp_mbr::name, HIPC_cl_indp_stru::name, HIPC_cl_dp_stru::size_p, HIPC_client::smdp_p, HIPC_cl_indp::struct_p, HIPC_cl_dp::struct_p, and HIPC_cl_indp_mbr::type.
Referenced by hipcOpen().
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.
cl_p | pointer to a HIPC client |
struno | structure number for a message |
offset | offset for a message |
rngsize | range size for a message |
Definition at line 509 of file client.c.
References HIPC_ERR_PROTOCOL_VIOLATION, HIPC_SUCCESS, hipcClientSetError(), HIPC_client::indp_p, HIPC_cl_indp::n_struct, HIPC_client::smdp_p, and HIPC_cl_dp::struct_size_p.
Referenced by hipcClientFeedStrumsg(), hipcClientGetStrutpl(), hipcClientPack(), hipcClientUnpack(), hipcGenmsgGet(), and hipcGenmsgPut().
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.
cl_p | pointer to a HIPC client |
str | string that identifies an item |
struno_p | pointer to receive the structure number |
offset_p | pointer to receive the offset value |
size_p | pointer to receive the size |
Definition at line 698 of file client.c.
References HIPC_ERR_INV_ID_STR, HIPC_client::hipc_errno, HIPC_MBR_STRUCT, HIPC_SUCCESS, hipcClientCheckStrutpl(), HIPC_client::indp_p, HIPC_cl_indp::n_struct, HIPC_cl_indp_stru::name, HIPC_client::smdp_p, HIPC_cl_indp::struct_p, HIPC_cl_dp::struct_size_p, HIPC_cl_indp_mbr::struno, and HIPC_cl_indp_mbr::type.
Referenced by hipcGet(), hipcPut(), and hipcSetHandler().
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(*)(void *const ccur_p, void *const scur_p, const size_t n) | fnc_p | ||
) |
Calls the function specified by fnc_p with each member between begin and end.
When mbr_p points structure type, zeros can be passed as ssize and csize.
cl_p | pointer to a HIPC client. |
mbr_p | pointer to an object that has data of the member. |
begin | beginning address in the image for the server. |
end | ending address in the image for the server. |
scur_p | server's cuurent pointer. |
ccur_p | client's cuurent pointer. |
ssize | size of the item (member) in the server |
csize | size of the item (member) in the client |
fnc_p | pointer to the function to be called. |
Definition at line 756 of file client.c.
References HIPC_cl_indp_mbr::ary_dim, HIPC_cl_indp_mbr::ary_max_idxs, HIPC_client::cmdp_p, HIPC_cl_indp_mbr::elm_struno, HIPC_cl_indp_mbr::elm_type, HIPC_ERR_INTERNAL_ERROR, HIPC_MBR_ARRAY, HIPC_MBR_SIMPLE, HIPC_MBR_STRUCT, HIPC_SUCCESS, hipcClientEachMbr(), hipcClientSetError(), HIPC_client::indp_p, HIPC_cl_indp_stru::mbr_p, HIPC_cl_indp_stru::n_member, HIPC_cl_dp_stru::offset_p, HIPC_cl_dp_stru::size_p, HIPC_client::smdp_p, HIPC_cl_indp::struct_p, HIPC_cl_dp::struct_p, HIPC_cl_indp_mbr::struno, and HIPC_cl_indp_mbr::type.
Referenced by hipcClientEachMbr(), hipcClientPack(), and hipcClientUnpack().
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.
struno, offset, and size determine the range. If simg is NULL, this function uses memory that has been internally allocated. If cimg is NULL, this function uses memory that was set by hipcClientSetCimg(). If cimg is NULL and no memory has been set yet, this function does nothing.
cl_p | pointer to a HIPC client. |
struno | structure number for the structure to be unpacked |
offset | offset of the range in the server representation |
size | size of the range in the server representation |
simg | Server-side image of the structure |
cimg | Client-side image of the structure |
Definition at line 908 of file client.c.
References HIPC_client::cimg_pp, HIPC_client::endian_convert, HIPC_MBR_STRUCT, HIPC_SUCCESS, hipcClientCheckStrutpl(), hipcClientEachMbr(), HIPC_client::simg_pp, HIPC_cl_indp_mbr::struno, and HIPC_cl_indp_mbr::type.
Referenced by hipcGet(), and hipcWaitReturn().
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.
struno, offset, and size determine the range. If simg is NULL, this function uses memory that has been internally allocated. If cimg is NULL, this function uses memory that was set by hipcClientSetCimg(). If cimg is NULL and no memory has been set yet, this function does nothing.
cl_p | pointer to a HIPC client. |
struno | structure number for the structure to be packed |
offset | offset of the range in the server representation |
size | size of the range in the server representation |
simg | Server-side image of the structure |
cimg | Client-side image of the structure |
Definition at line 962 of file client.c.
References HIPC_client::cimg_pp, HIPC_client::endian_convert, HIPC_MBR_STRUCT, HIPC_SUCCESS, hipcClientCheckStrutpl(), hipcClientEachMbr(), HIPC_client::simg_pp, HIPC_cl_indp_mbr::struno, and HIPC_cl_indp_mbr::type.
Referenced by hipcPut().
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.
The message must have an unstructured body.
cl_p | pointer to a HIPC client. |
msgR | message to be fed |
Definition at line 1011 of file client.c.
References HIPC_client::err_detail_str, HIPC_ERR_PROTOCOL_VIOLATION, HIPC_client::hipc_errno, HIPC_IMG_ALLOCSIZE, HIPC_MSGHDR_BYTE_BDYSZ, HIPC_MSGHDR_BYTE_OFFSET, HIPC_MSGHDR_BYTE_STRUNO, HIPC_MSGHDR_SIZE, HIPC_UNSTRU, and hipcClientSetError().
Referenced by hipcOpen(), and hipcWaitReturn().
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.
cl_p | pointer to a HIPC client. |
msgR | system message to be fed |
Definition at line 1087 of file client.c.
References HIPC_client::cmdp_p, HIPC_cl_dp::endian, HIPC_client::endian_convert, HIPC_ERR_INV_ENDIAN, HIPC_ERR_PROTOCOL_VIOLATION, HIPC_client::hipc_errno, HIPC_MESSAGE_TYPE_SYS, HIPC_MSGHDR_BYTE_BDYSZ, HIPC_MSGHDR_BYTE_OFFSET, HIPC_MSGHDR_BYTE_STRUNO, HIPC_MSGHDR_BYTE_TYPE, HIPC_MSGHDR_SIZE, HIPC_SUCCESS, HIPC_SYSMSG_TYPE_OFFSET, HIPC_SYSMSG_TYPE_OVERVIEW, HIPC_SYSMSG_TYPE_SIZE, hipcClientSetError(), HIPC_client::indp_p, HIPC_cl_indp::n_struct, HIPC_cl_dp_stru::offset_p, HIPC_client::simg_pp, HIPC_cl_dp_stru::size_p, HIPC_client::smdp_p, HIPC_cl_dp::struct_p, HIPC_cl_dp::struct_size_p, and HIPC_cl_indp_mbr::struno.
Referenced by hipcOpen().
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.
The message must have a structured body.
cl_p | pointer to a HIPC client. |
msgR | message to be fed |
Definition at line 1174 of file client.c.
References HIPC_MSGHDR_BYTE_BDYSZ, HIPC_MSGHDR_BYTE_OFFSET, HIPC_MSGHDR_BYTE_STRUNO, HIPC_MSGHDR_SIZE, HIPC_SUCCESS, hipcClientCheckStrutpl(), and HIPC_client::simg_pp.
Referenced by hipcWaitReturn().
void hipcGenmsgHello | ( | hipc_msg | msg, |
const struct HIPC_client *const | cl_p | ||
) |
Generates HELLO message.
cl_p | pointer to a HIPC client |
msg | HIPC message to be set as HELLO |
Definition at line 1201 of file client.c.
References HIPC_cl_indp::cfgid, HIPC_cl_indp::cfgid_size, HIPC_MESSAGE_TYPE_HELLO, HIPC_MSGHDR_BYTE_BDYSZ, HIPC_MSGHDR_BYTE_OFFSET, HIPC_MSGHDR_BYTE_STRUNO, HIPC_MSGHDR_BYTE_TYPE, HIPC_MSGHDR_SIZE, HIPC_UNSTRU, and HIPC_client::indp_p.
Referenced by hipcOpen().
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.
cl_p | pointer to a HIPC client |
msg | HIPC message to be set as GET |
struno | structure number of the message |
offset | offset of the message |
size | size of the message |
Definition at line 1223 of file client.c.
References HIPC_MESSAGE_TYPE_GET, HIPC_MSGHDR_BYTE_BDYSZ, HIPC_MSGHDR_BYTE_OFFSET, HIPC_MSGHDR_BYTE_STRUNO, HIPC_MSGHDR_BYTE_TYPE, HIPC_SUCCESS, hipcClientCheckStrutpl(), and HIPC_cl_indp_mbr::struno.
Referenced by hipcGet().
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.
cl_p | pointer to a HIPC client |
msg | HIPC message to be set as PUT |
struno | structure number of the message |
offset | offset of the message |
size | size of the message |
Definition at line 1253 of file client.c.
References HIPC_MESSAGE_TYPE_PUT, HIPC_MSGHDR_BYTE_BDYSZ, HIPC_MSGHDR_BYTE_OFFSET, HIPC_MSGHDR_BYTE_STRUNO, HIPC_MSGHDR_BYTE_TYPE, HIPC_MSGHDR_SIZE, HIPC_SUCCESS, hipcClientCheckStrutpl(), HIPC_client::simg_pp, and HIPC_cl_indp_mbr::struno.
Referenced by hipcPut().
void hipcGenmsgBye | ( | hipc_msg | msg | ) |
Initializes a HIPC message as a BYE message.
msg | HIPC message to be initialized as BYE |
Definition at line 1279 of file client.c.
References HIPC_MESSAGE_TYPE_BYE, HIPC_MSGHDR_BYTE_BDYSZ, HIPC_MSGHDR_BYTE_OFFSET, HIPC_MSGHDR_BYTE_STRUNO, HIPC_MSGHDR_BYTE_TYPE, and HIPC_UNSTRU.
Referenced by hipcClose().