[go: up one dir, main page]

Menu

[r519]: / main / src / ospfail.c  Maximize  Restore  History

Download this file

138 lines (118 with data), 4.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/**************************************************************************
*** COPYRIGHT (c) 2002 by TransNexus, Inc. ***
*** ***
*** This software is property of TransNexus, Inc. ***
*** This software is freely available under license from TransNexus. ***
*** The license terms and conditions for free use of this software by ***
*** third parties are defined in the OSP Toolkit Software License ***
*** Agreement (LICENSE.txt). Any use of this software by third ***
*** parties, which does not comply with the terms and conditions of the ***
*** OSP Toolkit Software License Agreement is prohibited without ***
*** the prior, express, written consent of TransNexus, Inc. ***
*** ***
*** Thank you for using the OSP ToolKit(TM). Please report any bugs, ***
*** suggestions or feedback to support@transnexus.com ***
*** ***
**************************************************************************/
/*
* ospfail.cpp - Failure reasons.
*/
#include "osp/osp.h"
#include "osp/ospfail.h"
/*
* Will return success as long as ospvFailureReason is between
* OSPC_FAIL_NONE (0) and OSPC_FAIL_GENERAL (999)
*/
int OSPPFailReasonFind(
OSPEFAILREASON ospvFailureReason)
{
int errorcode = OSPC_ERR_NO_ERROR;
if ((ospvFailureReason < OSPC_FAIL_NONE) || (ospvFailureReason > OSPC_FAIL_GENERAL)) {
errorcode = OSPC_ERR_FAILRSN_INVALID;
OSPM_DBGERRORLOG(errorcode, "Failure code invalid");
}
return errorcode;
}
/*
* OSPPHasTermCause() - Does request have termination cause
*/
OSPTBOOL OSPPHasTermCause( /* returns non-zero if time */
OSPT_TERM_CAUSE *ospvTermCause, /* usage request in question */
OSPE_TERM_CAUSE ospvType) /* termination cause type */
{
OSPTBOOL ospvHas = OSPC_FALSE;
if (ospvTermCause != OSPC_OSNULL) {
if ((ospvType >= OSPC_TCAUSE_START) && (ospvType < OSPC_TCAUSE_NUMBER)) {
ospvHas = ospvTermCause->hastermcause[ospvType];
}
}
return ospvHas;
}
/*
* OSPPHasTermCauseAny() - Does request have a termination cause
*/
OSPTBOOL OSPPHasTermCauseAny( /* returns non-zero if time */
OSPT_TERM_CAUSE *ospvTermCause) /* usage request in question */
{
OSPTBOOL ospvHas = OSPC_FALSE;
OSPE_TERM_CAUSE ospvType;
if (ospvTermCause != OSPC_OSNULL) {
for (ospvType = OSPC_TCAUSE_START; ospvType < OSPC_TCAUSE_NUMBER; ospvType++) {
ospvHas |= ospvTermCause->hastermcause[ospvType];
}
}
return ospvHas;
}
/*
* OSPPSetTermCause() - Set termination cause
*/
void OSPPSetTermCause( /* nothing returned */
OSPT_TERM_CAUSE *ospvTermCause,
OSPE_TERM_CAUSE ospvType,
unsigned ospvTCCode,
const char *ospvTCDesc)
{
if (ospvTermCause != OSPC_OSNULL) {
if ((ospvType >= OSPC_TCAUSE_START) && (ospvType < OSPC_TCAUSE_NUMBER)) {
ospvTermCause->tccode[ospvType] = ospvTCCode;
if ((ospvTCDesc != OSPC_OSNULL) && (ospvTCDesc[0] != '\0')) {
OSPM_STRNCPY(ospvTermCause->tcdesc[ospvType], ospvTCDesc, sizeof(ospvTermCause->tcdesc[ospvType]) - 1);
}
ospvTermCause->hastermcause[ospvType] = OSPC_TRUE;
}
}
}
/*
* OSPPGetTCCode() - returns termination cause code
*/
unsigned OSPPGetTCCode(
OSPT_TERM_CAUSE *ospvTermCause, /* Termination cause */
OSPE_TERM_CAUSE ospvType) /* Termination cause type */
{
unsigned ospvTCCode = 0;
if (ospvTermCause != OSPC_OSNULL) {
if ((ospvType >= OSPC_TCAUSE_START) && (ospvType < OSPC_TCAUSE_NUMBER)) {
if (ospvTermCause->hastermcause[ospvType]) {
ospvTCCode = ospvTermCause->tccode[ospvType];
}
}
}
return ospvTCCode;
}
/*
* OSPPGetTCDesc() - returns termination cause description
*/
const char *OSPPGetTCDesc(
OSPT_TERM_CAUSE *ospvTermCause, /* Termination cause */
OSPE_TERM_CAUSE ospvType) /* Termination cause type */
{
const char *ospvTCDesc = OSPC_OSNULL;
if (ospvTermCause != OSPC_OSNULL) {
if ((ospvType >= OSPC_TCAUSE_START) && (ospvType < OSPC_TCAUSE_NUMBER)) {
if (ospvTermCause->hastermcause[ospvType]) {
ospvTCDesc = ospvTermCause->tcdesc[ospvType];
}
}
}
return ospvTCDesc;
}