HIPC  0.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Macros | Typedefs | Enumerations | Functions
session.h File Reference
#include <hipc.h>
#include <hipc/msg.h>
#include <hipc/client.h>
Include dependency graph for session.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  HIPC_session
 

Macros

#define HIPC_ERRCHECK(sess_p)   hipcERRCHECK(sess_p, __FILE__, __LINE__)
 Checks whether an error has occurred. More...
 

Typedefs

typedef struct HIPC_session hipc_session
 

Enumerations

enum  HIPC_session_state { HIPC_SESS_TERMINATED = 0, HIPC_SESS_QUITTED, HIPC_SESS_ESTABLISHED }
 

Functions

enum HIPC_errno hipcRecvMsg (hipc_session *const sess_p, hipc_msg msgR)
 Receives a HIPC message. More...
 
enum HIPC_errno hipcSendMsg (hipc_session *const sess_p, hipc_msg msgS)
 Sends a HIPC message. More...
 
enum HIPC_errno hipcWaitReturn (hipc_session *const sess_p, hipc_msg msgR)
 Waits a return message from a HIPC server. More...
 
enum HIPC_errno hipcOpen (hipc_session *const sess_p, struct HIPC_client const *const clbase_p, enum HIPC_errno(*rfnc_p)(void *, hipc_msg), void *rarg, enum HIPC_errno(*wfnc_p)(void *, const hipc_msg), void *warg)
 Open a session to a HIPC server. More...
 
enum HIPC_errno hipcClose (hipc_session *const sess_p)
 Closes a session. More...
 
enum HIPC_errno hipcSetHandler (hipc_session *const sess_p, char const *const str, void *const cimg, enum HIPC_errno(*hndlr_p)(struct HIPC_client *, const hipc_msg, void *, void *), void *const arg)
 Set a handler to a structure type. More...
 
enum HIPC_errno hipcGet (hipc_session *const sess_p, char const *const str, void *const cimg)
 Gets data specified by str from a HIPC server. More...
 
enum HIPC_errno hipcPut (hipc_session *const sess_p, char const *const str, void *const cimg)
 Puts data specified by str from a HIPC server. More...
 
void hipcERRCHECK (hipc_session const *const sess_p, char const *const filename, const int lineno)
 Checks whether an error has occurred. More...
 

Macro Definition Documentation

#define HIPC_ERRCHECK (   sess_p)    hipcERRCHECK(sess_p, __FILE__, __LINE__)

Checks whether an error has occurred.

See hipcERRCHECK() for more details.

Parameters
sess_ppointer to a HIPC session.
Returns
pointer to the body of the HIPC message data.

Definition at line 72 of file session.h.

Referenced by closeDefaultSession(), main(), openDefaultSession(), test_hipcSession(), and test_hipcSession_cast().

Typedef Documentation

typedef struct HIPC_session hipc_session

Definition at line 22 of file session.h.

Enumeration Type Documentation

Enumerator
HIPC_SESS_TERMINATED 
HIPC_SESS_QUITTED 
HIPC_SESS_ESTABLISHED 

Definition at line 8 of file session.h.

Function Documentation

enum HIPC_errno hipcRecvMsg ( hipc_session *const  sess_p,
hipc_msg  msgR 
)

Receives a HIPC message.

Parameters
sess_ppointer to a HIPC session.
msgRmessage received
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 56 of file session.c.

References HIPC_session::cl, HIPC_SUCCESS, hipcClientSetError(), hipcClientSetStdErrno(), HIPC_session::rarg, and HIPC_session::rfnc_p.

Referenced by hipcOpen(), and hipcWaitReturn().

Here is the call graph for this function:

Here is the caller graph for this function:

enum HIPC_errno hipcSendMsg ( hipc_session *const  sess_p,
hipc_msg  msgS 
)

Sends a HIPC message.

Parameters
sess_ppointer to a HIPC session.
msgSmessage to be sent
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 76 of file session.c.

References HIPC_session::cl, HIPC_SUCCESS, hipcClientSetError(), hipcClientSetStdErrno(), HIPC_session::warg, and HIPC_session::wfnc_p.

Referenced by hipcClose(), hipcGet(), hipcOpen(), and hipcPut().

Here is the call graph for this function:

Here is the caller graph for this function:

enum HIPC_errno hipcWaitReturn ( hipc_session *const  sess_p,
hipc_msg  msgR 
)

Waits a return message from a HIPC server.

If a CAST messages is received while waiting, this function calls a handler.

Parameters
sess_ppointer to a HIPC session.
msgRlast message received
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 98 of file session.c.

References HIPC_session::cl, HIPC_ERR_PROTOCOL_VIOLATION, HIPC_ERR_SESS_STATE_MISMATCH, HIPC_MESSAGE_TYPE_CAST, HIPC_MESSAGE_TYPE_QUIT, HIPC_MESSAGE_TYPE_SUCCESS, HIPC_SESS_ESTABLISHED, HIPC_SESS_QUITTED, HIPC_SUCCESS, HIPC_UNSTRU, hipcClientCallHandler(), hipcClientFeedStrumsg(), hipcClientFeedUnstrumsgAsError(), hipcClientGetHipcErrno(), hipcClientSetError(), hipcClientUnpack(), hipcMsgOffset(), hipcMsgRngsize(), hipcMsgStruno(), hipcMsgType(), hipcRecvMsg(), and HIPC_session::state.

Referenced by hipcClose(), hipcGet(), hipcPut(), and test_hipcWaitReturn_err().

Here is the call graph for this function:

Here is the caller graph for this function:

