* eliminates remaining -ansic -pedantic warnings

* project settings set to report -pedantic warnings 

git-svn-id: https://svn.code.sf.net/p/openv2g/code/trunk@4 d9f2db14-54d0-4bde-b00c-16405c910529
This commit is contained in:
daniel_peintner 2010-09-28 07:46:44 +00:00
parent 8f499da64a
commit e42f201089
13 changed files with 1262 additions and 12504 deletions

View file

@ -30,11 +30,13 @@
<tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug.113647340" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.exe.debug">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.mingw.exe.debug.option.optimization.level.1898653479" name="Optimization Level" superClass="gnu.c.compiler.mingw.exe.debug.option.optimization.level" valueType="enumerated"/>
<option id="gnu.c.compiler.mingw.exe.debug.option.debugging.level.294845555" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.773068816" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<option id="gnu.c.compiler.option.include.paths.773068816" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/codec}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/service}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/OpenV2G/src/test}&quot;"/>
</option>
<option id="gnu.c.compiler.option.warnings.pedantic.1676854851" superClass="gnu.c.compiler.option.warnings.pedantic" value="true" valueType="boolean"/>
<option id="gnu.c.compiler.option.misc.ansi.722225100" superClass="gnu.c.compiler.option.misc.ansi" value="true" valueType="boolean"/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.67299528" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug.867726048" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.exe.debug">

View file

@ -1 +1 @@
<EFBFBD>˜A<EFBFBD>™¡©±ºcF€
<EFBFBD>˜A<EFBFBD>™¡©±ºc<EFBFBD>

View file

