X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ap-utils.git;a=blobdiff_plain;f=lib%2Fcmd.c;h=8895c7a0a6f9ed166f2d907dd2044469894d92b2;hp=61a553417a24b1ce20f8c77cd7f35b10d94eed80;hb=db905ff22705494136f504425cf0c75bb94cb81c;hpb=09ed626f25fb3e7c57ad7a59e5261ea005aa498f diff --git a/lib/cmd.c b/lib/cmd.c index 61a5534..8895c7a 100644 --- a/lib/cmd.c +++ b/lib/cmd.c @@ -20,9 +20,6 @@ #include #include "ap-utils.h" -#include "ap-curses.h" - -#define ANSW_NO _("(Y - Yes; N - No (it's safer to answer No, unless you really need this.)") extern WINDOW *main_sub; extern short ap_type; @@ -34,37 +31,24 @@ void defaults() 0x01, 0x04, 0x00 }, enable = 1; varbind varbinds[1]; - int i; if (ap_type == ATMEL12350) { sysLoadDefaults[5] = 0xE0; sysLoadDefaults[6] = 0x3E; } - print_title(_("Restore factory default configuration")); + print_top(NULL, _("Restore factory default configuration")); mvwaddstr(main_sub, 3, 2, _ - ("After restoring factory defaults your current configuration.")); + ("After restoring factory defaults your current configuration")); mvwaddstr(main_sub, 4, 2, _("will be lost.")); mvwaddstr(main_sub, 6, 20, _("Do you want to continue? ")); wrefresh(main_sub); - print_help(ANSW_NO); - i = 1; - while (i) - switch (getch()) { - case 'Y': - case 'y': - clear_main(3); - i = 0; - break; - case 'n': - case 'N': - clear_main(3); - goto quit; - } - print_help(WAIT_SET); + if (help_ysn()) + goto quit; + print_help(WAIT_SET); varbinds[0].oid = sysLoadDefaults; varbinds[0].len_oid = sizeof(sysLoadDefaults); @@ -79,32 +63,20 @@ void defaults() ("Factory default settings loaded. Press any key to continue.")); getch(); quit: - print_title(""); + print_top(NULL, NULL); } void reset() { - int i; - print_title(_("Reset Access Point")); + print_top(NULL, _("Reset Access Point")); if(ap_type == ATMEL410) mvwaddstr(main_sub, 3, 5, _("By reset you'll lose all non-uploaded configuration.")); mvwaddstr(main_sub, 5, 20, _("Do you want to continue? ")); wrefresh(main_sub); - print_help(ANSW_NO); - i = 1; - while (i) - switch (getch()) { - case 'Y': - case 'y': - clear_main(3); - i = 0; - break; - case 'n': - case 'N': - clear_main(3); - goto quit; - } + + if (help_ysn()) + goto quit; print_help(WAIT_SET); if (SysReset()) @@ -113,7 +85,7 @@ void reset() print_help(_("Access Point reset. Press any key to continue.")); getch(); quit: - print_title(""); + print_top(NULL, NULL); } int SysUpload() @@ -142,31 +114,18 @@ int SysUpload() void upload() { - int i; - print_title(_("Upload configuration")); + print_top(NULL, _("Upload configuration")); mvwaddstr(main_sub, 3, 2, - _ - ("You need to upload the configuration only if you've changed")); + _("You may need to upload the configuration only if you've")); mvwaddstr(main_sub, 4, 2, - _ - ("some option values before. Using this option may cause loss")); - mvwaddstr(main_sub, 5, 2, _("of your current configuration.")); + _("changed some option values before. Using this option may")); + mvwaddstr(main_sub, 5, 2, + _("cause loss of your current configuration.")); mvwaddstr(main_sub, 7, 20, ("Do you want to continue? ")); wrefresh(main_sub); - print_help(ANSW_NO); - i = 1; - while (i) - switch (getch()) { - case 'Y': - case 'y': - clear_main(3); - i = 0; - break; - case 'n': - case 'N': - clear_main(3); - goto quit; - } + + if (help_ysn()) + goto quit; print_help(WAIT_SET); if (SysUpload()) @@ -176,6 +135,6 @@ void upload() (_("Configuration uploaded. Press any key to continue.")); getch(); quit: - print_title(""); + print_top(NULL, NULL); }