HIPC  0.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions | Variables
client.c File Reference
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hipc/client.h>
Include dependency graph for client.c:

Go to the source code of this file.

Functions

static void * hipcClientMalloc (struct HIPC_client *const cl_p, size_t size)
 Allocates memory by using malloc. More...
 
static void * hipcClientCalloc (struct HIPC_client *const cl_p, size_t nmemb, size_t size)
 Allocates memory by using calloc. More...
 
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...
 
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. 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...
 
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. 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...
 
static void memcpy_wrapper (void *const scur_p, void *const ccur_p, const size_t n)
 
static void contra_memcpy (void *const scur_p, void *const ccur_p, const size_t n)
 
static void convert_endian (void *const scur_p, void *const ccur_p, const size_t n)
 
static void contra_convert_endian (void *const scur_p, void *const ccur_p, const size_t n)
 
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...
 
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. 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...
 

Variables

static const char * hipc_errstr [HIPC_N_ERR]
 

Function Documentation

static void* hipcClientMalloc ( struct HIPC_client *const  cl_p,
size_t  size 
)
static

Allocates memory by using malloc.

A HIPC client keeps track of memory allocation.

Parameters
cl_ppointer to a HIPC client
sizesize of memory to be allocated
Returns
a pointer to the allocated memory, or NULL on failure.

Definition at line 49 of file client.c.

References HIPC_ERR_C_STD, HIPC_client::hipc_errno, HIPC_ptr_link_list::next, HIPC_client::pllist_p, HIPC_ptr_link_list::ptr, and HIPC_client::std_errno.

Referenced by FeedSysmsg_OFFSET_SIZE(), hipcClientFeedSysmsg(), hipcClientInit(), test_client_memope_malloc(), and test_client_memope_multi().

Here is the caller graph for this function:

static void* hipcClientCalloc ( struct HIPC_client *const  cl_p,
size_t  nmemb,
size_t  size 
)
static

Allocates memory by using calloc.

A HIPC client keeps track of memory allocation.

Parameters
cl_ppointer to a HIPC client
sizesize of an element to be allocated
nmembnumber of elements to be allocated
Returns
a pointer to the allocated memory, or NULL on failure.

Definition at line 84 of file client.c.

References HIPC_ERR_C_STD, HIPC_client::hipc_errno, HIPC_ptr_link_list::next, HIPC_client::pllist_p, HIPC_ptr_link_list::ptr, and HIPC_client::std_errno.

Referenced by hipcClientInit(), test_client_memope_calloc(), and test_client_memope_multi().

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to the HIPC client
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 119 of file client.c.

References HIPC_client::std_errno.

Referenced by hipcRecvMsg(), hipcSendMsg(), and test_StdErrno().

Here is the caller graph for this function:

int hipcClientGetStdErrno ( const struct HIPC_client *const  cl_p)

Gets an errno value saved by hipcClientSetStdErrno().

Parameters
cl_ppointer to a HIPC client
Returns
errno value

Definition at line 131 of file client.c.

References HIPC_client::std_errno.

Referenced by hipcERRCHECK(), and test_StdErrno().

Here is the caller graph for this function:

enum HIPC_errno hipcClientGetHipcErrno ( const struct HIPC_client *const  cl_p)

Gets a HIPC error number that has been set.

Parameters
cl_ppointer to a HIPC client
Returns
HIPC error number

Definition at line 143 of file client.c.

References HIPC_client::hipc_errno.

Referenced by hipcERRCHECK(), hipcWaitReturn(), and test_Err().

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to the HIPC client
Returns
string describing the error

Definition at line 155 of file client.c.

References HIPC_client::hipc_errno, hipc_errstr, and HIPC_N_ERR.

Referenced by hipcERRCHECK(), and test_Err().

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to the HIPC client
Returns
string describing details of the error

Definition at line 171 of file client.c.

References HIPC_client::err_detail_str.

Referenced by hipcERRCHECK(), test_Err(), test_ErrorDetailStr(), test_ErrorDetailStr_longStr(), test_hipcClientCheckMbrSize(), test_hipcClientGetStrutpl_tooLargeName(), and test_hipcWaitReturn_err().

Here is the caller graph for this function:

static void hipcClientSetErrDtlStr ( struct HIPC_client *const  cl_p,
char const *const  str0,
char const *const  str1,
size_t  ls1 
)
static

Sets a string describing details of an error, which will be a concatenation of str0 and str1.

