~ubuntu-branches/ubuntu/trusty/osptoolkit/trusty

« back to all changes in this revision

Viewing changes to src/ospasn1ids.c

  • Committer: Bazaar Package Importer
  • Author(s): TransNexus, Inc.
  • Date: 2007-12-30 20:37:26 UTC
  • Revision ID: james.westby@ubuntu.com-20071230203726-dysah2e93yqd3vbp
Tags: upstream-3.4.2
ImportĀ upstreamĀ versionĀ 3.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************
 
2
*** COPYRIGHT (c) 2002 by TransNexus, Inc.                              ***
 
3
***                                                                     ***
 
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.             ***
 
12
***                                                                     ***
 
13
*** Thank you for using the OSP ToolKit(TM).  Please report any bugs,   ***
 
14
*** suggestions or feedback to support@transnexus.com                   ***
 
15
***                                                                     ***
 
16
**************************************************************************/
 
17
 
 
18
 
 
19
 
 
20
 
 
21
 
 
22
 
 
23
 
 
24
/*
 
25
 * ospasn1ids.c - ASN1 defined ID's definitions and functions.
 
26
 */
 
27
 
 
28
#define OSPC_OSPASN1ID_INCLUDE_STATIC 1 /* Forces inclusion of static */
 
29
/* data defined in ospasn1id.h */
 
30
#include "osp/osp.h"
 
31
#include "osp/ospasn1.h"
 
32
#include "osp/ospasn1ids.h"         
 
33
 
 
34
 
 
35
/* FUNCTION PROTOTYPES */
 
36
 
 
37
/* ---------------------------------------------------------*/
 
38
/* Member functions                                         */
 
39
/* ---------------------------------------------------------*/
 
40
 
 
41
int
 
42
OSPPASN1IdGetValue(
 
43
    OSPEASN1ID      ospvId,
 
44
    unsigned char   **ospvIdValue,
 
45
    unsigned        *ospvIdLength)
 
46
{
 
47
    int errorcode = OSPC_ERR_NO_ERROR;
 
48
    OSPTIDINDEX *idxRec = OSPC_OSNULL;
 
49
 
 
50
    if ((ospvId < 0) || (ospvId > OSPEID_LISTEND))
 
51
    {
 
52
        errorcode = OSPC_ERR_ASN1_OBJECTID_NOT_FOUND;   
 
53
        OSPM_DBGERRORLOG(errorcode, "Object Id enum out of range");
 
54
    } 
 
55
    else if (ospvIdValue == OSPC_OSNULL)
 
56
    {
 
57
        errorcode = OSPC_ERR_ASN1_NULL_POINTER;
 
58
        OSPM_DBGERRORLOG(errorcode, 
 
59
            "Invalid Null Pointer provided for object Id return");
 
60
    }
 
61
 
 
62
    if (errorcode == OSPC_ERR_NO_ERROR)
 
63
    {
 
64
        idxRec = &(ospgASN1IDIndex[ospvId]);
 
65
        if (idxRec->Id != ospvId)
 
66
        {
 
67
            errorcode = OSPC_ERR_ASN1_OBJECTID_MISMATCH;
 
68
            OSPM_DBGERRORLOG(errorcode,
 
69
                "ID definitions and reference enums are out-of-sync");
 
70
        }
 
71
    }
 
72
 
 
73
    if (errorcode == OSPC_ERR_NO_ERROR)
 
74
    {
 
75
        *ospvIdValue = idxRec->Value;
 
76
        *ospvIdLength = idxRec->ValueLength;
 
77
    }
 
78
 
 
79
    if (errorcode != OSPC_ERR_NO_ERROR)
 
80
    {
 
81
        *ospvIdValue = OSPC_OSNULL;
 
82
        *ospvIdLength = 0;
 
83
    }
 
84
 
 
85
    return errorcode;
 
86
}
 
87