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