If str0 is NULL, this function does nothing. If str1 is NULL, only str0 will be set, and ls1 is ignored. If ls1 is zero, the length of str1 is determined by strlen(), so str1 must terminate with a null character. If ls1 is not zero, ls1 characters are concatenated to str0. If the length of str0 or the concatenation of str0 and str1 is over the size of a buffer in a client structure, a string written to the buffer will be curtailed to just fit to the buffer, and the last character of the buffer will be a null character.

Parameters
str0string no. 0, which must terminate with a null character
str1string no. 1
ls1length of the string no. 1
cl_ppointer to a HIPC client
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 196 of file client.c.

References HIPC_client::err_detail_str.

Referenced by GetStrutpl_mbr(), hipcClientCheckMbrSize(), hipcClientGetStrutpl(), hipcClientSetError(), test_ErrorDetailStr(), and test_ErrorDetailStr_longStr().

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to the HIPC client
hipc_errnoHIPC error number to be set
strstring of the error detail
Returns
the same value as hipc_errno.

Definition at line 240 of file client.c.

References HIPC_client::hipc_errno, and hipcClientSetErrDtlStr().

Referenced by FeedSysmsg_OFFSET_SIZE(), GetStrutpl_mbr(), handler_err(), hipcClientCheckStrutpl(), hipcClientEachMbr(), hipcClientFeedSysmsg(), hipcClientFeedUnstrumsgAsError(), hipcClientInit(), hipcGet(), hipcPut(), hipcRecvMsg(), hipcSendMsg(), hipcSetHandler(), hipcWaitReturn(), and test_Err().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client
strunostructure number
cimg_paddress that points the structure instance

Definition at line 260 of file client.c.

References HIPC_client::cimg_pp.

Referenced by hipcSetHandler(), test_handler(), test_hipcClientPack_NULLarg(), and test_hipcClientUnpack_NULLarg().

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client
strunostructure number
hndlr_pfunction pointer, which is the handler.
argargument for the handler

Definition at line 279 of file client.c.

References HIPC_client::hdarg_pp, and HIPC_client::hndlr_pp.

Referenced by hipcSetHandler(), and test_handler().

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client
strunostructure number
msgRHIPC message to be passed to the handler
Returns
what the handler returns

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(), and test_handler().

Here is the caller graph for this function:

unsigned char hipcClientGetNsysmsg ( struct HIPC_client const *const  cl_p)

Gets the number of system messages.

Parameters
cl_pPointer to a HIPC client
Returns
Number of system messages

Definition at line 326 of file client.c.

References HIPC_client::indp_p, and HIPC_cl_indp::n_sysmsg.

Referenced by hipcOpen(), and test_hipcClientGetNsysmsg().

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client to be initialized. This must not be NULL.
clbase_ppointer to a HIPC client with which cl_p is initialized.
Returns
HIPC_SUCCESS on success, or an error on failure.

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, hipcClientCalloc(), hipcClientMalloc(), 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(), routine_hipcClientEachMbr(), setupTestClient(), test_handler(), test_hipcClientEachMbr_err(), test_hipcClientFeedSysmsg(), and test_hipcClientInit().

Here is the call graph for this function:

Here is the caller graph for this function:

void hipcClientTerminate ( struct HIPC_client *const  cl_p)

Terminates a HIPC client with releasing the memory space that the client has.

Parameters
cl_ppointer 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(), routine_hipcClientEachMbr(), test_client_memope_calloc(), test_client_memope_malloc(), test_client_memope_multi(), test_client_memope_no_allocation(), test_hipcClientEachMbr_err(), test_hipcClientFeedStrumsg(), test_hipcClientFeedSysmsg(), test_hipcClientFeedUnstrumsgAsError(), and test_hipcClientInit().

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client
Returns
HIPC_SUCCESS on success, or an error on failure.

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, hipcClientSetErrDtlStr(), 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(), and test_hipcClientCheckMbrSize().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client
strunostructure number for a message
offsetoffset for a message
rngsizerange size for a message
Returns
HIPC_SUCCESS on success, or an error on failure.

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(), hipcGenmsgPut(), and test_hipcClientCheckStrutpl().

Here is the call graph for this function:

Here is the caller graph for this function:

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 
)
static

Gets offset, and size from member structure and a string that specify further.

Parameters
cl_ppointer to a HIPC client
strstring that identifies an item beneath the member specified by mbr_p
mbr_pa member of a structure
offset_ppointer to receive the offset value
size_ppointer to receive the size
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 565 of file client.c.

