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