[1] | 1 | /* newt-specific.c
|
---|
[99] | 2 | $Id: newt-specific.c 3822 2024-03-03 01:44:57Z bruno $
|
---|
[1] | 3 |
|
---|
| 4 | subroutines which do display-type things
|
---|
| 5 | and use the newt library to do them
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | /**
|
---|
| 10 | * @file
|
---|
| 11 | * Functions for doing display-type things with the Newt library.
|
---|
| 12 | */
|
---|
| 13 |
|
---|
| 14 | #define MAX_NEWT_COMMENT_LEN 200
|
---|
| 15 |
|
---|
| 16 | #if __cplusplus
|
---|
| 17 | extern "C" {
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
| 20 | #include "my-stuff.h"
|
---|
[2211] | 21 | #include "mr_mem.h"
|
---|
[3194] | 22 | #include "mr_str.h"
|
---|
[1] | 23 | #include "mondostructures.h"
|
---|
| 24 | #include "newt-specific.h"
|
---|
| 25 | #include "libmondo-string-EXT.h"
|
---|
| 26 | #include "libmondo-files-EXT.h"
|
---|
| 27 | #include "libmondo-devices-EXT.h"
|
---|
| 28 | #include "libmondo-tools-EXT.h"
|
---|
| 29 | #include "libmondo-fork-EXT.h"
|
---|
[541] | 30 | #include "libmondo-gui-EXT.h"
|
---|
| 31 | #include "lib-common-externs.h"
|
---|
[1] | 32 |
|
---|
[1316] | 33 | extern char *MONDO_LOGFILE;
|
---|
| 34 |
|
---|
[1665] | 35 | extern struct s_bkpinfo *bkpinfo;
|
---|
| 36 |
|
---|
[3413] | 37 | extern char *mr_center_string(char *in, int width);
|
---|
| 38 |
|
---|
[1] | 39 | /*@unused@*/
|
---|
[99] | 40 | //static char cvsid[] = "$Id: newt-specific.c 3822 2024-03-03 01:44:57Z bruno $";
|
---|
[1] | 41 |
|
---|
[128] | 42 | extern pid_t g_mastermind_pid;
|
---|
[2030] | 43 | /*
|
---|
[128] | 44 | extern char *g_tmpfs_mountpt;
|
---|
[2030] | 45 | */
|
---|
[128] | 46 | extern char *g_boot_mountpt;
|
---|
[792] | 47 | extern char *ps_options;
|
---|
[928] | 48 | extern char *ps_proc_id;
|
---|
[1] | 49 |
|
---|
[128] | 50 | extern void set_signals(int);
|
---|
[1] | 51 |
|
---|
| 52 | /**
|
---|
| 53 | * @addtogroup globalGroup
|
---|
| 54 | * @{
|
---|
| 55 | */
|
---|
| 56 | /**
|
---|
| 57 | * Whether we are currently in a nested call of fatal_error().
|
---|
| 58 | */
|
---|
[128] | 59 | bool g_exiting = FALSE;
|
---|
[1] | 60 |
|
---|
[3141] | 61 | // Decide whether we should continue to ask questions or exit (cron use case)
|
---|
| 62 | extern bool g_fail_immediately;
|
---|
| 63 |
|
---|
[1] | 64 | /**
|
---|
| 65 | * Padding below the Newt components, to overcome bugs in Newt.
|
---|
| 66 | */
|
---|
[128] | 67 | char g_haharrrrr[500];
|
---|
[1] | 68 |
|
---|
| 69 |
|
---|
[128] | 70 | newtComponent g_timeline = NULL, ///< The line of the progress form that shows the time elapsed/remaining
|
---|
| 71 | g_percentline = NULL, ///< The line of the progress form that shows the percent completed/remaining
|
---|
| 72 | g_scale = NULL, ///< The progress bar component in the progress form
|
---|
| 73 | g_progressForm = NULL, ///< The progress form component itself
|
---|
| 74 | g_blurb1 = NULL, ///< The component for line 1 of the blurb in the progress form
|
---|
| 75 | g_blurb2 = NULL, ///< The component for line 2 of the blurb in the progress form
|
---|
| 76 | g_blurb3 = NULL, ///< The component for line 3 (updated continuously) of the blurb in the progress form
|
---|
| 77 | g_label = NULL; ///< ????? @bug ?????
|
---|
[1] | 78 |
|
---|
| 79 | /**
|
---|
| 80 | * Padding above the Newt components, to overcome bugs in Newt.
|
---|
| 81 | */
|
---|
[128] | 82 | char g_jim_lad_yarr[500];
|
---|
| 83 | char **err_log_lines = NULL, ///< The list of log lines to show on the screen.
|
---|
| 84 | g_blurb_str_1[MAX_NEWT_COMMENT_LEN] = "", ///< The string for line 1 of the blurb in the progress form
|
---|
| 85 | g_blurb_str_2[MAX_NEWT_COMMENT_LEN] = "", ///< The string for line 2 of the blurb in the progress form
|
---|
| 86 | g_blurb_str_3[MAX_NEWT_COMMENT_LEN] = ""; ///< The string for line 3 (updated continuously) of the blurb in the progress form
|
---|
| 87 | newtComponent g_isoform_main = NULL, ///< The evalcall form component itself
|
---|
| 88 | g_isoform_header = NULL, ///< The component for the evalcall form title
|
---|
| 89 | g_isoform_scale = NULL, ///< The progress bar component in the evalcall form
|
---|
| 90 | g_isoform_timeline = NULL, ///< The line of the evalcall form that shows the time elapsed/remaining
|
---|
| 91 | g_isoform_pcline = NULL; ///< The line of the evalcall form that shows the percent completed/remaining
|
---|
| 92 | long g_isoform_starttime; ///< The time (in seconds since the epoch) that the evalcall form was opened.
|
---|
| 93 | int g_isoform_old_progress = -1; ///< The most recent progress update of the evalcall form (percent).
|
---|
| 94 | char g_isoform_header_str[MAX_STR_LEN] = " "; ///< The string for the evalcall form title.
|
---|
| 95 | int g_mysterious_dot_counter; ///< The counter for the twirling baton (/ | \\ - ...) on percentage less than 3
|
---|
| 96 | int g_noof_log_lines = 6; ///< The number of lines to show in the log at the bottom of the screen.
|
---|
| 97 | int g_noof_rows = 25; ///< The number of rows on the screen.
|
---|
[1] | 98 |
|
---|
[128] | 99 | int g_currentY = 3; ///< The row to write background progress messages to. Incremented each time a message is written.
|
---|
| 100 | extern int g_current_media_number;
|
---|
| 101 | pid_t g_main_pid = 0; ///< The PID of the main Mondo process.
|
---|
[3191] | 102 | long g_maximum_progress = 999L; ///< The maximum amount of progress (100%) for the currently opened progress form.
|
---|
[128] | 103 | long g_current_progress = -999; ///< The current amount of progress (filelist #, etc.) for the currently opened progress form.
|
---|
[3191] | 104 | long g_start_time = 0L; ///< The time (in seconds since the epoch) that the progress form was opened.
|
---|
[128] | 105 | bool g_text_mode = TRUE; ///< If FALSE, use a newt interface; if TRUE, use an ugly (but more compatible) dumb terminal interface.
|
---|
[2380] | 106 | char *g_selfmounted_isodir; ///< Holds the NETFS mountpoint if mounted via mondoarchive.
|
---|
[1] | 107 |
|
---|
| 108 | /* @} - end of globalGroup */
|
---|
| 109 |
|
---|
[128] | 110 | void popup_and_OK(char *);
|
---|
[1] | 111 |
|
---|
| 112 |
|
---|
| 113 | /**
|
---|
| 114 | * @addtogroup guiGroup
|
---|
| 115 | * @{
|
---|
| 116 | */
|
---|
| 117 | /**
|
---|
| 118 | * Ask the user a yes/no question.
|
---|
| 119 | * @param prompt The question to ask the user.
|
---|
| 120 | * @return TRUE for yes; FALSE for no.
|
---|
| 121 | */
|
---|
[128] | 122 | bool ask_me_yes_or_no(char *prompt) {
|
---|
[1] | 123 |
|
---|
[128] | 124 | /*@ buffers ********************************************************** */
|
---|
[3191] | 125 | int i = 0;
|
---|
| 126 | char *tmp = NULL;
|
---|
[1] | 127 |
|
---|
[3141] | 128 | assert_string_is_neither_NULL_nor_zerolength(prompt);
|
---|
[1] | 129 |
|
---|
[3141] | 130 | if (g_fail_immediately) {
|
---|
| 131 | // We consider the user aborted by using the -F option
|
---|
| 132 | log_msg(3, "Exiting at first interaction request due to -F");
|
---|
| 133 | finish(1);
|
---|
| 134 | }
|
---|
[128] | 135 | if (g_text_mode) {
|
---|
| 136 | while (1) {
|
---|
[3191] | 137 | sync();
|
---|
| 138 | printf("---promptdialogYN---1--- %s\n---promptdialogYN---Q--- [yes] [no] ---\n--> ", prompt);
|
---|
| 139 | mr_getline(tmp, stdin);
|
---|
[128] | 140 | if (tmp[strlen(tmp) - 1] == '\n')
|
---|
| 141 | tmp[strlen(tmp) - 1] = '\0';
|
---|
[1] | 142 |
|
---|
[128] | 143 | i = (int) strlen(tmp);
|
---|
| 144 | if (i > 0 && tmp[i - 1] < 32) {
|
---|
| 145 | tmp[i - 1] = '\0';
|
---|
| 146 | }
|
---|
[541] | 147 | if (strstr("yesYES", tmp)) {
|
---|
[3191] | 148 | mr_free(tmp);
|
---|
[128] | 149 | return (TRUE);
|
---|
[541] | 150 | } else if (strstr("NOno", tmp)) {
|
---|
[3191] | 151 | mr_free(tmp);
|
---|
[128] | 152 | return (FALSE);
|
---|
| 153 | } else {
|
---|
[3191] | 154 | sync();
|
---|
| 155 | printf("Please enter either YES or NO (or yes or no, or y or n, or...)\n");
|
---|
[128] | 156 | }
|
---|
| 157 | }
|
---|
| 158 | } else {
|
---|
[541] | 159 | return (popup_with_buttons(prompt, "Yes", "No"));
|
---|
[128] | 160 | }
|
---|
| 161 | }
|
---|
[1] | 162 |
|
---|
| 163 |
|
---|
| 164 | /**
|
---|
| 165 | * Give the user the opportunity to continue the current operation (OK)
|
---|
| 166 | * or cancel it (Cancel).
|
---|
| 167 | * @param prompt The string to be displayed.
|
---|
| 168 | * @return TRUE for OK, FALSE for Cancel.
|
---|
| 169 | */
|
---|
[128] | 170 | bool ask_me_OK_or_cancel(char *prompt) {
|
---|
[1] | 171 |
|
---|
[128] | 172 | /*@ buffer *********************************************************** */
|
---|
[3191] | 173 | char *tmp = NULL;
|
---|
[128] | 174 | int i;
|
---|
[1] | 175 |
|
---|
[3141] | 176 | assert_string_is_neither_NULL_nor_zerolength(prompt);
|
---|
| 177 | if (g_fail_immediately) {
|
---|
| 178 | // We consider the user aborted by using the -F option
|
---|
| 179 | log_msg(3, "Exiting at first interaction request due to -F");
|
---|
| 180 | finish(1);
|
---|
| 181 | }
|
---|
[3191] | 182 |
|
---|
[128] | 183 | if (g_text_mode) {
|
---|
[3191] | 184 | sync();
|
---|
| 185 | printf("---promptdialogOKC---1--- %s\n---promptdialogOKC---Q--- [OK] [Cancel] ---\n--> ", prompt);
|
---|
| 186 | mr_getline(tmp, stdin);
|
---|
[128] | 187 | if (tmp[strlen(tmp) - 1] == '\n')
|
---|
| 188 | tmp[strlen(tmp) - 1] = '\0';
|
---|
[1] | 189 |
|
---|
[128] | 190 | i = (int) strlen(tmp);
|
---|
| 191 | if (i > 0 && tmp[i - 1] < 32) {
|
---|
| 192 | tmp[i - 1] = '\0';
|
---|
| 193 | }
|
---|
[541] | 194 | if (strstr("okOKOkYESyes", tmp)) {
|
---|
[3191] | 195 | mr_free(tmp);
|
---|
[128] | 196 | return (TRUE);
|
---|
| 197 | } else {
|
---|
[3191] | 198 | mr_free(tmp);
|
---|
[128] | 199 | return (FALSE);
|
---|
| 200 | }
|
---|
| 201 | } else {
|
---|
[541] | 202 | return (popup_with_buttons(prompt, " Okay ", "Cancel"));
|
---|
[128] | 203 | }
|
---|
[1] | 204 | }
|
---|
| 205 |
|
---|
| 206 |
|
---|
| 207 |
|
---|
| 208 | /**
|
---|
| 209 | * Close the currently opened evalcall form.
|
---|
| 210 | */
|
---|
[128] | 211 | void
|
---|
| 212 | close_evalcall_form(void) {
|
---|
| 213 | if (g_text_mode) {
|
---|
| 214 | return;
|
---|
| 215 | }
|
---|
| 216 | if (g_isoform_main == NULL) {
|
---|
| 217 | return;
|
---|
| 218 | }
|
---|
| 219 | update_evalcall_form(100);
|
---|
| 220 | usleep(500000);
|
---|
| 221 | if (g_text_mode) {
|
---|
| 222 | log_msg(2, "Closing evalcall form");
|
---|
| 223 | return;
|
---|
| 224 | }
|
---|
| 225 | newtPopHelpLine();
|
---|
| 226 | newtFormDestroy(g_isoform_main);
|
---|
| 227 | newtPopWindow();
|
---|
[2290] | 228 |
|
---|
| 229 | /* Reset globals */
|
---|
[128] | 230 | g_isoform_main = NULL;
|
---|
| 231 | g_isoform_old_progress = -1;
|
---|
[2290] | 232 | g_isoform_header = NULL;
|
---|
| 233 | g_isoform_scale = NULL;
|
---|
| 234 | g_isoform_timeline = NULL;
|
---|
| 235 | g_isoform_pcline = NULL;
|
---|
| 236 | }
|
---|
[1] | 237 |
|
---|
| 238 | /**
|
---|
| 239 | * Close the currently opened progress form.
|
---|
| 240 | */
|
---|
[128] | 241 | void
|
---|
| 242 | close_progress_form() {
|
---|
| 243 | if (g_text_mode) {
|
---|
| 244 | return;
|
---|
| 245 | }
|
---|
| 246 | if (g_current_progress == -999) {
|
---|
[3191] | 247 | log_msg(2, "Trying to close the progress form when it ain't open!");
|
---|
[128] | 248 | return;
|
---|
| 249 | }
|
---|
| 250 | g_current_progress = g_maximum_progress;
|
---|
| 251 | update_progress_form("Complete");
|
---|
| 252 | sleep(1);
|
---|
| 253 | if (g_text_mode) {
|
---|
| 254 | log_msg(2, "Closing progress form");
|
---|
| 255 | return;
|
---|
| 256 | }
|
---|
| 257 | newtPopHelpLine();
|
---|
| 258 | newtFormDestroy(g_progressForm);
|
---|
| 259 | newtPopWindow();
|
---|
[2290] | 260 |
|
---|
| 261 | /* Reset globals */
|
---|
[128] | 262 | g_progressForm = NULL;
|
---|
| 263 | g_current_progress = -999;
|
---|
[2290] | 264 | g_timeline = NULL;
|
---|
| 265 | g_percentline = NULL;
|
---|
| 266 | g_scale = NULL;
|
---|
| 267 |
|
---|
[128] | 268 | }
|
---|
[1] | 269 |
|
---|
[792] | 270 | /**
|
---|
| 271 | * Kill any process containing the string @p str surrounded by spaces in its commandline.
|
---|
| 272 | */
|
---|
| 273 | void kill_anything_like_this(char *str) {
|
---|
[1] | 274 |
|
---|
[792] | 275 | char *tmp = NULL;
|
---|
[1850] | 276 | char *tmp1 = NULL;
|
---|
[1] | 277 |
|
---|
[3185] | 278 | mr_asprintf(tmp,"ps %s | grep \" %s \" | grep -v \"grep\" | awk '{print %s;}'", ps_options, str , ps_proc_id);
|
---|
[1294] | 279 | run_program_and_log_output(tmp, TRUE);
|
---|
[1850] | 280 | if (strlen(tmp) > 0) {
|
---|
[3185] | 281 | mr_asprintf(tmp1,"kill `%s`", tmp);
|
---|
[1850] | 282 | run_program_and_log_output(tmp1, TRUE);
|
---|
[3191] | 283 | mr_free(tmp1);
|
---|
[1850] | 284 | }
|
---|
[3191] | 285 | mr_free(tmp);
|
---|
[792] | 286 | }
|
---|
[1] | 287 |
|
---|
[792] | 288 |
|
---|
[1] | 289 | /**
|
---|
| 290 | * Exit Mondo with a fatal error.
|
---|
| 291 | * @param error_string The error message to present to the user before exiting.
|
---|
| 292 | * @note This function never returns.
|
---|
| 293 | */
|
---|
[3191] | 294 | void fatal_error(char *error_string) {
|
---|
| 295 |
|
---|
[128] | 296 | /*@ buffers ***************************************************** */
|
---|
[3191] | 297 | char *command = NULL;
|
---|
[128] | 298 | static bool already_exiting = FALSE;
|
---|
[1] | 299 |
|
---|
[128] | 300 | /*@ end vars **************************************************** */
|
---|
[1] | 301 |
|
---|
[128] | 302 | set_signals(FALSE); // link to external func
|
---|
| 303 | g_exiting = TRUE;
|
---|
| 304 | log_msg(1, "Fatal error received - '%s'", error_string);
|
---|
| 305 | printf("Fatal error... %s\n", error_string);
|
---|
| 306 | if (getpid() == g_mastermind_pid) {
|
---|
| 307 | log_msg(2, "mastermind %d is exiting", (int) getpid());
|
---|
| 308 | kill(g_main_pid, SIGTERM);
|
---|
| 309 | finish(1);
|
---|
| 310 | }
|
---|
[1] | 311 |
|
---|
[128] | 312 | if (getpid() != g_main_pid) {
|
---|
| 313 | if (g_mastermind_pid != 0 && getpid() != g_mastermind_pid) {
|
---|
| 314 | log_msg(2, "non-m/m %d is exiting", (int) getpid());
|
---|
| 315 | kill(g_main_pid, SIGTERM);
|
---|
| 316 | finish(1);
|
---|
| 317 | }
|
---|
| 318 | }
|
---|
[1] | 319 |
|
---|
[128] | 320 | log_msg(3, "OK, I think I'm the main PID.");
|
---|
| 321 | if (already_exiting) {
|
---|
| 322 | log_msg(3, "...I'm already exiting. Give me time, Julian!");
|
---|
| 323 | finish(1);
|
---|
| 324 | }
|
---|
[1] | 325 |
|
---|
[128] | 326 | already_exiting = TRUE;
|
---|
| 327 | log_msg(2, "I'm going to do some cleaning up now.");
|
---|
| 328 | paranoid_system("killall mindi 2> /dev/null");
|
---|
| 329 | kill_anything_like_this("/mondo/do-not");
|
---|
[3154] | 330 | kill_anything_like_this("mondo.tmp");
|
---|
[296] | 331 | kill_anything_like_this("ntfsclone");
|
---|
[128] | 332 | sync();
|
---|
[1] | 333 |
|
---|
[3060] | 334 | if (chdir("/")) {
|
---|
| 335 | // FIXME
|
---|
| 336 | }
|
---|
[128] | 337 | if (g_selfmounted_isodir) {
|
---|
[3191] | 338 | mr_asprintf(command, "umount -d %s", g_selfmounted_isodir);
|
---|
[128] | 339 | run_program_and_log_output(command, 5);
|
---|
[3191] | 340 | mr_free(command);
|
---|
| 341 | mr_asprintf(command, "rmdir %s", g_selfmounted_isodir);
|
---|
[128] | 342 | run_program_and_log_output(command, 5);
|
---|
[3191] | 343 | mr_free(command);
|
---|
[128] | 344 | }
|
---|
[99] | 345 |
|
---|
[128] | 346 | if (!g_text_mode) {
|
---|
[3191] | 347 | log_msg(0, "-------FATAL ERROR---------");
|
---|
[128] | 348 | log_msg(0, error_string);
|
---|
| 349 | }
|
---|
[1] | 350 |
|
---|
[128] | 351 | printf("---FATALERROR--- %s\n", error_string);
|
---|
[3191] | 352 | printf("If you require technical support, please contact the mailing list.\n");
|
---|
[541] | 353 | printf("See http://www.mondorescue.org for details.\n");
|
---|
[3191] | 354 | printf("The list's members can help you, if you attach that file to your e-mail.\n");
|
---|
[541] | 355 | printf("Log file: %s\n", MONDO_LOGFILE);
|
---|
| 356 | printf("Mondo has aborted.\n");
|
---|
[128] | 357 | if (!g_main_pid) {
|
---|
| 358 | log_msg(3, "FYI - g_main_pid is blank");
|
---|
| 359 | }
|
---|
| 360 | finish(254);
|
---|
| 361 | }
|
---|
[1] | 362 |
|
---|
[2241] | 363 | /* Free memory allocated for newt */
|
---|
| 364 | void free_newt_stuff() {
|
---|
[1] | 365 |
|
---|
[2241] | 366 | int i;
|
---|
[1] | 367 |
|
---|
[3508] | 368 | if (err_log_lines == NULL) {
|
---|
| 369 | return;
|
---|
| 370 | }
|
---|
| 371 |
|
---|
[2241] | 372 | for (i = 0; i < g_noof_log_lines; i++) {
|
---|
| 373 | mr_free(err_log_lines[i]);
|
---|
| 374 | }
|
---|
| 375 | mr_free(err_log_lines);
|
---|
| 376 | }
|
---|
| 377 |
|
---|
| 378 |
|
---|
| 379 |
|
---|
[1] | 380 | /**
|
---|
| 381 | * Exit Mondo normally.
|
---|
| 382 | * @param signal The exit code (0 indicates a successful backup; 1 for Mondo means the
|
---|
| 383 | * user aborted; 254 means a fatal error occured).
|
---|
| 384 | * @note This function never returns.
|
---|
| 385 | */
|
---|
[3191] | 386 | void finish(int signal) {
|
---|
| 387 |
|
---|
[1708] | 388 | char *command = NULL;
|
---|
[1] | 389 |
|
---|
[2910] | 390 | /* Before removing dir, make sure we're out of them */
|
---|
[3060] | 391 | if (chdir("/tmp")) {
|
---|
| 392 | // FIXME
|
---|
| 393 | }
|
---|
[2878] | 394 | run_program_and_log_output("umount -d " MNT_CDROM, FALSE);
|
---|
[128] | 395 | if (g_selfmounted_isodir) {
|
---|
[3185] | 396 | mr_asprintf(command, "umount -d %s", g_selfmounted_isodir);
|
---|
[128] | 397 | run_program_and_log_output(command, 1);
|
---|
[3191] | 398 | mr_free(command);
|
---|
| 399 |
|
---|
[3185] | 400 | mr_asprintf(command, "rmdir %s", g_selfmounted_isodir);
|
---|
[128] | 401 | run_program_and_log_output(command, 1);
|
---|
[3191] | 402 | mr_free(command);
|
---|
[128] | 403 | }
|
---|
[2241] | 404 | if (bkpinfo->tmpdir) {
|
---|
| 405 | log_msg(8,"tempdir is %s",bkpinfo->tmpdir);
|
---|
| 406 | if (strstr(bkpinfo->tmpdir ,"mondo.tmp.") != NULL) {
|
---|
[2907] | 407 | log_msg(8,"erasing tempdir %s",bkpinfo->tmpdir);
|
---|
[3185] | 408 | mr_asprintf(command, "rm -Rf %s", bkpinfo->tmpdir);
|
---|
[3060] | 409 | paranoid_system(command);
|
---|
[2697] | 410 | mr_free(command);
|
---|
[2241] | 411 | }
|
---|
[1999] | 412 | }
|
---|
[2241] | 413 | if (bkpinfo->scratchdir) {
|
---|
| 414 | log_msg(8,"scratchdir is %s", bkpinfo->scratchdir);
|
---|
| 415 | if (strstr(bkpinfo->scratchdir ,"mondo.scratch.") != NULL) {
|
---|
[2907] | 416 | log_msg(8,"erasing scratchdir %s",bkpinfo->scratchdir);
|
---|
[3185] | 417 | mr_asprintf(command, "rm -Rf %s", bkpinfo->scratchdir);
|
---|
[3060] | 418 | paranoid_system(command);
|
---|
[2697] | 419 | mr_free(command);
|
---|
[2241] | 420 | }
|
---|
| 421 | }
|
---|
| 422 | /* Free all allocated strings in bkpinfo */
|
---|
[2380] | 423 | mr_free(bkpinfo->netfs_user);
|
---|
| 424 | mr_free(bkpinfo->netfs_proto);
|
---|
[3208] | 425 | mr_free(bkpinfo->netfs_remote_dir);
|
---|
[2424] | 426 | mr_free(bkpinfo->exclude_devs);
|
---|
[2697] | 427 | mr_free(bkpinfo->exclude_paths);
|
---|
[3292] | 428 | mr_free(bkpinfo->include_paths);
|
---|
[2769] | 429 | mr_free(bkpinfo->subdir);
|
---|
[3821] | 430 | mr_free(bkpinfo->image_devs);
|
---|
[3822] | 431 | mr_free(bkpinfo->media_device);
|
---|
[2241] | 432 | /* Then free the structure */
|
---|
[1703] | 433 | paranoid_free(bkpinfo);
|
---|
[3191] | 434 |
|
---|
[128] | 435 | free_libmondo_global_strings();
|
---|
[2241] | 436 | free_newt_stuff();
|
---|
[3191] | 437 | if (!g_text_mode) {
|
---|
| 438 | if (does_file_exist("/THIS-IS-A-RAMDISK")) {
|
---|
| 439 | log_msg(1, "Calling newtFinished()");
|
---|
| 440 | newtFinished();
|
---|
| 441 | } else {
|
---|
| 442 | log_msg(1, "Calling newtSuspend()");
|
---|
| 443 | newtSuspend();
|
---|
| 444 | }
|
---|
| 445 | }
|
---|
| 446 | printf("Execution run ended; result=%d\n", signal);
|
---|
| 447 | printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE);
|
---|
[128] | 448 | exit(signal);
|
---|
| 449 | }
|
---|
[1] | 450 |
|
---|
| 451 |
|
---|
| 452 | /**
|
---|
| 453 | * Log the last @p g_noof_log_lines lines of @p filename that match @p
|
---|
| 454 | * grep_for_me to the screen.
|
---|
| 455 | * @param filename The file to give the end of.
|
---|
| 456 | * @param grep_for_me If not "", then only give lines in @p filename that match this regular expression.
|
---|
| 457 | */
|
---|
[3191] | 458 | void log_file_end_to_screen(char *filename, char *grep_for_me) {
|
---|
[1] | 459 |
|
---|
[128] | 460 | /*@ buffers ********************************************************** */
|
---|
[2700] | 461 | char *command = NULL;
|
---|
| 462 | char *tmp = NULL;
|
---|
[3060] | 463 | char *p = NULL;
|
---|
[1] | 464 |
|
---|
[128] | 465 | /*@ pointers ********************************************************* */
|
---|
| 466 | FILE *fin;
|
---|
[1] | 467 |
|
---|
[128] | 468 | /*@ int ************************************************************** */
|
---|
| 469 | int i = 0;
|
---|
[1] | 470 |
|
---|
[128] | 471 | assert_string_is_neither_NULL_nor_zerolength(filename);
|
---|
| 472 | assert(grep_for_me != NULL);
|
---|
[1] | 473 |
|
---|
[128] | 474 | if (!does_file_exist(filename)) {
|
---|
| 475 | return;
|
---|
[1] | 476 | }
|
---|
[128] | 477 | if (grep_for_me[0] != '\0') {
|
---|
[3191] | 478 | mr_asprintf(command, "grep '%s' %s | tail -n%d", grep_for_me, filename, g_noof_log_lines);
|
---|
[128] | 479 | } else {
|
---|
[3191] | 480 | mr_asprintf(command, "tail -n%d %s", g_noof_log_lines, filename);
|
---|
[1] | 481 | }
|
---|
[128] | 482 | fin = popen(command, "r");
|
---|
| 483 | if (!fin) {
|
---|
| 484 | log_OS_error(command);
|
---|
| 485 | } else {
|
---|
| 486 | for (i = 0; i < g_noof_log_lines; i++) {
|
---|
| 487 | for (err_log_lines[i][0] = '\0';
|
---|
| 488 | strlen(err_log_lines[i]) < 2 && !feof(fin);) {
|
---|
[3060] | 489 | p = fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN, fin);
|
---|
| 490 | if (!p) {
|
---|
| 491 | // FIXME
|
---|
| 492 | }
|
---|
[1274] | 493 | /* Commented to make valgrind happy and avoid crash
|
---|
[128] | 494 | strip_spaces(err_log_lines[i]);
|
---|
[1274] | 495 | */
|
---|
[128] | 496 | if (!strncmp(err_log_lines[i], "root:", 5)) {
|
---|
[3185] | 497 | mr_asprintf(tmp, "%s", err_log_lines[i] + 6);
|
---|
[2700] | 498 | strncpy(err_log_lines[i], tmp, (size_t)MAX_NEWT_COMMENT_LEN);
|
---|
| 499 | mr_free(tmp);
|
---|
[128] | 500 | }
|
---|
| 501 | if (feof(fin)) {
|
---|
| 502 | break;
|
---|
| 503 | }
|
---|
| 504 | }
|
---|
| 505 | }
|
---|
| 506 | paranoid_pclose(fin);
|
---|
| 507 | }
|
---|
[2700] | 508 | mr_free(command);
|
---|
[128] | 509 | refresh_log_screen();
|
---|
[1] | 510 | }
|
---|
| 511 |
|
---|
| 512 |
|
---|
| 513 | /**
|
---|
| 514 | * Log a message to the screen.
|
---|
| 515 | * @param fmt A printf-style format string to write. The following parameters are its arguments.
|
---|
| 516 | * @note The message is also written to the logfile.
|
---|
| 517 | */
|
---|
[3191] | 518 | void log_to_screen(const char *fmt, ...) {
|
---|
[1] | 519 |
|
---|
[128] | 520 | /*@ int ************************************************************** */
|
---|
| 521 | int i = 0;
|
---|
| 522 | int j = 0;
|
---|
| 523 | va_list args;
|
---|
[1] | 524 |
|
---|
[128] | 525 | /*@ buffers ********************************************************** */
|
---|
| 526 | char *output;
|
---|
[1] | 527 |
|
---|
[128] | 528 | malloc_string(output);
|
---|
[1] | 529 |
|
---|
[128] | 530 | va_start(args, fmt);
|
---|
[2700] | 531 | vsnprintf(output, MAX_STR_LEN-1, fmt, args);
|
---|
[128] | 532 | log_msg(0, output);
|
---|
| 533 | output[80] = '\0';
|
---|
| 534 | va_end(args);
|
---|
| 535 | i = (int) strlen(output);
|
---|
| 536 | if (i > 0 && output[i - 1] < 32) {
|
---|
| 537 | output[i - 1] = '\0';
|
---|
| 538 | }
|
---|
[1] | 539 |
|
---|
[128] | 540 | if (err_log_lines) {
|
---|
| 541 | for (i = 1; i < g_noof_log_lines; i++) {
|
---|
| 542 | strcpy(err_log_lines[i - 1],
|
---|
| 543 | " ");
|
---|
| 544 | strcpy(err_log_lines[i - 1], err_log_lines[i]);
|
---|
| 545 | }
|
---|
| 546 | }
|
---|
| 547 | while (strlen(output) > 0 && output[strlen(output) - 1] < 32) {
|
---|
| 548 | output[strlen(output) - 1] = '\0';
|
---|
| 549 | }
|
---|
| 550 | for (j = 0; j < (int) strlen(output); j++) {
|
---|
| 551 | if (output[j] < 32) {
|
---|
| 552 | output[j] = ' ';
|
---|
| 553 | }
|
---|
| 554 | }
|
---|
| 555 | if (err_log_lines)
|
---|
| 556 | strcpy(err_log_lines[g_noof_log_lines - 1], output);
|
---|
| 557 | if (g_text_mode) {
|
---|
| 558 | printf("%s\n", output);
|
---|
| 559 | } else {
|
---|
| 560 | refresh_log_screen();
|
---|
| 561 | }
|
---|
| 562 | paranoid_free(output);
|
---|
[1] | 563 | }
|
---|
| 564 |
|
---|
| 565 |
|
---|
| 566 |
|
---|
| 567 |
|
---|
| 568 | /**
|
---|
| 569 | * Write a string to the root window at (@p x, @p y) and also to the logfile.
|
---|
| 570 | * @param y The row to write the string to.
|
---|
| 571 | * @param x The column to write the string to.
|
---|
| 572 | * @param output The string to write.
|
---|
| 573 | */
|
---|
[3191] | 574 | void mvaddstr_and_log_it(int y, int x, char *output) {
|
---|
| 575 |
|
---|
[128] | 576 | assert_string_is_neither_NULL_nor_zerolength(output);
|
---|
| 577 | log_msg(0, output);
|
---|
| 578 | if (g_text_mode) {
|
---|
| 579 | printf("%s\n", output);
|
---|
| 580 | } else {
|
---|
| 581 | newtDrawRootText(x, y, output);
|
---|
| 582 | newtRefresh();
|
---|
| 583 | }
|
---|
| 584 | }
|
---|
[1] | 585 |
|
---|
| 586 |
|
---|
| 587 |
|
---|
| 588 |
|
---|
| 589 | /**
|
---|
| 590 | * Open an evalcall form with title @p ttl.
|
---|
| 591 | * @param ttl The title to use for the evalcall form.
|
---|
| 592 | */
|
---|
[3191] | 593 | void open_evalcall_form(char *ttl) {
|
---|
[1] | 594 |
|
---|
[128] | 595 | /*@ buffers ********************************************************* */
|
---|
[3191] | 596 | char *tmp = NULL;
|
---|
[1] | 597 |
|
---|
[128] | 598 | /*@ initialize ****************************************************** */
|
---|
| 599 | g_isoform_old_progress = -1;
|
---|
| 600 | g_mysterious_dot_counter = 0;
|
---|
[1] | 601 |
|
---|
[128] | 602 | assert(ttl != NULL);
|
---|
[3191] | 603 | malloc_string(tmp);
|
---|
| 604 | strcpy(g_isoform_header_str, ttl);
|
---|
[128] | 605 | if (g_text_mode) {
|
---|
[3191] | 606 | log_msg(0, ttl);
|
---|
[128] | 607 | } else {
|
---|
[3191] | 608 | strcpy(tmp, ttl);
|
---|
[128] | 609 | center_string(tmp, 80);
|
---|
| 610 | newtPushHelpLine(tmp);
|
---|
| 611 | }
|
---|
| 612 | center_string(g_isoform_header_str, 36);
|
---|
| 613 | g_isoform_starttime = get_time();
|
---|
| 614 | if (g_text_mode) {
|
---|
| 615 | log_msg(0, g_isoform_header_str);
|
---|
| 616 | } else {
|
---|
| 617 | g_isoform_header = newtLabel(1, 1, g_isoform_header_str);
|
---|
| 618 | g_isoform_scale = newtScale(3, 3, 34, 100);
|
---|
[3191] | 619 | newtCenteredWindow(40, 7, ttl);
|
---|
[3292] | 620 | if (g_isoform_main != NULL) {
|
---|
| 621 | newtFormDestroy(g_isoform_main);
|
---|
| 622 | }
|
---|
[128] | 623 | g_isoform_main = newtForm(NULL, NULL, 0);
|
---|
[2881] | 624 | g_isoform_timeline = newtLabel(1, 5, " ");
|
---|
| 625 | g_isoform_pcline = newtLabel(1, 6, " ");
|
---|
[128] | 626 | newtFormAddComponents(g_isoform_main, g_isoform_timeline,
|
---|
| 627 | g_isoform_pcline, g_isoform_header,
|
---|
| 628 | g_isoform_scale, NULL);
|
---|
[2879] | 629 | newtDrawForm(g_isoform_main);
|
---|
[128] | 630 | newtRefresh();
|
---|
| 631 | }
|
---|
| 632 | update_evalcall_form(0);
|
---|
| 633 | paranoid_free(tmp);
|
---|
| 634 | }
|
---|
[1] | 635 |
|
---|
| 636 |
|
---|
| 637 |
|
---|
| 638 | /**
|
---|
| 639 | * Open a progress form with title @p title.
|
---|
| 640 | * @param title The title to use for the progress form (will be put in the title bar on Newt).
|
---|
| 641 | * @param b1 The first line of the blurb; generally static.
|
---|
| 642 | * @param b2 The second line of the blurb; generally static.
|
---|
| 643 | * @param b3 The third line of the blurb; generally dynamic (it is passed
|
---|
| 644 | * to update_evalcall_form() every time).
|
---|
| 645 | * @param max_val The maximum amount of progress (number of filesets, etc.)
|
---|
| 646 | */
|
---|
[3191] | 647 | void open_progress_form(char *title, char *b1, char *b2, char *b3, long max_val) {
|
---|
[1] | 648 |
|
---|
[128] | 649 | /*@ buffers ********************************************************* */
|
---|
| 650 | char *b1c;
|
---|
[3191] | 651 | char *blurb1 = NULL;
|
---|
| 652 | char *blurb2 = NULL;
|
---|
| 653 | char *blurb3 = NULL;
|
---|
[1] | 654 |
|
---|
[128] | 655 | /*@ initialize ****************************************************** */
|
---|
| 656 | g_mysterious_dot_counter = 0;
|
---|
[1] | 657 |
|
---|
[128] | 658 | malloc_string(b1c);
|
---|
[1] | 659 |
|
---|
[128] | 660 | assert(title != NULL);
|
---|
| 661 | assert(b1 != NULL);
|
---|
| 662 | assert(b2 != NULL);
|
---|
| 663 | assert(b3 != NULL);
|
---|
[1] | 664 |
|
---|
[3235] | 665 | malloc_string(blurb1);
|
---|
| 666 | malloc_string(blurb2);
|
---|
| 667 | malloc_string(blurb3);
|
---|
| 668 | strcpy(blurb1, b1);
|
---|
| 669 | strcpy(blurb2, b2);
|
---|
| 670 | strcpy(blurb3, b3);
|
---|
[3191] | 671 |
|
---|
[128] | 672 | strcpy(b1c, b1);
|
---|
| 673 | center_string(b1c, 80);
|
---|
| 674 | if (max_val <= 0) {
|
---|
| 675 | max_val = 1;
|
---|
| 676 | }
|
---|
[1] | 677 |
|
---|
[128] | 678 | g_start_time = get_time();
|
---|
| 679 | g_maximum_progress = max_val;
|
---|
| 680 | g_current_progress = 0;
|
---|
| 681 | strcpy(g_blurb_str_1, blurb1);
|
---|
| 682 | strcpy(g_blurb_str_2, blurb3);
|
---|
| 683 | strcpy(g_blurb_str_3, blurb2);
|
---|
| 684 | if (g_text_mode) {
|
---|
| 685 | log_msg(0, blurb1);
|
---|
| 686 | log_msg(0, blurb2);
|
---|
| 687 | log_msg(0, blurb3);
|
---|
| 688 | } else {
|
---|
| 689 | g_blurb1 = newtLabel(2, 1, blurb1);
|
---|
| 690 | g_blurb2 = newtLabel(2, 2, blurb3);
|
---|
| 691 | g_blurb3 = newtLabel(2, 4, blurb2);
|
---|
| 692 | newtCenteredWindow(60, 11, title);
|
---|
[3191] | 693 | g_scale = newtScale(3, 6, 54, (long long)g_maximum_progress);
|
---|
[128] | 694 | g_progressForm = newtForm(NULL, NULL, 0);
|
---|
[2886] | 695 | g_percentline = newtLabel(10, 9, " ");
|
---|
| 696 | g_timeline = newtLabel(10, 8, " ");
|
---|
[3191] | 697 | newtFormAddComponents(g_progressForm, g_percentline, g_timeline, g_scale, g_blurb1, g_blurb3, g_blurb2, NULL);
|
---|
[128] | 698 | newtPushHelpLine(b1c);
|
---|
[2879] | 699 | newtDrawForm(g_progressForm);
|
---|
[128] | 700 | newtRefresh();
|
---|
| 701 | }
|
---|
| 702 | update_progress_form_full(blurb1, blurb2, blurb3);
|
---|
| 703 | paranoid_free(b1c);
|
---|
[3235] | 704 | paranoid_free(blurb1);
|
---|
| 705 | paranoid_free(blurb2);
|
---|
| 706 | paranoid_free(blurb3);
|
---|
[128] | 707 | }
|
---|
| 708 |
|
---|
[1] | 709 | /**
|
---|
| 710 | * Give a message to the user in the form of a dialog box (under Newt).
|
---|
| 711 | * @param prompt The message.
|
---|
| 712 | */
|
---|
[3191] | 713 | void popup_and_OK(char *prompt) {
|
---|
| 714 |
|
---|
[128] | 715 | char ch;
|
---|
[1] | 716 |
|
---|
[128] | 717 | assert_string_is_neither_NULL_nor_zerolength(prompt);
|
---|
[1] | 718 |
|
---|
[128] | 719 | log_msg(0, prompt);
|
---|
| 720 | if (g_text_mode) {
|
---|
[3191] | 721 | printf("---promptpopup---1--- %s\n---promptpopup---Q--- [OK] ---\n--> ", prompt);
|
---|
[128] | 722 | while (((ch = getchar()) != '\n') && (ch != EOF));
|
---|
| 723 | } else {
|
---|
[541] | 724 | (void) popup_with_buttons(prompt, " OK ", "");
|
---|
[128] | 725 | }
|
---|
| 726 | }
|
---|
[1] | 727 |
|
---|
| 728 | /**
|
---|
| 729 | * Ask the user to enter a value.
|
---|
| 730 | * @param title The title of the dialog box.
|
---|
| 731 | * @param b The blurb (e.g. what you want the user to enter).
|
---|
[3377] | 732 | * @param input The string to initialize the user's answer with.
|
---|
| 733 | * @return value needs to be freed up by caller
|
---|
| 734 | */
|
---|
| 735 | char *mr_popup_and_get_string(char *title, char *b, char *input) {
|
---|
| 736 |
|
---|
| 737 | /*@ newt ************************************************************ */
|
---|
| 738 | newtComponent myForm;
|
---|
| 739 | newtComponent b_1;
|
---|
| 740 | newtComponent b_2;
|
---|
| 741 | newtComponent b_res;
|
---|
| 742 | newtComponent text;
|
---|
| 743 | newtComponent type_here;
|
---|
| 744 |
|
---|
| 745 | char *entry_value = NULL;
|
---|
| 746 | char *blurb = NULL;
|
---|
| 747 | char *out = NULL;
|
---|
| 748 |
|
---|
| 749 | assert_string_is_neither_NULL_nor_zerolength(title);
|
---|
| 750 | assert(b != NULL);
|
---|
| 751 |
|
---|
| 752 | if (g_text_mode) {
|
---|
| 753 | printf("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q---\n--> ", title, b);
|
---|
| 754 | mr_getline(out, stdin);
|
---|
| 755 | if (out[strlen(out) - 1] == '\n')
|
---|
| 756 | out[strlen(out) - 1] = '\0';
|
---|
| 757 | return(out);
|
---|
| 758 | }
|
---|
| 759 |
|
---|
| 760 | assert(input != NULL);
|
---|
| 761 | text = newtTextboxReflowed(2, 1, b, 48, 5, 5, 0);
|
---|
| 762 | type_here = newtEntry(2, newtTextboxGetNumLines(text) + 2, input, 50, (void *) &entry_value, NEWT_FLAG_RETURNEXIT);
|
---|
| 763 | b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, " OK ");
|
---|
| 764 | b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, "Cancel");
|
---|
| 765 | newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title);
|
---|
| 766 | myForm = newtForm(NULL, NULL, 0);
|
---|
| 767 | newtFormAddComponents(myForm, text, type_here, b_1, b_2, NULL);
|
---|
| 768 | blurb = mr_center_string(b, 80);
|
---|
| 769 | newtPushHelpLine(blurb);
|
---|
| 770 | b_res = newtRunForm(myForm);
|
---|
| 771 |
|
---|
[3618] | 772 | if (b_res != b_2) {
|
---|
| 773 | /* We need to copy the value as newtFormDestroy will clear entry_value */
|
---|
| 774 | mr_asprintf(out, "%s", entry_value);
|
---|
| 775 | }
|
---|
[3377] | 776 | newtPopHelpLine();
|
---|
| 777 | newtFormDestroy(myForm);
|
---|
| 778 | newtPopWindow();
|
---|
| 779 | mr_free(blurb);
|
---|
| 780 |
|
---|
| 781 | return(out);
|
---|
| 782 | }
|
---|
| 783 |
|
---|
| 784 | /**
|
---|
| 785 | * Ask the user to enter a value.
|
---|
| 786 | * @param title The title of the dialog box.
|
---|
| 787 | * @param b The blurb (e.g. what you want the user to enter).
|
---|
[1] | 788 | * @param output The string to put the user's answer in.
|
---|
| 789 | * @param maxsize The size in bytes allocated to @p output.
|
---|
| 790 | * @return TRUE if the user pressed OK, FALSE if they pressed Cancel.
|
---|
| 791 | */
|
---|
[3191] | 792 | bool popup_and_get_string(char *title, char *b, char *output, int maxsize) {
|
---|
[1] | 793 |
|
---|
[128] | 794 | /*@ newt ************************************************************ */
|
---|
| 795 | newtComponent myForm;
|
---|
| 796 | newtComponent b_1;
|
---|
| 797 | newtComponent b_2;
|
---|
| 798 | newtComponent b_res;
|
---|
| 799 | newtComponent text;
|
---|
| 800 | newtComponent type_here;
|
---|
[1] | 801 |
|
---|
[128] | 802 | /*@ pointers ********************************************************* */
|
---|
| 803 | char *entry_value;
|
---|
[1] | 804 |
|
---|
[128] | 805 | /*@ buffers ********************************************************** */
|
---|
[3191] | 806 | char *blurb = NULL;
|
---|
[3060] | 807 | char *p;
|
---|
[3191] | 808 | char *original_contents = NULL;
|
---|
[1] | 809 |
|
---|
[128] | 810 | assert_string_is_neither_NULL_nor_zerolength(title);
|
---|
| 811 | assert(b != NULL);
|
---|
| 812 | assert(output != NULL);
|
---|
[1] | 813 |
|
---|
[128] | 814 | if (g_text_mode) {
|
---|
[3191] | 815 | printf("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q---\n--> ", title, b);
|
---|
[3060] | 816 | p = fgets(output, maxsize, stdin);
|
---|
| 817 | if (!p) {
|
---|
| 818 | // FIXME
|
---|
| 819 | }
|
---|
[128] | 820 | if (output[strlen(output) - 1] == '\n')
|
---|
| 821 | output[strlen(output) - 1] = '\0';
|
---|
| 822 | return (TRUE);
|
---|
| 823 | }
|
---|
[3191] | 824 |
|
---|
| 825 | blurb = malloc(MAX_NEWT_COMMENT_LEN);
|
---|
[128] | 826 | strcpy(blurb, b);
|
---|
| 827 | text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0);
|
---|
[3191] | 828 | mr_asprintf(original_contents, "%s", output);
|
---|
[128] | 829 | output[0] = '\0';
|
---|
[3191] | 830 | type_here = newtEntry(2, newtTextboxGetNumLines(text) + 2, original_contents, 50,
|
---|
[1] | 831 | #ifdef __cplusplus
|
---|
[128] | 832 | 0, NEWT_FLAG_RETURNEXIT
|
---|
[1] | 833 | #else
|
---|
[128] | 834 | (void *) &entry_value, NEWT_FLAG_RETURNEXIT
|
---|
[1] | 835 | #endif
|
---|
[128] | 836 | );
|
---|
[541] | 837 | b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, " OK ");
|
---|
| 838 | b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, "Cancel");
|
---|
[128] | 839 | newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title);
|
---|
| 840 | myForm = newtForm(NULL, NULL, 0);
|
---|
| 841 | newtFormAddComponents(myForm, text, type_here, b_1, b_2, NULL);
|
---|
| 842 | center_string(blurb, 80);
|
---|
| 843 | newtPushHelpLine(blurb);
|
---|
| 844 | b_res = newtRunForm(myForm);
|
---|
| 845 | strcpy(output, entry_value);
|
---|
| 846 | newtPopHelpLine();
|
---|
| 847 | newtFormDestroy(myForm);
|
---|
| 848 | newtPopWindow();
|
---|
[3191] | 849 | paranoid_free(blurb);
|
---|
| 850 |
|
---|
[128] | 851 | if (b_res == b_2) {
|
---|
| 852 | strcpy(output, original_contents);
|
---|
[3191] | 853 | mr_free(original_contents);
|
---|
[128] | 854 | return (FALSE);
|
---|
| 855 | } else {
|
---|
[3191] | 856 | mr_free(original_contents);
|
---|
[128] | 857 | return (TRUE);
|
---|
| 858 | }
|
---|
| 859 | }
|
---|
[1] | 860 |
|
---|
| 861 |
|
---|
| 862 | /**
|
---|
| 863 | * Pop up a dialog box with user-defined buttons.
|
---|
| 864 | * @param p The text to put in the dialog box.
|
---|
| 865 | * @param button1 The label on the first button.
|
---|
| 866 | * @param button2 The label on the second button, or "" if you only want one button.
|
---|
| 867 | * @return TRUE if @p button1 was pushed, FALSE otherwise.
|
---|
| 868 | */
|
---|
[3191] | 869 | bool popup_with_buttons(char *p, char *button1, char *button2) {
|
---|
[1] | 870 |
|
---|
[128] | 871 | /*@ buffers *********************************************************** */
|
---|
[3191] | 872 | char *prompt = NULL;
|
---|
[1] | 873 |
|
---|
[128] | 874 | /*@ newt ************************************************************** */
|
---|
| 875 | newtComponent myForm;
|
---|
| 876 | newtComponent b_1;
|
---|
| 877 | newtComponent b_2;
|
---|
| 878 | newtComponent b_res;
|
---|
| 879 | newtComponent text;
|
---|
[1] | 880 |
|
---|
[128] | 881 | assert_string_is_neither_NULL_nor_zerolength(p);
|
---|
| 882 | assert(button1 != NULL);
|
---|
| 883 | assert(button2 != NULL);
|
---|
| 884 | if (g_text_mode) {
|
---|
| 885 | if (strlen(button2) == 0) {
|
---|
| 886 | printf("%s (%s) --> ", p, button1);
|
---|
| 887 | } else {
|
---|
| 888 | printf("%s (%s or %s) --> ", p, button1, button2);
|
---|
| 889 | }
|
---|
[3191] | 890 | mr_getline(prompt, stdin);
|
---|
| 891 | while (strcmp(prompt, button1) && (strlen(button2) == 0 || strcmp(prompt, button2))) {
|
---|
[128] | 892 | printf("--> ");
|
---|
[3191] | 893 | mr_free(prompt);
|
---|
| 894 | mr_getline(prompt, stdin);
|
---|
[128] | 895 | }
|
---|
[2136] | 896 | if (!strcmp(prompt, button1)) {
|
---|
[3191] | 897 | mr_free(prompt);
|
---|
[128] | 898 | return (TRUE);
|
---|
| 899 | } else {
|
---|
[3191] | 900 | mr_free(prompt);
|
---|
[128] | 901 | return (FALSE);
|
---|
| 902 | }
|
---|
| 903 | }
|
---|
[1] | 904 |
|
---|
[3191] | 905 | prompt = malloc(MAX_NEWT_COMMENT_LEN);
|
---|
[877] | 906 | strncpy(prompt, p, MAX_NEWT_COMMENT_LEN - 1);
|
---|
[883] | 907 | prompt[MAX_NEWT_COMMENT_LEN - 1] = '\0';
|
---|
[128] | 908 | text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0);
|
---|
[3191] | 909 | b_1 = newtButton(20 - ((button2[0] != '\0') ? strlen(button1) + 2 : strlen(button1) / 2), newtTextboxGetNumLines(text) + 3, button1);
|
---|
[128] | 910 | if (button2[0] != '\0') {
|
---|
[3191] | 911 | b_2 = newtButton(24, newtTextboxGetNumLines(text) + 3, button2);
|
---|
[128] | 912 | } else {
|
---|
| 913 | b_2 = NULL;
|
---|
| 914 | }
|
---|
[541] | 915 | newtCenteredWindow(46, newtTextboxGetNumLines(text) + 7, "Alert");
|
---|
[128] | 916 | myForm = newtForm(NULL, NULL, 0);
|
---|
| 917 | newtFormAddComponents(myForm, text, b_1, b_2, NULL);
|
---|
| 918 | center_string(prompt, 80);
|
---|
| 919 | newtPushHelpLine(prompt);
|
---|
| 920 | b_res = newtRunForm(myForm);
|
---|
| 921 | newtPopHelpLine();
|
---|
| 922 | newtFormDestroy(myForm);
|
---|
| 923 | newtPopWindow();
|
---|
| 924 | if (b_res == b_1) {
|
---|
| 925 | paranoid_free(prompt);
|
---|
| 926 | return (TRUE);
|
---|
| 927 | } else {
|
---|
| 928 | paranoid_free(prompt);
|
---|
| 929 | return (FALSE);
|
---|
| 930 | }
|
---|
| 931 | }
|
---|
[1] | 932 |
|
---|
| 933 |
|
---|
| 934 |
|
---|
[128] | 935 |
|
---|
[1] | 936 | /**
|
---|
| 937 | * Synchronize the log messages stored in @p err_log_lines with those shown
|
---|
| 938 | * on the screen.
|
---|
| 939 | */
|
---|
[3191] | 940 | void refresh_log_screen() {
|
---|
[1] | 941 |
|
---|
[128] | 942 | /*@ int *********************************************************** */
|
---|
| 943 | int i = 0;
|
---|
[1] | 944 |
|
---|
| 945 |
|
---|
[128] | 946 | if (g_text_mode || !err_log_lines) {
|
---|
| 947 | return;
|
---|
| 948 | }
|
---|
| 949 | for (i = g_noof_log_lines - 1; i >= 0; i--) {
|
---|
| 950 | newtDrawRootText(0, i + g_noof_rows - 1 - g_noof_log_lines,
|
---|
| 951 | " ");
|
---|
| 952 | }
|
---|
| 953 | newtRefresh();
|
---|
| 954 | for (i = g_noof_log_lines - 1; i >= 0; i--) {
|
---|
| 955 | err_log_lines[i][79] = '\0';
|
---|
| 956 | newtDrawRootText(0, i + g_noof_rows - 1 - g_noof_log_lines,
|
---|
| 957 | err_log_lines[i]);
|
---|
| 958 | }
|
---|
| 959 | newtRefresh();
|
---|
| 960 | }
|
---|
[1] | 961 |
|
---|
| 962 |
|
---|
| 963 | /**
|
---|
| 964 | * Set up the Newt graphical environment. If @p g_text_mode is TRUE, then
|
---|
| 965 | * only allocate some memory.
|
---|
| 966 | */
|
---|
[3191] | 967 | void setup_newt_stuff() {
|
---|
[1] | 968 |
|
---|
[128] | 969 | /*@ int *********************************************************** */
|
---|
| 970 | int i = 0;
|
---|
| 971 | int cols;
|
---|
[1] | 972 |
|
---|
[128] | 973 | if (!g_text_mode) {
|
---|
| 974 | newtInit();
|
---|
| 975 | newtCls();
|
---|
[3191] | 976 | newtPushHelpLine("Welcome to Mondo Rescue, by Dev Team and the Internet. All rights reversed.");
|
---|
[128] | 977 | newtDrawRootText(18, 0, WELCOME_STRING);
|
---|
| 978 | newtRefresh();
|
---|
| 979 | newtGetScreenSize(&cols, &g_noof_rows);
|
---|
| 980 | g_noof_log_lines = (g_noof_rows / 5) + 1;
|
---|
| 981 | }
|
---|
[1] | 982 |
|
---|
[3191] | 983 | err_log_lines = (char **) mr_malloc(sizeof(char *) * g_noof_log_lines);
|
---|
[1] | 984 |
|
---|
[128] | 985 | for (i = 0; i < g_noof_log_lines; i++) {
|
---|
[3191] | 986 | err_log_lines[i] = (char *) mr_malloc(MAX_NEWT_COMMENT_LEN);
|
---|
[128] | 987 | }
|
---|
[1] | 988 |
|
---|
[128] | 989 | for (i = 0; i < g_noof_log_lines; i++) {
|
---|
| 990 | err_log_lines[i][0] = '\0';
|
---|
| 991 | }
|
---|
| 992 | }
|
---|
[1] | 993 |
|
---|
| 994 |
|
---|
| 995 | /**
|
---|
| 996 | * Update the evalcall form to show (<tt>num</tt>/<tt>denom</tt>)*100 %.
|
---|
| 997 | * @param num The numerator of the ratio.
|
---|
| 998 | * @param denom The denomenator of the ratio.
|
---|
| 999 | */
|
---|
[3191] | 1000 | void update_evalcall_form_ratio(int num, int denom) {
|
---|
[1] | 1001 |
|
---|
[128] | 1002 | /*@ long ************************************************************ */
|
---|
[3191] | 1003 | long current_time = 0L;
|
---|
| 1004 | long time_taken = 0L;
|
---|
| 1005 | long time_total_est = 0L;
|
---|
| 1006 | long time_remaining = 0L;
|
---|
[1] | 1007 |
|
---|
[128] | 1008 | /*@ buffers ********************************************************** */
|
---|
[3191] | 1009 | char *timeline_str = NULL;
|
---|
[2211] | 1010 | char *pcline_str = NULL;
|
---|
| 1011 | char *taskprogress = NULL;
|
---|
[1] | 1012 |
|
---|
[128] | 1013 | /*@ int ************************************************************** */
|
---|
| 1014 | int percentage = 0;
|
---|
| 1015 | int i = 0;
|
---|
| 1016 | int j = 0;
|
---|
[1] | 1017 |
|
---|
[128] | 1018 | if (num * 100 < denom) {
|
---|
| 1019 | percentage = 1;
|
---|
| 1020 | } else {
|
---|
| 1021 | percentage = (num * 100 + denom / 2) / denom;
|
---|
| 1022 | }
|
---|
| 1023 |
|
---|
| 1024 | current_time = get_time();
|
---|
| 1025 | time_taken = current_time - g_isoform_starttime;
|
---|
| 1026 | if (num) {
|
---|
| 1027 | time_total_est = time_taken * denom / num;
|
---|
| 1028 | time_remaining = time_total_est - time_taken;
|
---|
| 1029 | } else {
|
---|
[3191] | 1030 | time_remaining = 0L;
|
---|
[128] | 1031 | }
|
---|
| 1032 | if (!g_text_mode) {
|
---|
[1899] | 1033 | if (g_isoform_header) {
|
---|
| 1034 | newtLabelSetText(g_isoform_header, g_isoform_header_str);
|
---|
| 1035 | }
|
---|
[128] | 1036 | }
|
---|
| 1037 | g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27;
|
---|
[3205] | 1038 | if ((percentage < 3 && g_isoform_old_progress < 3) || percentage > g_isoform_old_progress) {
|
---|
[128] | 1039 | g_isoform_old_progress = percentage;
|
---|
[3191] | 1040 | mr_asprintf(timeline_str, "%2ld:%02ld taken %2ld:%02ld remaining", (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60);
|
---|
[128] | 1041 | if (percentage < 3) {
|
---|
[3185] | 1042 | mr_asprintf(pcline_str, " Working");
|
---|
[128] | 1043 | for (j = 0; j < g_mysterious_dot_counter; j++) {
|
---|
[2211] | 1044 | mr_strcat(pcline_str, ".");
|
---|
[128] | 1045 | }
|
---|
| 1046 | for (; j < 27; j++) {
|
---|
[2211] | 1047 | mr_strcat(pcline_str, " ");
|
---|
[128] | 1048 | }
|
---|
[2211] | 1049 | mr_strcat(pcline_str, " %c", special_dot_char(g_mysterious_dot_counter));
|
---|
[128] | 1050 | } else {
|
---|
[3191] | 1051 | mr_asprintf(pcline_str, " %3d%% done %3d%% to go", percentage, 100 - percentage);
|
---|
[128] | 1052 | }
|
---|
| 1053 | if (g_text_mode) {
|
---|
[3185] | 1054 | mr_asprintf(taskprogress, "TASK: [");
|
---|
[128] | 1055 | for (i = 0; i < percentage; i += 5) {
|
---|
[2211] | 1056 | mr_strcat(taskprogress, "*");
|
---|
[128] | 1057 | }
|
---|
| 1058 | for (; i < 100; i += 5) {
|
---|
[2211] | 1059 | mr_strcat(taskprogress, ".");
|
---|
[128] | 1060 | }
|
---|
| 1061 | if (percentage >= 3) {
|
---|
[3191] | 1062 | mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage, (long) time_remaining / 60, (long) time_remaining % 60);
|
---|
| 1063 | printf("---evalcall---1--- %s\n", g_isoform_header_str);
|
---|
[1899] | 1064 | printf("---evalcall---2--- %s\n", taskprogress);
|
---|
| 1065 | printf("---evalcall---E---\n");
|
---|
[128] | 1066 | }
|
---|
[3191] | 1067 | mr_free(taskprogress);
|
---|
[128] | 1068 | } else {
|
---|
[3191] | 1069 | newtScaleSet(g_isoform_scale, (unsigned long long) percentage);
|
---|
[1899] | 1070 | if (g_isoform_pcline) {
|
---|
| 1071 | newtLabelSetText(g_isoform_pcline, pcline_str);
|
---|
| 1072 | }
|
---|
| 1073 | if ((percentage >= 3) && (g_isoform_timeline)) {
|
---|
[128] | 1074 | newtLabelSetText(g_isoform_timeline, timeline_str);
|
---|
| 1075 | }
|
---|
| 1076 | }
|
---|
[3191] | 1077 | mr_free(pcline_str);
|
---|
| 1078 | mr_free(timeline_str);
|
---|
[128] | 1079 | }
|
---|
| 1080 | if (!g_text_mode) {
|
---|
[2879] | 1081 | newtDrawForm(g_isoform_main);
|
---|
[128] | 1082 | newtRefresh();
|
---|
| 1083 | }
|
---|
[1] | 1084 | }
|
---|
| 1085 |
|
---|
| 1086 |
|
---|
| 1087 |
|
---|
| 1088 | /**
|
---|
| 1089 | * Update the evalcall form to show @p curr %.
|
---|
| 1090 | * @param curr The current amount of progress (percentage) in the evalcall form.
|
---|
| 1091 | */
|
---|
[3191] | 1092 | void update_evalcall_form(int curr) {
|
---|
| 1093 |
|
---|
[128] | 1094 | update_evalcall_form_ratio(curr, 100);
|
---|
[3191] | 1095 | }
|
---|
[1] | 1096 |
|
---|
| 1097 |
|
---|
| 1098 |
|
---|
| 1099 | /**
|
---|
| 1100 | * Update the progress form to show @p blurb3 and the current value of
|
---|
| 1101 | * @p g_maximum_progress.
|
---|
| 1102 | * @param blurb3 The new third line of the blurb; use @p g_blurb_str_2 (no, that's not a typo) to keep it the same.
|
---|
| 1103 | */
|
---|
[3191] | 1104 | void update_progress_form(char *blurb3) {
|
---|
| 1105 |
|
---|
[128] | 1106 | if (g_current_progress == -999) {
|
---|
| 1107 | return;
|
---|
| 1108 | }
|
---|
| 1109 | strcpy(g_blurb_str_2, blurb3);
|
---|
[3191] | 1110 | update_progress_form_full(g_blurb_str_1, g_blurb_str_2, g_blurb_str_3);
|
---|
| 1111 | }
|
---|
[1] | 1112 |
|
---|
| 1113 |
|
---|
| 1114 | /**
|
---|
| 1115 | * Update the progress form's complete blurb and show @p g_current_progress.
|
---|
| 1116 | * @param blurb1 The first line of the blurb. Use @p g_blurb_str_1 to keep it unchanged.
|
---|
| 1117 | * @param blurb2 The second line of the blurb. Use @p g_blurb_str_3 (no, that's not a typo) to keep it the same.
|
---|
| 1118 | * @param blurb3 The third line of the blurb. Use @p g_blurb_str_2 (no, that's not a typo either) to keep it the same.
|
---|
| 1119 | */
|
---|
[3191] | 1120 | void update_progress_form_full(char *blurb1, char *blurb2, char *blurb3) {
|
---|
| 1121 |
|
---|
[128] | 1122 | /*@ long ***************************************************** */
|
---|
[2374] | 1123 | long current_time = 0L;
|
---|
| 1124 | long time_taken = 0L;
|
---|
| 1125 | long time_remaining = 0L;
|
---|
| 1126 | long time_total_est = 0L;
|
---|
[1] | 1127 |
|
---|
[128] | 1128 | /*@ int ******************************************************* */
|
---|
| 1129 | int percentage = 0;
|
---|
| 1130 | int i = 0;
|
---|
[1] | 1131 |
|
---|
[128] | 1132 | /*@ buffers *************************************************** */
|
---|
[3191] | 1133 | char *percentline_str = NULL;
|
---|
| 1134 | char *timeline_str = NULL;
|
---|
[2211] | 1135 | char *taskprogress = NULL;
|
---|
[1] | 1136 |
|
---|
[128] | 1137 | if (!g_text_mode) {
|
---|
| 1138 | assert(blurb1 != NULL);
|
---|
| 1139 | assert(blurb2 != NULL);
|
---|
| 1140 | assert(blurb3 != NULL);
|
---|
| 1141 | assert(g_timeline != NULL);
|
---|
| 1142 | }
|
---|
[1] | 1143 |
|
---|
[128] | 1144 | current_time = get_time();
|
---|
| 1145 | time_taken = current_time - g_start_time;
|
---|
| 1146 | if (g_maximum_progress == 0) {
|
---|
| 1147 | percentage = 0;
|
---|
| 1148 | } else {
|
---|
| 1149 | if (g_current_progress > g_maximum_progress) {
|
---|
[3191] | 1150 | log_msg(0, "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld", blurb1, blurb2, blurb3, g_current_progress, g_maximum_progress);
|
---|
[128] | 1151 | g_current_progress = g_maximum_progress;
|
---|
| 1152 | }
|
---|
[3191] | 1153 | percentage = (int) ((g_current_progress * 100L) / g_maximum_progress);
|
---|
[128] | 1154 | }
|
---|
| 1155 | if (percentage < 1) {
|
---|
| 1156 | percentage = 1;
|
---|
| 1157 | }
|
---|
| 1158 | if (percentage > 100) {
|
---|
| 1159 | percentage = 100;
|
---|
| 1160 | }
|
---|
| 1161 | if (g_current_progress) {
|
---|
[3191] | 1162 | time_total_est = time_taken * (long) g_maximum_progress / (long) g_current_progress;
|
---|
[128] | 1163 | time_remaining = time_total_est - time_taken;
|
---|
| 1164 | } else {
|
---|
[2374] | 1165 | time_remaining = 0L;
|
---|
[128] | 1166 | }
|
---|
| 1167 | g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27;
|
---|
| 1168 | if (g_text_mode) {
|
---|
[1899] | 1169 | printf("---progress-form---1--- %s\n", blurb1);
|
---|
| 1170 | printf("---progress-form---2--- %s\n", blurb2);
|
---|
| 1171 | printf("---progress-form---3--- %s\n", blurb3);
|
---|
[541] | 1172 | printf("---progress-form---E---\n");
|
---|
[3185] | 1173 | mr_asprintf(taskprogress, "TASK: [");
|
---|
[128] | 1174 | for (i = 0; i < percentage; i += 5) {
|
---|
[2211] | 1175 | mr_strcat(taskprogress, "*");
|
---|
[128] | 1176 | }
|
---|
| 1177 | for (; i < 100; i += 5) {
|
---|
[2211] | 1178 | mr_strcat(taskprogress, ".");
|
---|
[128] | 1179 | }
|
---|
| 1180 | if (percentage > 100) {
|
---|
[541] | 1181 | log_msg(2, "percentage = %d", percentage);
|
---|
[128] | 1182 | }
|
---|
[3191] | 1183 | mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage, (long) time_remaining / 60, (long) time_remaining % 60);
|
---|
[1899] | 1184 | printf("---progress-form---4--- %s\n", taskprogress);
|
---|
[2211] | 1185 | paranoid_free(taskprogress);
|
---|
[128] | 1186 | } else {
|
---|
[3191] | 1187 | mr_asprintf(timeline_str, "%2ld:%02ld taken %2ld:%02ld remaining ", (long) time_taken / 60, (long) time_taken % 60, (long) time_remaining / 60, (long) time_remaining % 60);
|
---|
| 1188 | mr_asprintf(percentline_str, " %3d%% done %3d%% to go", percentage, 100 - percentage);
|
---|
| 1189 |
|
---|
[128] | 1190 | center_string(blurb1, 54);
|
---|
| 1191 | center_string(blurb2, 54);
|
---|
| 1192 | center_string(blurb3, 54);
|
---|
[1899] | 1193 | if (g_blurb1) {
|
---|
| 1194 | newtLabelSetText(g_blurb1, blurb1);
|
---|
| 1195 | }
|
---|
| 1196 | if (g_blurb2) {
|
---|
| 1197 | newtLabelSetText(g_blurb2, blurb3);
|
---|
| 1198 | }
|
---|
| 1199 | if (g_blurb3) {
|
---|
| 1200 | newtLabelSetText(g_blurb3, blurb2);
|
---|
| 1201 | }
|
---|
[128] | 1202 | newtScaleSet(g_scale, (unsigned long long) g_current_progress);
|
---|
[1899] | 1203 | if ((percentage >= 2) && (g_timeline)) {
|
---|
[128] | 1204 | newtLabelSetText(g_timeline, timeline_str);
|
---|
| 1205 | }
|
---|
[3191] | 1206 | mr_free(timeline_str);
|
---|
| 1207 |
|
---|
[1899] | 1208 | if (g_percentline) {
|
---|
| 1209 | newtLabelSetText(g_percentline, percentline_str);
|
---|
| 1210 | }
|
---|
[3191] | 1211 | mr_free(percentline_str);
|
---|
| 1212 |
|
---|
[2879] | 1213 | newtDrawForm(g_progressForm);
|
---|
[128] | 1214 | newtRefresh();
|
---|
| 1215 | }
|
---|
[1] | 1216 | }
|
---|
| 1217 |
|
---|
| 1218 |
|
---|
| 1219 | /**
|
---|
| 1220 | * Ask the user which backup media type they would like to use.
|
---|
| 1221 | * The choices are @p none (exit to shell), @c cdr, @c cdrw, @c dvd,
|
---|
[2380] | 1222 | * @c tape, @c cdstream, @c udev (only when @p g_text_mode is TRUE), @c netfs,
|
---|
[1] | 1223 | * and @c iso.
|
---|
| 1224 | * @param restoring TRUE if we're restoring, FALSE if we're backing up.
|
---|
| 1225 | * @return The backup type chosen, or @c none if the user chose "Exit to shell".
|
---|
| 1226 | */
|
---|
[3191] | 1227 | t_bkptype which_backup_media_type(bool restoring) {
|
---|
[1] | 1228 |
|
---|
[128] | 1229 | /*@ char ************************************************************ */
|
---|
| 1230 | t_bkptype output;
|
---|
[1] | 1231 |
|
---|
| 1232 |
|
---|
[128] | 1233 | /*@ newt ************************************************************ */
|
---|
[3191] | 1234 | char *title_sz = NULL;
|
---|
| 1235 | char *minimsg_sz = NULL;
|
---|
| 1236 | static t_bkptype possible_bkptypes[] = { none, cdr, cdrw, dvd, tape, cdstream, udev, netfs, iso };
|
---|
| 1237 | static char *possible_responses[] = { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev", "netfs", "iso", NULL };
|
---|
| 1238 | char *outstr = NULL;
|
---|
[3614] | 1239 | char *instr = NULL;
|
---|
[128] | 1240 | t_bkptype backup_type;
|
---|
| 1241 | int i;
|
---|
[1] | 1242 |
|
---|
[128] | 1243 | newtComponent b1;
|
---|
| 1244 | newtComponent b2;
|
---|
| 1245 | newtComponent b3;
|
---|
| 1246 | newtComponent b4;
|
---|
| 1247 | newtComponent b5;
|
---|
| 1248 | newtComponent b6;
|
---|
| 1249 | newtComponent b7;
|
---|
| 1250 | newtComponent b8;
|
---|
| 1251 | newtComponent b_res;
|
---|
| 1252 | newtComponent myForm;
|
---|
[1] | 1253 |
|
---|
[128] | 1254 | if (g_text_mode) {
|
---|
| 1255 | for (backup_type = none; backup_type == none;) {
|
---|
[541] | 1256 | printf("Backup type (");
|
---|
[128] | 1257 | for (i = 0; possible_responses[i]; i++) {
|
---|
| 1258 | printf("%c%s", (i == 0) ? '\0' : ' ',
|
---|
| 1259 | possible_responses[i]);
|
---|
| 1260 | }
|
---|
| 1261 | printf(")\n--> ");
|
---|
[3614] | 1262 | mr_getline(instr, stdin);
|
---|
| 1263 | outstr = mr_strip_spaces(instr);
|
---|
| 1264 | mr_free(instr);
|
---|
[128] | 1265 | for (i = 0; possible_responses[i]; i++) {
|
---|
| 1266 | if (!strcmp(possible_responses[i], outstr)) {
|
---|
| 1267 | backup_type = possible_bkptypes[i];
|
---|
| 1268 | }
|
---|
| 1269 | }
|
---|
[3191] | 1270 | mr_free(outstr);
|
---|
[128] | 1271 | }
|
---|
| 1272 | return (backup_type);
|
---|
| 1273 | }
|
---|
| 1274 | newtDrawRootText(18, 0, WELCOME_STRING);
|
---|
| 1275 | if (restoring) {
|
---|
[3191] | 1276 | mr_asprintf(title_sz, "Please choose the backup media from which you want to read data.");
|
---|
| 1277 | mr_asprintf(minimsg_sz, "Read from:");
|
---|
[128] | 1278 | } else {
|
---|
[3191] | 1279 | mr_asprintf(title_sz, "Please choose the backup media to which you want to archive data.");
|
---|
| 1280 | mr_asprintf(minimsg_sz, "Backup to:");
|
---|
[128] | 1281 | }
|
---|
| 1282 | newtPushHelpLine(title_sz);
|
---|
| 1283 | newtCenteredWindow(34, 17, minimsg_sz);
|
---|
[541] | 1284 | b1 = newtButton(1, 1, "CD-R disks ");
|
---|
| 1285 | b2 = newtButton(17, 1, "CD-RW disks");
|
---|
| 1286 | b3 = newtButton(1, 9, "Tape drive ");
|
---|
[1703] | 1287 | b4 = newtButton(17, 5, "USB Key/Disk");
|
---|
[541] | 1288 | b5 = newtButton(1, 5, " DVD disks ");
|
---|
[2380] | 1289 | b6 = newtButton(17, 9, " Net mount ");
|
---|
[541] | 1290 | b7 = newtButton(1, 13, " Hard disk ");
|
---|
| 1291 | b8 = newtButton(17, 13, " Exit ");
|
---|
[128] | 1292 | myForm = newtForm(NULL, NULL, 0);
|
---|
[3477] | 1293 | newtFormAddComponents(myForm, b1, b5, b3, b7, b2, b4, b6, b8, NULL);
|
---|
[128] | 1294 | b_res = newtRunForm(myForm);
|
---|
| 1295 | newtFormDestroy(myForm);
|
---|
| 1296 | newtPopWindow();
|
---|
| 1297 | if (b_res == b1) {
|
---|
| 1298 | output = cdr;
|
---|
| 1299 | } else if (b_res == b2) {
|
---|
| 1300 | output = cdrw;
|
---|
| 1301 | } else if (b_res == b3) {
|
---|
| 1302 | output = tape;
|
---|
| 1303 | } else if (b_res == b4) {
|
---|
[1703] | 1304 | output = usb;
|
---|
[128] | 1305 | } else if (b_res == b5) {
|
---|
| 1306 | output = dvd;
|
---|
| 1307 | } else if (b_res == b6) {
|
---|
[2380] | 1308 | output = netfs;
|
---|
[128] | 1309 | } else if (b_res == b7) {
|
---|
| 1310 | output = iso;
|
---|
| 1311 | } else {
|
---|
| 1312 | output = none;
|
---|
| 1313 | }
|
---|
| 1314 | newtPopHelpLine();
|
---|
[3191] | 1315 | mr_free(title_sz);
|
---|
| 1316 | mr_free(minimsg_sz);
|
---|
[128] | 1317 | return (output);
|
---|
| 1318 | }
|
---|
[1] | 1319 |
|
---|
| 1320 |
|
---|
| 1321 |
|
---|
| 1322 |
|
---|
| 1323 | /**
|
---|
[2771] | 1324 | * Ask the user which compression type they would like to use.
|
---|
[3207] | 1325 | * The choices are "bzip2", "gzip", "lzo", "lzma". NULL for exit
|
---|
[2771] | 1326 | */
|
---|
| 1327 | char *which_compression_type() {
|
---|
| 1328 |
|
---|
| 1329 | /*@ char ************************************************************ */
|
---|
| 1330 | char *output = NULL;
|
---|
| 1331 |
|
---|
| 1332 |
|
---|
| 1333 | /*@ newt ************************************************************ */
|
---|
| 1334 |
|
---|
| 1335 | newtComponent b1;
|
---|
| 1336 | newtComponent b2;
|
---|
| 1337 | newtComponent b3;
|
---|
[3191] | 1338 | newtComponent b4;
|
---|
[2771] | 1339 | newtComponent b5;
|
---|
| 1340 | newtComponent b_res;
|
---|
| 1341 | newtComponent myForm;
|
---|
| 1342 |
|
---|
| 1343 | newtDrawRootText(18, 0, WELCOME_STRING);
|
---|
| 1344 | newtPushHelpLine
|
---|
| 1345 | (" Please specify the type of compression that you want.");
|
---|
| 1346 | newtCenteredWindow(34, 13, "Type of compression?");
|
---|
| 1347 | b1 = newtButton(4, 1, "bzip2");
|
---|
| 1348 | b2 = newtButton(18, 1, "gzip");
|
---|
| 1349 | b3 = newtButton(4, 5, "lzo");
|
---|
[3191] | 1350 | b4 = newtButton(18, 5, "lzma");
|
---|
[2771] | 1351 | b5 = newtButton(4, 9, " Exit ");
|
---|
| 1352 | myForm = newtForm(NULL, NULL, 0);
|
---|
[3207] | 1353 | newtFormAddComponents(myForm, b1, b3, b2, b4, b5, NULL);
|
---|
[2771] | 1354 | b_res = newtRunForm(myForm);
|
---|
| 1355 | newtFormDestroy(myForm);
|
---|
| 1356 | newtPopWindow();
|
---|
| 1357 | if (b_res == b1) {
|
---|
[3185] | 1358 | mr_asprintf(output, "%s", "bzip2");
|
---|
[2771] | 1359 | } else if (b_res == b2) {
|
---|
[3185] | 1360 | mr_asprintf(output, "%s", "gzip");
|
---|
[2771] | 1361 | } else if (b_res == b3) {
|
---|
[3185] | 1362 | mr_asprintf(output, "%s", "lzo");
|
---|
[3191] | 1363 | } else if (b_res == b4) {
|
---|
| 1364 | mr_asprintf(output, "%s", "lzma");
|
---|
[2771] | 1365 | }
|
---|
| 1366 | newtPopHelpLine();
|
---|
| 1367 | return(output);
|
---|
| 1368 | }
|
---|
| 1369 |
|
---|
| 1370 |
|
---|
| 1371 | /**
|
---|
[1] | 1372 | * Ask the user how much compression they would like to use.
|
---|
| 1373 | * The choices are "None" (0), "Minimum" (1), "Average" (4), and "Maximum" (9).
|
---|
| 1374 | * @return The compression level (0-9) chosen, or -1 for "Exit".
|
---|
| 1375 | */
|
---|
[3191] | 1376 | int which_compression_level() {
|
---|
[1] | 1377 |
|
---|
[128] | 1378 | /*@ char ************************************************************ */
|
---|
| 1379 | int output = none;
|
---|
[1] | 1380 |
|
---|
| 1381 |
|
---|
[128] | 1382 | /*@ newt ************************************************************ */
|
---|
[1] | 1383 |
|
---|
[128] | 1384 | newtComponent b1;
|
---|
| 1385 | newtComponent b2;
|
---|
| 1386 | newtComponent b3;
|
---|
| 1387 | newtComponent b4;
|
---|
| 1388 | newtComponent b5;
|
---|
| 1389 | newtComponent b_res;
|
---|
| 1390 | newtComponent myForm;
|
---|
[1] | 1391 |
|
---|
[128] | 1392 | newtDrawRootText(18, 0, WELCOME_STRING);
|
---|
[3191] | 1393 | newtPushHelpLine(" Please specify the level of compression that you want.");
|
---|
[541] | 1394 | newtCenteredWindow(34, 13, "How much compression?");
|
---|
[3114] | 1395 | b1 = newtButton(4, 1, "Maximum (9)");
|
---|
| 1396 | b2 = newtButton(18, 1, "Average (4)");
|
---|
| 1397 | b3 = newtButton(4, 5, "Minimum (1)");
|
---|
| 1398 | b4 = newtButton(18, 5, " None (0) ");
|
---|
[541] | 1399 | b5 = newtButton(4, 9, " Exit ");
|
---|
[128] | 1400 | myForm = newtForm(NULL, NULL, 0);
|
---|
| 1401 | newtFormAddComponents(myForm, b1, b3, b2, b4, b5, NULL);
|
---|
| 1402 | b_res = newtRunForm(myForm);
|
---|
| 1403 | newtFormDestroy(myForm);
|
---|
| 1404 | newtPopWindow();
|
---|
| 1405 | if (b_res == b1) {
|
---|
| 1406 | output = 9;
|
---|
| 1407 | } else if (b_res == b2) {
|
---|
| 1408 | output = 4;
|
---|
| 1409 | } else if (b_res == b3) {
|
---|
| 1410 | output = 1;
|
---|
| 1411 | } else if (b_res == b4) {
|
---|
| 1412 | output = 0;
|
---|
| 1413 | } else if (b_res == b5) {
|
---|
| 1414 | output = -1;
|
---|
| 1415 | }
|
---|
| 1416 | newtPopHelpLine();
|
---|
| 1417 | return (output);
|
---|
| 1418 | }
|
---|
[1] | 1419 |
|
---|
| 1420 |
|
---|
| 1421 |
|
---|
| 1422 |
|
---|
| 1423 |
|
---|
| 1424 | /**
|
---|
| 1425 | * Load @p source_file (a list of files) into @p filelist. There can be no more than
|
---|
| 1426 | * @p ARBITRARY_MAXIMUM entries.
|
---|
| 1427 | * @param filelist The filelist structure to load @p source_file into.
|
---|
| 1428 | * @param source_file The file containing a list of filenames to load into @p filelist.
|
---|
| 1429 | */
|
---|
[3191] | 1430 | int load_filelist_into_array(struct s_filelist *filelist, char *source_file) {
|
---|
| 1431 |
|
---|
[128] | 1432 | int i;
|
---|
[1662] | 1433 | int j = 0;
|
---|
[128] | 1434 | bool done;
|
---|
[3191] | 1435 | char *tmp = NULL;
|
---|
[1662] | 1436 | char *tmp1 = NULL;
|
---|
| 1437 | FILE *fin, *fout;
|
---|
[128] | 1438 | struct s_filelist_entry dummy_fle;
|
---|
[1] | 1439 |
|
---|
[128] | 1440 | assert(filelist != NULL);
|
---|
| 1441 | assert_string_is_neither_NULL_nor_zerolength(source_file);
|
---|
[1] | 1442 |
|
---|
[2230] | 1443 | log_it("entering");
|
---|
[128] | 1444 | if (!(fin = fopen(source_file, "r"))) {
|
---|
| 1445 | log_OS_error(source_file);
|
---|
| 1446 | log_msg(2, "Can't open %s; therefore, cannot popup list",
|
---|
| 1447 | source_file);
|
---|
| 1448 | return (1);
|
---|
| 1449 | }
|
---|
[1662] | 1450 |
|
---|
[3185] | 1451 | mr_asprintf(tmp1,"%s/icantfindthesefiles.txt",bkpinfo->tmpdir);
|
---|
[1662] | 1452 | if (!(fout = fopen(tmp1, "a"))) {
|
---|
| 1453 | log_msg(2, "Can't write to %s", tmp1);
|
---|
[3191] | 1454 | mr_free(tmp1);
|
---|
[1662] | 1455 | return(1);
|
---|
| 1456 | }
|
---|
| 1457 |
|
---|
[128] | 1458 | log_msg(2, "Loading %s", source_file);
|
---|
[3191] | 1459 | for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM; ) {
|
---|
| 1460 | mr_free(tmp);
|
---|
[128] | 1461 | if (feof(fin)) {
|
---|
| 1462 | break;
|
---|
| 1463 | }
|
---|
[3191] | 1464 | mr_getline(tmp, fin);
|
---|
[128] | 1465 | i = (int) strlen(tmp);
|
---|
| 1466 | if (i < 2) {
|
---|
[3191] | 1467 | continue;
|
---|
[128] | 1468 | }
|
---|
| 1469 | if (tmp[i - 1] < 32) {
|
---|
| 1470 | tmp[--i] = '\0';
|
---|
| 1471 | }
|
---|
| 1472 | if (i < 2) {
|
---|
[3191] | 1473 | continue;
|
---|
[128] | 1474 | }
|
---|
[1662] | 1475 | if (!does_file_exist(tmp) && !feof(fin)) {
|
---|
| 1476 | j++;
|
---|
| 1477 | fprintf(fout, "%s\n", tmp);
|
---|
[3191] | 1478 | continue;
|
---|
[128] | 1479 | }
|
---|
[3191] | 1480 | filelist->el[filelist->entries].severity = severity_of_difference(tmp, NULL);
|
---|
[128] | 1481 | strcpy(filelist->el[filelist->entries].filename, tmp);
|
---|
| 1482 | if (feof(fin)) {
|
---|
| 1483 | break;
|
---|
| 1484 | }
|
---|
[3191] | 1485 | filelist->entries++;
|
---|
[128] | 1486 | }
|
---|
[3191] | 1487 | mr_free(tmp);
|
---|
[128] | 1488 | paranoid_fclose(fin);
|
---|
[1662] | 1489 | paranoid_fclose(fout);
|
---|
| 1490 | if (j > 0) {
|
---|
| 1491 | log_to_screen("%d files listed in %s/changed.files have been deleted since backup was made\nand are referenced in %s", j, bkpinfo->tmpdir,tmp1);
|
---|
| 1492 | }
|
---|
[3191] | 1493 | mr_free(tmp1);
|
---|
[128] | 1494 | if (filelist->entries >= ARBITRARY_MAXIMUM) {
|
---|
[541] | 1495 | log_to_screen("Arbitrary limits suck, man!");
|
---|
[128] | 1496 | return (1);
|
---|
| 1497 | }
|
---|
| 1498 | for (done = FALSE; !done;) {
|
---|
| 1499 | done = TRUE;
|
---|
| 1500 | for (i = 0; i < filelist->entries - 1; i++) {
|
---|
[1] | 1501 | // if (strcmp(filelist->el[i].filename, filelist->el[i+1].filename) > 0)
|
---|
[128] | 1502 | if (filelist->el[i].severity < filelist->el[i + 1].severity
|
---|
| 1503 | || (filelist->el[i].severity ==
|
---|
| 1504 | filelist->el[i + 1].severity
|
---|
| 1505 | && strcmp(filelist->el[i].filename,
|
---|
| 1506 | filelist->el[i + 1].filename) > 0)) {
|
---|
| 1507 | memcpy((void *) &dummy_fle,
|
---|
| 1508 | (void *) &(filelist->el[i]),
|
---|
| 1509 | sizeof(struct s_filelist_entry));
|
---|
| 1510 | memcpy((void *) &(filelist->el[i]),
|
---|
| 1511 | (void *) &(filelist->el[i + 1]),
|
---|
| 1512 | sizeof(struct s_filelist_entry));
|
---|
| 1513 | memcpy((void *) &(filelist->el[i + 1]),
|
---|
| 1514 | (void *) &dummy_fle,
|
---|
| 1515 | sizeof(struct s_filelist_entry));
|
---|
| 1516 | log_msg(2, "Swapping %s and %s",
|
---|
| 1517 | filelist->el[i].filename,
|
---|
| 1518 | filelist->el[i + 1].filename);
|
---|
| 1519 | done = FALSE;
|
---|
| 1520 | }
|
---|
| 1521 | }
|
---|
| 1522 | }
|
---|
[2230] | 1523 | log_it("leaving");
|
---|
[128] | 1524 | return (0);
|
---|
| 1525 | }
|
---|
[1] | 1526 |
|
---|
| 1527 |
|
---|
| 1528 | /**
|
---|
| 1529 | * Generate a pretty string based on @p flentry.
|
---|
| 1530 | * @param flentry The filelist entry to stringify.
|
---|
| 1531 | * @return The string form of @p flentry.
|
---|
| 1532 | * @note The returned value points to static storage that will be overwritten with each call.
|
---|
| 1533 | */
|
---|
[3191] | 1534 | char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
|
---|
[128] | 1535 | static char comment[100];
|
---|
[2211] | 1536 | char *tmp = NULL;
|
---|
[1] | 1537 |
|
---|
[3191] | 1538 | log_msg(8, "entering");
|
---|
[128] | 1539 | assert(flentry != NULL);
|
---|
| 1540 | if (flentry->severity == 0) {
|
---|
[3185] | 1541 | mr_asprintf(tmp, "0 ");
|
---|
[128] | 1542 | } else if (flentry->severity == 1) {
|
---|
[3185] | 1543 | mr_asprintf(tmp, "low ");
|
---|
[128] | 1544 | } else if (flentry->severity == 2) {
|
---|
[3185] | 1545 | mr_asprintf(tmp, "med ");
|
---|
[128] | 1546 | } else {
|
---|
[3185] | 1547 | mr_asprintf(tmp, "high");
|
---|
[128] | 1548 | }
|
---|
[2211] | 1549 | mr_strcat(tmp, " ");
|
---|
| 1550 | mr_strcat(tmp, flentry->filename);
|
---|
| 1551 | strncpy(comment, tmp, 99);
|
---|
[3191] | 1552 | mr_free(tmp);
|
---|
[2211] | 1553 |
|
---|
[2230] | 1554 | log_it("leaving");
|
---|
[128] | 1555 | return (comment);
|
---|
| 1556 | }
|
---|
[1] | 1557 |
|
---|
| 1558 |
|
---|
| 1559 | /**
|
---|
| 1560 | * Pop up a list containing the filenames in @p source_file and the severity if they have changed since the
|
---|
| 1561 | * last backup. There can be no more than @p ARBITRARY_MAXIMUM files in @p source_file.
|
---|
| 1562 | * @param source_file The file containing a list of changed files.
|
---|
| 1563 | */
|
---|
[3191] | 1564 | void popup_changelist_from_file(char *source_file) {
|
---|
| 1565 |
|
---|
| 1566 | char *reason = NULL;
|
---|
[128] | 1567 | newtComponent myForm;
|
---|
| 1568 | newtComponent bClose;
|
---|
| 1569 | newtComponent bSelect;
|
---|
| 1570 | newtComponent b_res;
|
---|
| 1571 | newtComponent fileListbox;
|
---|
| 1572 | newtComponent headerMsg;
|
---|
[1] | 1573 |
|
---|
[128] | 1574 | /*@ ???? ************************************************************ */
|
---|
| 1575 | void *curr_choice;
|
---|
| 1576 | void *keylist[ARBITRARY_MAXIMUM];
|
---|
[1] | 1577 |
|
---|
[128] | 1578 | /*@ int ************************************************************* */
|
---|
| 1579 | int currline = 0;
|
---|
| 1580 | int finished = FALSE;
|
---|
[738] | 1581 |
|
---|
| 1582 | /*@ long ************************************************************ */
|
---|
| 1583 | long i = 0;
|
---|
[128] | 1584 | long lng = 0;
|
---|
[1] | 1585 |
|
---|
[128] | 1586 | /*@ buffers ********************************************************* */
|
---|
[3191] | 1587 | char *tmp = NULL;
|
---|
| 1588 | char *differ_sz = NULL;
|
---|
[1] | 1589 |
|
---|
[128] | 1590 | struct s_filelist *filelist;
|
---|
| 1591 | assert_string_is_neither_NULL_nor_zerolength(source_file);
|
---|
| 1592 | if (g_text_mode) {
|
---|
| 1593 | log_msg(2, "Text mode. Therefore, no popup list.");
|
---|
[3191] | 1594 | return;
|
---|
[128] | 1595 | }
|
---|
| 1596 | log_msg(2, "Examining file %s", source_file);
|
---|
[1] | 1597 |
|
---|
[128] | 1598 | lng = count_lines_in_file(source_file);
|
---|
| 1599 | if (lng < 1) {
|
---|
| 1600 | log_msg(2, "No lines in file. Therefore, no popup list.");
|
---|
[3191] | 1601 | return;
|
---|
[128] | 1602 | } else if (lng >= ARBITRARY_MAXIMUM) {
|
---|
| 1603 | log_msg(2, "Too many files differ for me to list.");
|
---|
[3191] | 1604 | return;
|
---|
[128] | 1605 | }
|
---|
[1] | 1606 |
|
---|
[128] | 1607 | filelist = (struct s_filelist *) malloc(sizeof(struct s_filelist));
|
---|
| 1608 | fileListbox =
|
---|
| 1609 | newtListbox(2, 2, 12, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
|
---|
| 1610 | newtListboxClear(fileListbox);
|
---|
[1] | 1611 |
|
---|
[128] | 1612 | if (load_filelist_into_array(filelist, source_file)) {
|
---|
[3191] | 1613 | log_msg(2, "Can't open %s; therefore, cannot popup list", source_file);
|
---|
[128] | 1614 | return;
|
---|
| 1615 | }
|
---|
[3191] | 1616 | log_msg(2, "%d files loaded into filelist array", filelist->entries);
|
---|
[128] | 1617 | for (i = 0; i < filelist->entries; i++) {
|
---|
| 1618 | keylist[i] = (void *) i;
|
---|
| 1619 | newtListboxAppendEntry(fileListbox,
|
---|
| 1620 | filelist_entry_to_string(&
|
---|
| 1621 | (filelist->
|
---|
| 1622 | el[i])),
|
---|
| 1623 | keylist[i]);
|
---|
| 1624 | }
|
---|
[3191] | 1625 | mr_asprintf(differ_sz, " %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", i);
|
---|
[128] | 1626 | newtPushHelpLine(differ_sz);
|
---|
[3191] | 1627 | mr_free(differ_sz);
|
---|
| 1628 |
|
---|
[541] | 1629 | bClose = newtCompactButton(10, 15, " Close ");
|
---|
| 1630 | bSelect = newtCompactButton(30, 15, " Select ");
|
---|
[3191] | 1631 | mr_asprintf(tmp, "%-10s %-20s", "Priority", "Filename");
|
---|
[128] | 1632 | headerMsg = newtLabel(2, 1, tmp);
|
---|
[3191] | 1633 | mr_free(tmp);
|
---|
| 1634 |
|
---|
[541] | 1635 | newtOpenWindow(5, 4, 70, 16, "Non-matching files");
|
---|
[128] | 1636 | myForm = newtForm(NULL, NULL, 0);
|
---|
[3191] | 1637 | newtFormAddComponents(myForm, headerMsg, fileListbox, bClose, bSelect, NULL);
|
---|
| 1638 |
|
---|
[128] | 1639 | while (!finished) {
|
---|
| 1640 | b_res = newtRunForm(myForm);
|
---|
| 1641 | if (b_res == bClose) {
|
---|
| 1642 | finished = TRUE;
|
---|
| 1643 | } else {
|
---|
| 1644 | curr_choice = newtListboxGetCurrent(fileListbox);
|
---|
| 1645 | for (i = 0;
|
---|
| 1646 | i < filelist->entries && keylist[i] != curr_choice;
|
---|
| 1647 | i++);
|
---|
| 1648 | if (i == filelist->entries && filelist->entries > 0) {
|
---|
[541] | 1649 | log_to_screen("I don't know what that button does!");
|
---|
[128] | 1650 | } else {
|
---|
| 1651 | currline = i;
|
---|
| 1652 | if (filelist->entries > 0) {
|
---|
[3191] | 1653 | malloc_string(reason);
|
---|
[3194] | 1654 | severity_of_difference(filelist->el[currline].filename, &reason);
|
---|
[3191] | 1655 | mr_asprintf(tmp, "%s --- %s", filelist->el[currline].filename, reason);
|
---|
| 1656 |
|
---|
[128] | 1657 | popup_and_OK(tmp);
|
---|
[3191] | 1658 | mr_free(tmp);
|
---|
| 1659 | paranoid_free(reason);
|
---|
[128] | 1660 | }
|
---|
| 1661 | }
|
---|
| 1662 | }
|
---|
| 1663 | }
|
---|
| 1664 | newtFormDestroy(myForm);
|
---|
| 1665 | newtPopWindow();
|
---|
| 1666 | newtPopHelpLine();
|
---|
| 1667 | return;
|
---|
[1] | 1668 | }
|
---|
| 1669 |
|
---|
| 1670 | /* @} - end of guiGroup */
|
---|
| 1671 |
|
---|
| 1672 |
|
---|
| 1673 | #if __cplusplus
|
---|
[128] | 1674 | } /* extern "C" */
|
---|
[1] | 1675 | #endif
|
---|