1
/**************************************************************************
2
*** COPYRIGHT (c) 2002 by TransNexus, Inc. ***
4
*** This software is property of TransNexus, Inc. ***
5
*** This software is freely available under license from TransNexus. ***
6
*** The license terms and conditions for free use of this software by ***
7
*** third parties are defined in the OSP Toolkit Software License ***
8
*** Agreement (LICENSE.txt). Any use of this software by third ***
9
*** parties, which does not comply with the terms and conditions of the ***
10
*** OSP Toolkit Software License Agreement is prohibited without ***
11
*** the prior, express, written consent of TransNexus, Inc. ***
13
*** Thank you for using the OSP ToolKit(TM). Please report any bugs, ***
14
*** suggestions or feedback to support@transnexus.com ***
16
**************************************************************************/
29
#include "osp/ospmsginfo.h"
34
OSPTMSGINFO *ospvMsgInfo)
36
int errorcode = OSPC_ERR_NO_ERROR,
37
tmperror = OSPC_ERR_NO_ERROR;
39
OSPM_DBGENTER(("ENTER: osppMsgInfoInitSync()\n"));
40
OSPM_MUTEX_INIT(ospvMsgInfo->Mutex, NULL, errorcode);
41
if (errorcode == OSPC_ERR_NO_ERROR)
43
OSPM_CONDVAR_INIT(ospvMsgInfo->CondVar, NULL, errorcode);
44
if (errorcode != OSPC_ERR_NO_ERROR)
46
OSPM_MUTEX_DESTROY(ospvMsgInfo->Mutex, tmperror);
49
OSPM_DBGEXIT(("EXIT : osppMsgInfoInitSync()\n"));
55
OSPTMSGINFO **ospvMsgInfo)
57
int errorcode = OSPC_ERR_NO_ERROR;
59
OSPM_DBGENTER(("ENTER: OSPPMsgInfoNew()\n"));
60
OSPM_MALLOC(*ospvMsgInfo, OSPTMSGINFO, sizeof(OSPTMSGINFO));
61
if (*ospvMsgInfo != (OSPTMSGINFO *)OSPC_OSNULL)
63
OSPM_MEMSET(*ospvMsgInfo, 0, sizeof(OSPTMSGINFO));
65
errorcode = osppMsgInfoInitSync(*ospvMsgInfo);
66
if (errorcode != OSPC_ERR_NO_ERROR)
68
OSPM_FREE(*ospvMsgInfo);
69
*ospvMsgInfo = (OSPTMSGINFO *)OSPC_OSNULL;
72
OSPM_DBGEXIT(("EXIT : OSPPMsgInfoNew()\n"));
78
OSPTMSGINFO **ospvMsgInfo)
80
int errorcode = OSPC_ERR_NO_ERROR;
82
OSPM_DBGENTER(("ENTER: OSPPMsgInfoDelete()\n"));
85
if ((*ospvMsgInfo)->ResponseMsg != (unsigned char *)OSPC_OSNULL)
86
OSPM_FREE((*ospvMsgInfo)->ResponseMsg);
88
if ((*ospvMsgInfo)->RequestMsg != (unsigned char *)OSPC_OSNULL)
89
OSPM_FREE((*ospvMsgInfo)->RequestMsg);
91
if ((*ospvMsgInfo)->ContentType != (unsigned char *)OSPC_OSNULL)
92
OSPM_FREE((*ospvMsgInfo)->ContentType);
95
OSPM_MUTEX_DESTROY((*ospvMsgInfo)->Mutex, errorcode);
97
OSPM_CONDVAR_DESTROY((*ospvMsgInfo)->CondVar, errorcode);
99
OSPM_FREE(*ospvMsgInfo);
100
*ospvMsgInfo = (OSPTMSGINFO *)OSPC_OSNULL;
102
OSPM_DBGEXIT(("EXIT : OSPPMsgInfoDelete()\n"));
107
OSPPMsgInfoAssignRequestMsg(
108
OSPTMSGINFO *ospvMsgInfo,
109
unsigned char *ospvRequestMsg,
110
unsigned ospvRequestSz)
112
OSPM_DBGENTER(("ENTER: OSPPMsgInfoAssignRequestMsg()\n"));
113
if (ospvMsgInfo != (OSPTMSGINFO *)OSPC_OSNULL)
116
ospvMsgInfo->RequestMsg = ospvRequestMsg;
117
ospvMsgInfo->RequestSz = ospvRequestSz;
119
OSPM_DBGEXIT(("EXIT : OSPPMsgInfoAssignRequestMsg()\n"));
124
OSPPMsgInfoProcessResponse(
125
OSPTMSGINFO *ospvMsgInfo)
127
int errorcode = OSPC_ERR_NO_ERROR,
128
tmperrcode = OSPC_ERR_NO_ERROR;
130
OSPM_DBGENTER(("ENTER: OSPPMsgInfoProcessResponse()\n"));
132
if (ospvMsgInfo->IsNonBlocking == OSPC_FALSE)
135
* once signalled, acquire the mutex for the individual
138
OSPM_MUTEX_LOCK(ospvMsgInfo->Mutex, errorcode);
139
if (errorcode == OSPC_ERR_NO_ERROR)
141
ospvMsgInfo->HasBeenProcessed = OSPC_TRUE;
142
OSPM_CONDVAR_SIGNAL(ospvMsgInfo->CondVar, errorcode);
143
OSPM_MUTEX_UNLOCK(ospvMsgInfo->Mutex, tmperrcode);
148
OSPPMsgInfoDelete(&ospvMsgInfo);
152
OSPM_DBGEXIT(("EXIT : OSPPMsgInfoProcessResponse()\n"));
157
OSPPMsgInfoWaitForMsg(
158
OSPTMSGINFO *ospvMsgInfo)
160
int errorcode = OSPC_ERR_NO_ERROR;
162
OSPM_DBGENTER(("ENTER: OSPPMsgInfoWaitForMsg()\n"));
164
OSPM_MUTEX_LOCK(ospvMsgInfo->Mutex, errorcode);
165
if (errorcode == OSPC_ERR_NO_ERROR)
167
while (ospvMsgInfo->HasBeenProcessed == OSPC_FALSE)
169
OSPM_CONDVAR_WAIT(ospvMsgInfo->CondVar, ospvMsgInfo->Mutex,
173
OSPM_MUTEX_UNLOCK(ospvMsgInfo->Mutex, errorcode);
175
OSPM_DBGEXIT(("EXIT : OSPPMsgInfoWaitForMsg()\n"));