/* this configuration deals with the 'naspasswd' file */ #include #include #include #include "radiusconf.h" #include "radiusconf.m" #include "rc_parser.h" #include "rc_tools.h" void edit_naspasswd_entry(VIEWITEMS &given_vitems, int which_one) { DIALOG my_dialog; MENU_STATUS my_button=(MENU_STATUS)0; int my_selection=0; SSTRING dialog_title; /* loads vars.. */ /* builds gui.. */ EASY_STR2(ipdata,0,MSG_U(F_IP,"IP:")); EASY_STR2(logindata,1,MSG_U(F_LOGIN,"Login:")); EASY_STR2(passwddata,2,MSG_U(F_PASSWORD,"Password:")); while(1){ /* opens dialog.. */ dialog_title.setfromf(MSG_U(T_NASPASSWORDENTRYN,"NAS password entry %d"), which_one+1); my_selection=0; my_button=my_dialog.editmenu(dialog_title.get(), "", hf_naspasswd, my_selection, MENUBUT_QUIT|MENUBUT_ACCEPT|MENUBUT_DEL); switch(my_button){ case MENU_QUIT: case MENU_ESCAPE: return; case MENU_ACCEPT: { /* save vars.. */ SSTRING my_line; if((invalid_entry(ipdata.get()))||(invalid_entry(logindata.get()))||(invalid_entry(passwddata.get()))){ informative_window(MSG_U(T_INVALIDENTRY3,"Invalid entry"), MSG_U(E_INVALIDENTRY3,"None of these fields may be left empty\nneither have space characters.")); }else{ my_line.setfromf("%s %s %s", ipdata.get(), logindata.get(), passwddata.get()); given_vitems.getitem(which_one)->line.setfrom(my_line); given_vitems.write(cf_naspasswd, 0); return; } } break; case MENU_DEL: /* remove this entry */ given_vitems.remove_del(which_one); given_vitems.write(cf_naspasswd, 0); return; break; default: break; } } } void show_naspasswd_list(void) { DIALOG_RECORDS my_dialog; MENU_STATUS my_button=(MENU_STATUS)0; int my_selection=0; VIEWITEMS_PARSER my_vitems_parser; VIEWITEMS my_vitems(my_vitems_parser); my_vitems.read(cf_naspasswd); my_dialog.newf_head("", MSG_U(F_IPLOGINNAMEHEAD,"IP\tlogin name")); while(1){ int progressive_counter=0, regressive_counter; SSTRING primary_entry, secondary_entry; /* fills list.. */ regressive_counter=my_vitems.getnb(); while(regressive_counter--){ gimme_word_from_string(my_vitems.getitem(progressive_counter)->line.get(), primary_entry, 0); gimme_word_from_string(my_vitems.getitem(progressive_counter)->line.get(), secondary_entry, 1); my_dialog.set_menuitem(progressive_counter, primary_entry.get(), secondary_entry.get()); progressive_counter++; } // remove entries below (they're the previous ones and useless now) my_dialog.remove_last(progressive_counter+1); my_button=my_dialog.editmenu(MSG_U(T_NASPASSWORDS,"NAS passwords"), MSG_U(I_NASPASSWORDS,"You ONLY need to enter passwords here\nif you use a non-SNMP method to poll\nthe terminal servers,\neg ONLY with USR/3Com Total Control servers!"), hf_general_list, my_selection, MENUBUT_QUIT|MENUBUT_ADD); switch(my_button){ case MENU_QUIT: case MENU_ESCAPE: return; case MENU_ADD: { int how_many; how_many=my_vitems.getnb(); my_vitems.add(new VIEWITEM(MSG_U(X_1234ROOTDEFINEPASSWD, "1.2.3.4 !root define_a_password_here"))); edit_naspasswd_entry(my_vitems, how_many); my_vitems.write(cf_naspasswd, 0); } break; default: edit_naspasswd_entry(my_vitems, my_selection); break; } } }