/* if is_new_entry!=0 then the 'del' button is not shown */ /* retuns !=0 if user confirmed, ==0 if cancelled or removed the entry */ int section_edit_ipxdevs_prop(VIEWITEMS &my_vitems, int which_group, int which_item, int is_new_entry) { DIALOG my_dialog; MENU_STATUS my_button=MENU_NULL; int my_selection=0; int illegal_entry_found=1; int did_user_accept; // 0 user cancelled, !=0 user confirmed INIT_PROPERTIES_EDITION; CREATE_STR_FIELD(my_netnumber,0,MSG_U(F_NETNUMBER, "Net number:")); CREATE_CBOX_FIELD(my_device,cb_device,1,MSG_U(F_DEVICE, "Device:")); ADD_LIST_ITEM(cb_device,"*"); ADD_LIST_ITEM(cb_device,"eth0"); ADD_LIST_ITEM(cb_device,"arc0"); ADD_LIST_ITEM(cb_device,"ppp0"); CREATE_CBOX_FIELD(my_frame,cb_frame,2,MSG_U(F_FRAMETYPE, "Frame type:")); ADD_LIST_ITEM(cb_frame,"ETHERNET_II"); ADD_LIST_ITEM(cb_frame,"802.2"); ADD_LIST_ITEM(cb_frame,"802.3"); ADD_LIST_ITEM(cb_frame,"SNAP"); ADD_LIST_ITEM(cb_frame,"TOKEN"); ADD_LIST_ITEM(cb_frame,"AUTO"); CREATE_STR_FIELD(my_ticks,3,MSG_U(F_TICKS, "Ticks (opt.):")); while(illegal_entry_found){ illegal_entry_found=0; if(is_new_entry){ my_button=my_dialog.edit(MSG_U(T_INSERTINGNEWINTERFACE, "Inserting new interface..."), "", hf_ipxdev_props, my_selection, MENUBUT_ACCEPT|MENUBUT_QUIT); }else{ my_button=my_dialog.edit(MSG_U(T_EDITINGINTERFACE, "Editing interface..."), "", hf_ipxdev_props, my_selection, MENUBUT_ACCEPT|MENUBUT_DEL|MENUBUT_QUIT); } did_user_accept=0; switch(my_button){ case MENU_DEL: if(askuser_for_deletion()){ parser_remove_line(my_vitems, which_group, which_item); SAVE_FILE_NWSERVCONF; return(0); } illegal_entry_found=1; break; case MENU_ACCEPT: did_user_accept=1; illegal_entry_found|=replace_word(line_storage, my_netnumber.get(), 0, ILLEGAL_SPACES|ILLEGAL_EMPTYNESS); illegal_entry_found|=replace_word(line_storage, my_device.get(), 1, ILLEGAL_SPACES|ILLEGAL_EMPTYNESS); illegal_entry_found|=replace_word(line_storage, my_frame.get(), 2, ILLEGAL_SPACES|ILLEGAL_EMPTYNESS); illegal_entry_found|=replace_word(line_storage, my_ticks.get(), 3, ILLEGAL_SPACES|DIGITS_ONLY); if(!illegal_entry_found){ CLOSE_PROPERTIES_EDITION; SAVE_FILE_NWSERVCONF; }else{ warnuser_invalid_data_entered(); } break; default: break; } } return(did_user_accept); } void section_edit_ipxdevs(void) { INIT_FILE_NWSERVCONF; DIALOG_RECORDS my_dialog; MENU_STATUS my_button=MENU_NULL; int my_selection=0; int which_group=4; my_dialog.newf_head("", MSG_U(X_NWINTERFACE_FRAMETYPE, "network interface\tframe type")); while(1){ insert_to_dialog_records(my_dialog, my_vitems, which_group, 1, 2); my_selection=0; my_button=my_dialog.editmenu(MSG_U(T_DEFINEDNWINTERFC, "Defined network interfaces"), "", help_nil, my_selection, MENUBUT_QUIT|MENUBUT_ADD); switch(my_button){ case MENU_QUIT: case MENU_ESCAPE: return; case MENU_ADD: /* adds item, but if used does not confirm the properties' window the item is removed */ if(!section_edit_ipxdevs_prop(my_vitems, which_group, parser_add_line(my_vitems, MSG_U(X_NWINTERFACENEWENTRY, "0x0\teth0\tAUTO"), which_group), 1)){ my_vitems.remove_all(); my_vitems.read(cf_nwservconf); } break; default: section_edit_ipxdevs_prop(my_vitems, which_group, my_selection, 0); break; } } }