enum HIPC_errno hipcOpen ( hipc_session *const  sess_p,
struct HIPC_client const *const  clbase_p,
enum HIPC_errno(*)(void *, hipc_msg rfnc_p,
void *  rarg,
enum HIPC_errno(*)(void *, const hipc_msg wfnc_p,
void *  warg 
)

Open a session to a HIPC server.

The server is specified by clbase_p. Also, read/write functions to communicate with the server must be given as arguments.

Parameters
sess_ppointer to a HIPC session.
clbase_pHIPC client as a base for the session
rfnc_ppointer to a function that reads a HIPC message
rargargument passed to the function of rfnc_p
wfnc_ppointer to a function that writes a HIPC message
wargargument passed to the function of wfnc_p
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 217 of file session.c.

References HIPC_session::cl, HIPC_MESSAGE_TYPE_QUIT, HIPC_SESS_ESTABLISHED, HIPC_SESS_QUITTED, HIPC_SUCCESS, hipcClientCheckMbrSize(), hipcClientFeedSysmsg(), hipcClientFeedUnstrumsgAsError(), hipcClientGetNsysmsg(), hipcClientInit(), hipcGenmsgHello(), hipcMsgType(), hipcRecvMsg(), hipcSendMsg(), HIPC_session::rarg, HIPC_session::rfnc_p, HIPC_session::state, HIPC_session::warg, and HIPC_session::wfnc_p.

Referenced by main(), openDefaultSession(), test_hipcOpen_err(), test_hipcSession(), and test_hipcSession_cast().

Here is the call graph for this function:

Here is the caller graph for this function:

enum HIPC_errno hipcClose ( hipc_session *const  sess_p)

Closes a session.

Data about the session are cleared even if an error occurs in communication with a server for the close.

Parameters
sess_ppointer to a HIPC session.
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 276 of file session.c.

References HIPC_session::cl, HIPC_SESS_ESTABLISHED, HIPC_SESS_TERMINATED, HIPC_SUCCESS, hipcClientTerminate(), hipcGenmsgBye(), hipcSendMsg(), hipcWaitReturn(), HIPC_session::rarg, HIPC_session::rfnc_p, HIPC_session::state, HIPC_session::warg, and HIPC_session::wfnc_p.

Referenced by closeDefaultSession(), main(), test_hipcClose_err(), test_hipcOpen_err(), test_hipcSession(), and test_hipcSession_cast().

Here is the call graph for this function:

Here is the caller graph for this function:

enum HIPC_errno hipcSetHandler ( hipc_session *const  sess_p,
char const *const  str,
void *const  cimg,
enum HIPC_errno(*)(struct HIPC_client *, const hipc_msg, void *, void *)  hndlr_p,
void *const  arg 
)

Set a handler to a structure type.

The handler will be called when a CAST message of the type is received.

Parameters
sess_ppointer to a HIPC session.
strstring that identifies the structure type.
cimgclient-side image
hndlr_phandler
argargument to be passed to the handler
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 174 of file session.c.

References HIPC_session::cl, HIPC_ERR_SESS_STATE_MISMATCH, HIPC_SESS_ESTABLISHED, HIPC_SUCCESS, hipcClientGetStrutpl(), hipcClientSetCimg(), hipcClientSetError(), hipcClientSetHandler(), and HIPC_session::state.

Referenced by main(), test_hipcSession_cast(), test_hipcSetHandler_err(), and test_hipcWaitReturn_err().

Here is the call graph for this function:

Here is the caller graph for this function:

enum HIPC_errno hipcGet ( hipc_session *const  sess_p,
char const *const  str,
void *const  cimg 
)

Gets data specified by str from a HIPC server.

The data are unpacked to cimg.

Parameters
sess_ppointer to a HIPC session.
strstring that identifies an item to be gotten
cimgClient-side image of the structure
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 312 of file session.c.

References HIPC_session::cl, HIPC_ERR_SESS_STATE_MISMATCH, HIPC_SESS_ESTABLISHED, HIPC_SUCCESS, hipcClientGetStrutpl(), hipcClientSetError(), hipcClientUnpack(), hipcGenmsgGet(), hipcSendMsg(), hipcWaitReturn(), and HIPC_session::state.

Referenced by main(), test_hipcGet_err(), test_hipcSession(), and test_hipcSession_cast().

Here is the call graph for this function:

Here is the caller graph for this function:

enum HIPC_errno hipcPut ( hipc_session *const  sess_p,
char const *const  str,
void *const  cimg 
)

Puts data specified by str from a HIPC server.

This function packs contents of cimg and puts it.

Parameters
sess_ppointer to a HIPC session.
strstring that identifies an item to be put
cimgClient-side image of the structure
Returns
HIPC_SUCCESS on success, or an error on failure.

Definition at line 361 of file session.c.

References HIPC_session::cl, HIPC_ERR_SESS_STATE_MISMATCH, HIPC_SESS_ESTABLISHED, HIPC_SUCCESS, hipcClientGetStrutpl(), hipcClientPack(), hipcClientSetError(), hipcGenmsgPut(), hipcSendMsg(), hipcWaitReturn(), and HIPC_session::state.

Referenced by main(), test_hipcPut_err(), test_hipcSession(), and test_hipcSession_cast().

Here is the call graph for this function:

Here is the caller graph for this function:

void hipcERRCHECK ( const hipc_session *const  sess_p,
const char *const  filename,
const int  lineno 
)

Checks whether an error has occurred.

If an error is detected, this function terminates the process after printing error location, which consists of filename, lineno, and function, and error details to stderr.

Parameters
sess_ppointer to a HIPC session.
filenamefile name
linenoline number

Definition at line 17 of file session.c.

References HIPC_session::cl, HIPC_SUCCESS, hipcClientGetErrDtlStr(), hipcClientGetErrStr(), hipcClientGetHipcErrno(), and hipcClientGetStdErrno().

Here is the call graph for this function: