static newtComponent nmt_newt_listbox_build_component (NmtNewtComponent *component, gboolean sensitive) { NmtNewtListboxPrivate *priv = NMT_NEWT_LISTBOX_GET_PRIVATE (component); newtComponent co; int i, active; if (priv->active == -1) update_active_internal (NMT_NEWT_LISTBOX (component), 0); active = priv->active; co = newtListbox (-1, -1, priv->height, convert_flags (priv->flags)); newtComponentAddCallback (co, selection_changed_callback, component); for (i = 0; i < priv->entries->len; i++) { newtListboxAppendEntry (co, priv->entries->pdata[i], GUINT_TO_POINTER (i)); if (active == -1 && priv->keys->pdata[i] == priv->active_key) active = i; } if (active != -1) newtListboxSetCurrent (co, active); return co; }
static void show_spans(void) { newtComponent form; newtComponent quit; newtComponent label; newtComponent sel; struct newtExitStruct es; quit = newtButton(50,14,"Quit"); sel = newtButton(10,14,"Select"); spans = newtListbox(5, 2, 10, NEWT_FLAG_SCROLL); newtListboxSetWidth(spans, 65); label = newtLabel(5,1,"Alarms Span"); newtCenteredWindow(72,18, "DAHDI Telephony Interfaces"); form = newtForm(NULL, NULL, 0); newtFormSetTimer(form, 200); newtFormAddComponents(form, spans, sel, quit, label, NULL); newtComponentAddCallback(spans, sel_callback, NULL); newtFormAddHotKey(form, NEWT_KEY_F1); newtFormAddHotKey(form, NEWT_KEY_F10); for(;;) { /* Wait for user to select something */ do { add_cards(spans); newtFormRun(form, &es); } while(es.reason == NEWT_EXIT_TIMER); switch(es.reason) { case NEWT_EXIT_COMPONENT: if (es.u.co == quit) { /* Quit if appropriate */ newtFormDestroy(form); return; } else if (es.u.co == sel) { show_span(-1); } break; case NEWT_EXIT_HOTKEY: switch(es.u.key) { case NEWT_KEY_F1: show_span(-1); break; case NEWT_KEY_F10: newtFormDestroy(form); return; } break; default: break; } } }
/* only supports up to 50 buttons and entries -- shucks! */ static int mynewtWinEntries(char * title, char * text, int suggestedWidth, int flexDown, int flexUp, int dataWidth, void (*callback_func)(char ** strings), struct newtWinEntry * items, char * button1, ...) { newtComponent buttons[50], result, form, textw; newtGrid grid, buttonBar, subgrid; int numItems; int rc, i; int numButtons; char * buttonName; newtComponent entries[50]; va_list args; textw = newtTextboxReflowed(-1, -1, text, suggestedWidth, flexDown, flexUp, 0); for (numItems = 0; items[numItems].text; numItems++); buttonName = button1, numButtons = 0; va_start(args, button1); while (buttonName) { buttons[numButtons] = newtButton(-1, -1, buttonName); numButtons++; buttonName = va_arg(args, char *); } va_end(args); buttonBar = newtCreateGrid(numButtons, 1); for (i = 0; i < numButtons; i++) { newtGridSetField(buttonBar, i, 0, NEWT_GRID_COMPONENT, buttons[i], i ? 1 : 0, 0, 0, 0, 0, 0); } if (callback_func) { callback_real_function = callback_func; entries[numItems] = NULL; } else callback_real_function = NULL; subgrid = newtCreateGrid(2, numItems); for (i = 0; i < numItems; i++) { newtComponent entr = newtEntry(-1, -1, items[i].value ? *items[i].value : NULL, dataWidth, (const char**)items[i].value, items[i].flags); newtGridSetField(subgrid, 0, i, NEWT_GRID_COMPONENT, newtLabel(-1, -1, items[i].text), 0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0); newtGridSetField(subgrid, 1, i, NEWT_GRID_COMPONENT, entr, 1, 0, 0, 0, 0, 0); if (callback_func) { entries[i] = entr; newtComponentAddCallback(entr, default_callback, entries); } } grid = newtCreateGrid(1, 3); form = newtForm(NULL, 0, 0); newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, textw, 0, 0, 0, 0, NEWT_ANCHOR_LEFT, 0); newtGridSetField(grid, 0, 1, NEWT_GRID_SUBGRID, subgrid, 0, 1, 0, 0, 0, 0); newtGridSetField(grid, 0, 2, NEWT_GRID_SUBGRID, buttonBar, 0, 1, 0, 0, 0, NEWT_GRID_FLAG_GROWX); newtGridAddComponentsToForm(grid, form, 1); newtGridWrappedWindow(grid, title); newtGridFree(grid, 1); result = newtRunForm(form); for (rc = 0; rc < numItems; rc++) *items[rc].value = strdup(*items[rc].value); for (rc = 0; result != buttons[rc] && rc < numButtons; rc++); if (rc == numButtons) rc = 0; /* F12 */ else rc++; newtFormDestroy(form); newtPopWindow(); return rc; }
int handledhcp(void) { char *results[MAX_BOXES]; char enabledresult; char startenabled; struct newtExitStruct es; newtComponent header; newtComponent labels[MAX_BOXES]; newtComponent ok, cancel; char message[1000]; char *labeltexts[MAX_BOXES] = { _("Start address:"), _("End address:"), _("Primary DNS:"), _("Secondary DNS:"), _("Default lease (mins):"), _("Max lease (mins):"), _("Domain name suffix:") }; char *varnames[MAX_BOXES] = { "START_ADDR_GREEN", "END_ADDR_GREEN", "DNS1_GREEN", "DNS2_GREEN", "DEFAULT_LEASE_TIME_GREEN", "MAX_LEASE_TIME_GREEN", "DOMAIN_NAME_GREEN" }; char defaults[MAX_BOXES][STRING_SIZE]; int result; int c; char temp[STRING_SIZE]; struct keyvalue *mainkv = initkeyvalues(); struct keyvalue *dhcpkv = initkeyvalues(); struct keyvalue *ethernetkv = initkeyvalues(); int error; FILE *file; char greenaddress[STRING_SIZE]; char greennetaddress[STRING_SIZE]; char greennetmask[STRING_SIZE]; memset(defaults, 0, sizeof(char) * STRING_SIZE * MAX_BOXES); if (!(readkeyvalues(dhcpkv, CONFIG_ROOT "/dhcp/settings"))) { freekeyvalues(dhcpkv); freekeyvalues(ethernetkv); errorbox(_("Unable to open settings file")); return 0; } if (!(readkeyvalues(ethernetkv, CONFIG_ROOT "/ethernet/settings"))) { freekeyvalues(dhcpkv); freekeyvalues(ethernetkv); errorbox(_("Unable to open settings file")); return 0; } if (!(readkeyvalues(mainkv, CONFIG_ROOT "/main/settings"))) { freekeyvalues(dhcpkv); freekeyvalues(ethernetkv); freekeyvalues(mainkv); errorbox(_("Unable to open settings file")); return 0; } /* Set default values. */ findkey(ethernetkv, "GREEN_ADDRESS", defaults[PRIMARY_DNS]); findkey(mainkv, "DOMAINNAME", defaults[DOMAIN_NAME_SUFFIX]); strcpy(defaults[DEFAULT_LEASE_TIME], "60"); strcpy(defaults[MAX_LEASE_TIME], "120"); newtCenteredWindow(55, 18, _("DHCP server configuration")); dhcpform = newtForm(NULL, NULL, 0); header = newtTextboxReflowed(1, 1, _("Configure the DHCP server by entering the settings information."), 52, 0, 0, 0); newtFormAddComponent(dhcpform, header); strcpy(temp, ""); findkey(dhcpkv, "ENABLE_GREEN", temp); if (strcmp(temp, "on") == 0) startenabled = '*'; else startenabled = ' '; enabledcheckbox = newtCheckbox(2, TOP + 0, _("Enabled"), startenabled, " *", &enabledresult); newtFormAddComponent(dhcpform, enabledcheckbox); newtComponentAddCallback(enabledcheckbox, dhcpdialogcallbackdhcp, NULL); for (c = 0; c < MAX_BOXES; c++) { labels[c] = newtTextbox(2, TOP + 2 + c, 33, 1, 0); newtTextboxSetText(labels[c], labeltexts[c]); newtFormAddComponent(dhcpform, labels[c]); strcpy(temp, defaults[c]); findkey(dhcpkv, varnames[c], temp); entries[c] = newtEntry(34, TOP + 2 + c, temp, 18, &results[c], 0); newtFormAddComponent(dhcpform, entries[c]); if (startenabled == ' ') newtEntrySetFlags(entries[c], NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); } ok = newtButton(10, c + 7, _("OK")); cancel = newtButton(34, c + 7, _("Cancel")); newtFormAddComponents(dhcpform, ok, cancel, NULL); do { error = 0; newtFormRun(dhcpform, &es); if (es.u.co == ok) { /* OK was pressed; verify the contents of each entry. */ if (enabledresult == '*') { strcpy(message, _("The following fields are invalid:\n\n")); if (inet_addr(results[START_ADDRESS]) == INADDR_NONE) { strcat(message, _("Start address")); strcat(message, "\n"); error = 1; } if (inet_addr(results[END_ADDRESS]) == INADDR_NONE) { strcat(message, _("End address")); strcat(message, "\n"); error = 1; } if (strlen(results[SECONDARY_DNS])) { if (inet_addr(results[PRIMARY_DNS]) == INADDR_NONE) { strcat(message, _("Primary DNS")); strcat(message, "\n"); error = 1; } } if (strlen(results[SECONDARY_DNS])) { if (inet_addr(results[SECONDARY_DNS]) == INADDR_NONE) { strcat(message, _("Secondary DNS")); strcat(message, "\n"); error = 1; } } if (!(atol(results[DEFAULT_LEASE_TIME]))) { strcat(message, _("Default lease time")); strcat(message, "\n"); error = 1; } if (!(atol(results[MAX_LEASE_TIME]))) { strcat(message, _("Max. lease time")); strcat(message, "\n"); error = 1; } } if (error) errorbox(message); else { for (c = 0; c < MAX_BOXES; c++) replacekeyvalue(dhcpkv, varnames[c], results[c]); if (enabledresult == '*') { replacekeyvalue(dhcpkv, "ENABLE_GREEN", "on"); fclose(fopen(CONFIG_ROOT "/dhcp/enable_green", "w")); chown(CONFIG_ROOT "/dhcp/enable_green", 99, 99); mysystem(NULL, "/usr/local/bin/dhcpctrl enable"); } else { replacekeyvalue(dhcpkv, "ENABLE_GREEN", "off"); unlink(CONFIG_ROOT "/dhcp/enable_green"); mysystem(NULL, "/usr/local/bin/dhcpctrl disable"); } replacekeyvalue(dhcpkv, "VALID", "yes"); writekeyvalues(dhcpkv, CONFIG_ROOT "/dhcp/settings"); findkey(ethernetkv, "GREEN_ADDRESS", greenaddress); findkey(ethernetkv, "GREEN_NETADDRESS", greennetaddress); findkey(ethernetkv, "GREEN_NETMASK", greennetmask); file = fopen(CONFIG_ROOT "/dhcp/dhcpd.conf", "w"); fprintf(file, "ddns-update-style none;\n"); fprintf(file, "authoritative;\n"); fprintf(file, "subnet %s netmask %s\n", greennetaddress, greennetmask); fprintf(file, "{\n"); fprintf(file, "\toption subnet-mask %s;\n", greennetmask); fprintf(file, "\toption domain-name \"%s\";\n", results[DOMAIN_NAME_SUFFIX]); fprintf(file, "\toption routers %s;\n", greenaddress); if (strlen(results[PRIMARY_DNS])) { fprintf(file, "\toption domain-name-servers "); fprintf(file, "%s", results[PRIMARY_DNS]); if (strlen(results[SECONDARY_DNS])) fprintf(file, ", %s", results[SECONDARY_DNS]); fprintf(file, ";\n"); } fprintf(file, "\trange %s %s;\n", results[START_ADDRESS], results[END_ADDRESS]); fprintf(file, "\tdefault-lease-time %d;\n", (int) atol(results[DEFAULT_LEASE_TIME]) * 60); fprintf(file, "\tmax-lease-time %d;\n", (int) atol(results[MAX_LEASE_TIME]) * 60); fprintf(file, "}\n"); fclose(file); chown(CONFIG_ROOT "/dhcp/dhcpd.conf", 99, 99); if (automode == 0) mysystem(NULL, "/usr/local/bin/dhcpctrl enable"); } result = 1; } else result = 0; } while (error); newtFormDestroy(dhcpform); newtPopWindow(); freekeyvalues(dhcpkv); freekeyvalues(ethernetkv); freekeyvalues(mainkv); return result; }
/* This is a groovie dialog for showing network info. Takes a keyvalue list, * a colour and a dhcp flag. Shows the current settings, and rewrites them * if necessary. DHCP flag sets wether to show the dhcp checkbox. */ int changeaddress(struct keyvalue *kv, char *colour, int typeflag, char *defaultdhcphostname) { char *addressresult; char *netmaskresult; char *dhcphostnameresult; char *dhcpforcemturesult; struct newtExitStruct es; newtComponent header; newtComponent addresslabel; newtComponent netmasklabel; newtComponent dhcphostnamelabel; newtComponent dhcpforcemtulabel; newtComponent ok, cancel; char message[1000]; char temp[STRING_SIZE]; char addressfield[STRING_SIZE]; char netmaskfield[STRING_SIZE]; char typefield[STRING_SIZE]; char dhcphostnamefield[STRING_SIZE]; char dhcpforcemtufield[STRING_SIZE]; int error; int result = 0; char type[STRING_SIZE]; int startstatictype = 0; int startdhcptype = 0; int startpppoetype = 0; /* Build some key strings. */ sprintf(addressfield, "%s_ADDRESS", colour); sprintf(netmaskfield, "%s_NETMASK", colour); sprintf(typefield, "%s_TYPE", colour); sprintf(dhcphostnamefield, "%s_DHCP_HOSTNAME", colour); sprintf(dhcpforcemtufield, "%s_DHCP_FORCE_MTU", colour); sprintf(message, _("Interface - %s"), colour); newtCenteredWindow(44, (typeflag ? 18 : 12), message); networkform = newtForm(NULL, NULL, 0); sprintf(message, _("Enter the IP address information for the %s interface."), colour); header = newtTextboxReflowed(1, 1, message, 42, 0, 0, 0); newtFormAddComponent(networkform, header); /* See if we need a dhcp checkbox. If we do, then we shift the contents * of the window down two rows to make room. */ if (typeflag) { strcpy(temp, "STATIC"); findkey(kv, typefield, temp); if (strcmp(temp, "STATIC") == 0) startstatictype = 1; if (strcmp(temp, "DHCP") == 0) startdhcptype = 1; if (strcmp(temp, "PPPOE") == 0) startpppoetype = 1; statictyperadio = newtRadiobutton(2, 4, _("Static"), startstatictype, NULL); dhcptyperadio = newtRadiobutton(2, 5, _("DHCP"), startdhcptype, statictyperadio); pppoetyperadio = newtRadiobutton(2, 6, _("PPP DIALUP (PPPoE, modem, ATM ...)"), startpppoetype, dhcptyperadio); newtFormAddComponents(networkform, statictyperadio, dhcptyperadio, pppoetyperadio, NULL); newtComponentAddCallback(statictyperadio, networkdialogcallbacktype, NULL); newtComponentAddCallback(dhcptyperadio, networkdialogcallbacktype, NULL); newtComponentAddCallback(pppoetyperadio, networkdialogcallbacktype, NULL); dhcphostnamelabel = newtTextbox(2, 8, 18, 1, 0); newtTextboxSetText(dhcphostnamelabel, _("DHCP Hostname:")); dhcpforcemtulabel = newtTextbox(2, 9, 18, 1, 0); newtTextboxSetText(dhcpforcemtulabel, _("Force DHCP MTU:")); strcpy(temp, defaultdhcphostname); findkey(kv, dhcphostnamefield, temp); dhcphostnameentry = newtEntry(20, 8, temp, 20, &dhcphostnameresult, 0); strcpy(temp, ""); findkey(kv, dhcpforcemtufield, temp); dhcpforcemtuentry = newtEntry(20, 9, temp, 20, &dhcpforcemturesult, 0); newtFormAddComponent(networkform, dhcphostnamelabel); newtFormAddComponent(networkform, dhcphostnameentry); newtFormAddComponent(networkform, dhcpforcemtulabel); newtFormAddComponent(networkform, dhcpforcemtuentry); if (startdhcptype == 0) { newtEntrySetFlags(dhcphostnameentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); newtEntrySetFlags(dhcpforcemtuentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); } } /* Address */ addresslabel = newtTextbox(2, (typeflag ? 11 : 4) + 0, 18, 1, 0); newtTextboxSetText(addresslabel, _("IP address:")); strcpy(temp, ""); findkey(kv, addressfield, temp); addressentry = newtEntry(20, (typeflag ? 11 : 4) + 0, temp, 20, &addressresult, 0); newtEntrySetFilter(addressentry, ip_input_filter, NULL); if (typeflag == 1 && startstatictype == 0) newtEntrySetFlags(addressentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); newtFormAddComponent(networkform, addresslabel); newtFormAddComponent(networkform, addressentry); /* Netmask */ netmasklabel = newtTextbox(2, (typeflag ? 11 : 4) + 1, 18, 1, 0); newtTextboxSetText(netmasklabel, _("Network mask:")); strcpy(temp, "255.255.255.0"); findkey(kv, netmaskfield, temp); netmaskentry = newtEntry(20, (typeflag ? 11 : 4) + 1, temp, 20, &netmaskresult, 0); newtEntrySetFilter(netmaskentry, ip_input_filter, NULL); if (typeflag == 1 && startstatictype == 0) newtEntrySetFlags(netmaskentry, NEWT_FLAG_DISABLED, NEWT_FLAGS_SET); newtFormAddComponent(networkform, netmasklabel); newtFormAddComponent(networkform, netmaskentry); /* Buttons. */ ok = newtButton(8, (typeflag ? 14 : 7), _("OK")); cancel = newtButton(26, (typeflag ? 14 : 7), _("Cancel")); newtFormAddComponents(networkform, ok, cancel, NULL); newtRefresh(); newtDrawForm(networkform); do { error = 0; newtFormRun(networkform, &es); if (es.u.co == ok) { /* OK was pressed; verify the contents of each entry. */ strcpy(message, _("The following fields are invalid:")); strcat(message, "\n\n"); strcpy(type, "STATIC"); if (typeflag) gettype(type); if (strcmp(type, "STATIC") == 0) { if (inet_addr(addressresult) == INADDR_NONE) { strcat(message, _("IP address")); strcat(message, "\n"); error = 1; } if (inet_addr(netmaskresult) == INADDR_NONE) { strcat(message, _("Network mask")); strcat(message, "\n"); error = 1; } } if (strcmp(type, "DHCP") == 0) { if (!strlen(dhcphostnameresult)) { strcat(message, _("DHCP hostname")); strcat(message, "\n"); error = 1; } } if (error) errorbox(message); else { /* No errors! Set new values, depending on dhcp flag etc. */ if (typeflag) { replacekeyvalue(kv, dhcphostnamefield, dhcphostnameresult); replacekeyvalue(kv, dhcpforcemtufield, dhcpforcemturesult); if (strcmp(type, "STATIC") != 0) { replacekeyvalue(kv, addressfield, "0.0.0.0"); replacekeyvalue(kv, netmaskfield, "0.0.0.0"); } else { replacekeyvalue(kv, addressfield, addressresult); replacekeyvalue(kv, netmaskfield, netmaskresult); } replacekeyvalue(kv, typefield, type); } else { replacekeyvalue(kv, addressfield, addressresult); replacekeyvalue(kv, netmaskfield, netmaskresult); } setnetaddress(kv, colour); result = 1; } } /* Workaround for a bug that dhcp radiobutton also end the dialog at arm */ else { if (es.u.co != cancel) { error = 1; } } } while (error); newtFormDestroy(networkform); newtPopWindow(); return result; }
int main(void) { newtComponent b1, b2, r1, r2, r3, e2, e3, l1, l2, l3, scale; newtComponent lb, t, rsf, answer, timeLabel; newtComponent cs[10]; newtComponent f, chklist, e1; struct callbackInfo cbis[3]; char results[10]; char * enr2, * enr3, * scaleVal; void ** selectedList; int i, numsel; char buf[20]; const char * spinner = "-\\|/\\|/"; const char * spinState; struct newtExitStruct es; newtInit(); newtCls(); newtSetSuspendCallback(suspend, NULL); newtSetHelpCallback(helpCallback); newtDrawRootText(0, 0, "Newt test program"); newtPushHelpLine(NULL); newtDrawRootText(-50, 0, "More root text"); newtOpenWindow(2, 2, 30, 10, "first window"); newtOpenWindow(10, 5, 65, 16, "window 2"); f = newtForm(NULL, "This is some help text", 0); chklist = newtForm(NULL, NULL, 0); b1 = newtButton(3, 1, "Exit"); b2 = newtButton(18, 1, "Update"); r1 = newtRadiobutton(20, 10, "Choice 1", 0, NULL); r2 = newtRadiobutton(20, 11, "Chc 2", 1, r1); r3 = newtRadiobutton(20, 12, "Choice 3", 0, r2); rsf = newtForm(NULL, NULL, 0); newtFormAddComponents(rsf, r1, r2, r3, NULL); newtFormSetBackground(rsf, NEWT_COLORSET_CHECKBOX); for (i = 0; i < 10; i++) { sprintf(buf, "Check %d", i); cs[i] = newtCheckbox(3, 10 + i, buf, ' ', NULL, &results[i]); newtFormAddComponent(chklist, cs[i]); } l1 = newtLabel(3, 6, "Scale:"); l2 = newtLabel(3, 7, "Scrolls:"); l3 = newtLabel(3, 8, "Hidden:"); e1 = newtEntry(12, 6, "", 20, &scaleVal, 0); e2 = newtEntry(12, 7, "Default", 20, &enr2, NEWT_FLAG_SCROLL); /* e3 = newtEntry(12, 8, NULL, 20, &enr3, NEWT_FLAG_HIDDEN); */ e3 = newtEntry(12, 8, NULL, 20, &enr3, NEWT_FLAG_PASSWORD); cbis[0].state = &results[0]; cbis[0].en = e1; newtComponentAddCallback(cs[0], disableCallback, &cbis[0]); scale = newtScale(3, 14, 32, 100); newtFormSetHeight(chklist, 3); newtFormAddComponents(f, b1, b2, l1, l2, l3, e1, e2, e3, chklist, NULL); newtFormAddComponents(f, rsf, scale, NULL); lb = newtListbox(45, 1, 6, NEWT_FLAG_MULTIPLE | NEWT_FLAG_BORDER | NEWT_FLAG_SCROLL | NEWT_FLAG_SHOWCURSOR); newtListboxAppendEntry(lb, "First", (void *) 1); newtListboxAppendEntry(lb, "Second", (void *) 2); newtListboxAppendEntry(lb, "Third", (void *) 3); newtListboxAppendEntry(lb, "Fourth", (void *) 4); newtListboxAppendEntry(lb, "Sixth", (void *) 6); newtListboxAppendEntry(lb, "Seventh", (void *) 7); newtListboxAppendEntry(lb, "Eighth", (void *) 8); newtListboxAppendEntry(lb, "Ninth", (void *) 9); newtListboxAppendEntry(lb, "Tenth", (void *) 10); newtListboxInsertEntry(lb, "Fifth", (void *) 5, (void *) 4); newtListboxInsertEntry(lb, "Eleventh", (void *) 11, (void *) 10); newtListboxDeleteEntry(lb, (void *) 11); spinState = spinner; timeLabel = newtLabel(45, 8, "Spinner: -"); t = newtTextbox(45, 10, 17, 5, NEWT_FLAG_WRAP); newtTextboxSetText(t, "This is some text does it look okay?\nThis should be alone.\nThis shouldn't be printed"); newtFormAddComponents(f, lb, timeLabel, t, NULL); newtRefresh(); newtFormSetTimer(f, 200); do { newtFormRun(f, &es); if (es.reason == NEWT_EXIT_COMPONENT && es.u.co == b2) { newtScaleSet(scale, atoi(scaleVal)); newtRefresh(); answer = NULL; } else if (es.reason == NEWT_EXIT_TIMER) { spinState++; if (!*spinState) spinState = spinner; sprintf(buf, "Spinner: %c", *spinState); newtLabelSetText(timeLabel, buf); } } while (es.reason != NEWT_EXIT_COMPONENT || es.u.co == b2); scaleVal = strdup(scaleVal); enr2 = strdup(enr2); enr3 = strdup(enr3); selectedList = newtListboxGetSelection(lb, &numsel); newtFormDestroy(f); newtPopWindow(); newtPopWindow(); newtFinished(); printf("got string 1: %s\n", scaleVal); printf("got string 2: %s\n", enr2); printf("got string 3: %s\n", enr3); if(selectedList) { printf("\nSelected listbox items:\n"); for(i = 0; i < numsel; i++) puts(selectedList[i]); } return 0; }