git-svn-id: https://svn.code.sf.net/p/openv2g/code/trunk@57 d9f2db14-54d0-4bde-b00c-16405c910529

This commit is contained in:
daniel_peintner 2012-02-07 12:45:01 +00:00
parent 31f84795e0
commit 5ec7db1987
7 changed files with 6 additions and 2613 deletions

File diff suppressed because it is too large Load diff

View file

@ -37,146 +37,6 @@
/* ==================================== */ /* ==================================== */
/* String Table Population */ /* String Table Population */
#if EXI_DEBUG == EXI_DEBUG_ON
/* localName entries for URI id = 0 */
char * localNames0[] = {
"Algorithm", "Encoding", "Id", "MimeType", "Name",
"Target", "Type", "URI", "ValueType"
};
/* localName entries for URI id = 1 */
char * localNames1[] = {
"base", "id", "lang", "space"
};
/* localName entries for URI id = 2 */
char * localNames2[] = {
"nil", "type"
};
/* localName entries for URI id = 3 */
char * localNames3[] = {
"ENTITIES", "ENTITY", "ID", "IDREF", "IDREFS",
"NCName", "NMTOKEN", "NMTOKENS", "NOTATION", "Name",
"QName", "anySimpleType", "anyType", "anyURI", "base64Binary",
"boolean", "byte", "date", "dateTime", "decimal",
"double", "duration", "float", "gDay", "gMonth",
"gMonthDay", "gYear", "gYearMonth", "hexBinary", "int",
"integer", "language", "long", "negativeInteger", "nonNegativeInteger",
"nonPositiveInteger", "normalizedString", "positiveInteger", "short", "string",
"time", "token", "unsignedByte", "unsignedInt", "unsignedLong",
"unsignedShort"
};
/* localName entries for URI id = 4 */
char * localNames4[] = {
"CanonicalizationMethod", "CanonicalizationMethodType", "CryptoBinary", "DSAKeyValue", "DSAKeyValueType",
"DigestMethod", "DigestMethodType", "DigestValue", "DigestValueType", "Exponent",
"G", "HMACOutputLength", "HMACOutputLengthType", "J", "KeyInfo",
"KeyInfoType", "KeyName", "KeyValue", "KeyValueType", "Manifest",
"ManifestType", "MgmtData", "Modulus", "Object", "ObjectType",
"P", "PGPData", "PGPDataType", "PGPKeyID", "PGPKeyPacket",
"PgenCounter", "Q", "RSAKeyValue", "RSAKeyValueType", "Reference",
"ReferenceType", "RetrievalMethod", "RetrievalMethodType", "SPKIData", "SPKIDataType",
"SPKISexp", "Seed", "Signature", "SignatureMethod", "SignatureMethodType",
"SignatureProperties", "SignaturePropertiesType", "SignatureProperty", "SignaturePropertyType", "SignatureType",
"SignatureValue", "SignatureValueType", "SignedInfo", "SignedInfoType", "Transform",
"TransformType", "Transforms", "TransformsType", "X509CRL", "X509Certificate",
"X509Data", "X509DataType", "X509IssuerName", "X509IssuerSerial", "X509IssuerSerialType",
"X509SKI", "X509SerialNumber", "X509SubjectName", "XPath", "Y"
};
/* localName entries for URI id = 5 */
char * localNames5[] = {
"AC_EVSEStatus", "BulkChargingComplete", "CableCheckReq", "CableCheckReqType", "CableCheckRes",
"CableCheckResType", "CertificateInstallationReq", "CertificateInstallationReqType", "CertificateInstallationRes", "CertificateInstallationResType",
"CertificateUpdateReq", "CertificateUpdateReqType", "CertificateUpdateRes", "CertificateUpdateResType", "ChargeParameterDiscoveryReq",
"ChargeParameterDiscoveryReqType", "ChargeParameterDiscoveryRes", "ChargeParameterDiscoveryResType", "ChargeService", "ChargingComplete",
"ChargingProfile", "ChargingStatusReq", "ChargingStatusReqType", "ChargingStatusRes", "ChargingStatusResType",
"ContractAuthenticationReq", "ContractAuthenticationReqType", "ContractAuthenticationRes", "ContractAuthenticationResType", "ContractEncryptionEncryptedPrivateKey",
"ContractID", "ContractSignatureCertChain", "ContractSignatureEncryptedPrivateKey", "CurrentDemandReq", "CurrentDemandReqType",
"CurrentDemandRes", "CurrentDemandResType", "DC_EVSEStatus", "DC_EVStatus", "DHParams",
"DateTimeNow", "EVCCID", "EVMaximumCurrentLimit", "EVMaximumPowerLimit", "EVMaximumVoltageLimit",
"EVRequestedEnergyTransferType", "EVSECurrentLimitAchieved", "EVSEID", "EVSEMaxCurrent", "EVSEMaximumCurrentLimit",
"EVSEMaximumPowerLimit", "EVSEMaximumVoltageLimit", "EVSEPowerLimitAchieved", "EVSEPresentCurrent", "EVSEPresentVoltage",
"EVSEVoltageLimitAchieved", "EVTargetCurrent", "EVTargetVoltage", "GenChallenge", "ListOfRootCertificateIDs",
"MeterInfo", "MeteringReceiptReq", "MeteringReceiptReqType", "MeteringReceiptRes", "MeteringReceiptResType",
"OEMProvisioningCert", "PaymentDetailsReq", "PaymentDetailsReqType", "PaymentDetailsRes", "PaymentDetailsResType",
"PaymentOptions", "PowerDeliveryReq", "PowerDeliveryReqType", "PowerDeliveryRes", "PowerDeliveryResType",
"PreChargeReq", "PreChargeReqType", "PreChargeRes", "PreChargeResType", "ReadyToChargeState",
"ReceiptRequired", "RemainingTimeToBulkSoC", "RemainingTimeToFullSoC", "ResponseCode", "RetryCounter",
"SAScheduleTupleID", "SelectedPaymentOption", "SelectedServiceList", "ServiceCategory", "ServiceDetailReq",
"ServiceDetailReqType", "ServiceDetailRes", "ServiceDetailResType", "ServiceDiscoveryReq", "ServiceDiscoveryReqType",
"ServiceDiscoveryRes", "ServiceDiscoveryResType", "ServiceID", "ServiceList", "ServiceParameterList",
"ServicePaymentSelectionReq", "ServicePaymentSelectionReqType", "ServicePaymentSelectionRes", "ServicePaymentSelectionResType", "ServiceScope",
"SessionID", "SessionSetupReq", "SessionSetupReqType", "SessionSetupRes", "SessionSetupResType",
"SessionStopReq", "SessionStopRes", "SessionStopResType", "SessionStopType", "WeldingDetectionReq",
"WeldingDetectionReqType", "WeldingDetectionRes", "WeldingDetectionResType"
};
/* localName entries for URI id = 6 */
char * localNames6[] = {
"AC_EVChargeParameter", "AC_EVChargeParameterType", "AC_EVSEChargeParameter", "AC_EVSEChargeParameterType", "AC_EVSEStatus",
"AC_EVSEStatusType", "BulkChargingComplete", "BulkSOC", "Certificate", "CertificateChainType",
"ChargingComplete", "ChargingProfileEntryMaxPower", "ChargingProfileEntryStart", "ChargingProfileType", "ConsumptionCost",
"ConsumptionCostType", "Cost", "CostType", "DC_EVChargeParameter", "DC_EVChargeParameterType",
"DC_EVErrorCodeType", "DC_EVPowerDeliveryParameter", "DC_EVPowerDeliveryParameterType", "DC_EVSEChargeParameter", "DC_EVSEChargeParameterType",
"DC_EVSEStatus", "DC_EVSEStatusCodeType", "DC_EVSEStatusType", "DC_EVStatus", "DC_EVStatusType",
"DepartureTime", "EAmount", "EPriceLevel", "EVCabinConditioning", "EVChargeParameter",
"EVChargeParameterType", "EVEnergyCapacity", "EVEnergyRequest", "EVErrorCode", "EVMaxCurrent",
"EVMaxVoltage", "EVMaximumCurrentLimit", "EVMaximumPowerLimit", "EVMaximumVoltageLimit", "EVMinCurrent",
"EVPowerDeliveryParameter", "EVPowerDeliveryParameterType", "EVRESSConditioning", "EVRESSSOC", "EVReady",
"EVRequestedEnergyTransferType", "EVSEChargeParameter", "EVSEChargeParameterType", "EVSECurrentRegulationTolerance", "EVSEEnergyToBeDelivered",
"EVSEIsolationStatus", "EVSEMaxCurrent", "EVSEMaxVoltage", "EVSEMaximumCurrentLimit", "EVSEMaximumPowerLimit",
"EVSEMaximumVoltageLimit", "EVSEMinCurrent", "EVSEMinimumCurrentLimit", "EVSEMinimumVoltageLimit", "EVSEPeakCurrentRipple",
"EVSEStatus", "EVSEStatusCode", "EVSEStatusType", "EVSESupportedEnergyTransferType", "EVStatus",
"EVStatusType", "EnergyTransferType", "Entry", "EntryType", "FaultCode",
"FaultMsg", "FreeService", "FullSOC", "IntervalType", "ListOfRootCertificateIDsType",
"MeterID", "MeterInfoType", "MeterReading", "MeterStatus", "Multiplier",
"NotificationType", "NumEPriceLevels", "PMax", "PMaxSchedule", "PMaxScheduleEntry",
"PMaxScheduleEntryType", "PMaxScheduleID", "PMaxScheduleType", "PMaxType", "Parameter",
"ParameterSet", "ParameterSetID", "ParameterSetType", "ParameterType", "PaymentOption",
"PaymentOptionsType", "PhysicalValueType", "PowerSwitchClosed", "ProfileEntry", "ProfileEntryType",
"RCD", "RelativeTimeInterval", "RelativeTimeIntervalType", "RootCertificateID", "SAIDType",
"SAScheduleList", "SAScheduleListType", "SAScheduleTuple", "SAScheduleTupleID", "SAScheduleTupleType",
"SASchedules", "SASchedulesType", "SalesTariff", "SalesTariffDescription", "SalesTariffEntry",
"SalesTariffEntryType", "SalesTariffID", "SalesTariffType", "SelectedService", "SelectedServiceListType",
"SelectedServiceType", "Service", "ServiceCategory", "ServiceCharge", "ServiceChargeType",
"ServiceID", "ServiceName", "ServiceParameterListType", "ServiceScope", "ServiceTag",
"ServiceTagListType", "ServiceTagType", "ServiceType", "ShutDownTime", "SigMeterReading",
"StopCharging", "SubCertificates", "SubCertificatesType", "TMeter", "TimeInterval",
"Unit", "Value", "amount", "amountMultiplier", "boolValue",
"byteValue", "certificateType", "contractIDType", "costKind", "costKindType",
"dHParamsType", "duration", "evccIDType", "evseIDType", "faultCodeType",
"faultMsgType", "genChallengeType", "intValue", "isolationLevelType", "meterIDType",
"meterStatusType", "paymentOptionType", "percentValueType", "physicalValue", "privateKeyType",
"responseCodeType", "rootCertificateIDType", "serviceCategoryType", "serviceIDType", "serviceNameType",
"serviceScopeType", "sessionIDType", "shortValue", "sigMeterReadingType", "start",
"startValue", "stringValue", "tariffDescriptionType", "unitMultiplierType", "unitSymbolType",
"valueType"
};
/* localName entries for URI id = 7 */
char * localNames7[] = {
"Body", "BodyBaseType", "BodyElement", "BodyType", "Header",
"V2G_Message"
};
/* localName entries for URI id = 8 */
char * localNames8[] = {
"MessageHeaderType", "Notification", "SessionID"
};
char * uris[] = {
"", "http://www.w3.org/XML/1998/namespace", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/2000/09/xmldsig#", "urn:iso:15118:2:2010:MsgBody", "urn:iso:15118:2:2010:MsgDataTypes", "urn:iso:15118:2:2010:MsgDef", "urn:iso:15118:2:2010:MsgHeader"
};
#endif /*EXI_DEBUG*/
#if EXI_DEBUG == EXI_DEBUG_ON
struct exiNamePartition localNamePartitions[9] = {
{ 9, localNames0 },
{ 4, localNames1 },
{ 2, localNames2 },
{ 46, localNames3 },
{ 70, localNames4 },
{ 118, localNames5 },
{ 186, localNames6 },
{ 6, localNames7 },
{ 3, localNames8 }
};
#endif /*EXI_DEBUG*/
#if EXI_DEBUG == EXI_DEBUG_OFF #if EXI_DEBUG == EXI_DEBUG_OFF
static struct exiNamePartition localNamePartitions[9] = { static struct exiNamePartition localNamePartitions[9] = {
@ -192,10 +52,6 @@ static struct exiNamePartition localNamePartitions[9] = {
}; };
#endif /*EXI_DEBUG*/ #endif /*EXI_DEBUG*/
#if EXI_DEBUG == EXI_DEBUG_ON
exi_name_table_prepopulated_t exiNameTablePrepopulated = { 9, uris, localNamePartitions };
#endif /*EXI_DEBUG*/
#if EXI_DEBUG == EXI_DEBUG_OFF #if EXI_DEBUG == EXI_DEBUG_OFF
exi_name_table_prepopulated_t exiNameTablePrepopulated = { 9, localNamePartitions }; exi_name_table_prepopulated_t exiNameTablePrepopulated = { 9, localNamePartitions };
#endif /*EXI_DEBUG*/ #endif /*EXI_DEBUG*/

View file

@ -35,129 +35,11 @@
#include "StringTable.h" #include "StringTable.h"
#include "NameTableEntries.h" #include "NameTableEntries.h"
#if EXI_DEBUG == EXI_DEBUG_ON
int exiGetUri(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t uriID,
const char** uri) {
if (uriID < prepopulatedTable->len) {
*uri = prepopulatedTable->uris[uriID];
} else {
int i = 0;
uriID -= prepopulatedTable->len;
for(i=0; i<(runtimeTable->addedUriEntries+runtimeTable->addedLocalNameEntries); i++) {
if ( runtimeTable->namePartitionsEntries[i].namePartitionType == URI_PARTITION ) {
if (uriID == 0) {
*uri = runtimeTable->namePartitionsEntries[i].entry.uriPartition.uri;
return 0;
}
uriID--;
}
}
return EXI_ERROR_OUT_OF_BOUNDS;
}
return 0;
}
/* 0 ... Success, 1 ... Miss, -1 ... Error */
int exiGetUriID(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, const char* uri,
uint16_t* uriID) {
unsigned int i;
for (i = 0; i < prepopulatedTable->len; i++) {
if (strcmp(uri, prepopulatedTable->uris[i]) == 0) {
*uriID = i;
return 0;
}
}
if (runtimeTable->addedUriEntries > 0) {
*uriID = prepopulatedTable->len - 1;
for(i=0; i< (runtimeTable->addedUriEntries + runtimeTable->addedLocalNameEntries); i++) {
if ( runtimeTable->namePartitionsEntries[i].namePartitionType == URI_PARTITION ) {
*uriID = *uriID + 1;
if (strcmp(uri, runtimeTable->namePartitionsEntries[i].entry.uriPartition.uri) == 0) {
return 0;
}
}
}
}
/* no URI ID found */
return +1;
}
#endif /*EXI_DEBUG*/
int exiGetUriSize(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t* uriLength) { int exiGetUriSize(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t* uriLength) {
*uriLength = prepopulatedTable->len; *uriLength = prepopulatedTable->len;
return 0; return 0;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
int exiGetLocalName(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t uriID,
uint16_t localNameID, const char** localName) {
int i;
if (uriID < prepopulatedTable->len) {
if (localNameID < prepopulatedTable->localNames[uriID].len) {
*localName = prepopulatedTable->localNames[uriID].names[localNameID];
return 0;
} else {
localNameID -= prepopulatedTable->localNames[uriID].len;
}
}
/* runtime tables */
for(i=0; i<(runtimeTable->addedLocalNameEntries+runtimeTable->addedUriEntries); i++) {
if ( runtimeTable->namePartitionsEntries[i].namePartitionType == LOCALNAME_PARTITION &&
runtimeTable->namePartitionsEntries[i].entry.localNamePartition.uriID == uriID ) {
if (localNameID == 0) {
*localName = runtimeTable->namePartitionsEntries[i].entry.localNamePartition.localName;
return 0;
}
localNameID--;
}
}
return EXI_ERROR_OUT_OF_BOUNDS;
}
/* 0 ... Success, 1 ... Miss, -1 ... Error */
int exiGetLocalNameID(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t uriID,
const char* localName, uint16_t* localNameID) {
unsigned int i;
if (uriID < prepopulatedTable->len) {
/* pre-populated names */
/* TODO binary search */
for (i = 0; i < prepopulatedTable->localNames[uriID].len; i++) {
if (strcmp(localName, prepopulatedTable->localNames[uriID].names[i]) == 0) {
*localNameID = i;
return 0;
}
}
/* runtime names */
for (i = 0; i < (runtimeTable->addedUriEntries + runtimeTable->addedLocalNameEntries); i++) {
if (runtimeTable->namePartitionsEntries[i].namePartitionType == LOCALNAME_PARTITION &&
strcmp(localName, runtimeTable->namePartitionsEntries[i].entry.localNamePartition.localName ) == 0) {
*localNameID = runtimeTable->namePartitionsEntries[i].entry.localNamePartition.localNameID;
return 0;
}
}
/* no localName ID found */
return +1;
} else if (uriID == prepopulatedTable->len) {
/* UCD profile */
/* no localName ID found */
return +1;
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}
}
#endif /*EXI_DEBUG*/
int exiGetLocalNameSize(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, int exiGetLocalNameSize(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable,
uint16_t uriID, uint16_t* localNameLength) { uint16_t uriID, uint16_t* localNameLength) {
*localNameLength = 0; *localNameLength = 0;

View file

@ -36,20 +36,9 @@ extern "C" {
#include "EXITypes.h" #include "EXITypes.h"
#if EXI_DEBUG == EXI_DEBUG_ON
int exiGetUri(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t uriID, const char** uri);
/* 0 ... Success, 1 ... Miss, -1 ... Error */
int exiGetUriID(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, const char* uri, uint16_t* uriID);
#endif /*EXI_DEBUG*/
int exiGetUriSize(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t* uriLength); int exiGetUriSize(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t* uriLength);
#if EXI_DEBUG == EXI_DEBUG_ON
int exiGetLocalName(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t uriID, uint16_t localNameID, const char** localName);
/* 0 ... Success, 1 ... Miss, -1 ... Error */
int exiGetLocalNameID(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t uriID, const char* localName, uint16_t* localNameID);
#endif /*EXI_DEBUG*/
int exiGetLocalNameSize(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t uriID, uint16_t* localNameLength); int exiGetLocalNameSize(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t uriID, uint16_t* localNameLength);
/* inits counter et cetera */ /* inits counter et cetera */

View file

@ -249,53 +249,6 @@ static int _exiEncodeNamespaceUriID(bitstream_t* stream, exi_name_table_prepopul
} }
#if EXI_DEBUG == EXI_DEBUG_ON
static int _exiEncodeNamespaceUri(bitstream_t* stream, exi_name_table_prepopulated_t* nameTable, exi_name_table_runtime_t* runtimeTable,
char** uri, uint16_t* uriID) {
int errn;
uint16_t uriCodingLength;
uint16_t uriSize;
errn = exiGetUriSize(nameTable, runtimeTable, &uriSize);
if (errn) {
return errn;
}
/* URI Entries + 1 */
errn = exiGetCodingLength(uriSize + 1, &uriCodingLength);
if (errn) {
return errn;
}
errn = exiGetUriID(nameTable, runtimeTable, *uri, uriID);
if (errn < 0) {
return errn;
} else if (errn == 1) {
/* uri string value was not found */
/* ==> zero (0) as an n-nit unsigned integer */
/* followed by uri encoded as string */
errn = encodeNBitUnsignedInteger(stream, uriCodingLength, 0);
if (errn) {
return errn;
}
/* ASCII String */
errn = encodeASCII(stream, *uri);
if (errn) {
return errn;
}
/* after encoding string value is added to table */
/* in UCD Profile NOT */
*uriID = uriSize;
} else {
/* uri string value found */
/* ==> value(i+1) is encoded as n-bit unsigned integer */
errn = encodeNBitUnsignedInteger(stream, uriCodingLength, *uriID + 1);
}
return errn;
}
#endif /*EXI_DEBUG*/
static int _exiEncodeLocalNameID(bitstream_t* stream, exi_name_table_prepopulated_t* nameTable, exi_name_table_runtime_t* runtimeTable, static int _exiEncodeLocalNameID(bitstream_t* stream, exi_name_table_prepopulated_t* nameTable, exi_name_table_runtime_t* runtimeTable,
uint16_t uriID, uint16_t localNameID) { uint16_t uriID, uint16_t localNameID) {
int errn; int errn;
@ -325,76 +278,6 @@ static int _exiEncodeLocalNameID(bitstream_t* stream, exi_name_table_prepopulate
} }
#if EXI_DEBUG == EXI_DEBUG_ON
static int _exiEncodeLocalName(bitstream_t* stream, exi_name_table_prepopulated_t* nameTable, exi_name_table_runtime_t* runtimeTable,
char** localName,
uint16_t uriID) {
int errn;
uint16_t localNameID;
uint16_t localNameSize;
uint16_t localNameCodingLength;
uint32_t slen;
/* look for localNameID */
errn = exiGetLocalNameID(nameTable, runtimeTable, uriID, *localName, &localNameID);
if (errn < 0) {
return errn;
}
if (errn == 1) {
/* string value was not found in local partition */
/* ==> string literal is encoded as a String */
/* with the length of the string incremented by one */
slen = (uint32_t)strlen(*localName);
errn = encodeUnsignedInteger32(stream, slen + 1 );
if (errn >= 0) {
errn = encodeASCIICharacters(stream, *localName, slen);
}
} else {
/* string value found in local partition */
/* ==> string value is represented as zero (0) encoded as an */
errn = encodeUnsignedInteger32(stream, 0 );
if (errn < 0) {
return errn;
}
/* Unsigned Integer followed by an the compact identifier of the */
/* string value as an n-bit unsigned integer n is log2 m and m is */
/* the number of entries in the string table partition */
errn = exiGetLocalNameSize(nameTable, runtimeTable, uriID, &localNameSize);
if (errn < 0) {
return errn;
}
errn = exiGetCodingLength(localNameSize, &localNameCodingLength);
if (errn) {
return errn;
}
errn = encodeNBitUnsignedInteger(stream, localNameCodingLength, localNameID);
}
return errn;
}
#endif /*EXI_DEBUG*/
#if EXI_DEBUG == EXI_DEBUG_ON
static int _exiEncodeQName(bitstream_t* stream, exi_name_table_prepopulated_t* nameTable, exi_name_table_runtime_t* runtimeTable,
char** uri, char** localName) {
uint16_t uriID;
/* uri */
int errn =_exiEncodeNamespaceUri(stream, nameTable, runtimeTable, uri, &uriID);
if (errn) {
return errn;
}
/* localName */
errn = _exiEncodeLocalName(stream, nameTable, runtimeTable, localName, uriID);
if (errn) {
return errn;
}
return 0 ;
}
#endif /*EXI_DEBUG*/
static int _exiEncodeStartElement(bitstream_t* stream, uint16_t nbits, static int _exiEncodeStartElement(bitstream_t* stream, uint16_t nbits,
uint32_t val, exi_state_t* state, eqname_t* se, uint16_t stackId, uint32_t val, exi_state_t* state, eqname_t* se, uint16_t stackId,
@ -410,36 +293,6 @@ static int _exiEncodeStartElement(bitstream_t* stream, uint16_t nbits,
return exiPushStack(state, newState, se); return exiPushStack(state, newState, se);
} }
#if EXI_DEBUG == EXI_DEBUG_ON
static eqname_t eqnGeneric = {65535, 65535}; /* UNSIGNED_INT16_MAX */
static int _exiEncodeStartElementGeneric(bitstream_t* stream, uint16_t nbits,
uint32_t val, exi_state_t* state, char** uri, char** localName, uint16_t stackId,
uint16_t newState) {
uint16_t uriID;
/* event-code */
int errn = encodeNBitUnsignedInteger(stream, nbits, val);
if (errn) {
return errn;
}
/* qualified name */
errn = _exiEncodeNamespaceUri(stream, &(state->nameTablePrepopulated), &(state->nameTableRuntime), uri, &uriID);
if (errn) {
return errn;
}
errn = _exiEncodeLocalName(stream, &(state->nameTablePrepopulated), &(state->nameTableRuntime), localName, uriID);
if (errn) {
return errn;
}
/* move on */
state->grammarStack[state->stackIndex] = stackId;
/* push element on stack */
return exiPushStack(state, newState, &eqnGeneric);
}
#endif /*EXI_DEBUG*/
int exiappHandEncodeStartElement(bitstream_t* stream, exi_state_t* state, eqname_t* se) { int exiappHandEncodeStartElement(bitstream_t* stream, exi_state_t* state, eqname_t* se) {
switch (state->grammarStack[state->stackIndex]) { switch (state->grammarStack[state->stackIndex]) {
case 1: case 1:
@ -703,369 +556,15 @@ int exiappHandEncodeStartElement(bitstream_t* stream, exi_state_t* state, eqname
return EXI_ERROR_UNEXPECTED_START_ELEMENT; return EXI_ERROR_UNEXPECTED_START_ELEMENT;
} }
/* Qualified Name unknown!! */
#if EXI_DEBUG == EXI_DEBUG_ON
static int exiEncodeStartElementGenericUnknown(bitstream_t* stream, exi_state_t* state,
char** uri, char** localName) {
uint16_t grammarID;
uint16_t eventCodeLength;
int errn = _exiGet1stLevelEventCode(state, START_ELEMENT_GENERIC, &grammarID);
if (errn < 0) {
return errn;
} else if (errn == 1) {
/* not found --> try undeclared SE */
errn = _exiGet1stLevelEventCode(state, START_ELEMENT_GENERIC_UNDECLARED, &grammarID);
if (errn < 0) {
return errn;
} else if (errn == 1) {
/* Should never happen except in STRICT mode */
return EXI_ERROR_UNEXPECTED_EVENT_LEVEL1;
} else {
/* found START_ELEMENT_GENERIC_UNDECLARED */
errn = _exiGetEventCodeLength(state, &eventCodeLength);
if (errn < 0) {
return errn;
} else {
/* encode event code*/
errn = encodeNBitUnsignedInteger(stream, eventCodeLength, grammarID);
if (errn) {
return errn;
}
}
}
} else {
/* found START_ELEMENT_GENERIC */
errn = _exiGetEventCodeLength(state, &eventCodeLength);
if (errn < 0) {
return errn;
} else {
/* encode event code*/
errn = encodeNBitUnsignedInteger(stream, eventCodeLength, grammarID);
if (errn) {
return errn;
}
}
}
/* encode qualified name */
errn = _exiEncodeQName(stream, &(state->nameTablePrepopulated), &(state->nameTableRuntime), uri, localName);
if (errn) {
return errn;
}
/* learn event, not in UCD Profile */
/* move on */
/* push element on stack */
switch (state->grammarStack[state->stackIndex]) {
/* $EXI_ENCODE_START_ELEMENT_GENERIC$ */
case DOC_CONTENT:
/* move on to DocEnd */
state->grammarStack[state->stackIndex] = DOC_END;
/* push new ur-type grammar on stack */
return exiPushStack(state, UR_TYPE_GRAMMAR_0, NULL);
break;
case UR_TYPE_GRAMMAR_0:
/* move on to UR_TYPE_GRAMMAR_1 */
state->grammarStack[state->stackIndex] = UR_TYPE_GRAMMAR_1;
/* push new ur-type grammar on stack */
return exiPushStack(state, UR_TYPE_GRAMMAR_0, NULL);
break;
case UR_TYPE_GRAMMAR_1:
/* remain in UR_TYPE_GRAMMAR_1 */
/* push new ur-type grammar on stack */
return exiPushStack(state, UR_TYPE_GRAMMAR_0, NULL);
break;
default:
return EXI_ERROR_UNEXPECTED_START_ELEMENT_GENERIC;
}
return 0;
}
#endif /*EXI_DEBUG*/
/* Look first for qualified name */ /* Look first for qualified name */
int exiappHandEncodeStartElementGeneric(bitstream_t* stream, exi_state_t* state, int exiappHandEncodeStartElementGeneric(bitstream_t* stream, exi_state_t* state,
string_ascii_t* namespaceURI , string_ascii_t* localName) { string_ascii_t* namespaceURI , string_ascii_t* localName) {
int errn = -1; int errn = -1;
#if EXI_DEBUG == EXI_DEBUG_ON
eqname_t se;
/* uri */
errn = exiGetUriID(&(state->nameTablePrepopulated), &(state->nameTableRuntime), namespaceURI->chars, &se.namespaceURI);
if (errn == -1) {
return errn;
} else if (errn == 1) {
/* No URI (and localNameID) found */
exiEncodeStartElementGenericUnknown(stream, state, &(namespaceURI->chars), &(localName->chars));
} else {
/* localName */
errn = exiGetLocalNameID(&(state->nameTablePrepopulated), &(state->nameTableRuntime), se.namespaceURI, localName->chars, &se.localPart);
if (errn == -1) {
return errn;
} else if (errn == 1) {
/* No localName found, use generic StartElement(*) method */
exiEncodeStartElementGenericUnknown(stream, state, &(namespaceURI->chars), &(localName->chars));
} else {
/* Uri&LocalName found, use "efficient" StartElement method */
return exiappHandEncodeStartElement(stream, state, &se);
}
}
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
static int _exiEncodeEndElementUndeclared(bitstream_t* stream, exi_state_t* state) {
int16_t currentID = state->grammarStack[state->stackIndex];
switch (currentID) {
case 9:
/* Element[] */
/* 1st level and 2nd level event code */
encodeNBitUnsignedInteger(stream, 0, 0);
encodeNBitUnsignedInteger(stream, 2, 0);
return 0;
case 70:
/* Element[CHARACTERS[STRING]] */
case 124:
/* Element[CHARACTERS[STRING]] */
case 139:
/* Element[CHARACTERS[UNSIGNED_INTEGER]] */
case 46:
/* Element[CHARACTERS[ENUMERATION]] */
case 22:
/* Element[START_ELEMENT(ProtocolNamespace)] */
case 86:
/* Element[CHARACTERS[DATETIME]] */
case 92:
/* Element[CHARACTERS[FLOAT]] */
case 134:
/* Element[CHARACTERS[STRING]] */
case 120:
/* Element[CHARACTERS[UNSIGNED_INTEGER]] */
case 100:
/* Element[CHARACTERS[DATETIME]] */
case 54:
/* Element[CHARACTERS[STRING]] */
case 68:
/* Element[CHARACTERS[STRING]] */
case 72:
/* Element[CHARACTERS[STRING]] */
case 21:
/* Element[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
case 78:
/* Element[CHARACTERS[STRING]] */
case 141:
/* Element[CHARACTERS[UNSIGNED_INTEGER]] */
case 52:
/* Element[CHARACTERS[LIST]] */
case 102:
/* Element[CHARACTERS[DATETIME]] */
case 96:
/* Element[CHARACTERS[FLOAT]] */
case 60:
/* Element[CHARACTERS[LIST]] */
case 82:
/* Element[CHARACTERS[BOOLEAN]] */
case 88:
/* Element[CHARACTERS[DATETIME]] */
case 116:
/* Element[CHARACTERS[INTEGER]] */
case 98:
/* Element[CHARACTERS[DATETIME]] */
case 128:
/* Element[CHARACTERS[INTEGER]] */
case 13:
/* Element[CHARACTERS[UNSIGNED_INTEGER]] */
case 90:
/* Element[CHARACTERS[DECIMAL]] */
case 42:
/* Element[START_ELEMENT(AppProtocol)] */
case 143:
/* Element[CHARACTERS[STRING]] */
case 110:
/* Element[CHARACTERS[INTEGER]] */
case 66:
/* Element[CHARACTERS[LIST]] */
case 94:
/* Element[CHARACTERS[STRING]] */
case 112:
/* Element[CHARACTERS[INTEGER]] */
case 58:
/* Element[CHARACTERS[STRING]] */
case 14:
/* Element[START_ELEMENT(SchemaID)] */
case 122:
/* Element[CHARACTERS[INTEGER]] */
case 16:
/* Element[START_ELEMENT(Priority)] */
case 104:
/* Element[CHARACTERS[DATETIME]] */
case 114:
/* Element[CHARACTERS[STRING]] */
case 108:
/* Element[CHARACTERS[BINARY_HEX]] */
case 84:
/* Element[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
case 106:
/* Element[CHARACTERS[DATETIME]] */
case 11:
/* Element[START_ELEMENT(VersionNumberMinor)] */
case 74:
/* Element[CHARACTERS[STRING]] */
case 6:
/* Element[START_ELEMENT(VersionNumberMajor)] */
case 64:
/* Element[CHARACTERS[STRING]] */
case 62:
/* Element[CHARACTERS[STRING]] */
case 130:
/* Element[CHARACTERS[STRING]] */
case 126:
/* Element[CHARACTERS[UNSIGNED_INTEGER]] */
case 118:
/* Element[CHARACTERS[INTEGER]] */
case 48:
/* Element[START_ELEMENT(ResponseCode)] */
case 10:
/* Element[CHARACTERS[STRING]] */
case 136:
/* Element[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
case 80:
/* Element[CHARACTERS[BINARY_BASE64]] */
case 56:
/* Element[CHARACTERS[STRING]] */
case 132:
/* Element[CHARACTERS[DATETIME]] */
case 18:
/* Element[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
/* 1st level and 2nd level event code */
encodeNBitUnsignedInteger(stream, 1, 1);
encodeNBitUnsignedInteger(stream, 2, 0);
return 0;
case 109:
/* FirstStartTag[CHARACTERS[INTEGER]] */
case 113:
/* FirstStartTag[CHARACTERS[STRING]] */
case 12:
/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
case 140:
/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
case 57:
/* FirstStartTag[CHARACTERS[STRING]] */
case 97:
/* FirstStartTag[CHARACTERS[DATETIME]] */
case 135:
/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
case 5:
/* FirstStartTag[START_ELEMENT(ProtocolNamespace)] */
case 91:
/* FirstStartTag[CHARACTERS[FLOAT]] */
case 111:
/* FirstStartTag[CHARACTERS[INTEGER]] */
case 7:
/* FirstStartTag[CHARACTERS[STRING]] */
case 123:
/* FirstStartTag[CHARACTERS[STRING]] */
case 61:
/* FirstStartTag[CHARACTERS[STRING]] */
case 99:
/* FirstStartTag[CHARACTERS[DATETIME]] */
case 73:
/* FirstStartTag[CHARACTERS[STRING]] */
case 53:
/* FirstStartTag[CHARACTERS[STRING]] */
case 93:
/* FirstStartTag[CHARACTERS[STRING]] */
case 59:
/* FirstStartTag[CHARACTERS[LIST]] */
case 63:
/* FirstStartTag[CHARACTERS[STRING]] */
case 115:
/* FirstStartTag[CHARACTERS[INTEGER]] */
case 101:
/* FirstStartTag[CHARACTERS[DATETIME]] */
case 71:
/* FirstStartTag[CHARACTERS[STRING]] */
case 77:
/* FirstStartTag[CHARACTERS[STRING]] */
case 142:
/* FirstStartTag[CHARACTERS[STRING]] */
case 121:
/* FirstStartTag[CHARACTERS[INTEGER]] */
case 17:
/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
case 83:
/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
case 117:
/* FirstStartTag[CHARACTERS[INTEGER]] */
case 3:
/* FirstStartTag[START_ELEMENT(AppProtocol)] */
case 87:
/* FirstStartTag[CHARACTERS[DATETIME]] */
case 79:
/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
case 67:
/* FirstStartTag[CHARACTERS[STRING]] */
case 137:
/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
case 81:
/* FirstStartTag[CHARACTERS[BOOLEAN]] */
case 119:
/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
case 51:
/* FirstStartTag[CHARACTERS[LIST]] */
case 105:
/* FirstStartTag[CHARACTERS[DATETIME]] */
case 69:
/* FirstStartTag[CHARACTERS[STRING]] */
case 45:
/* FirstStartTag[CHARACTERS[ENUMERATION]] */
case 65:
/* FirstStartTag[CHARACTERS[LIST]] */
case 129:
/* FirstStartTag[CHARACTERS[STRING]] */
case 55:
/* FirstStartTag[CHARACTERS[STRING]] */
case 43:
/* FirstStartTag[START_ELEMENT(ResponseCode)] */
case 20:
/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
case 85:
/* FirstStartTag[CHARACTERS[DATETIME]] */
case 125:
/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
case 103:
/* FirstStartTag[CHARACTERS[DATETIME]] */
case 138:
/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
case 15:
/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
case 133:
/* FirstStartTag[CHARACTERS[STRING]] */
case 131:
/* FirstStartTag[CHARACTERS[DATETIME]] */
case 89:
/* FirstStartTag[CHARACTERS[DECIMAL]] */
case 107:
/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
case 127:
/* FirstStartTag[CHARACTERS[INTEGER]] */
case 95:
/* FirstStartTag[CHARACTERS[FLOAT]] */
/* 1st level and 2nd level event code */
encodeNBitUnsignedInteger(stream, 1, 1);
encodeNBitUnsignedInteger(stream, 3, 0);
return 0;
}
return EXI_ERROR_UNEXPECTED_END_ELEMENT;
}
int exiappHandEncodeEndElement(bitstream_t* stream, exi_state_t* state) { int exiappHandEncodeEndElement(bitstream_t* stream, exi_state_t* state) {
int errn = 0; int errn = 0;
@ -1135,16 +634,7 @@ int exiappHandEncodeEndElement(bitstream_t* stream, exi_state_t* state) {
break; break;
default: default:
if (currentID < 0) { return EXI_ERROR_UNEXPECTED_END_ELEMENT;
/* runtime grammars */
return -1;
} else {
errn = _exiEncodeEndElementUndeclared(stream, state);
if (errn < 0) {
return errn;
}
}
/* return EXI_ERROR_UNEXPECTED_END_ELEMENT; */
} }
if (errn < 0) { if (errn < 0) {
@ -1852,63 +1342,6 @@ int exiappHandEncodeAttribute(bitstream_t* stream, exi_state_t* state, eqname_t*
/* return EXI_ERROR_UNEXPECTED_ATTRIBUTE; */ /* return EXI_ERROR_UNEXPECTED_ATTRIBUTE; */
} }
#if EXI_DEBUG == EXI_DEBUG_ON
static int exiEncodeAttribute2(bitstream_t* stream, exi_state_t* state, qname_t* at,
exi_value_t* val) {
int errn;
eqname_t eat;
/* attribute generic undeclared */
uint16_t codeLength1, codeLength2;
uint32_t ec1, ec2;
errn = exiGetUriID(&state->nameTablePrepopulated, &state->nameTableRuntime, at->namespaceURI.chars, &eat.namespaceURI);
if (errn < 0) {
return errn;
} else if (errn > 0) {
/* uri not found*/
} else {
/* uri found, try to find localname id */
errn = exiGetLocalNameID(&state->nameTablePrepopulated, &state->nameTableRuntime, eat.namespaceURI,
at->localName.chars, &eat.localPart);
if (errn < 0) {
return errn;
} else if (errn > 0) {
/* local-name not found*/
} else {
/* found uri and local-name */
errn = exiappHandEncodeAttribute(stream, state, &eat, val);
if (errn < 0) {
return errn;
}
if (errn == 0) {
return errn;
}
}
}
/* event codes */
encodeNBitUnsignedInteger(stream, codeLength1, ec1);
encodeNBitUnsignedInteger(stream, codeLength2, ec2);
/* qname */
/*
errn = _exiEncodeQName(stream, state->nameTablePrepopulated, state->nameTableRuntime,
char** uri, char** localName);
QName qname = qnameDatatype.encodeQName(uri, localName, null, channel);
*/
/* content as string */
/*
typeEncoder.isValid(BuiltIn.DEFAULT_DATATYPE, value);
typeEncoder.writeValue(qname, channel);
*/
return -1;
}
#endif /*EXI_DEBUG*/
int exiappHandEncodeAttributeXsiNil(bitstream_t* stream, exi_state_t* state, int exiappHandEncodeAttributeXsiNil(bitstream_t* stream, exi_state_t* state,
exi_value_t* val) { exi_value_t* val) {

View file

@ -37,53 +37,6 @@
/* ==================================== */ /* ==================================== */
/* String Table Population */ /* String Table Population */
#if EXI_DEBUG == EXI_DEBUG_ON
/* localName entries for URI id = 0 */
char * localNames0[] = {
"AppProtocol", "Priority", "ProtocolNamespace", "ResponseCode", "SchemaID",
"VersionNumberMajor", "VersionNumberMinor"
};
/* localName entries for URI id = 1 */
char * localNames1[] = {
"base", "id", "lang", "space"
};
/* localName entries for URI id = 2 */
char * localNames2[] = {
"nil", "type"
};
/* localName entries for URI id = 3 */
char * localNames3[] = {
"ENTITIES", "ENTITY", "ID", "IDREF", "IDREFS",
"NCName", "NMTOKEN", "NMTOKENS", "NOTATION", "Name",
"QName", "anySimpleType", "anyType", "anyURI", "base64Binary",
"boolean", "byte", "date", "dateTime", "decimal",
"double", "duration", "float", "gDay", "gMonth",
"gMonthDay", "gYear", "gYearMonth", "hexBinary", "int",
"integer", "language", "long", "negativeInteger", "nonNegativeInteger",
"nonPositiveInteger", "normalizedString", "positiveInteger", "short", "string",
"time", "token", "unsignedByte", "unsignedInt", "unsignedLong",
"unsignedShort"
};
/* localName entries for URI id = 4 */
char * localNames4[] = {
"AppProtocolType", "idType", "priorityType", "protocolNameType", "protocolNamespaceType",
"responseCodeType", "supportedAppProtocolReq", "supportedAppProtocolRes"
};
char * uris[] = {
"", "http://www.w3.org/XML/1998/namespace", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/2001/XMLSchema", "urn:iso:15118:2:2010:AppProtocol"
};
#endif /*EXI_DEBUG*/
#if EXI_DEBUG == EXI_DEBUG_ON
static struct exiNamePartition localNamePartitions[5] = {
{ 7, localNames0 },
{ 4, localNames1 },
{ 2, localNames2 },
{ 46, localNames3 },
{ 8, localNames4 }
};
#endif /*EXI_DEBUG*/
#if EXI_DEBUG == EXI_DEBUG_OFF #if EXI_DEBUG == EXI_DEBUG_OFF
struct exiNamePartition localNamePartitions[5] = { struct exiNamePartition localNamePartitions[5] = {
{ 7 }, { 7 },
@ -94,10 +47,6 @@ struct exiNamePartition localNamePartitions[5] = {
}; };
#endif /*EXI_DEBUG*/ #endif /*EXI_DEBUG*/
#if EXI_DEBUG == EXI_DEBUG_ON
exi_name_table_prepopulated_t exiappHandNameTablePrepopulated = { 5, uris, localNamePartitions };
#endif /*EXI_DEBUG*/
#if EXI_DEBUG == EXI_DEBUG_OFF #if EXI_DEBUG == EXI_DEBUG_OFF
exi_name_table_prepopulated_t exiappHandNameTablePrepopulated = { 5, localNamePartitions }; exi_name_table_prepopulated_t exiappHandNameTablePrepopulated = { 5, localNamePartitions };
#endif /*EXI_DEBUG*/ #endif /*EXI_DEBUG*/

View file

@ -61,9 +61,6 @@ uint32_t codepoints[ARRAY_SIZE_STRINGS];
char charsNamespaceURI[ARRAY_SIZE_STRINGS_ASCII]; char charsNamespaceURI[ARRAY_SIZE_STRINGS_ASCII];
char charsLocalName[ARRAY_SIZE_STRINGS_ASCII]; char charsLocalName[ARRAY_SIZE_STRINGS_ASCII];
#if EXI_DEBUG == EXI_DEBUG_ON
static void debugValue(exi_value_t* val);
#endif /*EXI_DEBUG*/
int main_codec(int argc, char *argv[]) { int main_codec(int argc, char *argv[]) {
@ -87,10 +84,6 @@ int main_codec(int argc, char *argv[]) {
/* BINARY memory setup */ /* BINARY memory setup */
bytes_t bytes = { ARRAY_SIZE_BYTES, bytesData, 0 }; bytes_t bytes = { ARRAY_SIZE_BYTES, bytesData, 0 };
#if EXI_DEBUG == EXI_DEBUG_ON
const char * localName;
const char * namespaceURI;
#endif /*EXI_DEBUG*/
int noEndOfDocument = 1; /* true */ int noEndOfDocument = 1; /* true */
/* STRING memory setup */ /* STRING memory setup */
@ -157,24 +150,14 @@ int main_codec(int argc, char *argv[]) {
errn = exiInitNameTableRuntime(&runtimeTableEncode); errn = exiInitNameTableRuntime(&runtimeTableEncode);
exiInitEncoder(&oStream, &stateEncode, runtimeTableEncode); exiInitEncoder(&oStream, &stateEncode, runtimeTableEncode);
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[DECODE] >>> EXI >>> [ENCODE] \n");
#endif /*EXI_DEBUG*/
do { do {
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Encode-ERROR] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
errn = exiDecodeNextEvent(&iStream, &stateDecode, errn = exiDecodeNextEvent(&iStream, &stateDecode,
&event); &event);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
@ -184,14 +167,8 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeStartDocument(&iStream, errn = exiDecodeStartDocument(&iStream,
&stateDecode); &stateDecode);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-SD] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
printf(">> START_DOCUMENT \n");
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn = exiEncodeStartDocument(&oStream, errn = exiEncodeStartDocument(&oStream,
&stateEncode); &stateEncode);
@ -201,14 +178,8 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeEndDocument(&iStream, errn = exiDecodeEndDocument(&iStream,
&stateDecode); &stateDecode);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-ED] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
printf(">> END_DOCUMENT \n");
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn = exiEncodeEndDocument(&oStream, errn = exiEncodeEndDocument(&oStream,
&stateEncode); &stateEncode);
@ -220,19 +191,8 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeStartElement(&iStream, errn = exiDecodeStartElement(&iStream,
&stateDecode, &eqn); &stateDecode, &eqn);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-SE] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
exiGetLocalName(&(stateDecode.nameTablePrepopulated),
&(stateDecode.nameTableRuntime), eqn.namespaceURI,
eqn.localPart, &localName);
exiGetUri(&(stateDecode.nameTablePrepopulated),
&(stateDecode.nameTableRuntime), eqn.namespaceURI,
&namespaceURI);
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn = exiEncodeStartElement(&oStream, errn = exiEncodeStartElement(&oStream,
&stateEncode, &eqn); &stateEncode, &eqn);
@ -242,15 +202,8 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeStartElementGeneric(&iStream, errn = exiDecodeStartElementGeneric(&iStream,
&stateDecode, &qn); &stateDecode, &qn);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-SEgen] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
printf(">> SE_Gen {%s}%s \n", stringNamespaceURI.chars,
stringLocalName.chars);
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn = exiEncodeStartElementGeneric(&oStream, errn = exiEncodeStartElementGeneric(&oStream,
&stateEncode, &stringNamespaceURI, &stringLocalName); &stateEncode, &stringNamespaceURI, &stringLocalName);
@ -260,14 +213,8 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeEndElement(&iStream, errn = exiDecodeEndElement(&iStream,
&stateDecode, &eqn); &stateDecode, &eqn);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-EE] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
printf("<< EE \n");
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn errn
= exiEncodeEndElement(&oStream, = exiEncodeEndElement(&oStream,
@ -278,14 +225,8 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeEndElementUndeclared(&iStream, errn = exiDecodeEndElementUndeclared(&iStream,
&stateDecode, &eqn); &stateDecode, &eqn);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-EE-Undecl] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
printf("<< EEundecl \n");
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn errn
= exiEncodeEndElement(&oStream, = exiEncodeEndElement(&oStream,
@ -296,14 +237,8 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeCharacters(&iStream, errn = exiDecodeCharacters(&iStream,
&stateDecode, &val); &stateDecode, &val);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-CH] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
debugValue(&val);
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn = exiEncodeCharacters(&oStream, errn = exiEncodeCharacters(&oStream,
&stateEncode, &val); &stateEncode, &val);
@ -313,14 +248,8 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeCharactersGeneric(&iStream, errn = exiDecodeCharactersGeneric(&iStream,
&stateDecode, &val); &stateDecode, &val);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-CHgen] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
debugValue(&val);
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn = exiEncodeCharacters(&oStream, errn = exiEncodeCharacters(&oStream,
&stateEncode, &val); &stateEncode, &val);
@ -330,14 +259,8 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeCharactersGenericUndeclared( errn = exiDecodeCharactersGenericUndeclared(
&iStream, &stateDecode, &val); &iStream, &stateDecode, &val);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-CHgenUndecl] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
debugValue(&val);
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn = exiEncodeCharacters(&oStream, errn = exiEncodeCharacters(&oStream,
&stateEncode, &val); &stateEncode, &val);
@ -347,21 +270,8 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeAttribute(&iStream, &stateDecode, errn = exiDecodeAttribute(&iStream, &stateDecode,
&eqn, &val); &eqn, &val);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-AT] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
exiGetLocalName(&(stateDecode.nameTablePrepopulated),
&(stateDecode.nameTableRuntime), eqn.namespaceURI,
eqn.localPart, &localName);
exiGetUri(&(stateDecode.nameTablePrepopulated),
&(stateDecode.nameTableRuntime), eqn.namespaceURI,
&namespaceURI);
printf(" AT {%s}%s \n", namespaceURI, localName);
debugValue(&val);
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn = exiEncodeAttribute(&oStream, &stateEncode, errn = exiEncodeAttribute(&oStream, &stateEncode,
&eqn, &val); &eqn, &val);
@ -371,14 +281,8 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeAttributeXsiNil(&iStream, errn = exiDecodeAttributeXsiNil(&iStream,
&stateDecode, &val); &stateDecode, &val);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-AT-NIL] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
printf(" AT {xsi}nil == %i \n", val.boolean);
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn = exiEncodeAttributeXsiNil(&oStream, errn = exiEncodeAttributeXsiNil(&oStream,
&stateEncode, &val); &stateEncode, &val);
@ -388,20 +292,8 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeAttributeXsiType(&iStream, errn = exiDecodeAttributeXsiType(&iStream,
&stateDecode, &val); &stateDecode, &val);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-AT-TYPE] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
exiGetLocalName(&(stateDecode.nameTablePrepopulated),
&(stateDecode.nameTableRuntime), val.eqname.namespaceURI,
val.eqname.localPart, &localName);
exiGetUri(&(stateDecode.nameTablePrepopulated),
&(stateDecode.nameTableRuntime), val.eqname.namespaceURI,
&namespaceURI);
printf(" AT {type}type == {%s}%s \n", namespaceURI, localName);
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn = exiEncodeAttributeXsiType(&oStream, errn = exiEncodeAttributeXsiType(&oStream,
&stateEncode, &val); &stateEncode, &val);
@ -411,26 +303,14 @@ int main_codec(int argc, char *argv[]) {
errn = exiDecodeAttributeGenericUndeclared( errn = exiDecodeAttributeGenericUndeclared(
&iStream, &stateDecode, &qn, &val); &iStream, &stateDecode, &qn, &val);
if (errn < 0) { if (errn < 0) {
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Decode-ERROR-ATgenUnd] %d \n", errn);
#endif /*EXI_DEBUG*/
return errn; return errn;
} }
#if EXI_DEBUG == EXI_DEBUG_ON
/* exiGetLocalName(&(stateDecode.nameTablePrepopulated), &(stateDecode.nameTableRuntime), eqn.namespaceURI, eqn.localPart, &localName);
exiGetUri(&(stateDecode.nameTablePrepopulated), &(stateDecode.nameTableRuntime), eqn.namespaceURI, &namespaceURI); */
printf(" AT {%s}%s \n", qn.namespaceURI.chars, qn.localName.chars);
debugValue(&val);
#endif /*EXI_DEBUG*/
/* encode */ /* encode */
errn = exiEncodeAttribute(&oStream, &stateEncode, errn = exiEncodeAttribute(&oStream, &stateEncode,
&eqn, &val); &eqn, &val);
break; break;
default: default:
/* ERROR */ /* ERROR */
#if EXI_DEBUG == EXI_DEBUG_ON
printf("[Unknown-Event] %d \n", event);
#endif /*EXI_DEBUG*/
return EXI_ERROR_UNKOWN_EVENT; return EXI_ERROR_UNKOWN_EVENT;
} }
@ -448,98 +328,3 @@ int main_codec(int argc, char *argv[]) {
return 0; return 0;
} }
static int _setInt32Value(integer_t* iv, int32_t* int32) {
int errn = 0;
switch (iv->type) {
/* Unsigned Integer */
case UNSIGNED_INTEGER_8:
*int32 = iv->val.uint8;
break;
case UNSIGNED_INTEGER_16:
*int32 = iv->val.uint16;
break;
case UNSIGNED_INTEGER_32:
if (iv->val.uint32 <= 2147483647) {
*int32 = iv->val.uint32;
} else {
errn = EXI_UNSUPPORTED_INTEGER_VALUE;
}
break;
case UNSIGNED_INTEGER_64:
errn = EXI_UNSUPPORTED_INTEGER_VALUE;
break;
/* (Signed) Integer */
case INTEGER_8:
*int32 = iv->val.int8;
break;
case INTEGER_16:
*int32 = iv->val.int16;
break;
case INTEGER_32:
*int32 = iv->val.int32;
break;
case INTEGER_64:
errn = EXI_UNSUPPORTED_INTEGER_VALUE;
}
return errn;
}
#if EXI_DEBUG == EXI_DEBUG_ON
static void debugValue(exi_value_t* val) {
int i;
switch (val->type) {
case INTEGER:
switch (val->integer.type) {
/* Unsigned Integer */
case UNSIGNED_INTEGER_8:
printf(" Value uint8 : %d \n", val->integer.val.uint8);
break;
case UNSIGNED_INTEGER_16:
printf(" Value uint16 : %d \n", val->integer.val.uint16);
break;
case UNSIGNED_INTEGER_32:
printf(" Value uint32 : %d \n", val->integer.val.uint32);
break;
case UNSIGNED_INTEGER_64:
printf(" Value uint64 : %ld \n",
(long unsigned int) val->integer.val.uint64);
break;
/* (Signed) Integer */
case INTEGER_8:
printf(" Value int8 : %d \n", val->integer.val.int8);
break;
case INTEGER_16:
printf(" Value int16 : %d \n", val->integer.val.int16);
break;
case INTEGER_32:
printf(" Value int32 : %d \n", val->integer.val.int32);
break;
case INTEGER_64:
printf(" Value int64 : %ld \n", (long int) val->integer.val.int64);
break;
}
break;
case BINARY_BASE64:
case BINARY_HEX:
printf(" Value Binary (len == %d) : ", val->binary.len);
for (i = 0; i < val->binary.len; i++) {
printf(" [%d]", val->binary.data[i]);
}
printf("\n");
break;
case BOOLEAN:
printf(" Value Boolean : %d \n", val->boolean);
break;
case STRING:
printf(" Value String (len==%d) : '", val->string.len);
for (i = 0; i < val->string.len; i++) {
printf("%c", (char) val->string.codepoints[i]);
}
printf("'\n");
break;
default:
printf(" Value ?? \n");
}
}
#endif /*EXI_DEBUG*/