VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/asn1/asn1-ut-null.cpp@ 57444

Last change on this file since 57444 was 57358, checked in by vboxsync, 9 years ago

*: scm cleanup run.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: asn1-ut-null.cpp 57358 2015-08-14 15:16:38Z vboxsync $ */
2/** @file
3 * IPRT - ASN.1, NULL type.
4 */
5
6/*
7 * Copyright (C) 2006-2015 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include "internal/iprt.h"
32#include <iprt/asn1.h>
33
34#include <iprt/err.h>
35#include <iprt/string.h>
36
37#include <iprt/formats/asn1.h>
38
39
40/*
41 * ASN.1 NULL - Special Methods.
42 */
43
44
45/*
46 * ASN.1 NULL - Standard Methods.
47 */
48
49
50RT_DECL_DATA_CONST(RTASN1COREVTABLE const) g_RTAsn1Null_Vtable =
51{
52 "RTAsn1Null",
53 sizeof(RTASN1NULL),
54 ASN1_TAG_NULL,
55 ASN1_TAGCLASS_UNIVERSAL | ASN1_TAGFLAG_PRIMITIVE,
56 0,
57 (PFNRTASN1COREVTDTOR)RTAsn1Null_Delete,
58 (PFNRTASN1COREVTENUM)RTAsn1Null_Enum,
59 (PFNRTASN1COREVTCLONE)RTAsn1Null_Clone,
60 (PFNRTASN1COREVTCOMPARE)RTAsn1Null_Compare,
61 (PFNRTASN1COREVTCHECKSANITY)RTAsn1Null_CheckSanity,
62 NULL,
63 NULL
64};
65
66
67RTDECL(int) RTAsn1Null_Init(PRTASN1NULL pThis, PCRTASN1ALLOCATORVTABLE pAllocator)
68{
69 return RTAsn1Core_InitEx(&pThis->Asn1Core, ASN1_TAG_NULL, ASN1_TAGCLASS_UNIVERSAL | ASN1_TAGFLAG_PRIMITIVE,
70 &g_RTAsn1Null_Vtable, RTASN1CORE_F_PRESENT | RTASN1CORE_F_PRIMITE_TAG_STRUCT);
71}
72
73
74RTDECL(int) RTAsn1Null_Clone(PRTASN1NULL pThis, PCRTASN1NULL pSrc, PCRTASN1ALLOCATORVTABLE pAllocator)
75{
76 AssertPtr(pSrc); AssertPtr(pThis); AssertPtr(pAllocator);
77 RT_ZERO(*pThis);
78 if (RTAsn1Null_IsPresent(pSrc))
79 {
80 AssertReturn(pSrc->Asn1Core.pOps == &g_RTAsn1Null_Vtable, VERR_INTERNAL_ERROR_3);
81 AssertReturn(pSrc->Asn1Core.cb == 0, VERR_INTERNAL_ERROR_4);
82
83 int rc = RTAsn1Core_CloneNoContent(&pThis->Asn1Core, &pSrc->Asn1Core);
84 if (RT_FAILURE(rc))
85 return rc;
86 }
87 return VINF_SUCCESS;
88}
89
90
91RTDECL(void) RTAsn1Null_Delete(PRTASN1NULL pThis)
92{
93 if ( pThis
94 && RTAsn1Null_IsPresent(pThis))
95 {
96 Assert(pThis->Asn1Core.pOps == &g_RTAsn1Null_Vtable);
97 RT_ZERO(*pThis);
98 }
99}
100
101
102RTDECL(int) RTAsn1Null_Enum(PRTASN1NULL pThis, PFNRTASN1ENUMCALLBACK pfnCallback, uint32_t uDepth, void *pvUser)
103{
104 Assert(pThis && (!RTAsn1Null_IsPresent(pThis) || pThis->Asn1Core.pOps == &g_RTAsn1Null_Vtable));
105
106 /* No children to enumerate. */
107 return VINF_SUCCESS;
108}
109
110
111RTDECL(int) RTAsn1Null_Compare(PCRTASN1NULL pLeft, PCRTASN1NULL pRight)
112{
113 Assert(pLeft && (!RTAsn1Null_IsPresent(pLeft) || pLeft->Asn1Core.pOps == &g_RTAsn1Null_Vtable));
114 Assert(pRight && (!RTAsn1Null_IsPresent(pRight) || pRight->Asn1Core.pOps == &g_RTAsn1Null_Vtable));
115
116 return (int)RTAsn1Null_IsPresent(pLeft) - (int)RTAsn1Null_IsPresent(pRight);
117}
118
119
120RTDECL(int) RTAsn1Null_CheckSanity(PCRTASN1NULL pThis, uint32_t fFlags, PRTERRINFO pErrInfo, const char *pszErrorTag)
121{
122 if (RT_UNLIKELY(!RTAsn1Null_IsPresent(pThis)))
123 return RTErrInfoSetF(pErrInfo, VERR_ASN1_NOT_PRESENT, "%s: Missing (NULL).", pszErrorTag);
124 return VINF_SUCCESS;
125}
126
127/* No NULL object collections. */
128
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette