[1] | 1 | /* newt-specific.c
|
---|
[99] | 2 | $Id: newt-specific.c 3618 2016-12-17 23:19:56Z 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 3618 2016-12-17 23:19:56Z 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);
|
---|
[2241] | 430 | /* Then free the structure */
|
---|
[1703] | 431 | paranoid_free(bkpinfo);
|
---|
[3191] | 432 |
|
---|
[128] | 433 | free_libmondo_global_strings();
|
---|
[2241] | 434 | free_newt_stuff();
|
---|
[3191] | 435 | if (!g_text_mode) {
|
---|
| 436 | if (does_file_exist("/THIS-IS-A-RAMDISK")) {
|
---|
| 437 | log_msg(1, "Calling newtFinished()");
|
---|
| 438 | newtFinished();
|
---|
| 439 | } else {
|
---|
| 440 | log_msg(1, "Calling newtSuspend()");
|
---|
| 441 | newtSuspend();
|
---|
| 442 | }
|
---|
| 443 | }
|
---|
| 444 | printf("Execution run ended; result=%d\n", signal);
|
---|
| 445 | printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE);
|
---|
[128] | 446 | exit(signal);
|
---|
| 447 | }
|
---|
[1] | 448 |
|
---|
| 449 |
|
---|
| 450 | /**
|
---|
| 451 | * Log the last @p g_noof_log_lines lines of @p filename that match @p
|
---|
| 452 | * grep_for_me to the screen.
|
---|
| 453 | * @param filename The file to give the end of.
|
---|
| 454 | * @param grep_for_me If not "", then only give lines in @p filename that match this regular expression.
|
---|
| 455 | */
|
---|
[3191] | 456 | void log_file_end_to_screen(char *filename, char *grep_for_me) {
|
---|
[1] | 457 |
|
---|
[128] | 458 | /*@ buffers ********************************************************** */
|
---|
[2700] | 459 | char *command = NULL;
|
---|
| 460 | char *tmp = NULL;
|
---|
[3060] | 461 | char *p = NULL;
|
---|
[1] | 462 |
|
---|
[128] | 463 | /*@ pointers ********************************************************* */
|
---|
| 464 | FILE *fin;
|
---|
[1] | 465 |
|
---|
[128] | 466 | /*@ int ************************************************************** */
|
---|
| 467 | int i = 0;
|
---|
[1] | 468 |
|
---|
[128] | 469 | assert_string_is_neither_NULL_nor_zerolength(filename);
|
---|
| 470 | assert(grep_for_me != NULL);
|
---|
[1] | 471 |
|
---|
[128] | 472 | if (!does_file_exist(filename)) {
|
---|
| 473 | return;
|
---|
[1] | 474 | }
|
---|
[128] | 475 | if (grep_for_me[0] != '\0') {
|
---|
[3191] | 476 | mr_asprintf(command, "grep '%s' %s | tail -n%d", grep_for_me, filename, g_noof_log_lines);
|
---|
[128] | 477 | } else {
|
---|
[3191] | 478 | mr_asprintf(command, "tail -n%d %s", g_noof_log_lines, filename);
|
---|
[1] | 479 | }
|
---|
[128] | 480 | fin = popen(command, "r");
|
---|
| 481 | if (!fin) {
|
---|
| 482 | log_OS_error(command);
|
---|
| 483 | } else {
|
---|
| 484 | for (i = 0; i < g_noof_log_lines; i++) {
|
---|
| 485 | for (err_log_lines[i][0] = '\0';
|
---|
| 486 | strlen(err_log_lines[i]) < 2 && !feof(fin);) {
|
---|
[3060] | 487 | p = fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN, fin);
|
---|
| 488 | if (!p) {
|
---|
| 489 | // FIXME
|
---|
| 490 | }
|
---|
[1274] | 491 | /* Commented to make valgrind happy and avoid crash
|
---|
[128] | 492 | strip_spaces(err_log_lines[i]);
|
---|
[1274] | 493 | */
|
---|
[128] | 494 | if (!strncmp(err_log_lines[i], "root:", 5)) {
|
---|
[3185] | 495 | mr_asprintf(tmp, "%s", err_log_lines[i] + 6);
|
---|
[2700] | 496 | strncpy(err_log_lines[i], tmp, (size_t)MAX_NEWT_COMMENT_LEN);
|
---|
| 497 | mr_free(tmp);
|
---|
[128] | 498 | }
|
---|
| 499 | if (feof(fin)) {
|
---|
| 500 | break;
|
---|
| 501 | }
|
---|
| 502 | }
|
---|
| 503 | }
|
---|
| 504 | paranoid_pclose(fin);
|
---|
| 505 | }
|
---|
[2700] | 506 | mr_free(command);
|
---|
[128] | 507 | refresh_log_screen();
|
---|
[1] | 508 | }
|
---|
| 509 |
|
---|
| 510 |
|
---|
| 511 | /**
|
---|
| 512 | * Log a message to the screen.
|
---|
| 513 | * @param fmt A printf-style format string to write. The following parameters are its arguments.
|
---|
| 514 | * @note The message is also written to the logfile.
|
---|
| 515 | */
|
---|
[3191] | 516 | void log_to_screen(const char *fmt, ...) {
|
---|
[1] | 517 |
|
---|
[128] | 518 | /*@ int ************************************************************** */
|
---|
| 519 | int i = 0;
|
---|
| 520 | int j = 0;
|
---|
| 521 | va_list args;
|
---|
[1] | 522 |
|
---|
[128] | 523 | /*@ buffers ********************************************************** */
|
---|
| 524 | char *output;
|
---|
[1] | 525 |
|
---|
[128] | 526 | malloc_string(output);
|
---|
[1] | 527 |
|
---|
[128] | 528 | va_start(args, fmt);
|
---|
[2700] | 529 | vsnprintf(output, MAX_STR_LEN-1, fmt, args);
|
---|
[128] | 530 | log_msg(0, output);
|
---|
| 531 | output[80] = '\0';
|
---|
| 532 | va_end(args);
|
---|
| 533 | i = (int) strlen(output);
|
---|
| 534 | if (i > 0 && output[i - 1] < 32) {
|
---|
| 535 | output[i - 1] = '\0';
|
---|
| 536 | }
|
---|
[1] | 537 |
|
---|
[128] | 538 | if (err_log_lines) {
|
---|
| 539 | for (i = 1; i < g_noof_log_lines; i++) {
|
---|
| 540 | strcpy(err_log_lines[i - 1],
|
---|
| 541 | " ");
|
---|
| 542 | strcpy(err_log_lines[i - 1], err_log_lines[i]);
|
---|
| 543 | }
|
---|
| 544 | }
|
---|
| 545 | while (strlen(output) > 0 && output[strlen(output) - 1] < 32) {
|
---|
| 546 | output[strlen(output) - 1] = '\0';
|
---|
| 547 | }
|
---|
| 548 | for (j = 0; j < (int) strlen(output); j++) {
|
---|
| 549 | if (output[j] < 32) {
|
---|
| 550 | output[j] = ' ';
|
---|
| 551 | }
|
---|
| 552 | }
|
---|
| 553 | if (err_log_lines)
|
---|
| 554 | strcpy(err_log_lines[g_noof_log_lines - 1], output);
|
---|
| 555 | if (g_text_mode) {
|
---|
| 556 | printf("%s\n", output);
|
---|
| 557 | } else {
|
---|
| 558 | refresh_log_screen();
|
---|
| 559 | }
|
---|
| 560 | paranoid_free(output);
|
---|
[1] | 561 | }
|
---|
| 562 |
|
---|
| 563 |
|
---|
| 564 |
|
---|
| 565 |
|
---|
| 566 | /**
|
---|
| 567 | * Write a string to the root window at (@p x, @p y) and also to the logfile.
|
---|
| 568 | * @param y The row to write the string to.
|
---|
| 569 | * @param x The column to write the string to.
|
---|
| 570 | * @param output The string to write.
|
---|
| 571 | */
|
---|
[3191] | 572 | void mvaddstr_and_log_it(int y, int x, char *output) {
|
---|
| 573 |
|
---|
[128] | 574 | assert_string_is_neither_NULL_nor_zerolength(output);
|
---|
| 575 | log_msg(0, output);
|
---|
| 576 | if (g_text_mode) {
|
---|
| 577 | printf("%s\n", output);
|
---|
| 578 | } else {
|
---|
| 579 | newtDrawRootText(x, y, output);
|
---|
| 580 | newtRefresh();
|
---|
| 581 | }
|
---|
| 582 | }
|
---|
[1] | 583 |
|
---|
| 584 |
|
---|
| 585 |
|
---|
| 586 |
|
---|
| 587 | /**
|
---|
| 588 | * Open an evalcall form with title @p ttl.
|
---|
| 589 | * @param ttl The title to use for the evalcall form.
|
---|
| 590 | */
|
---|
[3191] | 591 | void open_evalcall_form(char *ttl) {
|
---|
[1] | 592 |
|
---|
[128] | 593 | /*@ buffers ********************************************************* */
|
---|
[3191] | 594 | char *tmp = NULL;
|
---|
[1] | 595 |
|
---|
[128] | 596 | /*@ initialize ****************************************************** */
|
---|
| 597 | g_isoform_old_progress = -1;
|
---|
| 598 | g_mysterious_dot_counter = 0;
|
---|
[1] | 599 |
|
---|
[128] | 600 | assert(ttl != NULL);
|
---|
[3191] | 601 | malloc_string(tmp);
|
---|
| 602 | strcpy(g_isoform_header_str, ttl);
|
---|
[128] | 603 | if (g_text_mode) {
|
---|
[3191] | 604 | log_msg(0, ttl);
|
---|
[128] | 605 | } else {
|
---|
[3191] | 606 | strcpy(tmp, ttl);
|
---|
[128] | 607 | center_string(tmp, 80);
|
---|
| 608 | newtPushHelpLine(tmp);
|
---|
| 609 | }
|
---|
| 610 | center_string(g_isoform_header_str, 36);
|
---|
| 611 | g_isoform_starttime = get_time();
|
---|
| 612 | if (g_text_mode) {
|
---|
| 613 | log_msg(0, g_isoform_header_str);
|
---|
| 614 | } else {
|
---|
| 615 | g_isoform_header = newtLabel(1, 1, g_isoform_header_str);
|
---|
| 616 | g_isoform_scale = newtScale(3, 3, 34, 100);
|
---|
[3191] | 617 | newtCenteredWindow(40, 7, ttl);
|
---|
[3292] | 618 | if (g_isoform_main != NULL) {
|
---|
| 619 | newtFormDestroy(g_isoform_main);
|
---|
| 620 | }
|
---|
[128] | 621 | g_isoform_main = newtForm(NULL, NULL, 0);
|
---|
[2881] | 622 | g_isoform_timeline = newtLabel(1, 5, " ");
|
---|
| 623 | g_isoform_pcline = newtLabel(1, 6, " ");
|
---|
[128] | 624 | newtFormAddComponents(g_isoform_main, g_isoform_timeline,
|
---|
| 625 | g_isoform_pcline, g_isoform_header,
|
---|
| 626 | g_isoform_scale, NULL);
|
---|
[2879] | 627 | newtDrawForm(g_isoform_main);
|
---|
[128] | 628 | newtRefresh();
|
---|
| 629 | }
|
---|
| 630 | update_evalcall_form(0);
|
---|
| 631 | paranoid_free(tmp);
|
---|
| 632 | }
|
---|
[1] | 633 |
|
---|
| 634 |
|
---|
| 635 |
|
---|
| 636 | /**
|
---|
| 637 | * Open a progress form with title @p title.
|
---|
| 638 | * @param title The title to use for the progress form (will be put in the title bar on Newt).
|
---|
| 639 | * @param b1 The first line of the blurb; generally static.
|
---|
| 640 | * @param b2 The second line of the blurb; generally static.
|
---|
| 641 | * @param b3 The third line of the blurb; generally dynamic (it is passed
|
---|
| 642 | * to update_evalcall_form() every time).
|
---|
| 643 | * @param max_val The maximum amount of progress (number of filesets, etc.)
|
---|
| 644 | */
|
---|
[3191] | 645 | void open_progress_form(char *title, char *b1, char *b2, char *b3, long max_val) {
|
---|
[1] | 646 |
|
---|
[128] | 647 | /*@ buffers ********************************************************* */
|
---|
| 648 | char *b1c;
|
---|
[3191] | 649 | char *blurb1 = NULL;
|
---|
| 650 | char *blurb2 = NULL;
|
---|
| 651 | char *blurb3 = NULL;
|
---|
[1] | 652 |
|
---|
[128] | 653 | /*@ initialize ****************************************************** */
|
---|
| 654 | g_mysterious_dot_counter = 0;
|
---|
[1] | 655 |
|
---|
[128] | 656 | malloc_string(b1c);
|
---|
[1] | 657 |
|
---|
[128] | 658 | assert(title != NULL);
|
---|
| 659 | assert(b1 != NULL);
|
---|
| 660 | assert(b2 != NULL);
|
---|
| 661 | assert(b3 != NULL);
|
---|
[1] | 662 |
|
---|
[3235] | 663 | malloc_string(blurb1);
|
---|
| 664 | malloc_string(blurb2);
|
---|
| 665 | malloc_string(blurb3);
|
---|
| 666 | strcpy(blurb1, b1);
|
---|
| 667 | strcpy(blurb2, b2);
|
---|
| 668 | strcpy(blurb3, b3);
|
---|
[3191] | 669 |
|
---|
[128] | 670 | strcpy(b1c, b1);
|
---|
| 671 | center_string(b1c, 80);
|
---|
| 672 | if (max_val <= 0) {
|
---|
| 673 | max_val = 1;
|
---|
| 674 | }
|
---|
[1] | 675 |
|
---|
[128] | 676 | g_start_time = get_time();
|
---|
| 677 | g_maximum_progress = max_val;
|
---|
| 678 | g_current_progress = 0;
|
---|
| 679 | strcpy(g_blurb_str_1, blurb1);
|
---|
| 680 | strcpy(g_blurb_str_2, blurb3);
|
---|
| 681 | strcpy(g_blurb_str_3, blurb2);
|
---|
| 682 | if (g_text_mode) {
|
---|
| 683 | log_msg(0, blurb1);
|
---|
| 684 | log_msg(0, blurb2);
|
---|
| 685 | log_msg(0, blurb3);
|
---|
| 686 | } else {
|
---|
| 687 | g_blurb1 = newtLabel(2, 1, blurb1);
|
---|
| 688 | g_blurb2 = newtLabel(2, 2, blurb3);
|
---|
| 689 | g_blurb3 = newtLabel(2, 4, blurb2);
|
---|
| 690 | newtCenteredWindow(60, 11, title);
|
---|
[3191] | 691 | g_scale = newtScale(3, 6, 54, (long long)g_maximum_progress);
|
---|
[128] | 692 | g_progressForm = newtForm(NULL, NULL, 0);
|
---|
[2886] | 693 | g_percentline = newtLabel(10, 9, " ");
|
---|
| 694 | g_timeline = newtLabel(10, 8, " ");
|
---|
[3191] | 695 | newtFormAddComponents(g_progressForm, g_percentline, g_timeline, g_scale, g_blurb1, g_blurb3, g_blurb2, NULL);
|
---|
[128] | 696 | newtPushHelpLine(b1c);
|
---|
[2879] | 697 | newtDrawForm(g_progressForm);
|
---|
[128] | 698 | newtRefresh();
|
---|
| 699 | }
|
---|
| 700 | update_progress_form_full(blurb1, blurb2, blurb3);
|
---|
| 701 | paranoid_free(b1c);
|
---|
[3235] | 702 | paranoid_free(blurb1);
|
---|
| 703 | paranoid_free(blurb2);
|
---|
| 704 | paranoid_free(blurb3);
|
---|
[128] | 705 | }
|
---|
| 706 |
|
---|
[1] | 707 | /**
|
---|
| 708 | * Give a message to the user in the form of a dialog box (under Newt).
|
---|
| 709 | * @param prompt The message.
|
---|
| 710 | */
|
---|
[3191] | 711 | void popup_and_OK(char *prompt) {
|
---|
| 712 |
|
---|
[128] | 713 | char ch;
|
---|
[1] | 714 |
|
---|
[128] | 715 | assert_string_is_neither_NULL_nor_zerolength(prompt);
|
---|
[1] | 716 |
|
---|
[128] | 717 | log_msg(0, prompt);
|
---|
| 718 | if (g_text_mode) {
|
---|
[3191] | 719 | printf("---promptpopup---1--- %s\n---promptpopup---Q--- [OK] ---\n--> ", prompt);
|
---|
[128] | 720 | while (((ch = getchar()) != '\n') && (ch != EOF));
|
---|
| 721 | } else {
|
---|
[541] | 722 | (void) popup_with_buttons(prompt, " OK ", "");
|
---|
[128] | 723 | }
|
---|
| 724 | }
|
---|
[1] | 725 |
|
---|
| 726 | /**
|
---|
| 727 | * Ask the user to enter a value.
|
---|
| 728 | * @param title The title of the dialog box.
|
---|
| 729 | * @param b The blurb (e.g. what you want the user to enter).
|
---|
[3377] | 730 | * @param input The string to initialize the user's answer with.
|
---|
| 731 | * @return value needs to be freed up by caller
|
---|
| 732 | */
|
---|
| 733 | char *mr_popup_and_get_string(char *title, char *b, char *input) {
|
---|
| 734 |
|
---|
| 735 | /*@ newt ************************************************************ */
|
---|
| 736 | newtComponent myForm;
|
---|
| 737 | newtComponent b_1;
|
---|
| 738 | newtComponent b_2;
|
---|
| 739 | newtComponent b_res;
|
---|
| 740 | newtComponent text;
|
---|
| 741 | newtComponent type_here;
|
---|
| 742 |
|
---|
| 743 | char *entry_value = NULL;
|
---|
| 744 | char *blurb = NULL;
|
---|
| 745 | char *out = NULL;
|
---|
| 746 |
|
---|
| 747 | assert_string_is_neither_NULL_nor_zerolength(title);
|
---|
| 748 | assert(b != NULL);
|
---|
| 749 |
|
---|
| 750 | if (g_text_mode) {
|
---|
| 751 | printf("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q---\n--> ", title, b);
|
---|
| 752 | mr_getline(out, stdin);
|
---|
| 753 | if (out[strlen(out) - 1] == '\n')
|
---|
| 754 | out[strlen(out) - 1] = '\0';
|
---|
| 755 | return(out);
|
---|
| 756 | }
|
---|
| 757 |
|
---|
| 758 | assert(input != NULL);
|
---|
| 759 | text = newtTextboxReflowed(2, 1, b, 48, 5, 5, 0);
|
---|
| 760 | type_here = newtEntry(2, newtTextboxGetNumLines(text) + 2, input, 50, (void *) &entry_value, NEWT_FLAG_RETURNEXIT);
|
---|
| 761 | b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, " OK ");
|
---|
| 762 | b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, "Cancel");
|
---|
| 763 | newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title);
|
---|
| 764 | myForm = newtForm(NULL, NULL, 0);
|
---|
| 765 | newtFormAddComponents(myForm, text, type_here, b_1, b_2, NULL);
|
---|
| 766 | blurb = mr_center_string(b, 80);
|
---|
| 767 | newtPushHelpLine(blurb);
|
---|
| 768 | b_res = newtRunForm(myForm);
|
---|
| 769 |
|
---|
[3618] | 770 | if (b_res != b_2) {
|
---|
| 771 | /* We need to copy the value as newtFormDestroy will clear entry_value */
|
---|
| 772 | mr_asprintf(out, "%s", entry_value);
|
---|
| 773 | }
|
---|
[3377] | 774 | newtPopHelpLine();
|
---|
| 775 | newtFormDestroy(myForm);
|
---|
| 776 | newtPopWindow();
|
---|
| 777 | mr_free(blurb);
|
---|
| 778 |
|
---|
| 779 | return(out);
|
---|
| 780 | }
|
---|
| 781 |
|
---|
| 782 | /**
|
---|
| 783 | * Ask the user to enter a value.
|
---|
| 784 | * @param title The title of the dialog box.
|
---|
| 785 | * @param b The blurb (e.g. what you want the user to enter).
|
---|
[1] | 786 | * @param output The string to put the user's answer in.
|
---|
| 787 | * @param maxsize The size in bytes allocated to @p output.
|
---|
| 788 | * @return TRUE if the user pressed OK, FALSE if they pressed Cancel.
|
---|
| 789 | */
|
---|
[3191] | 790 | bool popup_and_get_string(char *title, char *b, char *output, int maxsize) {
|
---|
[1] | 791 |
|
---|
[128] | 792 | /*@ newt ************************************************************ */
|
---|
| 793 | newtComponent myForm;
|
---|
| 794 | newtComponent b_1;
|
---|
| 795 | newtComponent b_2;
|
---|
| 796 | newtComponent b_res;
|
---|
| 797 | newtComponent text;
|
---|
| 798 | newtComponent type_here;
|
---|
[1] | 799 |
|
---|
[128] | 800 | /*@ pointers ********************************************************* */
|
---|
| 801 | char *entry_value;
|
---|
[1] | 802 |
|
---|
[128] | 803 | /*@ buffers ********************************************************** */
|
---|
[3191] | 804 | char *blurb = NULL;
|
---|
[3060] | 805 | char *p;
|
---|
[3191] | 806 | char *original_contents = NULL;
|
---|
[1] | 807 |
|
---|
[128] | 808 | assert_string_is_neither_NULL_nor_zerolength(title);
|
---|
| 809 | assert(b != NULL);
|
---|
| 810 | assert(output != NULL);
|
---|
[1] | 811 |
|
---|
[128] | 812 | if (g_text_mode) {
|
---|
[3191] | 813 | printf("---promptstring---1--- %s\n---promptstring---2--- %s\n---promptstring---Q---\n--> ", title, b);
|
---|
[3060] | 814 | p = fgets(output, maxsize, stdin);
|
---|
| 815 | if (!p) {
|
---|
| 816 | // FIXME
|
---|
| 817 | }
|
---|
[128] | 818 | if (output[strlen(output) - 1] == '\n')
|
---|
| 819 | output[strlen(output) - 1] = '\0';
|
---|
| 820 | return (TRUE);
|
---|
| 821 | }
|
---|
[3191] | 822 |
|
---|
| 823 | blurb = malloc(MAX_NEWT_COMMENT_LEN);
|
---|
[128] | 824 | strcpy(blurb, b);
|
---|
| 825 | text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0);
|
---|
[3191] | 826 | mr_asprintf(original_contents, "%s", output);
|
---|
[128] | 827 | output[0] = '\0';
|
---|
[3191] | 828 | type_here = newtEntry(2, newtTextboxGetNumLines(text) + 2, original_contents, 50,
|
---|
[1] | 829 | #ifdef __cplusplus
|
---|
[128] | 830 | 0, NEWT_FLAG_RETURNEXIT
|
---|
[1] | 831 | #else
|
---|
[128] | 832 | (void *) &entry_value, NEWT_FLAG_RETURNEXIT
|
---|
[1] | 833 | #endif
|
---|
[128] | 834 | );
|
---|
[541] | 835 | b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, " OK ");
|
---|
| 836 | b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, "Cancel");
|
---|
[128] | 837 | newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title);
|
---|
| 838 | myForm = newtForm(NULL, NULL, 0);
|
---|
| 839 | newtFormAddComponents(myForm, text, type_here, b_1, b_2, NULL);
|
---|
| 840 | center_string(blurb, 80);
|
---|
| 841 | newtPushHelpLine(blurb);
|
---|
| 842 | b_res = newtRunForm(myForm);
|
---|
| 843 | strcpy(output, entry_value);
|
---|
| 844 | newtPopHelpLine();
|
---|
| 845 | newtFormDestroy(myForm);
|
---|
| 846 | newtPopWindow();
|
---|
[3191] | 847 | paranoid_free(blurb);
|
---|
| 848 |
|
---|
[128] | 849 | if (b_res == b_2) {
|
---|
| 850 | strcpy(output, original_contents);
|
---|
[3191] | 851 | mr_free(original_contents);
|
---|
[128] | 852 | return (FALSE);
|
---|
| 853 | } else {
|
---|
[3191] | 854 | mr_free(original_contents);
|
---|
[128] | 855 | return (TRUE);
|
---|
| 856 | }
|
---|
| 857 | }
|
---|
[1] | 858 |
|
---|
| 859 |
|
---|
| 860 | /**
|
---|
| 861 | * Pop up a dialog box with user-defined buttons.
|
---|
| 862 | * @param p The text to put in the dialog box.
|
---|
| 863 | * @param button1 The label on the first button.
|
---|
| 864 | * @param button2 The label on the second button, or "" if you only want one button.
|
---|
| 865 | * @return TRUE if @p button1 was pushed, FALSE otherwise.
|
---|
| 866 | */
|
---|
[3191] | 867 | bool popup_with_buttons(char *p, char *button1, char *button2) {
|
---|
[1] | 868 |
|
---|
[128] | 869 | /*@ buffers *********************************************************** */
|
---|
[3191] | 870 | char *prompt = NULL;
|
---|
[1] | 871 |
|
---|
[128] | 872 | /*@ newt ************************************************************** */
|
---|
| 873 | newtComponent myForm;
|
---|
| 874 | newtComponent b_1;
|
---|
| 875 | newtComponent b_2;
|
---|
| 876 | newtComponent b_res;
|
---|
| 877 | newtComponent text;
|
---|
[1] | 878 |
|
---|
[128] | 879 | assert_string_is_neither_NULL_nor_zerolength(p);
|
---|
| 880 | assert(button1 != NULL);
|
---|
| 881 | assert(button2 != NULL);
|
---|
| 882 | if (g_text_mode) {
|
---|
| 883 | if (strlen(button2) == 0) {
|
---|
| 884 | printf("%s (%s) --> ", p, button1);
|
---|
| 885 | } else {
|
---|
| 886 | printf("%s (%s or %s) --> ", p, button1, button2);
|
---|
| 887 | }
|
---|
[3191] | 888 | mr_getline(prompt, stdin);
|
---|
| 889 | while (strcmp(prompt, button1) && (strlen(button2) == 0 || strcmp(prompt, button2))) {
|
---|
[128] | 890 | printf("--> ");
|
---|
[3191] | 891 | mr_free(prompt);
|
---|
| 892 | mr_getline(prompt, stdin);
|
---|
[128] | 893 | }
|
---|
[2136] | 894 | if (!strcmp(prompt, button1)) {
|
---|
[3191] | 895 | mr_free(prompt);
|
---|
[128] | 896 | return (TRUE);
|
---|
| 897 | } else {
|
---|
[3191] | 898 | mr_free(prompt);
|
---|
[128] | 899 | return (FALSE);
|
---|
| 900 | }
|
---|
| 901 | }
|
---|
[1] | 902 |
|
---|
[3191] | 903 | prompt = malloc(MAX_NEWT_COMMENT_LEN);
|
---|
[877] | 904 | strncpy(prompt, p, MAX_NEWT_COMMENT_LEN - 1);
|
---|
[883] | 905 | prompt[MAX_NEWT_COMMENT_LEN - 1] = '\0';
|
---|
[128] | 906 | text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0);
|
---|
[3191] | 907 | b_1 = newtButton(20 - ((button2[0] != '\0') ? strlen(button1) + 2 : strlen(button1) / 2), newtTextboxGetNumLines(text) + 3, button1);
|
---|
[128] | 908 | if (button2[0] != '\0') {
|
---|
[3191] | 909 | b_2 = newtButton(24, newtTextboxGetNumLines(text) + 3, button2);
|
---|
[128] | 910 | } else {
|
---|
| 911 | b_2 = NULL;
|
---|
| 912 | }
|
---|
[541] | 913 | newtCenteredWindow(46, newtTextboxGetNumLines(text) + 7, "Alert");
|
---|
[128] | 914 | myForm = newtForm(NULL, NULL, 0);
|
---|
| 915 | newtFormAddComponents(myForm, text, b_1, b_2, NULL);
|
---|
| 916 | center_string(prompt, 80);
|
---|
| 917 | newtPushHelpLine(prompt);
|
---|
| 918 | b_res = newtRunForm(myForm);
|
---|
| 919 | newtPopHelpLine();
|
---|
| 920 | newtFormDestroy(myForm);
|
---|
| 921 | newtPopWindow();
|
---|
| 922 | if (b_res == b_1) {
|
---|
| 923 | paranoid_free(prompt);
|
---|
| 924 | return (TRUE);
|
---|
| 925 | } else {
|
---|
| 926 | paranoid_free(prompt);
|
---|
| 927 | return (FALSE);
|
---|
| 928 | }
|
---|
| 929 | }
|
---|
[1] | 930 |
|
---|
| 931 |
|
---|
| 932 |
|
---|
[128] | 933 |
|
---|
[1] | 934 | /**
|
---|
| 935 | * Synchronize the log messages stored in @p err_log_lines with those shown
|
---|
| 936 | * on the screen.
|
---|
| 937 | */
|
---|
[3191] | 938 | void refresh_log_screen() {
|
---|
[1] | 939 |
|
---|
[128] | 940 | /*@ int *********************************************************** */
|
---|
| 941 | int i = 0;
|
---|
[1] | 942 |
|
---|
| 943 |
|
---|
[128] | 944 | if (g_text_mode || !err_log_lines) {
|
---|
| 945 | return;
|
---|
| 946 | }
|
---|
| 947 | for (i = g_noof_log_lines - 1; i >= 0; i--) {
|
---|
| 948 | newtDrawRootText(0, i + g_noof_rows - 1 - g_noof_log_lines,
|
---|
| 949 | " ");
|
---|
| 950 | }
|
---|
| 951 | newtRefresh();
|
---|
| 952 | for (i = g_noof_log_lines - 1; i >= 0; i--) {
|
---|
| 953 | err_log_lines[i][79] = '\0';
|
---|
| 954 | newtDrawRootText(0, i + g_noof_rows - 1 - g_noof_log_lines,
|
---|
| 955 | err_log_lines[i]);
|
---|
| 956 | }
|
---|
| 957 | newtRefresh();
|
---|
| 958 | }
|
---|
[1] | 959 |
|
---|
| 960 |
|
---|
| 961 | /**
|
---|
| 962 | * Set up the Newt graphical environment. If @p g_text_mode is TRUE, then
|
---|
| 963 | * only allocate some memory.
|
---|
| 964 | */
|
---|
[3191] | 965 | void setup_newt_stuff() {
|
---|
[1] | 966 |
|
---|
[128] | 967 | /*@ int *********************************************************** */
|
---|
| 968 | int i = 0;
|
---|
| 969 | int cols;
|
---|
[1] | 970 |
|
---|
[128] | 971 | if (!g_text_mode) {
|
---|
| 972 | newtInit();
|
---|
| 973 | newtCls();
|
---|
[3191] | 974 | newtPushHelpLine("Welcome to Mondo Rescue, by Dev Team and the Internet. All rights reversed.");
|
---|
[128] | 975 | newtDrawRootText(18, 0, WELCOME_STRING);
|
---|
| 976 | newtRefresh();
|
---|
| 977 | newtGetScreenSize(&cols, &g_noof_rows);
|
---|
| 978 | g_noof_log_lines = (g_noof_rows / 5) + 1;
|
---|
| 979 | }
|
---|
[1] | 980 |
|
---|
[3191] | 981 | err_log_lines = (char **) mr_malloc(sizeof(char *) * g_noof_log_lines);
|
---|
[1] | 982 |
|
---|
[128] | 983 | for (i = 0; i < g_noof_log_lines; i++) {
|
---|
[3191] | 984 | err_log_lines[i] = (char *) mr_malloc(MAX_NEWT_COMMENT_LEN);
|
---|
[128] | 985 | }
|
---|
[1] | 986 |
|
---|
[128] | 987 | for (i = 0; i < g_noof_log_lines; i++) {
|
---|
| 988 | err_log_lines[i][0] = '\0';
|
---|
| 989 | }
|
---|
| 990 | }
|
---|
[1] | 991 |
|
---|
| 992 |
|
---|
| 993 | /**
|
---|
| 994 | * Update the evalcall form to show (<tt>num</tt>/<tt>denom</tt>)*100 %.
|
---|
| 995 | * @param num The numerator of the ratio.
|
---|
| 996 | * @param denom The denomenator of the ratio.
|
---|
| 997 | */
|
---|
[3191] | 998 | void update_evalcall_form_ratio(int num, int denom) {
|
---|
[1] | 999 |
|
---|
[128] | 1000 | /*@ long ************************************************************ */
|
---|
[3191] | 1001 | long current_time = 0L;
|
---|
| 1002 | long time_taken = 0L;
|
---|
| 1003 | long time_total_est = 0L;
|
---|
| 1004 | long time_remaining = 0L;
|
---|
[1] | 1005 |
|
---|
[128] | 1006 | /*@ buffers ********************************************************** */
|
---|
[3191] | 1007 | char *timeline_str = NULL;
|
---|
[2211] | 1008 | char *pcline_str = NULL;
|
---|
| 1009 | char *taskprogress = NULL;
|
---|
[1] | 1010 |
|
---|
[128] | 1011 | /*@ int ************************************************************** */
|
---|
| 1012 | int percentage = 0;
|
---|
| 1013 | int i = 0;
|
---|
| 1014 | int j = 0;
|
---|
[1] | 1015 |
|
---|
[128] | 1016 | if (num * 100 < denom) {
|
---|
| 1017 | percentage = 1;
|
---|
| 1018 | } else {
|
---|
| 1019 | percentage = (num * 100 + denom / 2) / denom;
|
---|
| 1020 | }
|
---|
| 1021 |
|
---|
| 1022 | current_time = get_time();
|
---|
| 1023 | time_taken = current_time - g_isoform_starttime;
|
---|
| 1024 | if (num) {
|
---|
| 1025 | time_total_est = time_taken * denom / num;
|
---|
| 1026 | time_remaining = time_total_est - time_taken;
|
---|
| 1027 | } else {
|
---|
[3191] | 1028 | time_remaining = 0L;
|
---|
[128] | 1029 | }
|
---|
| 1030 | if (!g_text_mode) {
|
---|
[1899] | 1031 | if (g_isoform_header) {
|
---|
| 1032 | newtLabelSetText(g_isoform_header, g_isoform_header_str);
|
---|
| 1033 | }
|
---|
[128] | 1034 | }
|
---|
| 1035 | g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27;
|
---|
[3205] | 1036 | if ((percentage < 3 && g_isoform_old_progress < 3) || percentage > g_isoform_old_progress) {
|
---|
[128] | 1037 | g_isoform_old_progress = percentage;
|
---|
[3191] | 1038 | 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] | 1039 | if (percentage < 3) {
|
---|
[3185] | 1040 | mr_asprintf(pcline_str, " Working");
|
---|
[128] | 1041 | for (j = 0; j < g_mysterious_dot_counter; j++) {
|
---|
[2211] | 1042 | mr_strcat(pcline_str, ".");
|
---|
[128] | 1043 | }
|
---|
| 1044 | for (; j < 27; j++) {
|
---|
[2211] | 1045 | mr_strcat(pcline_str, " ");
|
---|
[128] | 1046 | }
|
---|
[2211] | 1047 | mr_strcat(pcline_str, " %c", special_dot_char(g_mysterious_dot_counter));
|
---|
[128] | 1048 | } else {
|
---|
[3191] | 1049 | mr_asprintf(pcline_str, " %3d%% done %3d%% to go", percentage, 100 - percentage);
|
---|
[128] | 1050 | }
|
---|
| 1051 | if (g_text_mode) {
|
---|
[3185] | 1052 | mr_asprintf(taskprogress, "TASK: [");
|
---|
[128] | 1053 | for (i = 0; i < percentage; i += 5) {
|
---|
[2211] | 1054 | mr_strcat(taskprogress, "*");
|
---|
[128] | 1055 | }
|
---|
| 1056 | for (; i < 100; i += 5) {
|
---|
[2211] | 1057 | mr_strcat(taskprogress, ".");
|
---|
[128] | 1058 | }
|
---|
| 1059 | if (percentage >= 3) {
|
---|
[3191] | 1060 | mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage, (long) time_remaining / 60, (long) time_remaining % 60);
|
---|
| 1061 | printf("---evalcall---1--- %s\n", g_isoform_header_str);
|
---|
[1899] | 1062 | printf("---evalcall---2--- %s\n", taskprogress);
|
---|
| 1063 | printf("---evalcall---E---\n");
|
---|
[128] | 1064 | }
|
---|
[3191] | 1065 | mr_free(taskprogress);
|
---|
[128] | 1066 | } else {
|
---|
[3191] | 1067 | newtScaleSet(g_isoform_scale, (unsigned long long) percentage);
|
---|
[1899] | 1068 | if (g_isoform_pcline) {
|
---|
| 1069 | newtLabelSetText(g_isoform_pcline, pcline_str);
|
---|
| 1070 | }
|
---|
| 1071 | if ((percentage >= 3) && (g_isoform_timeline)) {
|
---|
[128] | 1072 | newtLabelSetText(g_isoform_timeline, timeline_str);
|
---|
| 1073 | }
|
---|
| 1074 | }
|
---|
[3191] | 1075 | mr_free(pcline_str);
|
---|
| 1076 | mr_free(timeline_str);
|
---|
[128] | 1077 | }
|
---|
| 1078 | if (!g_text_mode) {
|
---|
[2879] | 1079 | newtDrawForm(g_isoform_main);
|
---|
[128] | 1080 | newtRefresh();
|
---|
| 1081 | }
|
---|
[1] | 1082 | }
|
---|
| 1083 |
|
---|
| 1084 |
|
---|
| 1085 |
|
---|
| 1086 | /**
|
---|
| 1087 | * Update the evalcall form to show @p curr %.
|
---|
| 1088 | * @param curr The current amount of progress (percentage) in the evalcall form.
|
---|
| 1089 | */
|
---|
[3191] | 1090 | void update_evalcall_form(int curr) {
|
---|
| 1091 |
|
---|
[128] | 1092 | update_evalcall_form_ratio(curr, 100);
|
---|
[3191] | 1093 | }
|
---|
[1] | 1094 |
|
---|
| 1095 |
|
---|
| 1096 |
|
---|
| 1097 | /**
|
---|
| 1098 | * Update the progress form to show @p blurb3 and the current value of
|
---|
| 1099 | * @p g_maximum_progress.
|
---|
| 1100 | * @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.
|
---|
| 1101 | */
|
---|
[3191] | 1102 | void update_progress_form(char *blurb3) {
|
---|
| 1103 |
|
---|
[128] | 1104 | if (g_current_progress == -999) {
|
---|
| 1105 | return;
|
---|
| 1106 | }
|
---|
| 1107 | strcpy(g_blurb_str_2, blurb3);
|
---|
[3191] | 1108 | update_progress_form_full(g_blurb_str_1, g_blurb_str_2, g_blurb_str_3);
|
---|
| 1109 | }
|
---|
[1] | 1110 |
|
---|
| 1111 |
|
---|
| 1112 | /**
|
---|
| 1113 | * Update the progress form's complete blurb and show @p g_current_progress.
|
---|
| 1114 | * @param blurb1 The first line of the blurb. Use @p g_blurb_str_1 to keep it unchanged.
|
---|
| 1115 | * @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.
|
---|
| 1116 | * @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.
|
---|
| 1117 | */
|
---|
[3191] | 1118 | void update_progress_form_full(char *blurb1, char *blurb2, char *blurb3) {
|
---|
| 1119 |
|
---|
[128] | 1120 | /*@ long ***************************************************** */
|
---|
[2374] | 1121 | long current_time = 0L;
|
---|
| 1122 | long time_taken = 0L;
|
---|
| 1123 | long time_remaining = 0L;
|
---|
| 1124 | long time_total_est = 0L;
|
---|
[1] | 1125 |
|
---|
[128] | 1126 | /*@ int ******************************************************* */
|
---|
| 1127 | int percentage = 0;
|
---|
| 1128 | int i = 0;
|
---|
[1] | 1129 |
|
---|
[128] | 1130 | /*@ buffers *************************************************** */
|
---|
[3191] | 1131 | char *percentline_str = NULL;
|
---|
| 1132 | char *timeline_str = NULL;
|
---|
[2211] | 1133 | char *taskprogress = NULL;
|
---|
[1] | 1134 |
|
---|
[128] | 1135 | if (!g_text_mode) {
|
---|
| 1136 | assert(blurb1 != NULL);
|
---|
| 1137 | assert(blurb2 != NULL);
|
---|
| 1138 | assert(blurb3 != NULL);
|
---|
| 1139 | assert(g_timeline != NULL);
|
---|
| 1140 | }
|
---|
[1] | 1141 |
|
---|
[128] | 1142 | current_time = get_time();
|
---|
| 1143 | time_taken = current_time - g_start_time;
|
---|
| 1144 | if (g_maximum_progress == 0) {
|
---|
| 1145 | percentage = 0;
|
---|
| 1146 | } else {
|
---|
| 1147 | if (g_current_progress > g_maximum_progress) {
|
---|
[3191] | 1148 | 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] | 1149 | g_current_progress = g_maximum_progress;
|
---|
| 1150 | }
|
---|
[3191] | 1151 | percentage = (int) ((g_current_progress * 100L) / g_maximum_progress);
|
---|
[128] | 1152 | }
|
---|
| 1153 | if (percentage < 1) {
|
---|
| 1154 | percentage = 1;
|
---|
| 1155 | }
|
---|
| 1156 | if (percentage > 100) {
|
---|
| 1157 | percentage = 100;
|
---|
| 1158 | }
|
---|
| 1159 | if (g_current_progress) {
|
---|
[3191] | 1160 | time_total_est = time_taken * (long) g_maximum_progress / (long) g_current_progress;
|
---|
[128] | 1161 | time_remaining = time_total_est - time_taken;
|
---|
| 1162 | } else {
|
---|
[2374] | 1163 | time_remaining = 0L;
|
---|
[128] | 1164 | }
|
---|
| 1165 | g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27;
|
---|
| 1166 | if (g_text_mode) {
|
---|
[1899] | 1167 | printf("---progress-form---1--- %s\n", blurb1);
|
---|
| 1168 | printf("---progress-form---2--- %s\n", blurb2);
|
---|
| 1169 | printf("---progress-form---3--- %s\n", blurb3);
|
---|
[541] | 1170 | printf("---progress-form---E---\n");
|
---|
[3185] | 1171 | mr_asprintf(taskprogress, "TASK: [");
|
---|
[128] | 1172 | for (i = 0; i < percentage; i += 5) {
|
---|
[2211] | 1173 | mr_strcat(taskprogress, "*");
|
---|
[128] | 1174 | }
|
---|
| 1175 | for (; i < 100; i += 5) {
|
---|
[2211] | 1176 | mr_strcat(taskprogress, ".");
|
---|
[128] | 1177 | }
|
---|
| 1178 | if (percentage > 100) {
|
---|
[541] | 1179 | log_msg(2, "percentage = %d", percentage);
|
---|
[128] | 1180 | }
|
---|
[3191] | 1181 | mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage, (long) time_remaining / 60, (long) time_remaining % 60);
|
---|
[1899] | 1182 | printf("---progress-form---4--- %s\n", taskprogress);
|
---|
[2211] | 1183 | paranoid_free(taskprogress);
|
---|
[128] | 1184 | } else {
|
---|
[3191] | 1185 | 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);
|
---|
| 1186 | mr_asprintf(percentline_str, " %3d%% done %3d%% to go", percentage, 100 - percentage);
|
---|
| 1187 |
|
---|
[128] | 1188 | center_string(blurb1, 54);
|
---|
| 1189 | center_string(blurb2, 54);
|
---|
| 1190 | center_string(blurb3, 54);
|
---|
[1899] | 1191 | if (g_blurb1) {
|
---|
| 1192 | newtLabelSetText(g_blurb1, blurb1);
|
---|
| 1193 | }
|
---|
| 1194 | if (g_blurb2) {
|
---|
| 1195 | newtLabelSetText(g_blurb2, blurb3);
|
---|
| 1196 | }
|
---|
| 1197 | if (g_blurb3) {
|
---|
| 1198 | newtLabelSetText(g_blurb3, blurb2);
|
---|
| 1199 | }
|
---|
[128] | 1200 | newtScaleSet(g_scale, (unsigned long long) g_current_progress);
|
---|
[1899] | 1201 | if ((percentage >= 2) && (g_timeline)) {
|
---|
[128] | 1202 | newtLabelSetText(g_timeline, timeline_str);
|
---|
| 1203 | }
|
---|
[3191] | 1204 | mr_free(timeline_str);
|
---|
| 1205 |
|
---|
[1899] | 1206 | if (g_percentline) {
|
---|
| 1207 | newtLabelSetText(g_percentline, percentline_str);
|
---|
| 1208 | }
|
---|
[3191] | 1209 | mr_free(percentline_str);
|
---|
| 1210 |
|
---|
[2879] | 1211 | newtDrawForm(g_progressForm);
|
---|
[128] | 1212 | newtRefresh();
|
---|
| 1213 | }
|
---|
[1] | 1214 | }
|
---|
| 1215 |
|
---|
| 1216 |
|
---|
| 1217 | /**
|
---|
| 1218 | * Ask the user which backup media type they would like to use.
|
---|
| 1219 | * The choices are @p none (exit to shell), @c cdr, @c cdrw, @c dvd,
|
---|
[2380] | 1220 | * @c tape, @c cdstream, @c udev (only when @p g_text_mode is TRUE), @c netfs,
|
---|
[1] | 1221 | * and @c iso.
|
---|
| 1222 | * @param restoring TRUE if we're restoring, FALSE if we're backing up.
|
---|
| 1223 | * @return The backup type chosen, or @c none if the user chose "Exit to shell".
|
---|
| 1224 | */
|
---|
[3191] | 1225 | t_bkptype which_backup_media_type(bool restoring) {
|
---|
[1] | 1226 |
|
---|
[128] | 1227 | /*@ char ************************************************************ */
|
---|
| 1228 | t_bkptype output;
|
---|
[1] | 1229 |
|
---|
| 1230 |
|
---|
[128] | 1231 | /*@ newt ************************************************************ */
|
---|
[3191] | 1232 | char *title_sz = NULL;
|
---|
| 1233 | char *minimsg_sz = NULL;
|
---|
| 1234 | static t_bkptype possible_bkptypes[] = { none, cdr, cdrw, dvd, tape, cdstream, udev, netfs, iso };
|
---|
| 1235 | static char *possible_responses[] = { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev", "netfs", "iso", NULL };
|
---|
| 1236 | char *outstr = NULL;
|
---|
[3614] | 1237 | char *instr = NULL;
|
---|
[128] | 1238 | t_bkptype backup_type;
|
---|
| 1239 | int i;
|
---|
[1] | 1240 |
|
---|
[128] | 1241 | newtComponent b1;
|
---|
| 1242 | newtComponent b2;
|
---|
| 1243 | newtComponent b3;
|
---|
| 1244 | newtComponent b4;
|
---|
| 1245 | newtComponent b5;
|
---|
| 1246 | newtComponent b6;
|
---|
| 1247 | newtComponent b7;
|
---|
| 1248 | newtComponent b8;
|
---|
| 1249 | newtComponent b_res;
|
---|
| 1250 | newtComponent myForm;
|
---|
[1] | 1251 |
|
---|
[128] | 1252 | if (g_text_mode) {
|
---|
| 1253 | for (backup_type = none; backup_type == none;) {
|
---|
[541] | 1254 | printf("Backup type (");
|
---|
[128] | 1255 | for (i = 0; possible_responses[i]; i++) {
|
---|
| 1256 | printf("%c%s", (i == 0) ? '\0' : ' ',
|
---|
| 1257 | possible_responses[i]);
|
---|
| 1258 | }
|
---|
| 1259 | printf(")\n--> ");
|
---|
[3614] | 1260 | mr_getline(instr, stdin);
|
---|
| 1261 | outstr = mr_strip_spaces(instr);
|
---|
| 1262 | mr_free(instr);
|
---|
[128] | 1263 | for (i = 0; possible_responses[i]; i++) {
|
---|
| 1264 | if (!strcmp(possible_responses[i], outstr)) {
|
---|
| 1265 | backup_type = possible_bkptypes[i];
|
---|
| 1266 | }
|
---|
| 1267 | }
|
---|
[3191] | 1268 | mr_free(outstr);
|
---|
[128] | 1269 | }
|
---|
| 1270 | return (backup_type);
|
---|
| 1271 | }
|
---|
| 1272 | newtDrawRootText(18, 0, WELCOME_STRING);
|
---|
| 1273 | if (restoring) {
|
---|
[3191] | 1274 | mr_asprintf(title_sz, "Please choose the backup media from which you want to read data.");
|
---|
| 1275 | mr_asprintf(minimsg_sz, "Read from:");
|
---|
[128] | 1276 | } else {
|
---|
[3191] | 1277 | mr_asprintf(title_sz, "Please choose the backup media to which you want to archive data.");
|
---|
| 1278 | mr_asprintf(minimsg_sz, "Backup to:");
|
---|
[128] | 1279 | }
|
---|
| 1280 | newtPushHelpLine(title_sz);
|
---|
| 1281 | newtCenteredWindow(34, 17, minimsg_sz);
|
---|
[541] | 1282 | b1 = newtButton(1, 1, "CD-R disks ");
|
---|
| 1283 | b2 = newtButton(17, 1, "CD-RW disks");
|
---|
| 1284 | b3 = newtButton(1, 9, "Tape drive ");
|
---|
[1703] | 1285 | b4 = newtButton(17, 5, "USB Key/Disk");
|
---|
[541] | 1286 | b5 = newtButton(1, 5, " DVD disks ");
|
---|
[2380] | 1287 | b6 = newtButton(17, 9, " Net mount ");
|
---|
[541] | 1288 | b7 = newtButton(1, 13, " Hard disk ");
|
---|
| 1289 | b8 = newtButton(17, 13, " Exit ");
|
---|
[128] | 1290 | myForm = newtForm(NULL, NULL, 0);
|
---|
[3477] | 1291 | newtFormAddComponents(myForm, b1, b5, b3, b7, b2, b4, b6, b8, NULL);
|
---|
[128] | 1292 | b_res = newtRunForm(myForm);
|
---|
| 1293 | newtFormDestroy(myForm);
|
---|
| 1294 | newtPopWindow();
|
---|
| 1295 | if (b_res == b1) {
|
---|
| 1296 | output = cdr;
|
---|
| 1297 | } else if (b_res == b2) {
|
---|
| 1298 | output = cdrw;
|
---|
| 1299 | } else if (b_res == b3) {
|
---|
| 1300 | output = tape;
|
---|
| 1301 | } else if (b_res == b4) {
|
---|
[1703] | 1302 | output = usb;
|
---|
[128] | 1303 | } else if (b_res == b5) {
|
---|
| 1304 | output = dvd;
|
---|
| 1305 | } else if (b_res == b6) {
|
---|
[2380] | 1306 | output = netfs;
|
---|
[128] | 1307 | } else if (b_res == b7) {
|
---|
| 1308 | output = iso;
|
---|
| 1309 | } else {
|
---|
| 1310 | output = none;
|
---|
| 1311 | }
|
---|
| 1312 | newtPopHelpLine();
|
---|
[3191] | 1313 | mr_free(title_sz);
|
---|
| 1314 | mr_free(minimsg_sz);
|
---|
[128] | 1315 | return (output);
|
---|
| 1316 | }
|
---|
[1] | 1317 |
|
---|
| 1318 |
|
---|
| 1319 |
|
---|
| 1320 |
|
---|
| 1321 | /**
|
---|
[2771] | 1322 | * Ask the user which compression type they would like to use.
|
---|
[3207] | 1323 | * The choices are "bzip2", "gzip", "lzo", "lzma". NULL for exit
|
---|
[2771] | 1324 | */
|
---|
| 1325 | char *which_compression_type() {
|
---|
| 1326 |
|
---|
| 1327 | /*@ char ************************************************************ */
|
---|
| 1328 | char *output = NULL;
|
---|
| 1329 |
|
---|
| 1330 |
|
---|
| 1331 | /*@ newt ************************************************************ */
|
---|
| 1332 |
|
---|
| 1333 | newtComponent b1;
|
---|
| 1334 | newtComponent b2;
|
---|
| 1335 | newtComponent b3;
|
---|
[3191] | 1336 | newtComponent b4;
|
---|
[2771] | 1337 | newtComponent b5;
|
---|
| 1338 | newtComponent b_res;
|
---|
| 1339 | newtComponent myForm;
|
---|
| 1340 |
|
---|
| 1341 | newtDrawRootText(18, 0, WELCOME_STRING);
|
---|
| 1342 | newtPushHelpLine
|
---|
| 1343 | (" Please specify the type of compression that you want.");
|
---|
| 1344 | newtCenteredWindow(34, 13, "Type of compression?");
|
---|
| 1345 | b1 = newtButton(4, 1, "bzip2");
|
---|
| 1346 | b2 = newtButton(18, 1, "gzip");
|
---|
| 1347 | b3 = newtButton(4, 5, "lzo");
|
---|
[3191] | 1348 | b4 = newtButton(18, 5, "lzma");
|
---|
[2771] | 1349 | b5 = newtButton(4, 9, " Exit ");
|
---|
| 1350 | myForm = newtForm(NULL, NULL, 0);
|
---|
[3207] | 1351 | newtFormAddComponents(myForm, b1, b3, b2, b4, b5, NULL);
|
---|
[2771] | 1352 | b_res = newtRunForm(myForm);
|
---|
| 1353 | newtFormDestroy(myForm);
|
---|
| 1354 | newtPopWindow();
|
---|
| 1355 | if (b_res == b1) {
|
---|
[3185] | 1356 | mr_asprintf(output, "%s", "bzip2");
|
---|
[2771] | 1357 | } else if (b_res == b2) {
|
---|
[3185] | 1358 | mr_asprintf(output, "%s", "gzip");
|
---|
[2771] | 1359 | } else if (b_res == b3) {
|
---|
[3185] | 1360 | mr_asprintf(output, "%s", "lzo");
|
---|
[3191] | 1361 | } else if (b_res == b4) {
|
---|
| 1362 | mr_asprintf(output, "%s", "lzma");
|
---|
[2771] | 1363 | }
|
---|
| 1364 | newtPopHelpLine();
|
---|
| 1365 | return(output);
|
---|
| 1366 | }
|
---|
| 1367 |
|
---|
| 1368 |
|
---|
| 1369 | /**
|
---|
[1] | 1370 | * Ask the user how much compression they would like to use.
|
---|
| 1371 | * The choices are "None" (0), "Minimum" (1), "Average" (4), and "Maximum" (9).
|
---|
| 1372 | * @return The compression level (0-9) chosen, or -1 for "Exit".
|
---|
| 1373 | */
|
---|
[3191] | 1374 | int which_compression_level() {
|
---|
[1] | 1375 |
|
---|
[128] | 1376 | /*@ char ************************************************************ */
|
---|
| 1377 | int output = none;
|
---|
[1] | 1378 |
|
---|
| 1379 |
|
---|
[128] | 1380 | /*@ newt ************************************************************ */
|
---|
[1] | 1381 |
|
---|
[128] | 1382 | newtComponent b1;
|
---|
| 1383 | newtComponent b2;
|
---|
| 1384 | newtComponent b3;
|
---|
| 1385 | newtComponent b4;
|
---|
| 1386 | newtComponent b5;
|
---|
| 1387 | newtComponent b_res;
|
---|
| 1388 | newtComponent myForm;
|
---|
[1] | 1389 |
|
---|
[128] | 1390 | newtDrawRootText(18, 0, WELCOME_STRING);
|
---|
[3191] | 1391 | newtPushHelpLine(" Please specify the level of compression that you want.");
|
---|
[541] | 1392 | newtCenteredWindow(34, 13, "How much compression?");
|
---|
[3114] | 1393 | b1 = newtButton(4, 1, "Maximum (9)");
|
---|
| 1394 | b2 = newtButton(18, 1, "Average (4)");
|
---|
| 1395 | b3 = newtButton(4, 5, "Minimum (1)");
|
---|
| 1396 | b4 = newtButton(18, 5, " None (0) ");
|
---|
[541] | 1397 | b5 = newtButton(4, 9, " Exit ");
|
---|
[128] | 1398 | myForm = newtForm(NULL, NULL, 0);
|
---|
| 1399 | newtFormAddComponents(myForm, b1, b3, b2, b4, b5, NULL);
|
---|
| 1400 | b_res = newtRunForm(myForm);
|
---|
| 1401 | newtFormDestroy(myForm);
|
---|
| 1402 | newtPopWindow();
|
---|
| 1403 | if (b_res == b1) {
|
---|
| 1404 | output = 9;
|
---|
| 1405 | } else if (b_res == b2) {
|
---|
| 1406 | output = 4;
|
---|
| 1407 | } else if (b_res == b3) {
|
---|
| 1408 | output = 1;
|
---|
| 1409 | } else if (b_res == b4) {
|
---|
| 1410 | output = 0;
|
---|
| 1411 | } else if (b_res == b5) {
|
---|
| 1412 | output = -1;
|
---|
| 1413 | }
|
---|
| 1414 | newtPopHelpLine();
|
---|
| 1415 | return (output);
|
---|
| 1416 | }
|
---|
[1] | 1417 |
|
---|
| 1418 |
|
---|
| 1419 |
|
---|
| 1420 |
|
---|
| 1421 |
|
---|
| 1422 | /**
|
---|
| 1423 | * Load @p source_file (a list of files) into @p filelist. There can be no more than
|
---|
| 1424 | * @p ARBITRARY_MAXIMUM entries.
|
---|
| 1425 | * @param filelist The filelist structure to load @p source_file into.
|
---|
| 1426 | * @param source_file The file containing a list of filenames to load into @p filelist.
|
---|
| 1427 | */
|
---|
[3191] | 1428 | int load_filelist_into_array(struct s_filelist *filelist, char *source_file) {
|
---|
| 1429 |
|
---|
[128] | 1430 | int i;
|
---|
[1662] | 1431 | int j = 0;
|
---|
[128] | 1432 | bool done;
|
---|
[3191] | 1433 | char *tmp = NULL;
|
---|
[1662] | 1434 | char *tmp1 = NULL;
|
---|
| 1435 | FILE *fin, *fout;
|
---|
[128] | 1436 | struct s_filelist_entry dummy_fle;
|
---|
[1] | 1437 |
|
---|
[128] | 1438 | assert(filelist != NULL);
|
---|
| 1439 | assert_string_is_neither_NULL_nor_zerolength(source_file);
|
---|
[1] | 1440 |
|
---|
[2230] | 1441 | log_it("entering");
|
---|
[128] | 1442 | if (!(fin = fopen(source_file, "r"))) {
|
---|
| 1443 | log_OS_error(source_file);
|
---|
| 1444 | log_msg(2, "Can't open %s; therefore, cannot popup list",
|
---|
| 1445 | source_file);
|
---|
| 1446 | return (1);
|
---|
| 1447 | }
|
---|
[1662] | 1448 |
|
---|
[3185] | 1449 | mr_asprintf(tmp1,"%s/icantfindthesefiles.txt",bkpinfo->tmpdir);
|
---|
[1662] | 1450 | if (!(fout = fopen(tmp1, "a"))) {
|
---|
| 1451 | log_msg(2, "Can't write to %s", tmp1);
|
---|
[3191] | 1452 | mr_free(tmp1);
|
---|
[1662] | 1453 | return(1);
|
---|
| 1454 | }
|
---|
| 1455 |
|
---|
[128] | 1456 | log_msg(2, "Loading %s", source_file);
|
---|
[3191] | 1457 | for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM; ) {
|
---|
| 1458 | mr_free(tmp);
|
---|
[128] | 1459 | if (feof(fin)) {
|
---|
| 1460 | break;
|
---|
| 1461 | }
|
---|
[3191] | 1462 | mr_getline(tmp, fin);
|
---|
[128] | 1463 | i = (int) strlen(tmp);
|
---|
| 1464 | if (i < 2) {
|
---|
[3191] | 1465 | continue;
|
---|
[128] | 1466 | }
|
---|
| 1467 | if (tmp[i - 1] < 32) {
|
---|
| 1468 | tmp[--i] = '\0';
|
---|
| 1469 | }
|
---|
| 1470 | if (i < 2) {
|
---|
[3191] | 1471 | continue;
|
---|
[128] | 1472 | }
|
---|
[1662] | 1473 | if (!does_file_exist(tmp) && !feof(fin)) {
|
---|
| 1474 | j++;
|
---|
| 1475 | fprintf(fout, "%s\n", tmp);
|
---|
[3191] | 1476 | continue;
|
---|
[128] | 1477 | }
|
---|
[3191] | 1478 | filelist->el[filelist->entries].severity = severity_of_difference(tmp, NULL);
|
---|
[128] | 1479 | strcpy(filelist->el[filelist->entries].filename, tmp);
|
---|
| 1480 | if (feof(fin)) {
|
---|
| 1481 | break;
|
---|
| 1482 | }
|
---|
[3191] | 1483 | filelist->entries++;
|
---|
[128] | 1484 | }
|
---|
[3191] | 1485 | mr_free(tmp);
|
---|
[128] | 1486 | paranoid_fclose(fin);
|
---|
[1662] | 1487 | paranoid_fclose(fout);
|
---|
| 1488 | if (j > 0) {
|
---|
| 1489 | 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);
|
---|
| 1490 | }
|
---|
[3191] | 1491 | mr_free(tmp1);
|
---|
[128] | 1492 | if (filelist->entries >= ARBITRARY_MAXIMUM) {
|
---|
[541] | 1493 | log_to_screen("Arbitrary limits suck, man!");
|
---|
[128] | 1494 | return (1);
|
---|
| 1495 | }
|
---|
| 1496 | for (done = FALSE; !done;) {
|
---|
| 1497 | done = TRUE;
|
---|
| 1498 | for (i = 0; i < filelist->entries - 1; i++) {
|
---|
[1] | 1499 | // if (strcmp(filelist->el[i].filename, filelist->el[i+1].filename) > 0)
|
---|
[128] | 1500 | if (filelist->el[i].severity < filelist->el[i + 1].severity
|
---|
| 1501 | || (filelist->el[i].severity ==
|
---|
| 1502 | filelist->el[i + 1].severity
|
---|
| 1503 | && strcmp(filelist->el[i].filename,
|
---|
| 1504 | filelist->el[i + 1].filename) > 0)) {
|
---|
| 1505 | memcpy((void *) &dummy_fle,
|
---|
| 1506 | (void *) &(filelist->el[i]),
|
---|
| 1507 | sizeof(struct s_filelist_entry));
|
---|
| 1508 | memcpy((void *) &(filelist->el[i]),
|
---|
| 1509 | (void *) &(filelist->el[i + 1]),
|
---|
| 1510 | sizeof(struct s_filelist_entry));
|
---|
| 1511 | memcpy((void *) &(filelist->el[i + 1]),
|
---|
| 1512 | (void *) &dummy_fle,
|
---|
| 1513 | sizeof(struct s_filelist_entry));
|
---|
| 1514 | log_msg(2, "Swapping %s and %s",
|
---|
| 1515 | filelist->el[i].filename,
|
---|
| 1516 | filelist->el[i + 1].filename);
|
---|
| 1517 | done = FALSE;
|
---|
| 1518 | }
|
---|
| 1519 | }
|
---|
| 1520 | }
|
---|
[2230] | 1521 | log_it("leaving");
|
---|
[128] | 1522 | return (0);
|
---|
| 1523 | }
|
---|
[1] | 1524 |
|
---|
| 1525 |
|
---|
| 1526 | /**
|
---|
| 1527 | * Generate a pretty string based on @p flentry.
|
---|
| 1528 | * @param flentry The filelist entry to stringify.
|
---|
| 1529 | * @return The string form of @p flentry.
|
---|
| 1530 | * @note The returned value points to static storage that will be overwritten with each call.
|
---|
| 1531 | */
|
---|
[3191] | 1532 | char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
|
---|
[128] | 1533 | static char comment[100];
|
---|
[2211] | 1534 | char *tmp = NULL;
|
---|
[1] | 1535 |
|
---|
[3191] | 1536 | log_msg(8, "entering");
|
---|
[128] | 1537 | assert(flentry != NULL);
|
---|
| 1538 | if (flentry->severity == 0) {
|
---|
[3185] | 1539 | mr_asprintf(tmp, "0 ");
|
---|
[128] | 1540 | } else if (flentry->severity == 1) {
|
---|
[3185] | 1541 | mr_asprintf(tmp, "low ");
|
---|
[128] | 1542 | } else if (flentry->severity == 2) {
|
---|
[3185] | 1543 | mr_asprintf(tmp, "med ");
|
---|
[128] | 1544 | } else {
|
---|
[3185] | 1545 | mr_asprintf(tmp, "high");
|
---|
[128] | 1546 | }
|
---|
[2211] | 1547 | mr_strcat(tmp, " ");
|
---|
| 1548 | mr_strcat(tmp, flentry->filename);
|
---|
| 1549 | strncpy(comment, tmp, 99);
|
---|
[3191] | 1550 | mr_free(tmp);
|
---|
[2211] | 1551 |
|
---|
[2230] | 1552 | log_it("leaving");
|
---|
[128] | 1553 | return (comment);
|
---|
| 1554 | }
|
---|
[1] | 1555 |
|
---|
| 1556 |
|
---|
| 1557 | /**
|
---|
| 1558 | * Pop up a list containing the filenames in @p source_file and the severity if they have changed since the
|
---|
| 1559 | * last backup. There can be no more than @p ARBITRARY_MAXIMUM files in @p source_file.
|
---|
| 1560 | * @param source_file The file containing a list of changed files.
|
---|
| 1561 | */
|
---|
[3191] | 1562 | void popup_changelist_from_file(char *source_file) {
|
---|
| 1563 |
|
---|
| 1564 | char *reason = NULL;
|
---|
[128] | 1565 | newtComponent myForm;
|
---|
| 1566 | newtComponent bClose;
|
---|
| 1567 | newtComponent bSelect;
|
---|
| 1568 | newtComponent b_res;
|
---|
| 1569 | newtComponent fileListbox;
|
---|
| 1570 | newtComponent headerMsg;
|
---|
[1] | 1571 |
|
---|
[128] | 1572 | /*@ ???? ************************************************************ */
|
---|
| 1573 | void *curr_choice;
|
---|
| 1574 | void *keylist[ARBITRARY_MAXIMUM];
|
---|
[1] | 1575 |
|
---|
[128] | 1576 | /*@ int ************************************************************* */
|
---|
| 1577 | int currline = 0;
|
---|
| 1578 | int finished = FALSE;
|
---|
[738] | 1579 |
|
---|
| 1580 | /*@ long ************************************************************ */
|
---|
| 1581 | long i = 0;
|
---|
[128] | 1582 | long lng = 0;
|
---|
[1] | 1583 |
|
---|
[128] | 1584 | /*@ buffers ********************************************************* */
|
---|
[3191] | 1585 | char *tmp = NULL;
|
---|
| 1586 | char *differ_sz = NULL;
|
---|
[1] | 1587 |
|
---|
[128] | 1588 | struct s_filelist *filelist;
|
---|
| 1589 | assert_string_is_neither_NULL_nor_zerolength(source_file);
|
---|
| 1590 | if (g_text_mode) {
|
---|
| 1591 | log_msg(2, "Text mode. Therefore, no popup list.");
|
---|
[3191] | 1592 | return;
|
---|
[128] | 1593 | }
|
---|
| 1594 | log_msg(2, "Examining file %s", source_file);
|
---|
[1] | 1595 |
|
---|
[128] | 1596 | lng = count_lines_in_file(source_file);
|
---|
| 1597 | if (lng < 1) {
|
---|
| 1598 | log_msg(2, "No lines in file. Therefore, no popup list.");
|
---|
[3191] | 1599 | return;
|
---|
[128] | 1600 | } else if (lng >= ARBITRARY_MAXIMUM) {
|
---|
| 1601 | log_msg(2, "Too many files differ for me to list.");
|
---|
[3191] | 1602 | return;
|
---|
[128] | 1603 | }
|
---|
[1] | 1604 |
|
---|
[128] | 1605 | filelist = (struct s_filelist *) malloc(sizeof(struct s_filelist));
|
---|
| 1606 | fileListbox =
|
---|
| 1607 | newtListbox(2, 2, 12, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
|
---|
| 1608 | newtListboxClear(fileListbox);
|
---|
[1] | 1609 |
|
---|
[128] | 1610 | if (load_filelist_into_array(filelist, source_file)) {
|
---|
[3191] | 1611 | log_msg(2, "Can't open %s; therefore, cannot popup list", source_file);
|
---|
[128] | 1612 | return;
|
---|
| 1613 | }
|
---|
[3191] | 1614 | log_msg(2, "%d files loaded into filelist array", filelist->entries);
|
---|
[128] | 1615 | for (i = 0; i < filelist->entries; i++) {
|
---|
| 1616 | keylist[i] = (void *) i;
|
---|
| 1617 | newtListboxAppendEntry(fileListbox,
|
---|
| 1618 | filelist_entry_to_string(&
|
---|
| 1619 | (filelist->
|
---|
| 1620 | el[i])),
|
---|
| 1621 | keylist[i]);
|
---|
| 1622 | }
|
---|
[3191] | 1623 | mr_asprintf(differ_sz, " %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", i);
|
---|
[128] | 1624 | newtPushHelpLine(differ_sz);
|
---|
[3191] | 1625 | mr_free(differ_sz);
|
---|
| 1626 |
|
---|
[541] | 1627 | bClose = newtCompactButton(10, 15, " Close ");
|
---|
| 1628 | bSelect = newtCompactButton(30, 15, " Select ");
|
---|
[3191] | 1629 | mr_asprintf(tmp, "%-10s %-20s", "Priority", "Filename");
|
---|
[128] | 1630 | headerMsg = newtLabel(2, 1, tmp);
|
---|
[3191] | 1631 | mr_free(tmp);
|
---|
| 1632 |
|
---|
[541] | 1633 | newtOpenWindow(5, 4, 70, 16, "Non-matching files");
|
---|
[128] | 1634 | myForm = newtForm(NULL, NULL, 0);
|
---|
[3191] | 1635 | newtFormAddComponents(myForm, headerMsg, fileListbox, bClose, bSelect, NULL);
|
---|
| 1636 |
|
---|
[128] | 1637 | while (!finished) {
|
---|
| 1638 | b_res = newtRunForm(myForm);
|
---|
| 1639 | if (b_res == bClose) {
|
---|
| 1640 | finished = TRUE;
|
---|
| 1641 | } else {
|
---|
| 1642 | curr_choice = newtListboxGetCurrent(fileListbox);
|
---|
| 1643 | for (i = 0;
|
---|
| 1644 | i < filelist->entries && keylist[i] != curr_choice;
|
---|
| 1645 | i++);
|
---|
| 1646 | if (i == filelist->entries && filelist->entries > 0) {
|
---|
[541] | 1647 | log_to_screen("I don't know what that button does!");
|
---|
[128] | 1648 | } else {
|
---|
| 1649 | currline = i;
|
---|
| 1650 | if (filelist->entries > 0) {
|
---|
[3191] | 1651 | malloc_string(reason);
|
---|
[3194] | 1652 | severity_of_difference(filelist->el[currline].filename, &reason);
|
---|
[3191] | 1653 | mr_asprintf(tmp, "%s --- %s", filelist->el[currline].filename, reason);
|
---|
| 1654 |
|
---|
[128] | 1655 | popup_and_OK(tmp);
|
---|
[3191] | 1656 | mr_free(tmp);
|
---|
| 1657 | paranoid_free(reason);
|
---|
[128] | 1658 | }
|
---|
| 1659 | }
|
---|
| 1660 | }
|
---|
| 1661 | }
|
---|
| 1662 | newtFormDestroy(myForm);
|
---|
| 1663 | newtPopWindow();
|
---|
| 1664 | newtPopHelpLine();
|
---|
| 1665 | return;
|
---|
[1] | 1666 | }
|
---|
| 1667 |
|
---|
| 1668 | /* @} - end of guiGroup */
|
---|
| 1669 |
|
---|
| 1670 |
|
---|
| 1671 | #if __cplusplus
|
---|
[128] | 1672 | } /* extern "C" */
|
---|
[1] | 1673 | #endif
|
---|