Make machine configuration authoritative and restore native checkpoints exactly
This commit is contained in:
@@ -12,6 +12,18 @@ typedef struct {
|
||||
|
||||
static protocol_state state;
|
||||
|
||||
uint32_t sim_protocol_checkpoint_size(void) { return sizeof(state); }
|
||||
int32_t sim_protocol_checkpoint_export(uint8_t *output, uint32_t capacity) {
|
||||
if (output == NULL || capacity != sizeof(state)) return SIM_PROTOCOL_ERR_ARGUMENT;
|
||||
memcpy(output, &state, sizeof(state)); return SIM_PROTOCOL_OK;
|
||||
}
|
||||
int32_t sim_protocol_checkpoint_restore(const uint8_t *input, uint32_t length) {
|
||||
if (input == NULL || length != sizeof(state)) return SIM_PROTOCOL_ERR_ARGUMENT;
|
||||
const protocol_state *saved = (const protocol_state *)input;
|
||||
if (saved->state > SIM_PROTOCOL_DESTROYED) return SIM_PROTOCOL_ERR_ARGUMENT;
|
||||
memcpy(&state, saved, sizeof(state)); return SIM_PROTOCOL_OK;
|
||||
}
|
||||
|
||||
static int has_text(const char *value) {
|
||||
return value != NULL && value[0] != '\0' && strlen(value) <= 128;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user