- added const qualifiers to API functions (#348)

pull/356/head
Michael Zillgith 4 years ago
parent d49c159686
commit ce13002ce1

@ -242,7 +242,7 @@ Timestamp_create()
} }
Timestamp* Timestamp*
Timestamp_createFromByteArray(uint8_t* byteArray) Timestamp_createFromByteArray(const uint8_t* byteArray)
{ {
Timestamp* self = Timestamp_create(); Timestamp* self = Timestamp_create();
@ -471,7 +471,7 @@ Timestamp_getTimeInNs(Timestamp* self)
} }
void void
Timestamp_setByMmsUtcTime(Timestamp* self, MmsValue* mmsValue) Timestamp_setByMmsUtcTime(Timestamp* self, const MmsValue* mmsValue)
{ {
if (MmsValue_getType(mmsValue) == MMS_UTC_TIME) if (MmsValue_getType(mmsValue) == MMS_UTC_TIME)
memcpy(self->val, mmsValue->value.utcTime, 8); memcpy(self->val, mmsValue->value.utcTime, 8);

@ -423,7 +423,7 @@ LIB61850_API Timestamp*
Timestamp_create(void); Timestamp_create(void);
LIB61850_API Timestamp* LIB61850_API Timestamp*
Timestamp_createFromByteArray(uint8_t* byteArray); Timestamp_createFromByteArray(const uint8_t* byteArray);
LIB61850_API void LIB61850_API void
Timestamp_destroy(Timestamp* self); Timestamp_destroy(Timestamp* self);
@ -504,7 +504,7 @@ LIB61850_API void
Timestamp_setTimeInNanoseconds(Timestamp* self, nsSinceEpoch nsTime); Timestamp_setTimeInNanoseconds(Timestamp* self, nsSinceEpoch nsTime);
LIB61850_API void LIB61850_API void
Timestamp_setByMmsUtcTime(Timestamp* self, MmsValue* mmsValue); Timestamp_setByMmsUtcTime(Timestamp* self, const MmsValue* mmsValue);
/** /**
* \brief Set an MmsValue instance of type UTCTime to the timestamp value * \brief Set an MmsValue instance of type UTCTime to the timestamp value

@ -46,14 +46,14 @@ extern "C" {
/** /**
* \brief create a new IedModel instance * \brief create a new IedModel instance
* *
* The IedModel object is the root node of an IEC 61850 service data model. * The IedModel object is the root node of an IEC 61850 data model.
* *
* \param name the name of the IedModel or NULL (optional - NOT YET USED) * \param name the name of the IedModel
* *
* \return * \return the new data model instance
*/ */
LIB61850_API IedModel* LIB61850_API IedModel*
IedModel_create(const char* name/*, MemoryAllocator allocator*/); IedModel_create(const char* name);
/** /**
* \brief Set the name of the IED (use only for dynamic model!) * \brief Set the name of the IED (use only for dynamic model!)
@ -196,7 +196,7 @@ DataAttribute_setValue(DataAttribute* self, MmsValue* value);
* \return the new RCB instance. * \return the new RCB instance.
*/ */
LIB61850_API ReportControlBlock* LIB61850_API ReportControlBlock*
ReportControlBlock_create(const char* name, LogicalNode* parent, char* rptId, bool isBuffered, char* ReportControlBlock_create(const char* name, LogicalNode* parent, const char* rptId, bool isBuffered, const char*
dataSetName, uint32_t confRef, uint8_t trgOps, uint8_t options, uint32_t bufTm, uint32_t intgPd); dataSetName, uint32_t confRef, uint8_t trgOps, uint8_t options, uint32_t bufTm, uint32_t intgPd);
/** /**
@ -209,7 +209,7 @@ ReportControlBlock_create(const char* name, LogicalNode* parent, char* rptId, bo
* \param clientAddress buffer containing the client address (4 byte in case of an IPv4 address, 16 byte in case of an IPv6 address, NULL for no client) * \param clientAddress buffer containing the client address (4 byte in case of an IPv4 address, 16 byte in case of an IPv6 address, NULL for no client)
*/ */
LIB61850_API void LIB61850_API void
ReportControlBlock_setPreconfiguredClient(ReportControlBlock* self, uint8_t clientType, uint8_t* clientAddress); ReportControlBlock_setPreconfiguredClient(ReportControlBlock* self, uint8_t clientType, const uint8_t* clientAddress);
/** /**
* \brief create a new log control block (LCB) * \brief create a new log control block (LCB)
@ -229,7 +229,7 @@ ReportControlBlock_setPreconfiguredClient(ReportControlBlock* self, uint8_t clie
* \return the new LCB instance * \return the new LCB instance
*/ */
LIB61850_API LogControlBlock* LIB61850_API LogControlBlock*
LogControlBlock_create(const char* name, LogicalNode* parent, char* dataSetName, char* logRef, uint8_t trgOps, LogControlBlock_create(const char* name, LogicalNode* parent, const char* dataSetName, const char* logRef, uint8_t trgOps,
uint32_t intgPd, bool logEna, bool reasonCode); uint32_t intgPd, bool logEna, bool reasonCode);
/** /**
@ -274,7 +274,7 @@ SettingGroupControlBlock_create(LogicalNode* parent, uint8_t actSG, uint8_t numO
* \return the new GoCB instance * \return the new GoCB instance
*/ */
LIB61850_API GSEControlBlock* LIB61850_API GSEControlBlock*
GSEControlBlock_create(const char* name, LogicalNode* parent, char* appId, char* dataSet, uint32_t confRev, GSEControlBlock_create(const char* name, LogicalNode* parent, const char* appId, const char* dataSet, uint32_t confRev,
bool fixedOffs, int minTime, int maxTime); bool fixedOffs, int minTime, int maxTime);
/** /**
@ -294,7 +294,7 @@ GSEControlBlock_create(const char* name, LogicalNode* parent, char* appId, char*
* \return the new SvCB instance * \return the new SvCB instance
*/ */
LIB61850_API SVControlBlock* LIB61850_API SVControlBlock*
SVControlBlock_create(const char* name, LogicalNode* parent, char* svID, char* dataSet, uint32_t confRev, uint8_t smpMod, SVControlBlock_create(const char* name, LogicalNode* parent, const char* svID, const char* dataSet, uint32_t confRev, uint8_t smpMod,
uint16_t smpRate, uint8_t optFlds, bool isUnicast); uint16_t smpRate, uint8_t optFlds, bool isUnicast);
LIB61850_API void LIB61850_API void

@ -296,7 +296,7 @@ LogicalNode_addLogControlBlock(LogicalNode* self, LogControlBlock* lcb)
} }
LogControlBlock* LogControlBlock*
LogControlBlock_create(const char* name, LogicalNode* parent, char* dataSetName, char* logRef, uint8_t trgOps, LogControlBlock_create(const char* name, LogicalNode* parent, const char* dataSetName, const char* logRef, uint8_t trgOps,
uint32_t intPeriod, bool logEna, bool reasonCode) uint32_t intPeriod, bool logEna, bool reasonCode)
{ {
LogControlBlock* self = (LogControlBlock*) GLOBAL_MALLOC(sizeof(LogControlBlock)); LogControlBlock* self = (LogControlBlock*) GLOBAL_MALLOC(sizeof(LogControlBlock));
@ -334,7 +334,7 @@ LogicalNode_addReportControlBlock(LogicalNode* self, ReportControlBlock* rcb)
} }
ReportControlBlock* ReportControlBlock*
ReportControlBlock_create(const char* name, LogicalNode* parent, char* rptId, bool isBuffered, char* ReportControlBlock_create(const char* name, LogicalNode* parent, const char* rptId, bool isBuffered, const char*
dataSetName, uint32_t confRef, uint8_t trgOps, uint8_t options, uint32_t bufTm, uint32_t intgPd) dataSetName, uint32_t confRef, uint8_t trgOps, uint8_t options, uint32_t bufTm, uint32_t intgPd)
{ {
ReportControlBlock* self = (ReportControlBlock*) GLOBAL_MALLOC(sizeof(ReportControlBlock)); ReportControlBlock* self = (ReportControlBlock*) GLOBAL_MALLOC(sizeof(ReportControlBlock));
@ -368,7 +368,7 @@ ReportControlBlock_create(const char* name, LogicalNode* parent, char* rptId, bo
} }
void void
ReportControlBlock_setPreconfiguredClient(ReportControlBlock* self, uint8_t clientType, uint8_t* clientAddress) ReportControlBlock_setPreconfiguredClient(ReportControlBlock* self, uint8_t clientType, const uint8_t* clientAddress)
{ {
if (clientType == 4) { /* IPv4 address */ if (clientType == 4) { /* IPv4 address */
self->clientReservation[0] = 4; self->clientReservation[0] = 4;
@ -421,7 +421,7 @@ LogicalNode_addGSEControlBlock(LogicalNode* self, GSEControlBlock* gcb)
} }
GSEControlBlock* GSEControlBlock*
GSEControlBlock_create(const char* name, LogicalNode* parent, char* appId, char* dataSet, uint32_t confRef, bool fixedOffs, GSEControlBlock_create(const char* name, LogicalNode* parent, const char* appId, const char* dataSet, uint32_t confRef, bool fixedOffs,
int minTime, int maxTime) int minTime, int maxTime)
{ {
GSEControlBlock* self = (GSEControlBlock*) GLOBAL_MALLOC(sizeof(GSEControlBlock)); GSEControlBlock* self = (GSEControlBlock*) GLOBAL_MALLOC(sizeof(GSEControlBlock));
@ -455,7 +455,7 @@ GSEControlBlock_create(const char* name, LogicalNode* parent, char* appId, char*
} }
SVControlBlock* SVControlBlock*
SVControlBlock_create(const char* name, LogicalNode* parent, char* svID, char* dataSet, uint32_t confRev, uint8_t smpMod, SVControlBlock_create(const char* name, LogicalNode* parent, const char* svID, const char* dataSet, uint32_t confRev, uint8_t smpMod,
uint16_t smpRate, uint8_t optFlds, bool isUnicast) uint16_t smpRate, uint8_t optFlds, bool isUnicast)
{ {
SVControlBlock* self = (SVControlBlock*) GLOBAL_MALLOC(sizeof(SVControlBlock)); SVControlBlock* self = (SVControlBlock*) GLOBAL_MALLOC(sizeof(SVControlBlock));
@ -926,13 +926,11 @@ IedModel_destroy(IedModel* model)
log = nextLog; log = nextLog;
} }
/* delete generic model parts */ /* delete generic model parts */
if (model->name) if (model->name)
GLOBAL_FREEMEM(model->name); GLOBAL_FREEMEM(model->name);
GLOBAL_FREEMEM(model); GLOBAL_FREEMEM(model);
} }

@ -101,7 +101,7 @@ MmsVariableSpecification_getType(MmsVariableSpecification* self);
* \return true if type is matching, false otherwise * \return true if type is matching, false otherwise
*/ */
LIB61850_API bool LIB61850_API bool
MmsVariableSpecification_isValueOfType(MmsVariableSpecification* self, MmsValue* value); MmsVariableSpecification_isValueOfType(MmsVariableSpecification* self, const MmsValue* value);
/** /**
* \brief get the name of the variable * \brief get the name of the variable

@ -80,7 +80,7 @@ typedef struct sMmsValue MmsValue;
* \return a newly created array instance * \return a newly created array instance
*/ */
LIB61850_API MmsValue* LIB61850_API MmsValue*
MmsValue_createArray(MmsVariableSpecification* elementType, int size); MmsValue_createArray(const MmsVariableSpecification* elementType, int size);
/** /**
* \brief Get the size of an array. * \brief Get the size of an array.
@ -552,7 +552,7 @@ MmsValue_getBinaryTimeAsUtcMs(const MmsValue* self);
* \param size the size of the buffer that contains the new value * \param size the size of the buffer that contains the new value
*/ */
LIB61850_API void LIB61850_API void
MmsValue_setOctetString(MmsValue* self, uint8_t* buf, int size); MmsValue_setOctetString(MmsValue* self, const uint8_t* buf, int size);
/** /**
* \brief Returns the size in bytes of an MmsValue object of type MMS_OCTET_STRING. * \brief Returns the size in bytes of an MmsValue object of type MMS_OCTET_STRING.
@ -839,7 +839,7 @@ MmsValue_newBinaryTime(bool timeOfDay);
* \return new MmsValue instance of type MMS_VISIBLE_STRING * \return new MmsValue instance of type MMS_VISIBLE_STRING
*/ */
LIB61850_API MmsValue* LIB61850_API MmsValue*
MmsValue_newVisibleStringFromByteArray(uint8_t* byteArray, int size); MmsValue_newVisibleStringFromByteArray(const uint8_t* byteArray, int size);
/** /**
* \brief Create a new MmsValue instance of type MMS_STRING from the specified byte array * \brief Create a new MmsValue instance of type MMS_STRING from the specified byte array
@ -850,7 +850,7 @@ MmsValue_newVisibleStringFromByteArray(uint8_t* byteArray, int size);
* \return new MmsValue instance of type MMS_STRING * \return new MmsValue instance of type MMS_STRING
*/ */
LIB61850_API MmsValue* LIB61850_API MmsValue*
MmsValue_newMmsStringFromByteArray(uint8_t* byteArray, int size); MmsValue_newMmsStringFromByteArray(const uint8_t* byteArray, int size);
/** /**
* \brief Create a new MmsValue instance of type MMS_STRING. * \brief Create a new MmsValue instance of type MMS_STRING.
@ -860,7 +860,7 @@ MmsValue_newMmsStringFromByteArray(uint8_t* byteArray, int size);
* \return new MmsValue instance of type MMS_STRING * \return new MmsValue instance of type MMS_STRING
*/ */
LIB61850_API MmsValue* LIB61850_API MmsValue*
MmsValue_newMmsString(char* string); MmsValue_newMmsString(const char* string);
/** /**
* \brief Set the value of MmsValue instance of type MMS_STRING * \brief Set the value of MmsValue instance of type MMS_STRING

@ -103,7 +103,7 @@ MmsVariableSpecification_getType(MmsVariableSpecification* self)
} }
bool bool
MmsVariableSpecification_isValueOfType(MmsVariableSpecification* self, MmsValue* value) MmsVariableSpecification_isValueOfType(MmsVariableSpecification* self, const MmsValue* value)
{ {
if ((self->type) == (value->type)) { if ((self->type) == (value->type)) {

@ -1418,7 +1418,7 @@ MmsValue_newOctetString(int size, int maxSize)
} }
void void
MmsValue_setOctetString(MmsValue* self, uint8_t* buf, int size) MmsValue_setOctetString(MmsValue* self, const uint8_t* buf, int size)
{ {
if (size <= self->value.octetString.maxSize) { if (size <= self->value.octetString.maxSize) {
memcpy(self->value.octetString.buf, buf, size); memcpy(self->value.octetString.buf, buf, size);
@ -1691,7 +1691,7 @@ MmsValue_newVisibleStringWithSize(int size)
} }
MmsValue* MmsValue*
MmsValue_newMmsString(char* string) MmsValue_newMmsString(const char* string)
{ {
return MmsValue_newString(string, MMS_STRING); return MmsValue_newString(string, MMS_STRING);
} }
@ -1832,13 +1832,13 @@ exit_function:
} }
MmsValue* MmsValue*
MmsValue_newVisibleStringFromByteArray(uint8_t* byteArray, int size) MmsValue_newVisibleStringFromByteArray(const uint8_t* byteArray, int size)
{ {
return MmsValue_newStringFromByteArray(byteArray, size, MMS_VISIBLE_STRING); return MmsValue_newStringFromByteArray(byteArray, size, MMS_VISIBLE_STRING);
} }
MmsValue* MmsValue*
MmsValue_newMmsStringFromByteArray(uint8_t* byteArray, int size) MmsValue_newMmsStringFromByteArray(const uint8_t* byteArray, int size)
{ {
return MmsValue_newStringFromByteArray(byteArray, size, MMS_STRING); return MmsValue_newStringFromByteArray(byteArray, size, MMS_STRING);
} }
@ -1913,7 +1913,7 @@ MmsValue_newUtcTimeByMsTime(uint64_t timeval)
} }
MmsValue* MmsValue*
MmsValue_createArray(MmsVariableSpecification* elementType, int size) MmsValue_createArray(const MmsVariableSpecification* elementType, int size)
{ {
MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue)); MmsValue* self = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));

Loading…
Cancel
Save