- MmsValue_update function now allows adjusting octet-string size of target object

pull/143/head
Michael Zillgith 8 years ago
parent 33fb9206b3
commit f9030a8b4f

@ -223,67 +223,76 @@ MmsValue_equalTypes(const MmsValue* self, const MmsValue* otherValue)
bool bool
MmsValue_update(MmsValue* self, const MmsValue* update) MmsValue_update(MmsValue* self, const MmsValue* update)
{ {
if (self->type == update->type) { if (self->type == update->type) {
switch (self->type) { switch (self->type) {
case MMS_STRUCTURE: case MMS_STRUCTURE:
case MMS_ARRAY: case MMS_ARRAY:
if (updateStructuredComponent(self, update) == false) if (updateStructuredComponent(self, update) == false)
return false; return false;
break; break;
case MMS_BOOLEAN: case MMS_BOOLEAN:
self->value.boolean = update->value.boolean; self->value.boolean = update->value.boolean;
break; break;
case MMS_FLOAT: case MMS_FLOAT:
if (self->value.floatingPoint.formatWidth == update->value.floatingPoint.formatWidth) { if (self->value.floatingPoint.formatWidth == update->value.floatingPoint.formatWidth) {
self->value.floatingPoint.exponentWidth = update->value.floatingPoint.exponentWidth; self->value.floatingPoint.exponentWidth = update->value.floatingPoint.exponentWidth;
memcpy(self->value.floatingPoint.buf, update->value.floatingPoint.buf, memcpy(self->value.floatingPoint.buf, update->value.floatingPoint.buf,
self->value.floatingPoint.formatWidth / 8); self->value.floatingPoint.formatWidth / 8);
} }
else return false; else
break; return false;
case MMS_INTEGER: break;
case MMS_UNSIGNED: case MMS_INTEGER:
if (BerInteger_setFromBerInteger(self->value.integer, update->value.integer)) case MMS_UNSIGNED:
return true; if (BerInteger_setFromBerInteger(self->value.integer, update->value.integer))
else return true;
return false; else
break; return false;
case MMS_UTC_TIME: break;
memcpy(self->value.utcTime, update->value.utcTime, 8); case MMS_UTC_TIME:
break; memcpy(self->value.utcTime, update->value.utcTime, 8);
case MMS_BIT_STRING: break;
if (self->value.bitString.size == update->value.bitString.size) case MMS_BIT_STRING:
memcpy(self->value.bitString.buf, update->value.bitString.buf, bitStringByteSize(self)); if (self->value.bitString.size == update->value.bitString.size)
else return false; memcpy(self->value.bitString.buf, update->value.bitString.buf, bitStringByteSize(self));
break; else
case MMS_OCTET_STRING: return false;
if (self->value.octetString.maxSize == update->value.octetString.maxSize) { break;
memcpy(self->value.octetString.buf, update->value.octetString.buf, case MMS_OCTET_STRING:
update->value.octetString.size); {
int size = update->value.octetString.size;
self->value.octetString.size = update->value.octetString.size;
} if (size > self->value.octetString.maxSize) {
else return false; GLOBAL_FREEMEM(self->value.octetString.buf);
break; self->value.octetString.buf = GLOBAL_MALLOC(size);
case MMS_VISIBLE_STRING: self->value.octetString.maxSize = size;
MmsValue_setVisibleString(self, update->value.visibleString.buf); }
break; size = self->value.octetString.maxSize;
case MMS_STRING:
MmsValue_setMmsString(self, update->value.visibleString.buf); memcpy(self->value.octetString.buf, update->value.octetString.buf, size);
break;
case MMS_BINARY_TIME: self->value.octetString.size = size;
self->value.binaryTime.size = update->value.binaryTime.size; }
memcpy(self->value.binaryTime.buf, update->value.binaryTime.buf, break;
update->value.binaryTime.size); case MMS_VISIBLE_STRING:
break; MmsValue_setVisibleString(self, update->value.visibleString.buf);
default: break;
return false; case MMS_STRING:
break; MmsValue_setMmsString(self, update->value.visibleString.buf);
} break;
return true; case MMS_BINARY_TIME:
} self->value.binaryTime.size = update->value.binaryTime.size;
else memcpy(self->value.binaryTime.buf, update->value.binaryTime.buf,
return false; update->value.binaryTime.size);
break;
default:
return false;
break;
}
return true;
}
else
return false;
} }
MmsValue* MmsValue*

Loading…
Cancel
Save