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