@ -110,6 +110,7 @@ int decodeUnsignedInteger64(bitstream_t* stream, uint64_t* uint64) {
*/
int decodeInteger32(bitstream_t* stream, int32_t* int32) {
int b;
uint32_t uint32;
int errn = decodeBoolean(stream, &b);
if (errn < 0) {
@ -119,13 +120,15 @@ int decodeInteger32(bitstream_t* stream, int32_t* int32) {
if (b) {
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
errn = decodeUnsignedInteger32(stream, int32);
*int32 = -(*int32 + 1);
return errn;
errn = decodeUnsignedInteger32(stream, &uint32);
*int32 = -(uint32 + 1);
} else {
/* positive */
return decodeUnsignedInteger32(stream, int32);
errn = decodeUnsignedInteger32(stream, &uint32);
*int32 = (int32_t)(uint32);
}
return errn;
}
/**
@ -136,6 +139,7 @@ int decodeInteger32(bitstream_t* stream, int32_t* int32) {
*/
int decodeInteger64(bitstream_t* stream, int64_t* int64) {
int b;
uint64_t uint64;
int errn = decodeBoolean(stream, &b);
if (errn < 0) {
@ -145,13 +149,15 @@ int decodeInteger64(bitstream_t* stream, int64_t* int64) {
if (b) {
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
errn = decodeUnsignedInteger64(stream, int64);
*int64 = -(*int64 + 1);
return errn;
errn = decodeUnsignedInteger64(stream, &uint64);
*int64 = -(uint64 + 1);
} else {
/* positive */
return decodeUnsignedInteger64(stream, int64);
errn = decodeUnsignedInteger64(stream, &uint64);
*int64 = (int64_t)(uint64);
}
return errn;
}
/**

View file

@ -38,14 +38,11 @@
int toBitstream(const char * filename, bitstream_t* bitstream) {
FILE* f;
// bitstream_t* bitstream;
int character;
size_t len = 0, pos = 0, i;
f = fopen(filename, "rb");
// bitstream = malloc(sizeof(bitstream_t));
if (f == NULL) {
printf("\n[Error] no valid file handle !\n");
return -1;

View file

@ -49,7 +49,7 @@
int exiPushStack(exi_state_t* state, size_t newState, eqname_t* eqn) {
if ((state->stackIndex + 1) < EXI_ELEMENT_STACK_SIZE) {
state->grammarStack[++state->stackIndex] = newState;
// copy qname
/* copy qname */
state->elementStack[state->stackIndex].localPart = eqn->localPart;
state->elementStack[state->stackIndex].namespaceURI = eqn->namespaceURI;
return 0;

View file

@ -37,7 +37,7 @@ extern "C" {
#include "EXITypes.h"
// size_t exiGetCurrentState(struct exiState* state);
/* size_t exiGetCurrentState(struct exiState* state); */
int exiPushStack(exi_state_t* state, size_t newState, eqname_t* eqn);

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -74,15 +74,6 @@ typedef struct {
size_t len;
} string_ucs_t;
/* ASCII strings */
typedef struct {
size_t size;
char* ascii;
/* current length == number of characters, (len <= size) */
size_t len;
} string_ascii_t;
typedef struct {
/* range of the mantissa is -(2^63) to 2^63-1 */
int64_t mantissa;
@ -161,23 +152,22 @@ typedef struct {
typedef struct {
/* union of base types */
union {
int boolean;
int8_t int8;
uint8_t uint8;
uint32_t uint32;
int32_t int32;
int64_t int64;
uint8_t enumeration;
};
/* Bytes, Strings and Lists are not base types */
/* type of value */
exi_datatype_t type;
/* base types */
int boolean;
int8_t int8;
uint8_t uint8;
uint32_t uint32;
int32_t int32;
int64_t int64;
uint8_t enumeration;
/* Bytes, Strings and Lists are not native types anymore */
bytes_t binary;
string_ucs_t string;
list_t list;
/* value datatype */
exi_datatype_t type;
} exi_value_t;

View file

@ -72,7 +72,6 @@ int exiGetLocalName(size_t uriID, size_t localNameID, const char** localName) {
if ( uriID < stringTable.len ) {
if ( localNameID < stringTable.localNames[uriID].len ) {
*localName = stringTable.localNames[uriID].entries[localNameID];
// strcpy(stringTable.localNames[uriID].entries[localNameID], localName);
} else {
return EXI_ERROR_OUT_OF_BOUNDS;
}

View file

@ -59,20 +59,19 @@ const char * localNames3[] = {
};
/* localName entries for URI id = 4 */
const char * localNames4[] = {
"ChargingProfile", "ContractID", "EAmount", "EVSEID", "EVSEIMax",
"EVSEMaxPhases", "EVSEMaxPower", "EVSEStatus", "EVSEVoltage", "EnergyProvider",
"EoC", "LineLockReq", "LineLockReqType", "LineLockRes", "LineLockResType",
"MeterInfo", "MeteringAuthPubKey", "MeteringReceiptReq", "MeteringReceiptReqType", "MeteringReceiptRes",
"MeteringReceiptResType", "MeteringStatusReq", "MeteringStatusReqType", "MeteringStatusRes", "MeteringStatusResType",
"PCurrent", "PEVID", "PEVMaxPhases", "PEVMaxPower", "PEVMaxVoltage",
"PEVMinVoltage", "PEVPubKey", "PEVStatus", "PaymentDetailsReq", "PaymentDetailsReqType",
"PaymentDetailsRes", "PaymentDetailsResType", "PowerDeliveryReq", "PowerDeliveryReqType", "PowerDeliveryRes",
"PowerDeliveryResType", "PowerDiscoveryReq", "PowerDiscoveryReqType", "PowerDiscoveryRes", "PowerDiscoveryResType",
"ReqLockStatus", "ReqSwitchStatus", "ResponseCode", "ServiceDiscoveryReq", "ServiceDiscoveryReqType",
"ServiceDiscoveryRes", "ServiceDiscoveryResType", "ServiceList", "ServicePaymentSelectionReq", "ServicePaymentSelectionReqType",
"ServicePaymentSelectionRes", "ServicePaymentSelectionResType", "ServiceScope", "ServiceType", "SessionSetupReq",
"SessionSetupReqType", "SessionSetupRes", "SessionSetupResType", "TCurrent", "Tariff",
"TariffTable"
"ContractID", "EAmount", "EVSEID", "EVSEIMax", "EVSEMaxPhases",
"EVSEMaxPower", "EVSEStatus", "EVSEVoltage", "EnergyProvider", "EoC",
"LineLockReq", "LineLockReqType", "LineLockRes", "LineLockResType", "MeterInfo",
"MeteringAuthPubKey", "MeteringReceiptReq", "MeteringReceiptReqType", "MeteringReceiptRes", "MeteringReceiptResType",
"MeteringStatusReq", "MeteringStatusReqType", "MeteringStatusRes", "MeteringStatusResType", "PCurrent",
"PEVID", "PEVMaxPhases", "PEVMaxPower", "PEVMaxVoltage", "PEVMinVoltage",
"PEVPubKey", "PEVStatus", "PaymentDetailsReq", "PaymentDetailsReqType", "PaymentDetailsRes",
"PaymentDetailsResType", "PowerDeliveryReq", "PowerDeliveryReqType", "PowerDeliveryRes", "PowerDeliveryResType",
"PowerDiscoveryReq", "PowerDiscoveryReqType", "PowerDiscoveryRes", "PowerDiscoveryResType", "ReqLockStatus",
"ReqSwitchStatus", "ResponseCode", "ServiceDiscoveryReq", "ServiceDiscoveryReqType", "ServiceDiscoveryRes",
"ServiceDiscoveryResType", "ServiceList", "ServicePaymentSelectionReq", "ServicePaymentSelectionReqType", "ServicePaymentSelectionRes",
"ServicePaymentSelectionResType", "ServiceScope", "ServiceType", "SessionSetupReq", "SessionSetupReqType",
"SessionSetupRes", "SessionSetupResType", "TCurrent", "Tariff"
};
/* localName entries for URI id = 5 */
const char * localNames5[] = {
@ -80,37 +79,35 @@ const char * localNames5[] = {
"Currency", "EPrice", "EVSEStandby", "EVSEStatusType", "Event",
"EventList", "EventListType", "FatalError", "FaultCode", "FaultMsg",
"FloatingValueType", "MeterID", "MeterInfoType", "MeterPubKey", "MeterReading",
"MeterStatus", "Multiplier", "NotificationType", "PEVStatusType", "PaymentOption",
"PowerSwitchClosed", "ProtocolVersion", "RCD", "Service", "ServiceDescriptionType",
"ServiceDetails", "ServiceID", "ServiceListType", "ServiceName", "ServiceScope",
"ServiceSessionID", "ServiceType", "SessionID", "SessionInformationType", "ShutDownTime",
"SigMeterReading", "TMeter", "Tariff", "TariffDescrType", "TariffDescription",
"TariffEntries", "TariffEntriesType", "TariffEntry", "TariffEntryType", "TariffID",
"TariffPMax", "TariffStart", "TariffTableType", "Unit", "Value",
"contractIDType", "currencyType", "energyProviderType", "eventEntryType", "evseIDType",
"fatalErrorType", "faultCodeType", "lockStatusType", "maxPhasesType", "meterIDType",
"meterStatusType", "paymentOptionListType", "paymentOptionType", "pevIDType", "protocolVersionType",
"pubKeyType", "rcdType", "responseCode_LineLockType", "responseCode_MeteringReceiptType", "responseCode_MeteringStatusType",
"responseCode_PaymentDetailsType", "responseCode_PowerDeliveryType", "responseCode_PowerDiscoveryType", "responseCode_ServiceDiscoveryType", "responseCode_ServicePaymentSelectionType",
"responseCode_SessionSetupType", "serviceDetailsType", "serviceIDType", "serviceNameType", "serviceScopeType",
"serviceTypeType", "sessionIDType", "standbyType", "switchStatusType", "tariffDescriptionType",
"tariffIDType", "tariffStartType", "timeType", "unitMultiplierType", "unitSymbolType"
"MeterStatus", "Multiplier", "NotificationType", "PEVStatusType", "PowerSwitchClosed",
"ProtocolVersion", "RCD", "Service", "ServiceDescriptionType", "ServiceDetails",
"ServiceID", "ServiceListType", "ServiceName", "ServiceScope", "ServiceSessionID",
"ServiceType", "SessionID", "SessionInformationType", "ShutDownTime", "TMeter",
"Tariff", "TariffDescrType", "TariffDescription", "TariffEntries", "TariffEntriesType",
"TariffEntry", "TariffEntryType", "TariffID", "TariffPMax", "TariffStart",
"TariffTableType", "Unit", "Value", "contractIDType", "currencyType",
"energyProviderType", "eventEntryType", "evseIDType", "fatalErrorType", "faultCodeType",
"lockStatusType", "maxPhasesType", "meterIDType", "meterStatusType", "paymentOptionListType",
"paymentOptionType", "pevIDType", "protocolVersionType", "pubKeyType", "rcdType",
"responseCode_LineLockType", "responseCode_MeteringReceiptType", "responseCode_MeteringStatusType", "responseCode_PaymentDetailsType", "responseCode_PowerDeliveryType",
"responseCode_PowerDiscoveryType", "responseCode_ServiceDiscoveryType", "responseCode_ServicePaymentSelectionType", "responseCode_SessionSetupType", "serviceDetailsType",
"serviceIDType", "serviceNameType", "serviceScopeType", "serviceTypeType", "sessionIDType",
"standbyType", "switchStatusType", "tariffDescriptionType", "tariffIDType", "tariffStartType",
"timeType", "unitMultiplierType", "unitSymbolType"
};
/* localName entries for URI id = 6 */
const char * localNames6[] = {
"Body", "BodyBaseType", "BodyElement", "BodyType", "Header",
"HeaderType", "Notification", "Security", "SessionInformation", "V2G_Message"
"HeaderType", "Notification", "SessionInformation", "V2G_Message"
};
struct exiPartition localNamePartitions[7] = {
{ 0, localNames0 },
{ 4, localNames1 },
{ 2, localNames2 },
{ 46, localNames3 },
{ 66, localNames4 },
{ 95, localNames5 },
{ 10, localNames6 }
{ 64, localNames4 },
{ 93, localNames5 },
{ 9, localNames6 }
};
const 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:MsgBody", "urn:iso:15118:2:2010:MsgDataTypes", "urn:iso:15118:2:2010:MsgDef"

View file

@ -29,7 +29,7 @@ extern "C" {
#include "EXITypes.h"
// TODO utf8/cstring//wchar_t/char16_t/char32_t methods
/* TODO utf8/cstring//wchar_t/char16_t/char32_t methods */
#ifndef UCS_STRING_H
@ -37,7 +37,7 @@ extern "C" {
int toUCSString(char* chars, string_ucs_t* s);
// Note: fails if string contains non ASCII characters
/* Note: fails if string contains non ASCII characters */
int toASCIIString(string_ucs_t* string, char* outASCII);
#endif

View file

@ -36,6 +36,12 @@
#include "EXITypes.h"
#include "Bitstream.h"
#define ARRAY_SIZE_BYTES 50
#define ARRAY_SIZE_STRINGS 50
/* avoids warning: initializer element is not computable at load time */
uint8_t data[ARRAY_SIZE_BYTES];
uint32_t codepoints[ARRAY_SIZE_STRINGS];
int main(int argc, char *argv[]) {
@ -45,20 +51,18 @@ int main(int argc, char *argv[]) {
bitstream_t iStream, oStream;
size_t posDecode, posEncode;
// EXI set-up
/* EXI set-up */
exi_state_t stateDecode;
exi_state_t stateEncode;
exi_event_t event;
eqname_t eqn;
exi_value_t val;
// BINARY memory allocation
uint8_t data[10];
bytes_t bytes = { 10, data };
/* BINARY memory setup */
bytes_t bytes = { ARRAY_SIZE_BYTES, data, 0 };
// STRING memory allocation
uint32_t codepoints[50];
string_ucs_t string = { 50, codepoints };
/* STRING memory setuo */
string_ucs_t string = { ARRAY_SIZE_STRINGS, codepoints, 0 };
const char * localName;
const char * namespaceURI;
@ -73,13 +77,13 @@ int main(int argc, char *argv[]) {
/* parse EXI stream to internal byte structures */
toBitstream(argv[1], &iStream);
// input
/* input */
posDecode = 0;
iStream.pos = &posDecode;
iStream.buffer = 0;
iStream.capacity = 0;
// output
/* output */
posEncode = 0;
oStream.data = malloc(sizeof(uint8_t)*iStream.size);
oStream.size = iStream.size;
@ -112,31 +116,31 @@ int main(int argc, char *argv[]) {
switch (event) {
case START_DOCUMENT:
// decode
/* decode */
errn = exiDecodeStartDocument(&iStream, &stateDecode);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errno);
return errn;
}
printf(">> START_DOCUMENT \n");
// encode
/* encode */
errn = exiEncodeStartDocument(&oStream, &stateEncode);
break;
case END_DOCUMENT:
// decode
/* decode */
errn = exiDecodeEndDocument(&iStream, &stateDecode);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errno);
return errn;
}
printf(">> END_DOCUMENT \n");
// encode
/* encode */
errn = exiEncodeEndDocument(&oStream, &stateEncode);
/* signalize end of document */
noEndOfDocument = 0; /* false */
break;
case START_ELEMENT:
// decode
/* decode */
errn = exiDecodeStartElement(&iStream, &stateDecode, &eqn);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errno);
@ -145,11 +149,11 @@ int main(int argc, char *argv[]) {
exiGetLocalName(eqn.namespaceURI, eqn.localPart, &localName);
exiGetUri(eqn.namespaceURI, &namespaceURI);
printf(">> SE {%s}%s \n", namespaceURI, localName);
// encode
/* encode */
errn = exiEncodeStartElement(&oStream, &stateEncode, &eqn);
break;
case END_ELEMENT:
// decode
/* decode */
errn = exiDecodeEndElement(&iStream, &stateDecode, &eqn);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errno);
@ -158,11 +162,11 @@ int main(int argc, char *argv[]) {
exiGetLocalName(eqn.namespaceURI, eqn.localPart, &localName);
exiGetUri(eqn.namespaceURI, &namespaceURI);
printf("<< EE {%s}%s \n", namespaceURI, localName);
// encode
/* encode */
errn = exiEncodeEndElement(&oStream, &stateEncode, &eqn);
break;
case CHARACTERS:
// decode
/* decode */
errn = exiDecodeCharacters(&iStream, &stateDecode, &val);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errno);
@ -187,11 +191,11 @@ int main(int argc, char *argv[]) {
} else {
printf(" CH ?? \n");
}
// encode
/* encode */
errn = exiEncodeCharacters(&oStream, &stateEncode, &val);
break;
case ATTRIBUTE:
// decode
/* decode */
errn = exiDecodeAttribute(&iStream, &stateDecode, &eqn, &val);
if (errn < 0) {
printf("[Decode-ERROR] %d \n", errno);
@ -200,11 +204,11 @@ int main(int argc, char *argv[]) {
exiGetLocalName(eqn.namespaceURI, eqn.localPart, &localName);
exiGetUri(eqn.namespaceURI, &namespaceURI);
printf(" AT {%s}%s \n", namespaceURI, localName);
// encode
/* encode */
errn = exiEncodeAttribute(&oStream, &stateEncode, &eqn, &val);
break;
default:
// ERROR
/* ERROR */
return -1;
}