References HIPC_cl_indp_mbr::ary_dim, HIPC_cl_indp_mbr::ary_max_idxs, HIPC_cl_indp_mbr::elm_struno, HIPC_cl_indp_mbr::elm_type, HIPC_ERR_INTERNAL_ERROR, HIPC_ERR_INV_ID_STR, HIPC_client::hipc_errno, HIPC_MBR_ARRAY, HIPC_MBR_SIMPLE, HIPC_MBR_STRUCT, HIPC_SUCCESS, hipcClientSetErrDtlStr(), hipcClientSetError(), HIPC_client::indp_p, HIPC_cl_indp_stru::mbr_p, HIPC_cl_indp_stru::n_member, HIPC_cl_indp_mbr::name, 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 hipcClientGetStrutpl().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client
strstring that identifies an item
struno_ppointer to receive the structure number
offset_ppointer to receive the offset value
size_ppointer to receive the size
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 698 of file client.c.

References GetStrutpl_mbr(), HIPC_ERR_INV_ID_STR, HIPC_client::hipc_errno, HIPC_MBR_STRUCT, HIPC_SUCCESS, hipcClientCheckStrutpl(), hipcClientSetErrDtlStr(), 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(), hipcSetHandler(), test_hipcClientGetStrutpl(), and test_hipcClientGetStrutpl_tooLargeName().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client.
mbr_ppointer to an object that has data of the member.
beginbeginning address in the image for the server.
endending address in the image for the server.
scur_pserver's cuurent pointer.
ccur_pclient's cuurent pointer.
ssizesize of the item (member) in the server
csizesize of the item (member) in the client
fnc_ppointer to the function to be called.
Returns
HIPC_SUCCESS on success, or an error on failure.

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(), hipcClientUnpack(), routine_hipcClientEachMbr(), and test_hipcClientEachMbr_err().

Here is the call graph for this function:

Here is the caller graph for this function:

static void memcpy_wrapper ( void *const  scur_p,
void *const  ccur_p,
const size_t  n 
)
static

Definition at line 852 of file client.c.

Referenced by hipcClientPack().

Here is the caller graph for this function:

static void contra_memcpy ( void *const  scur_p,
void *const  ccur_p,
const size_t  n 
)
static

Definition at line 859 of file client.c.

Referenced by hipcClientUnpack().

Here is the caller graph for this function:

static void convert_endian ( void *const  scur_p,
void *const  ccur_p,
const size_t  n 
)
static

Definition at line 866 of file client.c.

Referenced by hipcClientPack().

Here is the caller graph for this function:

static void contra_convert_endian ( void *const  scur_p,
void *const  ccur_p,
const size_t  n 
)
static

Definition at line 879 of file client.c.

Referenced by hipcClientUnpack().

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client.
strunostructure number for the structure to be unpacked
offsetoffset of the range in the server representation
sizesize of the range in the server representation
simgServer-side image of the structure
cimgClient-side image of the structure
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 908 of file client.c.

References HIPC_client::cimg_pp, contra_convert_endian(), contra_memcpy(), 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(), hipcWaitReturn(), test_hipcClientUnpack(), and test_hipcClientUnpack_NULLarg().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client.
strunostructure number for the structure to be packed
offsetoffset of the range in the server representation
sizesize of the range in the server representation
simgServer-side image of the structure
cimgClient-side image of the structure
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 962 of file client.c.

References HIPC_client::cimg_pp, convert_endian(), HIPC_client::endian_convert, HIPC_MBR_STRUCT, HIPC_SUCCESS, hipcClientCheckStrutpl(), hipcClientEachMbr(), memcpy_wrapper(), HIPC_client::simg_pp, HIPC_cl_indp_mbr::struno, and HIPC_cl_indp_mbr::type.

Referenced by hipcPut(), test_hipcClientPack(), and test_hipcClientPack_NULLarg().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client.
msgRmessage to be fed
Returns
HIPC_ERR_PROTOCOL_VIOLATION if the message is inappropriate, or an error specified by the message.

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(), hipcWaitReturn(), and test_hipcClientFeedUnstrumsgAsError().

Here is the call graph for this function:

Here is the caller graph for this function:

static enum HIPC_errno FeedSysmsg_OFFSET_SIZE ( struct HIPC_client *const  cl_p,
const hipc_msg  msg,
unsigned char **const  tgtadr 
)
static

