static void _setMyBXattr (CDKOBJS *object, chtype character) { CDKALPHALIST *alphalist = (CDKALPHALIST *)object; setCDKEntryBoxAttribute (alphalist->entryField, character); setCDKScrollBoxAttribute (alphalist->scrollField, character); }
/* * Run the Add Device Group dialog */ void addDevGrpDialog(CDKSCREEN *main_cdk_screen) { CDKENTRY *dev_grp_name_entry = 0; char attr_path[MAX_SYSFS_PATH_SIZE] = {0}, attr_value[MAX_SYSFS_ATTR_SIZE] = {0}; char *dev_grp_name = NULL, *error_msg = NULL; int temp_int = 0; while (1) { /* Get new device group name (entry widget) */ dev_grp_name_entry = newCDKEntry(main_cdk_screen, CENTER, CENTER, "<C></31/B>Add New Device Group\n", "</B>New Group Name (no spaces): ", COLOR_DIALOG_SELECT, '_' | COLOR_DIALOG_INPUT, vMIXED, SCST_DEV_GRP_NAME_LEN, 0, SCST_DEV_GRP_NAME_LEN, TRUE, FALSE); if (!dev_grp_name_entry) { errorDialog(main_cdk_screen, ENTRY_ERR_MSG, NULL); break; } setCDKEntryBoxAttribute(dev_grp_name_entry, COLOR_DIALOG_BOX); setCDKEntryBackgroundAttrib(dev_grp_name_entry, COLOR_DIALOG_TEXT); /* Draw the entry widget */ curs_set(1); dev_grp_name = activateCDKEntry(dev_grp_name_entry, 0); /* Check exit from widget */ if (dev_grp_name_entry->exitType == vNORMAL) { /* Check group name for bad characters */ if (!checkInputStr(main_cdk_screen, NAME_CHARS, dev_grp_name)) break; /* Add the new device group */ snprintf(attr_path, MAX_SYSFS_PATH_SIZE, "%s/device_groups/mgmt", SYSFS_SCST_TGT); snprintf(attr_value, MAX_SYSFS_ATTR_SIZE, "create %s", dev_grp_name); if ((temp_int = writeAttribute(attr_path, attr_value)) != 0) { SAFE_ASPRINTF(&error_msg, "Couldn't add SCST (ALUA) device group: %s", strerror(temp_int)); errorDialog(main_cdk_screen, error_msg, NULL); FREE_NULL(error_msg); } } break; } /* Done */ destroyCDKEntry(dev_grp_name_entry); return; }
void setCDKFselectBoxAttribute (CDKFSELECT *fselect, chtype character) { setCDKEntryBoxAttribute (fselect->entryField, character); setCDKScrollBoxAttribute (fselect->scrollField, character); }
/* * Run the Add Target to Group dialog */ void addTgtToGrpDialog(CDKSCREEN *main_cdk_screen) { WINDOW *add_tgt_window = 0; CDKSCREEN *add_tgt_screen = 0; CDKLABEL *add_tgt_info = 0; CDKENTRY *tgt_name = 0; CDKSCALE *rel_tgt_id = 0; CDKBUTTON *ok_button = 0, *cancel_button = 0; tButtonCallback ok_cb = &okButtonCB, cancel_cb = &cancelButtonCB; char dev_grp_name[MAX_SYSFS_ATTR_SIZE] = {0}, tgt_grp_name[MAX_SYSFS_ATTR_SIZE] = {0}, attr_path[MAX_SYSFS_PATH_SIZE] = {0}, attr_value[MAX_SYSFS_ATTR_SIZE] = {0}; char *error_msg = NULL; char *add_tgt_info_msg[TGT_GRP_INFO_LINES] = {NULL}; int add_tgt_window_lines = 0, add_tgt_window_cols = 0, window_y = 0, window_x = 0, temp_int = 0, i = 0, traverse_ret = 0; /* Have the user choose a SCST device group */ getSCSTDevGrpChoice(main_cdk_screen, dev_grp_name); if (dev_grp_name[0] == '\0') return; /* Get target group choice from user (based on previously * selected device group) */ getSCSTTgtGrpChoice(main_cdk_screen, dev_grp_name, tgt_grp_name); if (tgt_grp_name[0] == '\0') return; /* New CDK screen */ add_tgt_window_lines = 11; add_tgt_window_cols = 55; window_y = ((LINES / 2) - (add_tgt_window_lines / 2)); window_x = ((COLS / 2) - (add_tgt_window_cols / 2)); add_tgt_window = newwin(add_tgt_window_lines, add_tgt_window_cols, window_y, window_x); if (add_tgt_window == NULL) { errorDialog(main_cdk_screen, NEWWIN_ERR_MSG, NULL); return; } add_tgt_screen = initCDKScreen(add_tgt_window); if (add_tgt_screen == NULL) { errorDialog(main_cdk_screen, CDK_SCR_ERR_MSG, NULL); return; } boxWindow(add_tgt_window, COLOR_DIALOG_BOX); wbkgd(add_tgt_window, COLOR_DIALOG_TEXT); wrefresh(add_tgt_window); while (1) { /* Information label */ SAFE_ASPRINTF(&add_tgt_info_msg[0], "</31/B>Adding SCST target to target group..."); SAFE_ASPRINTF(&add_tgt_info_msg[1], " "); SAFE_ASPRINTF(&add_tgt_info_msg[2], "</B>Device group:<!B>\t%s", dev_grp_name); SAFE_ASPRINTF(&add_tgt_info_msg[3], "</B>Target group:<!B>\t%s", tgt_grp_name); add_tgt_info = newCDKLabel(add_tgt_screen, (window_x + 1), (window_y + 1), add_tgt_info_msg, ADD_TGT_INFO_LINES, FALSE, FALSE); if (!add_tgt_info) { errorDialog(main_cdk_screen, LABEL_ERR_MSG, NULL); break; } setCDKLabelBackgroundAttrib(add_tgt_info, COLOR_DIALOG_TEXT); /* Target name (entry) */ tgt_name = newCDKEntry(add_tgt_screen, (window_x + 1), (window_y + 6), NULL, "</B>Target Name: ", COLOR_DIALOG_SELECT, '_' | COLOR_DIALOG_INPUT, vMIXED, 20, 0, SCST_TGT_NAME_LEN, FALSE, FALSE); if (!tgt_name) { errorDialog(main_cdk_screen, ENTRY_ERR_MSG, NULL); break; } setCDKEntryBoxAttribute(tgt_name, COLOR_DIALOG_INPUT); /* Relative target ID (scale) */ rel_tgt_id = newCDKScale(add_tgt_screen, (window_x + 1), (window_y + 7), NULL, "</B>Relative Target ID: ", COLOR_DIALOG_SELECT, 7, 0, MIN_SCST_REL_TGT_ID, MAX_SCST_REL_TGT_ID, 1, 100, FALSE, FALSE); if (!rel_tgt_id) { errorDialog(main_cdk_screen, SCALE_ERR_MSG, NULL); break; } setCDKScaleBackgroundAttrib(rel_tgt_id, COLOR_DIALOG_TEXT); /* Buttons */ ok_button = newCDKButton(add_tgt_screen, (window_x + 16), (window_y + 9), g_ok_cancel_msg[0], ok_cb, FALSE, FALSE); if (!ok_button) { errorDialog(main_cdk_screen, BUTTON_ERR_MSG, NULL); break; } setCDKButtonBackgroundAttrib(ok_button, COLOR_DIALOG_INPUT); cancel_button = newCDKButton(add_tgt_screen, (window_x + 26), (window_y + 9), g_ok_cancel_msg[1], cancel_cb, FALSE, FALSE); if (!cancel_button) { errorDialog(main_cdk_screen, BUTTON_ERR_MSG, NULL); break; } setCDKButtonBackgroundAttrib(cancel_button, COLOR_DIALOG_INPUT); /* Allow user to traverse the screen */ refreshCDKScreen(add_tgt_screen); traverse_ret = traverseCDKScreen(add_tgt_screen); /* User hit 'OK' button */ if (traverse_ret == 1) { /* Turn the cursor off (pretty) */ curs_set(0); /* Check the entry field for bad characters */ if (!checkInputStr(main_cdk_screen, INIT_CHARS, getCDKEntryValue(tgt_name))) break; /* Add the target to the target group */ snprintf(attr_path, MAX_SYSFS_PATH_SIZE, "%s/device_groups/%s/target_groups/%s/mgmt", SYSFS_SCST_TGT, dev_grp_name, tgt_grp_name); snprintf(attr_value, MAX_SYSFS_ATTR_SIZE, "add %s", getCDKEntryValue(tgt_name)); if ((temp_int = writeAttribute(attr_path, attr_value)) != 0) { SAFE_ASPRINTF(&error_msg, "Couldn't add SCST (ALUA) target to target group: %s", strerror(temp_int)); errorDialog(main_cdk_screen, error_msg, NULL); FREE_NULL(error_msg); break; } /* Set the relative target ID */ snprintf(attr_path, MAX_SYSFS_PATH_SIZE, "%s/device_groups/%s/target_groups/%s/%s/rel_tgt_id", SYSFS_SCST_TGT, dev_grp_name, tgt_grp_name, getCDKEntryValue(tgt_name)); snprintf(attr_value, MAX_SYSFS_ATTR_SIZE, "%d", getCDKScaleValue(rel_tgt_id)); if ((temp_int = writeAttribute(attr_path, attr_value)) != 0) { SAFE_ASPRINTF(&error_msg, SET_REL_TGT_ID_ERR, strerror(temp_int)); errorDialog(main_cdk_screen, error_msg, NULL); FREE_NULL(error_msg); break; } } break; } /* Done */ for (i = 0; i < ADD_TGT_INFO_LINES; i++) FREE_NULL(add_tgt_info_msg[i]); if (add_tgt_screen != NULL) { destroyCDKScreenObjects(add_tgt_screen); destroyCDKScreen(add_tgt_screen); delwin(add_tgt_window); } return; }
void setCDKAlphalistBoxAttribute (CDKALPHALIST *alphalist, chtype character) { setCDKEntryBoxAttribute (alphalist->entryField, character); setCDKScrollBoxAttribute (alphalist->scrollField, character); }