RTDECL(int) RTAsn1Integer_Clone(PRTASN1INTEGER pThis, PCRTASN1INTEGER pSrc, PCRTASN1ALLOCATORVTABLE pAllocator) { AssertPtr(pSrc); AssertPtr(pThis); AssertPtr(pAllocator); RT_ZERO(*pThis); if (RTAsn1Integer_IsPresent(pSrc)) { AssertReturn(pSrc->Asn1Core.pOps == &g_RTAsn1Integer_Vtable, VERR_INTERNAL_ERROR_3); int rc; if ( pSrc->Asn1Core.cb != 1 || pSrc->uValue.u >= RT_ELEMENTS(g_abSmall)) { /* Value is too large, copy it. */ rc = RTAsn1Core_CloneContent(&pThis->Asn1Core, &pSrc->Asn1Core, pAllocator); if (RT_FAILURE(rc)) return rc; } else { /* Use one of the const values. */ rc = RTAsn1Core_CloneNoContent(&pThis->Asn1Core, &pSrc->Asn1Core); if (RT_FAILURE(rc)) return rc; Assert(g_abSmall[pSrc->uValue.u] == pSrc->uValue.u); pThis->Asn1Core.uData.pv = (void *)&g_abSmall[pSrc->uValue.u]; } pThis->uValue.u = pSrc->uValue.u; } return VINF_SUCCESS; }
RTDECL(int) RTAsn1Boolean_Clone(PRTASN1BOOLEAN pThis, PCRTASN1BOOLEAN pSrc, PCRTASN1ALLOCATORVTABLE pAllocator) { AssertPtr(pSrc); AssertPtr(pThis); AssertPtr(pAllocator); RT_ZERO(*pThis); if (RTAsn1Boolean_IsPresent(pSrc)) { AssertReturn(pSrc->Asn1Core.pOps == &g_RTAsn1Boolean_Vtable, VERR_INTERNAL_ERROR_3); AssertReturn(pSrc->Asn1Core.cb <= 1, VERR_INTERNAL_ERROR_4); int rc; if ( pSrc->Asn1Core.cb == 1 && pSrc->Asn1Core.uData.pu8[0] != 0x00 && pSrc->Asn1Core.uData.pu8[0] != 0xff) { /* DER/CER incompatible value must be copied as-is. */ rc = RTAsn1Core_CloneContent(&pThis->Asn1Core, &pSrc->Asn1Core, pAllocator); if (RT_FAILURE(rc)) return rc; } else { /* No value or one of the standard values. */ rc = RTAsn1Core_CloneNoContent(&pThis->Asn1Core, &pSrc->Asn1Core); if (RT_FAILURE(rc)) return rc; pThis->Asn1Core.uData.pv = (void *)(pSrc->fValue ? &g_bTrue : &g_bFalse); } pThis->fValue = pSrc->fValue; } return VINF_SUCCESS; }
RTDECL(int) RTAsn1Core_Clone(PRTASN1CORE pThis, PCRTASN1CORE pSrc, PCRTASN1ALLOCATORVTABLE pAllocator) { int rc; RT_ZERO(*pThis); if (RTASN1CORE_IS_PRESENT(pSrc)) { Assert(pSrc->pOps == &g_RTAsn1Core_Vtable); rc = RTAsn1Core_CloneContent(pThis, pSrc, pAllocator); } else rc = VINF_SUCCESS; return rc; }
RTDECL(int) RTAsn1Time_Clone(PRTASN1TIME pThis, PCRTASN1TIME pSrc, PCRTASN1ALLOCATORVTABLE pAllocator) { AssertPtr(pSrc); AssertPtr(pThis); AssertPtr(pAllocator); RT_ZERO(*pThis); if (RTAsn1Time_IsPresent(pSrc)) { AssertReturn(pSrc->Asn1Core.pOps == &g_RTAsn1Time_Vtable, VERR_INTERNAL_ERROR_3); int rc = RTAsn1Core_CloneContent(&pThis->Asn1Core, &pSrc->Asn1Core, pAllocator); if (RT_SUCCESS(rc)) { pThis->Time = pSrc->Time; return VINF_SUCCESS; } return rc; } return VINF_SUCCESS; }