Feeds a system message whose type is HIPC_SYSMSG_TYPE_OFFSET or HIPC_SYSMSG_TYPE_SIZE.

Parameters
cl_ppointer to a HIPC client.
msgsystem message to be fed
tgtadrtarget address to which new data will be set
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 1038 of file client.c.

References HIPC_ERR_PROTOCOL_VIOLATION, HIPC_client::hipc_errno, HIPC_MSGHDR_BYTE_BDYSZ, HIPC_MSGHDR_BYTE_STRUNO, HIPC_MSGHDR_SIZE, HIPC_SUCCESS, hipcClientMalloc(), hipcClientSetError(), HIPC_client::indp_p, HIPC_cl_indp_stru::n_member, HIPC_cl_indp::n_struct, and HIPC_cl_indp::struct_p.

Referenced by hipcClientFeedSysmsg().

Here is the call graph for this function:

Here is the caller graph for this function:

enum HIPC_errno hipcClientFeedSysmsg ( struct HIPC_client *const  cl_p,
const hipc_msg  msgR 
)
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.

Parameters
cl_ppointer to a HIPC client.
msgRmessage to be fed
Returns
HIPC_SUCCESS on success, or an error on failure.

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(), and test_hipcClientFeedStrumsg().

Here is the call graph for this function:

Here is the caller graph for this function:

void hipcGenmsgHello ( hipc_msg  msg,
const struct HIPC_client *const  cl_p 
)

Generates HELLO message.

Parameters
cl_ppointer to a HIPC client
msgHIPC message to be set as HELLO
Returns
HIPC_SUCCESS on success, or an error on failure.

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(), and test_hipcGenmsgHello().

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client
msgHIPC message to be set as GET
strunostructure number of the message
offsetoffset of the message
sizesize of the message
Returns
HIPC_SUCCESS on success, or an error on failure.

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(), and test_hipcGenmsgGet().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
cl_ppointer to a HIPC client
msgHIPC message to be set as PUT
strunostructure number of the message
offsetoffset of the message
sizesize of the message
Returns
HIPC_SUCCESS on success, or an error on failure.

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(), and test_hipcGenmsgPut().

Here is the call graph for this function:

Here is the caller graph for this function:

void hipcGenmsgBye ( hipc_msg  msg)

Initializes a HIPC message as a BYE message.

Parameters
msgHIPC 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(), and test_hipcGenmsgBye().

Here is the caller graph for this function:

Variable Documentation

const char* hipc_errstr[HIPC_N_ERR]
static
Initial value:
= {
"HIPC_SUCCESS: No error",
"HIPC_ERR_S_INV_UDATA: Invalid user data",
"HIPC_ERR_S_INV_MSG_TYPE: Invalid message type",
"HIPC_ERR_S_INV_STRUNO: Invalid structure number",
"HIPC_ERR_S_INV_RW_RANGE: Invalid read/write range",
"HIPC_ERR_S_V_UNINIT_MSG: Virtually uninitialized HIPC message",
"HIPC_ERR_S_IO_READ: I/O read error",
"HIPC_ERR_S_IO_WRITE: I/O write error",
"HIPC_ERR_S_INV_CFG: Invalid Configuration",
"HIPC_ERR_S_INV_NULL: Invalid NULL value",
"HIPC_ERR_S_BUF_SHTG: Buffer shortage",
"HIPC_ERR_S_OVERSIZED_STRU: Oversized structure size",
"HIPC_ERR_S_PBANK_STAT_MISMATCH: pbank status mismatch",
"HIPC_ERR_C_STD: C standard library error",
"HIPC_ERR_INTERNAL_ERROR: Internal error in HIPC library",
"HIPC_ERR_IO_READ: I/O read error",
"HIPC_ERR_IO_WRITE: I/O write error",
"HIPC_ERR_PROTOCOL_VIOLATION: Protocol violation",
"HIPC_ERR_INV_ENDIAN: Invalid endian",
"HIPC_ERR_INV_ID_STR: Invalid ID string",
"HIPC_ERR_INV_BASE_CLIENT: Invalid base client",
"HIPC_ERR_MBR_SIZE_MISMATCH: Structure member size mismatch",
"HIPC_ERR_SESS_STATE_MISMATCH: Session state mismatch",
"HIPC_ERR_FOR_TESTING: Error only for testing",
"HIPC_ERR_TEST_LIB_INTERNAL: Internal error in a library only for testing",
}

Definition at line 10 of file client.c.

Referenced by hipcClientGetErrStr().