X-Git-Url: https://harishankar.org/repos/?p=wordblah.git;a=blobdiff_plain;f=wordblox.c;fp=wordblox.c;h=f30c039b24e5161a9b37bbb5e9903a8f2af106c3;hp=0cbb8049841b471e8aea76c67b6baa517e8e0898;hb=8f3a3d44db5d297336dc1138193514c6d79d080e;hpb=d2f6f0eb05c333a2b0991bb7613780aab629460f diff --git a/wordblox.c b/wordblox.c index 0cbb804..f30c039 100644 --- a/wordblox.c +++ b/wordblox.c @@ -70,22 +70,42 @@ void do_reset_puzzle (Puzzle *p) char ch = getchar (); } -/* set the password for the puzzle */ -void do_set_password (Puzzle *p) +/* set the solution password for the puzzle */ +void do_set_solution_password (Puzzle *p) { char* password; password = getpass (INPUT_PASSWORD); /* if empty reset the password to nothing */ if (strlen(password) == 0) { - set_puzzle_password (p, "\0"); - printf (PASSWORD_RESET); + set_solution_password (p, "\0"); + printf (SOLUTION_PASSWORD_RESET); char ch = getchar (); } /* set the password */ else { - set_puzzle_password (p, (const char* )password); + set_solution_password (p, (const char* )password); + printf (PASSWORD_SET); + char ch = getchar (); + } +} +/* set the master (editing) password for the puzzle */ +void do_set_master_password (Puzzle *p) +{ + char* password; + password = getpass (INPUT_PASSWORD); + /* if empty reset the password to nothing */ + if (strlen(password) == 0) + { + set_master_password (p, "\0"); + printf (MASTER_PASSWORD_RESET); + char ch = getchar (); + } + /* set the password */ + else + { + set_master_password (p, (const char* )password); printf (PASSWORD_SET); char ch = getchar (); } @@ -258,7 +278,7 @@ void puzzle_editor_loop (Puzzle *p, const char *filename) { char puzzle_title[60]; sprintf (puzzle_title, "%s - %s", PUZZLE_MENU_TITLE, filename); - print_menu (WHITE, BLUE, puzzle_title, PUZZLE_EDIT_MENU, 14, 50); + print_menu (WHITE, BLUE, puzzle_title, PUZZLE_EDIT_MENU, 15, 50); printf (INPUT_CHOICE); int ch = get_num (); switch (ch) @@ -288,15 +308,17 @@ void puzzle_editor_loop (Puzzle *p, const char *filename) printf ("%s\n",FILE_SAVED); ch = getchar (); break; - case 10: do_set_password (p); + case 10: do_set_master_password (p); + break; + case 11: do_set_solution_password (p); break; - case 11: do_reset_puzzle (p); + case 12: do_reset_puzzle (p); break; - case 12: do_export_puzzle (p); + case 13: do_export_puzzle (p); break; - case 13: do_export_clues (p); + case 14: do_export_clues (p); break; - case 14: loop = ! do_confirm_exit (); + case 15: loop = ! do_confirm_exit (); break; } } @@ -319,14 +341,14 @@ void do_open_puzzle (const char *filename) p = load_puzzle (filename); - if (strcmp (p.hashed_password, "\0") != 0) + if (strcmp (p.hashed_master_password, "\0") != 0) { char *passwd; passwd = getpass (INPUT_PASSWORD); if (strlen (passwd) == 0) return; - if (verify_password (&p, (const char*) passwd)) + if (verify_master_password (&p, (const char*) passwd)) puzzle_editor_loop (&p, filename); else {