static attr_value_t get_close(void *arg, conf_object_t *self, attr_value_t *idx) { uart_sampler_t *s = (uart_sampler_t *)self; s->active = 0; if (sampler_fini(&s->sampler)) { SIM_frontend_exception(SimExc_General, "Error flusing the dangling samples."); } return SIM_make_attr_nil(); }
static set_error_t set_filename(void *arg, conf_object_t *obj, attr_value_t *val, attr_value_t *idx) { byte_dump_device_t *bdd = (byte_dump_device_t *)obj; int fd = open(val->u.string, O_CREAT | O_RDWR | O_BINARY, 0666); if (fd < 0) { SIM_frontend_exception(SimExc_General, "Failed opening file"); return Sim_Set_Illegal_Value; } if (bdd->filename) { close(bdd->fd); MM_FREE((char *)bdd->filename); } bdd->fd = fd; bdd->filename = MM_STRDUP(val->u.string); return Sim_Set_Ok; }