struct dfui_form * dfui_decode_form(struct aura_buffer *e) { char *id; struct dfui_info *i; struct dfui_form *f; if (!aura_buffer_expect(e, "F{")) return(NULL); id = dfui_decode_string(e); i = dfui_decode_info(e); f = dfui_form_new(id, i); dfui_form_set_multiple(f, dfui_decode_bool(e)); dfui_form_set_extensible(f, dfui_decode_bool(e)); f->field_head = dfui_decode_fields(e); f->action_head = dfui_decode_actions(e); f->dataset_head = dfui_decode_datasets(e); f->property_head = dfui_decode_properties(e); aura_buffer_expect(e, "}"); free(id); return(f); }
static struct dfui_form * make_create_subpartitions_form(struct i_fn_args *a) { struct dfui_form *f; char msg_buf[1][1024]; snprintf(msg_buf[0], sizeof(msg_buf[0]), _("Subpartitions further divide a primary partition for " "use with %s. Some reasons you may want " "a set of subpartitions are:\n\n" "- you want to restrict how much data can be written " "to certain parts of the primary partition, to quell " "denial-of-service attacks; and\n" "- you want to speed up access to data on the disk." ""), OPERATING_SYSTEM_NAME); f = dfui_form_create( "create_subpartitions", _("Create Subpartitions"), _("Set up the subpartitions (also known as just `partitions' " "in BSD tradition) you want to have on this primary " "partition. In most cases you should be fine with " "the default settings.\n\n" "For Capacity, use 'M' to indicate megabytes, 'G' to " "indicate gigabytes, and so on (up to 'E'.) A single '*' " "indicates 'use the remaining space on the primary partition'."), msg_buf[0], "p", "special", "dfinstaller_create_subpartitions", "p", "minimum_width","64", "f", "mountpoint", _("Mountpoint"), "", "", "f", "capacity", _("Capacity"), "", "", "f", "encrypted", _("Encrypted"), "", "", "p", "control", "checkbox", "a", "ok", _("Accept and Create"), "", "", "a", "cancel", (disk_get_formatted(storage_get_selected_disk(a->s)) ? _("Return to Select Disk") : _("Return to Select Primary Partition")), "", "", "p", "accelerator", "ESC", NULL ); dfui_form_set_multiple(f, 1); dfui_form_set_extensible(f, 1); /* * Remove ATM until HAMMER installer support is better * dfui_form_set_extensible(f, 1); */ #if 0 if (expert) { fi = dfui_form_field_add(f, "softupdates", dfui_info_new(_("Softupdates"), "", "")); dfui_field_property_set(fi, "control", "checkbox"); fi = dfui_form_field_add(f, "tmpfsbacked", dfui_info_new(_("TMPFS"), "", "")); dfui_field_property_set(fi, "control", "checkbox"); fi = dfui_form_field_add(f, "fsize", dfui_info_new(_("Frag Sz"), "", "")); fi = dfui_form_field_add(f, "bsize", dfui_info_new(_("Block Sz"), "", "")); dfui_form_action_add(f, "switch", dfui_info_new(_("Switch to Normal Mode"), "", "")); } else { dfui_form_action_add(f, "switch", dfui_info_new(_("Switch to Expert Mode"), "", "")); } #endif return(f); }
static void set_dfui_properties_from_lua_table(lua_State *L, int table_idx, int dfui_obj_type, void *dfui_obj) { const char *key, *value; /* * Traverse the table, looking for key->value pairs that we can use * to modify the field. * For each entry, if it is standard (id, name, short_desc, long_desc) * ignore it; if it is anything else, assume it is a property. */ lua_pushnil(L); while (lua_next(L, table_idx) != 0) { if (lua_isstring(L, -2) && lua_isstring(L, -1)) { key = lua_tostring(L, -2); value = lua_tostring(L, -1); if (strcmp(key, "id") == 0 || strcmp(key, "name") == 0 || strcmp(key, "short_desc") == 0 || strcmp(key, "long_desc") == 0) { /* * Skip it, we've already done it. */ } else if (strcmp(key, "multiple") == 0 && dfui_obj_type == DFUI_OBJ_FORM) { dfui_form_set_multiple( (struct dfui_form *)dfui_obj, strcmp(value, "true") == 0 ); } else if (strcmp(key, "extensible") == 0 && dfui_obj_type == DFUI_OBJ_FORM) { dfui_form_set_extensible( (struct dfui_form *)dfui_obj, strcmp(value, "true") == 0 ); } else { /* * It's a property. */ switch (dfui_obj_type) { case DFUI_OBJ_FORM: dfui_form_property_set( (struct dfui_form *)dfui_obj, key, value); break; case DFUI_OBJ_FIELD: dfui_field_property_set( (struct dfui_field *)dfui_obj, key, value); break; case DFUI_OBJ_ACTION: dfui_action_property_set( (struct dfui_action *)dfui_obj, key, value); break; } } } else if (lua_isstring(L, -2) && lua_istable(L, -1)) { key = lua_tostring(L, -2); if (strcmp(key, "options") == 0 && dfui_obj_type == DFUI_OBJ_FIELD) { dfui_field_options_from_lua_table(L, (struct dfui_field *)dfui_obj ); } } else { /* * Either the key or the value is not a string, * so just skip it. */ } /* * Remove the value, but leave the key for the next iteration. */ lua_pop(L, 1); } }