Changeset 1181 in MondoRescue


Ignore:
Timestamp:
Feb 18, 2007, 8:04:30 PM (17 years ago)
Author:
Bruno Cornec
Message:

Merge from trun for memory mngt for newt-specific.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/common/newt-specific.c

    r1171 r1181  
    1 /* newt-specific.c
    2    $Id$
     1/* $Id$
    32
    43  subroutines which do display-type things
     
    1413#define MAX_NEWT_COMMENT_LEN 200
    1514
    16 #if __cplusplus
    17 extern "C" {
    18 #endif
     15#include <stdio.h>
     16#include <unistd.h>
     17#include <math.h>
    1918
    2019#include "my-stuff.h"
     
    3029#include "libmondo-tools-EXT.h"
    3130#include "libmondo-fork-EXT.h"
    32 #include "libmondo-gui-EXT.h"
     31#include "newt-specific-EXT.h"
    3332
    3433/*@unused@*/
    3534//static char cvsid[] = "$Id$";
    3635
    37     extern pid_t g_mastermind_pid;
    38     extern char *g_tmpfs_mountpt;
    39     extern char *g_boot_mountpt;
    40     extern char *g_mondo_home;
    41     extern char *ps_options;
    42     extern char *ps_proc_id;
    43 
    44     extern void set_signals(int);
     36extern pid_t g_mastermind_pid;
     37extern char *g_tmpfs_mountpt;
     38extern char *g_boot_mountpt;
     39extern char *g_mondo_home;
     40extern char *ps_options;
     41extern char *ps_proc_id;
     42
     43extern void set_signals(int);
    4544
    4645/**
     
    5150 * Whether we are currently in a nested call of fatal_error().
    5251 */
    53     bool g_exiting = FALSE;
     52bool g_exiting = FALSE;
    5453
    5554/**
    5655 * Padding below the Newt components, to overcome bugs in Newt.
    5756 */
    58     char g_haharrrrr[500];
    59 
    60 
    61     newtComponent g_timeline = NULL,    ///< The line of the progress form that shows the time elapsed/remaining
    62         g_percentline = NULL,   ///< The line of the progress form that shows the percent completed/remaining
    63         g_scale = NULL,         ///< The progress bar component in the progress form
    64         g_progressForm = NULL,  ///< The progress form component itself
    65         g_blurb1 = NULL,        ///< The component for line 1 of the blurb in the progress form
    66         g_blurb2 = NULL,        ///< The component for line 2 of the blurb in the progress form
    67         g_blurb3 = NULL,        ///< The component for line 3 (updated continuously) of the blurb in the progress form
    68         g_label = NULL;         ///< ????? @bug ?????
     57char g_haharrrrr[500];
     58
     59
     60newtComponent g_timeline = NULL,    ///< The line of the progress form that shows the time elapsed/remaining
     61    g_percentline = NULL,   ///< The line of the progress form that shows the percent completed/remaining
     62    g_scale = NULL,         ///< The progress bar component in the progress form
     63    g_progressForm = NULL,  ///< The progress form component itself
     64    g_blurb1 = NULL,        ///< The component for line 1 of the blurb in the progress form
     65    g_blurb2 = NULL,        ///< The component for line 2 of the blurb in the progress form
     66    g_blurb3 = NULL,        ///< The component for line 3 (updated continuously) of the blurb in the progress form
     67    g_label = NULL;         ///< ????? @bug ?????
    6968
    7069/**
    7170 * Padding above the Newt components, to overcome bugs in Newt.
    7271 */
    73     char g_jim_lad_yarr[500];
    74     char **err_log_lines = NULL,    ///< The list of log lines to show on the screen.
    75         g_blurb_str_1[MAX_NEWT_COMMENT_LEN] = "",   ///< The string for line 1 of the blurb in the progress form
    76         g_blurb_str_2[MAX_NEWT_COMMENT_LEN] = "",   ///< The string for line 2 of the blurb in the progress form
    77         g_blurb_str_3[MAX_NEWT_COMMENT_LEN] = "";   ///< The string for line 3 (updated continuously) of the blurb in the progress form
    78     newtComponent g_isoform_main = NULL,    ///< The evalcall form component itself
    79         g_isoform_header = NULL,    ///< The component for the evalcall form title
    80         g_isoform_scale = NULL, ///< The progress bar component in the evalcall form
    81         g_isoform_timeline = NULL,  ///< The line of the evalcall form that shows the time elapsed/remaining
    82         g_isoform_pcline = NULL;    ///< The line of the evalcall form that shows the percent completed/remaining
    83     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.
     72char g_jim_lad_yarr[500];
     73char **err_log_lines = NULL,    ///< The list of log lines to show on the screen.
     74    g_blurb_str_1[MAX_NEWT_COMMENT_LEN] = "",   ///< The string for line 1 of the blurb in the progress form
     75    g_blurb_str_2[MAX_NEWT_COMMENT_LEN] = "",   ///< The string for line 2 of the blurb in the progress form
     76    g_blurb_str_3[MAX_NEWT_COMMENT_LEN] = "";   ///< The string for line 3 (updated continuously) of the blurb in the progress form
     77
     78newtComponent g_isoform_main = NULL,    ///< The evalcall form component itself
     79    g_isoform_header = NULL,    ///< The component for the evalcall form title
     80    g_isoform_scale = NULL, ///< The progress bar component in the evalcall form
     81    g_isoform_timeline = NULL,  ///< The line of the evalcall form that shows the time elapsed/remaining
     82    g_isoform_pcline = NULL;    ///< The line of the evalcall form that shows the percent completed/remaining
     83
     84long g_isoform_starttime;   ///< The time (in seconds since the epoch) that the evalcall form was opened.
     85int g_isoform_old_progress = -1;    ///< The most recent progress update of the evalcall form (percent).
     86char g_isoform_header_str[MAX_STR_LEN] = "                                                                                                               "; ///< The string for the evalcall form title.
     87int g_mysterious_dot_counter;   ///< The counter for the twirling baton (/ | \\ - ...) on percentage less than 3
     88int g_noof_log_lines = 6;   ///< The number of lines to show in the log at the bottom of the screen.
     89int g_noof_rows = 25;       ///< The number of rows on the screen.
     90
     91int g_currentY = 3;         ///< The row to write background progress messages to. Incremented each time a message is written.
     92extern int g_current_media_number;
     93pid_t g_main_pid = 0;       ///< The PID of the main Mondo process.
     94long g_maximum_progress = 999;  ///< The maximum amount of progress (100%) for the currently opened progress form.
     95long g_current_progress = -999; ///< The current amount of progress (filelist #, etc.) for the currently opened progress form.
     96long g_start_time = 0;      ///< The time (in seconds since the epoch) that the progress form was opened.
     97bool g_text_mode = TRUE;    ///< If FALSE, use a newt interface; if TRUE, use an ugly (but more compatible) dumb terminal interface.
     98char g_xmondo_stdin[MAX_NEWT_COMMENT_LEN],  ///< ... @bug Unneeded w/current XMondo.
    9899     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.
     100bool g_called_by_xmondo = FALSE;    ///< @bug Unneeded w/current XMondo.
     101char *g_erase_tmpdir_and_scratchdir = NULL; ///< The command to run to erase the tmpdir and scratchdir at the end of Mondo.
     102char *g_selfmounted_isodir = NULL;  ///< Holds the NFS mountpoint if mounted via mondoarchive.
    102103
    103104/* @} - end of globalGroup */
    104105
    105 //int g_fd_in=-1, g_fd_out=-1;
    106 
    107     void popup_and_OK(char *);
     106void popup_and_OK(char *);
    108107
    109108
     
    117116 * @return TRUE for yes; FALSE for no.
    118117 */
    119      bool ask_me_yes_or_no(char *prompt) {
    120 
    121         /*@ buffers ********************************************************** */
    122         char *tmp;
    123         int i;
    124 
    125          tmp = mr_malloc(MAX_NEWT_COMMENT_LEN);
    126          assert_string_is_neither_NULL_nor_zerolength(prompt);
    127 
    128         if (g_text_mode) {
    129             while (1) {
    130                 system("sync");
     118bool ask_me_yes_or_no(char *prompt) {
     119
     120    /*@ buffers ********************************************************** */
     121    char *tmp = NULL;
     122    int i;
     123    size_t n = 0;
     124
     125     assert_string_is_neither_NULL_nor_zerolength(prompt);
     126
     127    if (g_text_mode) {
     128        while (1) {
     129            sync();
     130            printf
     131                ("---promptdialogYN---1--- %s\r\n---promptdialogYN---Q--- [yes] [no] ---\r\n--> ",
     132                 prompt);
     133            mr_getline(&tmp, &n, stdin);
     134            if (tmp[strlen(tmp) - 1] == '\n')
     135                tmp[strlen(tmp) - 1] = '\0';
     136            i = (int) strlen(tmp);
     137            if (i > 0 && tmp[i - 1] < 32) {
     138                tmp[i - 1] = '\0';
     139            }
     140            if (strstr(_("yesYES"), tmp)) {
     141                mr_free(tmp);
     142                return (TRUE);
     143            } else if (strstr(_("NOno"), tmp)) {
     144                mr_free(tmp);
     145                return (FALSE);
     146            } else {
     147                sync();
    131148                printf
    132                     ("---promptdialogYN---1--- %s\r\n---promptdialogYN---Q--- [yes] [no] ---\r\n--> ",
    133                      prompt);
    134                 (void) fgets(tmp, MAX_NEWT_COMMENT_LEN, stdin);
    135                 if (tmp[strlen(tmp) - 1] == '\n')
    136                     tmp[strlen(tmp) - 1] = '\0';
    137 
    138                 i = (int) strlen(tmp);
    139                 if (i > 0 && tmp[i - 1] < 32) {
    140                     tmp[i - 1] = '\0';
    141                 }
    142                 if (strstr("yesYES", tmp)) {
    143                     mr_free(tmp);
    144                     return (TRUE);
    145                 } else if (strstr("NOno", tmp)) {
    146                     mr_free(tmp);
    147                     return (FALSE);
    148                 } else {
    149                     system("sync");
    150                     printf
    151                         ("Please enter either YES or NO (or yes or no, or y or n, or...)\n");
    152                 }
     149                    (_("Please enter either YES or NO (or yes or no, or y or n, or...)\n"));
    153150            }
    154         } else {
    155             mr_free(tmp);
    156             return (popup_with_buttons(prompt, "Yes", "No"));
    157         }
    158     }
     151        }
     152    } else {
     153        return (popup_with_buttons(prompt, _("Yes"), _("No")));
     154    }
     155}
    159156
    160157
     
    165162 * @return TRUE for OK, FALSE for Cancel.
    166163 */
    167     bool ask_me_OK_or_cancel(char *prompt) {
    168 
    169         /*@ buffer *********************************************************** */
    170         char *tmp;
    171         int i;
    172 
    173         tmp = mr_malloc(MAX_NEWT_COMMENT_LEN);
    174         assert_string_is_neither_NULL_nor_zerolength(prompt);
    175         if (g_text_mode) {
    176             system("sync");
    177             printf
    178                 ("---promptdialogOKC---1--- %s\r\n---promptdialogOKC---Q--- [OK] [Cancel] ---\r\n--> ",
    179                  prompt);
    180             (void) fgets(tmp, MAX_NEWT_COMMENT_LEN, stdin);
    181             if (tmp[strlen(tmp) - 1] == '\n')
    182                 tmp[strlen(tmp) - 1] = '\0';
    183 
     164bool ask_me_OK_or_cancel(char *prompt) {
     165
     166    /*@ buffer *********************************************************** */
     167    char *tmp = NULL;
     168    int i;
     169    size_t n = 0;
     170
     171    assert_string_is_neither_NULL_nor_zerolength(prompt);
     172    if (g_text_mode) {
     173        sync();
     174        printf
     175            ("---promptdialogOKC---1--- %s\r\n---promptdialogOKC---Q--- [OK] [Cancel] ---\r\n--> ",
     176             prompt);
     177        mr_getline(&tmp, &n, stdin);
     178        if (tmp[strlen(tmp) - 1] == '\n')
     179            tmp[strlen(tmp) - 1] = '\0';
    184180            i = (int) strlen(tmp);
    185             if (i > 0 && tmp[i - 1] < 32) {
    186                 tmp[i - 1] = '\0';
    187             }
    188             if (strstr("okOKOkYESyes", tmp)) {
    189                 mr_free(tmp);
    190                 return (TRUE);
    191             } else {
    192                 mr_free(tmp);
    193                 return (FALSE);
    194             }
     181        if (i > 0 && tmp[i - 1] < 32) {
     182            tmp[i - 1] = '\0';
     183        }
     184        if (strstr(_("okOKOkYESyes"), tmp)) {
     185            mr_free(tmp);
     186            return (TRUE);
    195187        } else {
    196188            mr_free(tmp);
    197             return (popup_with_buttons(prompt, " Okay ", "Cancel"));
    198         }
    199     }
    200 
     189            return (FALSE);
     190        }
     191    } else {
     192        return (popup_with_buttons(prompt, _(" Okay "), _("Cancel")));
     193    }
     194}
    201195
    202196
     
    254248
    255249/**
    256  * Kill any process containing the string @p str surrounded by spaces in its commandline.
    257  */
    258 void kill_anything_like_this(char *str) {
    259 
    260 char *tmp = NULL;
    261 
    262 mr_asprintf(&tmp,"kill `ps %s | grep \" %s \" | awk '{print %s;}' | grep -vx \"\\?\"`", ps_options, str , ps_proc_id);
    263 run_program_and_log_output(tmp, TRUE);
    264 mr_free(tmp);
     250 * Kill any process containing the string @p str
     251 * surrounded by spaces in its commandline.
     252 */
     253static void
     254    kill_anything_like_this(char *str) {
     255
     256    char *tmp = NULL;
     257
     258    mr_asprintf(&tmp,"kill `ps %s | grep \" %s \" | awk '{print %s;}' | grep -vx \"\\?\"`", ps_options, str, ps_proc_id);
     259    run_program_and_log_output(tmp, TRUE);
     260    mr_free(tmp);
    265261}
    266262
     
    271267 * @note This function never returns.
    272268 */
    273     void
    274      fatal_error(char *error_string) {
    275         /*@ buffers ***************************************************** */
    276         char fatalstr[MAX_NEWT_COMMENT_LEN] =
    277             "-------FATAL ERROR---------";
    278         char *tmp;
    279         char *command;
    280         static bool already_exiting = FALSE;
    281         int i;
    282 
    283         /*@ end vars **************************************************** */
    284 
    285         malloc_string(command);
    286         tmp = mr_malloc(MAX_NEWT_COMMENT_LEN);
    287         set_signals(FALSE);     // link to external func
    288         g_exiting = TRUE;
    289         mr_msg(1, "Fatal error received - '%s'", error_string);
    290         printf("Fatal error... %s\n", error_string);
    291         if (getpid() == g_mastermind_pid) {
    292             mr_msg(2, "mastermind %d is exiting", (int) getpid());
     269void fatal_error(char *error_string) {
     270    /*@ buffers ***************************************************** */
     271    char *fatalstr = NULL;
     272    char *tmp = NULL;
     273    char *command = NULL;
     274    static bool already_exiting = FALSE;
     275    int i = 0;
     276
     277    /*@ end vars **************************************************** */
     278
     279    mr_asprintf(&fatalstr, "-------FATAL ERROR---------");
     280    set_signals(FALSE);     // link to external func
     281    g_exiting = TRUE;
     282    mr_msg(1, "%s - '%s'", fatalstr, error_string);
     283    printf("%s - %s\n", fatalstr, error_string);
     284    if (getpid() == g_mastermind_pid) {
     285        mr_msg(2, "mastermind %d is exiting", (int) getpid());
     286        kill(g_main_pid, SIGTERM);
     287        finish(1);
     288    }
     289
     290    if (getpid() != g_main_pid) {
     291        if (g_mastermind_pid != 0 && getpid() != g_mastermind_pid) {
     292            mr_msg(2, "non-m/m %d is exiting", (int) getpid());
    293293            kill(g_main_pid, SIGTERM);
    294             mr_free(tmp);
    295294            finish(1);
    296295        }
    297 
    298         if (getpid() != g_main_pid) {
    299             if (g_mastermind_pid != 0 && getpid() != g_mastermind_pid) {
    300                 mr_msg(2, "non-m/m %d is exiting", (int) getpid());
    301                 kill(g_main_pid, SIGTERM);
    302                 mr_free(tmp);
    303                 finish(1);
    304             }
    305         }
    306 
    307         mr_msg(3, "OK, I think I'm the main PID.");
    308         if (already_exiting) {
    309             mr_msg(3, "...I'm already exiting. Give me time, Julian!");
    310             mr_free(tmp);
    311             finish(1);
    312         }
    313 
    314         already_exiting = TRUE;
    315         mr_msg(2, "I'm going to do some cleaning up now.");
    316         paranoid_system("killall mindi 2> /dev/null");
    317         kill_anything_like_this("/mondo/do-not");
    318         kill_anything_like_this("tmp.mondo");
    319         kill_anything_like_this("ntfsclone");
    320         sync();
    321         sprintf(tmp, "umount %s", g_tmpfs_mountpt);
     296    }
     297
     298    mr_msg(3, "OK, I think I'm the main PID.");
     299    if (already_exiting) {
     300        mr_msg(3, "...I'm already exiting. Give me time, Julian!");
     301        finish(1);
     302    }
     303
     304    already_exiting = TRUE;
     305    mr_msg(2, "I'm going to do some cleaning up now.");
     306    paranoid_system("killall mindi 2> /dev/null");
     307    kill_anything_like_this("/mondo/do-not");
     308    kill_anything_like_this("tmp.mondo");
     309    kill_anything_like_this("ntfsclone");
     310    sync();
     311    if (g_tmpfs_mountpt != NULL) {
     312        mr_asprintf(&tmp, "umount %s", g_tmpfs_mountpt);
    322313        chdir("/");
    323314        for (i = 0; i < 10 && run_program_and_log_output(tmp, 5); i++) {
     
    326317            run_program_and_log_output(tmp, 5);
    327318        }
    328 
    329         if (g_erase_tmpdir_and_scratchdir[0]) {
    330             run_program_and_log_output(g_erase_tmpdir_and_scratchdir, 5);
    331         }
    332 
    333         if (g_selfmounted_isodir) {
    334             sprintf(command, "umount %s", g_selfmounted_isodir);
    335             run_program_and_log_output(command, 5);
    336             sprintf(command, "rmdir %s", g_selfmounted_isodir);
    337             run_program_and_log_output(command, 5);
    338         }
    339 
    340         if (!g_text_mode) {
    341             mr_msg(0, fatalstr);
    342             mr_msg(0, error_string);
    343             //      popup_and_OK (error_string);
    344             newtFinished();
    345         }
    346 
    347         printf("---FATALERROR--- %s\n", error_string);
    348         system
    349             ("gzip -9c /var/log/mondo-archive.log > /tmp/MA.log.gz 2> /dev/null");
     319        mr_free(tmp);
     320    }
     321
     322    if (g_erase_tmpdir_and_scratchdir[0]) {
     323        run_program_and_log_output(g_erase_tmpdir_and_scratchdir, 5);
     324    }
     325
     326    if (g_selfmounted_isodir) {
     327        mr_asprintf(&command, "umount %s", g_selfmounted_isodir);
     328        run_program_and_log_output(command, 5);
     329        mr_free(command);
     330
     331        mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir);
     332        run_program_and_log_output(command, 5);
     333        mr_free(command);
     334    }
     335
     336    if (!g_text_mode) {
     337        mr_msg(0, fatalstr);
     338        mr_msg(0, error_string);
     339        newtFinished();
     340    }
     341
     342    printf(_("If you require technical support, please contact the mailing list.\n"));
     343    printf(_("See http://www.mondorescue.org for details.\n"));
     344    printf(_("The list's members can help you, if you attach that file to your e-mail.\n"));
     345    printf(_("Log file: %s\n"), MONDO_LOGFILE);
     346/*
     347    system
     348        ("gzip -9c /var/log/mondo-archive.log > /tmp/MA.log.gz 2> /dev/null");
     349    if (does_file_exist("/tmp/MA.log.gz")) {
    350350        printf
    351                 ("If you require technical support, please contact the mailing list.\n");
    352         printf("See http://www.mondorescue.org for details.\n");
    353         printf
    354                 ("The list's members can help you, if you attach that file to your e-mail.\n");
    355         printf("Log file: %s\n", MONDO_LOGFILE);
    356         if (does_file_exist("/tmp/MA.log.gz")) {
    357             printf
    358                 ("FYI, I have gzipped the log and saved it to /tmp/MA.log.gz\n");
    359         }
    360         printf("Mondo has aborted.\n");
    361         register_pid(0, "mondo");   // finish() does this too, FYI
    362         if (!g_main_pid) {
    363             mr_msg(3, "FYI - g_main_pid is blank");
    364         }
    365         mr_free(tmp);
    366         mr_free(command);
    367         finish(254);
    368     }
    369 
     351            ("FYI, I have gzipped the log and saved it to /tmp/MA.log.gz\n");
     352        }
     353*/
     354    printf(_("Mondo has aborted.\n"));
     355    register_pid(0, "mondo");   // finish() does this too, FYI
     356    if (!g_main_pid) {
     357        mr_msg(3, "FYI - g_main_pid is blank");
     358    }
     359    finish(254);
     360}
    370361
    371362
     
    376367 * @note This function never returns.
    377368 */
    378     void
    379      finish(int signal_code) {
    380         char *command;
    381         malloc_string(command);
    382 
    383         /*  if (signal_code==0) { popup_and_OK("Please press <enter> to quit."); } */
    384 
    385         /* newtPopHelpLine(); */
    386 
    387         register_pid(0, "mondo");
    388         chdir("/");
    389         run_program_and_log_output("umount " MNT_CDROM, FALSE);
    390         run_program_and_log_output("rm -Rf /mondo.scratch.* /tmp.mondo.*",
     369void finish(int signal_code) {
     370    char *command = NULL;
     371
     372    register_pid(0, "mondo");
     373    chdir("/");
     374    run_program_and_log_output("umount " MNT_CDROM, FALSE);
     375    run_program_and_log_output("rm -Rf /mondo.scratch.* /tmp.mondo.*",
    391376                                   FALSE);
    392         if (g_erase_tmpdir_and_scratchdir) {
    393             run_program_and_log_output(g_erase_tmpdir_and_scratchdir, 1);
    394         }
    395         if (g_selfmounted_isodir) {
    396             sprintf(command, "umount %s", g_selfmounted_isodir);
    397             run_program_and_log_output(command, 1);
    398             sprintf(command, "rmdir %s", g_selfmounted_isodir);
    399             run_program_and_log_output(command, 1);
    400         }
    401 //  iamhere("foo");
    402         /* system("clear"); */
    403 //  iamhere("About to call newtFinished");
    404         if (!g_text_mode) {
    405             if (does_file_exist("/THIS-IS-A-RAMDISK")) {
    406                 mr_msg(1, "Calling newtFinished()");
    407                 newtFinished();
    408             } else {
    409                 mr_msg(1, "Calling newtSuspend()");
    410                 newtSuspend();
    411             }
    412         }
    413 //  system("clear");
    414 //  iamhere("Finished calling newtFinished");
    415         printf("Execution run ended; result=%d\n", signal_code);
    416         printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE);
    417         free_libmondo_global_strings();
    418         exit(signal_code);
    419     }
    420 
    421 
    422 
     377    if (g_erase_tmpdir_and_scratchdir) {
     378        run_program_and_log_output(g_erase_tmpdir_and_scratchdir, 1);
     379    }
     380    if (g_selfmounted_isodir) {
     381        mr_asprintf(&command, "umount %s", g_selfmounted_isodir);
     382        run_program_and_log_output(command, 1);
     383        mr_free(command);
     384
     385        mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir);
     386        run_program_and_log_output(command, 1);
     387        mr_free(command);
     388    }
     389    if (!g_text_mode) {
     390        if (does_file_exist("/THIS-IS-A-RAMDISK")) {
     391            mr_msg(1, "Calling newtFinished()");
     392            newtFinished();
     393        } else {
     394            mr_msg(1, "Calling newtSuspend()");
     395            newtSuspend();
     396        }
     397    }
     398    printf("Execution run ended; result=%d\n", signal_code);
     399    printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE);
     400    free_libmondo_global_strings();
     401    exit(signal_code);
     402}
    423403
    424404
     
    429409 * @param grep_for_me If not "", then only give lines in @p filename that match this regular expression.
    430410 */
    431     void
    432      log_file_end_to_screen(char *filename, char *grep_for_me) {
    433 
    434         /*@ buffers ********************************************************** */
    435         char *command;
    436         char *tmp;
    437 
    438         /*@ pointers ********************************************************* */
    439         FILE *fin;
    440 
    441         /*@ int ************************************************************** */
    442         int i = 0;
    443 
    444         malloc_string(command);
    445         malloc_string(tmp);
    446         assert_string_is_neither_NULL_nor_zerolength(filename);
    447         assert(grep_for_me != NULL);
    448 
    449         if (!does_file_exist(filename)) {
    450             mr_free(command);
    451             mr_free(tmp);
    452             return;
    453         }
    454         if (grep_for_me[0] != '\0') {
    455             sprintf(command, "grep '%s' %s | tail -n%d",
    456                     grep_for_me, filename, g_noof_log_lines);
    457         } else {
    458             sprintf(command, "tail -n%d %s", g_noof_log_lines,
    459                     filename);
    460         }
    461         fin = popen(command, "r");
    462         if (!fin) {
    463             log_OS_error(command);
    464         } else {
    465             for (i = 0; i < g_noof_log_lines; i++) {
    466                 for (err_log_lines[i][0] = '\0';
    467                      strlen(err_log_lines[i]) < 2 && !feof(fin);) {
    468                     (void) fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN,
    469                                  fin);
    470                     mr_strip_spaces(err_log_lines[i]);
    471                     if (!strncmp(err_log_lines[i], "root:", 5)) {
    472                         strcpy(tmp, err_log_lines[i] + 6);
    473                         strcpy(err_log_lines[i], tmp);
    474                     }
    475                     if (feof(fin)) {
    476                         break;
    477                     }
     411void log_file_end_to_screen(char *filename, char *grep_for_me) {
     412
     413    /*@ buffers ********************************************************** */
     414    char *command = NULL;
     415    char *tmp = NULL;
     416
     417    /*@ pointers ********************************************************* */
     418    FILE *fin = NULL;
     419
     420    /*@ int ************************************************************** */
     421    int i = 0;
     422    size_t n = 0;
     423
     424    assert_string_is_neither_NULL_nor_zerolength(filename);
     425    assert(grep_for_me != NULL);
     426
     427    if (!does_file_exist(filename)) {
     428        return;
     429    }
     430    if (grep_for_me[0] != '\0') {
     431        mr_asprintf(&command, "grep '%s' %s | tail -n%d",
     432                 grep_for_me, filename, g_noof_log_lines);
     433    } else {
     434        mr_asprintf(&command, "tail -n%d %s", g_noof_log_lines, filename);
     435    }
     436    fin = popen(command, "r");
     437    if (!fin) {
     438        log_OS_error(command);
     439    } else {
     440        for (i = 0; i < g_noof_log_lines; i++) {
     441            for (err_log_lines[i][0] = '\0';
     442                 strlen(err_log_lines[i]) < 2 && !feof(fin);) {
     443                (void) fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN,
     444                             fin);
     445                mr_strip_spaces(err_log_lines[i]);
     446                if (!strncmp(err_log_lines[i], "root:", 5)) {
     447                    mr_asprintf(&tmp, err_log_lines[i] + 6);
     448                    strcpy(err_log_lines[i], tmp);
     449                    mr_free(tmp);
     450                }
     451                if (feof(fin)) {
     452                    break;
    478453                }
    479454            }
    480             paranoid_pclose(fin);
    481         }
    482         refresh_log_screen();
    483         mr_free(command);
    484         mr_free(tmp);
    485     }
     455        }
     456        paranoid_pclose(fin);
     457    }
     458    refresh_log_screen();
     459    mr_free(command);
     460}
    486461
    487462
     
    491466 * @note The message is also written to the logfile.
    492467 */
    493     void
    494      log_to_screen(const char *fmt, ...) {
    495 
    496         /*@ int ************************************************************** */
    497         int i = 0;
    498         int j = 0;
    499         va_list args;
    500 
    501         /*@ buffers ********************************************************** */
    502         char *output;
    503 
    504         malloc_string(output);
    505 
    506         va_start(args, fmt);
    507         vsprintf(output, fmt, args);
    508         mr_msg(0, output);
     468void log_to_screen(const char *fmt, ...) {
     469
     470    /*@ int ************************************************************** */
     471    int i = 0;
     472    int j = 0;
     473    va_list args;
     474
     475    /*@ buffers ********************************************************** */
     476    char *output = NULL;
     477
     478    malloc_string(output);
     479
     480    va_start(args, fmt);
     481    vsprintf(output, fmt, args);
     482    mr_msg(0, output);
     483    if (strlen(output) > 80) {
    509484        output[80] = '\0';
    510         va_end(args);
    511         i = (int) strlen(output);
    512         if (i > 0 && output[i - 1] < 32) {
    513             output[i - 1] = '\0';
    514         }
    515 
    516         if (err_log_lines) {
    517             for (i = 1; i < g_noof_log_lines; i++) {
    518                 strcpy(err_log_lines[i - 1],
    519                        "                                                                                ");
    520                 strcpy(err_log_lines[i - 1], err_log_lines[i]);
    521             }
    522         }
    523         while (strlen(output) > 0 && output[strlen(output) - 1] < 32) {
    524             output[strlen(output) - 1] = '\0';
    525         }
    526         for (j = 0; j < (int) strlen(output); j++) {
    527             if (output[j] < 32) {
    528                 output[j] = ' ';
    529             }
    530         }
    531         if (err_log_lines)
    532             strcpy(err_log_lines[g_noof_log_lines - 1], output);
    533         if (g_text_mode) {
    534             printf("%s\n", output);
    535         } else {
    536             refresh_log_screen();
    537         }
    538         mr_free(output);
    539     }
    540 
    541 
     485    }
     486    va_end(args);
     487    i = (int) strlen(output);
     488    if (i > 0 && output[i - 1] < 32) {
     489        output[i - 1] = '\0';
     490    }
     491
     492    if (err_log_lines) {
     493        for (i = 1; i < g_noof_log_lines; i++) {
     494            strcpy(err_log_lines[i - 1],
     495                   "                                                                                ");
     496            strcpy(err_log_lines[i - 1], err_log_lines[i]);
     497        }
     498    }
     499    while (strlen(output) > 0 && output[strlen(output) - 1] < 32) {
     500        output[strlen(output) - 1] = '\0';
     501    }
     502    for (j = 0; j < (int) strlen(output); j++) {
     503        if (output[j] < 32) {
     504            output[j] = ' ';
     505        }
     506    }
     507    if (err_log_lines)
     508        strcpy(err_log_lines[g_noof_log_lines - 1], output);
     509    if (g_text_mode) {
     510        printf("%s\n", output);
     511    } else {
     512        refresh_log_screen();
     513    }
     514    mr_free(output);
     515}
    542516
    543517
     
    567541 * @param ttl The title to use for the evalcall form.
    568542 */
    569     void
    570      open_evalcall_form(char *ttl) {
    571 
    572         /*@ buffers ********************************************************* */
    573         char *title;
    574         char *tmp;
    575 
    576         /*@ initialize ****************************************************** */
    577         g_isoform_old_progress = -1;
    578         g_mysterious_dot_counter = 0;
    579         malloc_string(title);
    580         malloc_string(tmp);
    581 
    582         assert(ttl != NULL);
    583         strcpy(title, ttl);
    584         strcpy(g_isoform_header_str, title);
    585 //  center_string (title, 80);
    586         if (g_text_mode) {
    587             mr_msg(0, title);
    588         } else {
    589             strcpy(tmp, title);
    590             center_string(tmp, 80);
    591             newtPushHelpLine(tmp);
    592         }
    593         center_string(g_isoform_header_str, 36);
    594         g_isoform_starttime = get_time();
    595         if (g_text_mode) {
    596             mr_msg(0, g_isoform_header_str);
    597         } else {
    598             g_isoform_header = newtLabel(1, 1, g_isoform_header_str);
    599             g_isoform_scale = newtScale(3, 3, 34, 100);
    600             //      newtOpenWindow (20, 6, 40, 7, title);      // "Please Wait");
    601             newtCenteredWindow(40, 7, title);
    602             g_isoform_main = newtForm(NULL, NULL, 0);
    603             g_isoform_timeline = newtLabel(1, 5, "This is the timeline");
    604             g_isoform_pcline = newtLabel(1, 6, "This is the pcline");
    605             newtFormAddComponents(g_isoform_main, g_isoform_timeline,
    606                                   g_isoform_pcline, g_isoform_header,
    607                                   g_isoform_scale, NULL);
    608             newtRefresh();
    609         }
    610         update_evalcall_form(0);
     543void open_evalcall_form(char *ttl) {
     544
     545    /*@ buffers ********************************************************* */
     546    char *title = NULL;
     547    char *tmp = NULL;
     548
     549    /*@ initialize ****************************************************** */
     550    g_isoform_old_progress = -1;
     551    g_mysterious_dot_counter = 0;
     552    malloc_string(title);
     553
     554    assert(ttl != NULL);
     555    mr_asprintf(&title, ttl);
     556    strcpy(g_isoform_header_str, title);
     557    if (g_text_mode) {
     558        mr_msg(0, title);
     559    } else {
     560        mr_asprintf(&tmp, title);
     561        center_string(tmp, 80);
     562        newtPushHelpLine(tmp);
    611563        mr_free(tmp);
    612         mr_free(title);
    613     }
    614 
     564    }
     565    center_string(g_isoform_header_str, 36);
     566    g_isoform_starttime = get_time();
     567    if (g_text_mode) {
     568        mr_msg(0, g_isoform_header_str);
     569    } else {
     570        g_isoform_header = newtLabel(1, 1, g_isoform_header_str);
     571        g_isoform_scale = newtScale(3, 3, 34, 100);
     572        //      newtOpenWindow (20, 6, 40, 7, title);      // "Please Wait");
     573        newtCenteredWindow(40, 7, title);
     574        g_isoform_main = newtForm(NULL, NULL, 0);
     575        g_isoform_timeline = newtLabel(1, 5, "This is the timeline");
     576        g_isoform_pcline = newtLabel(1, 6, "This is the pcline");
     577        newtFormAddComponents(g_isoform_main, g_isoform_timeline,
     578                              g_isoform_pcline, g_isoform_header,
     579                              g_isoform_scale, NULL);
     580        newtRefresh();
     581    }
     582    update_evalcall_form(0);
     583    mr_free(title);
     584}
    615585
    616586
     
    624594 * @param max_val The maximum amount of progress (number of filesets, etc.)
    625595 */
    626     void
    627      open_progress_form(char *title, char *b1, char *b2, char *b3,
     596void open_progress_form(char *title, char *b1, char *b2, char *b3,
    628597                        long max_val) {
    629598
    630         /*@ buffers ********************************************************* */
    631         char *b1c;
    632         char *blurb1;
    633         char *blurb2;
    634         char *blurb3;
    635 
    636         /*@ initialize ****************************************************** */
    637         g_mysterious_dot_counter = 0;
    638 
    639         malloc_string(b1c);
    640         malloc_string(blurb1);
    641         malloc_string(blurb2);
    642         malloc_string(blurb3);
    643 
    644         assert(title != NULL);
    645         assert(b1 != NULL);
    646         assert(b2 != NULL);
    647         assert(b3 != NULL);
    648 
    649         strcpy(blurb1, b1);
    650         strcpy(blurb2, b2);
    651         strcpy(blurb3, b3);
    652         strcpy(b1c, b1);
    653         center_string(b1c, 80);
    654         if (max_val <= 0) {
    655             max_val = 1;
    656         }
    657 
    658         g_start_time = get_time();
    659         g_maximum_progress = max_val;
    660         g_current_progress = 0;
    661         strcpy(g_blurb_str_1, blurb1);
    662         strcpy(g_blurb_str_2, blurb3);
    663         strcpy(g_blurb_str_3, blurb2);
    664         if (g_text_mode) {
    665             mr_msg(0, blurb1);
    666             mr_msg(0, blurb2);
    667             mr_msg(0, blurb3);
    668         } else {
    669             g_blurb1 = newtLabel(2, 1, blurb1);
    670             g_blurb2 = newtLabel(2, 2, blurb3);
    671             g_blurb3 = newtLabel(2, 4, blurb2);
    672             //      newtOpenWindow (10, 4, 60, 11, title);
    673             newtCenteredWindow(60, 11, title);
    674             g_scale = newtScale(3, 6, 54, g_maximum_progress);
    675             g_progressForm = newtForm(NULL, NULL, 0);
    676             g_percentline = newtLabel(10, 9, "This is the percentline");
    677             g_timeline = newtLabel(10, 8, "This is the timeline");
    678             newtFormAddComponents(g_progressForm, g_percentline,
    679                                   g_timeline, g_scale, g_blurb1, g_blurb3,
    680                                   g_blurb2, NULL);
    681             newtPushHelpLine(b1c);
    682             newtRefresh();
    683         }
    684         update_progress_form_full(blurb1, blurb2, blurb3);
    685         mr_free(b1c);
    686         mr_free(blurb1);
    687         mr_free(blurb2);
    688         mr_free(blurb3);
    689     }
     599    /*@ buffers ********************************************************* */
     600    char *b1c = NULL;
     601    char *blurb1 = NULL;
     602    char *blurb2 = NULL;
     603    char *blurb3 = NULL;
     604
     605    /*@ initialize ****************************************************** */
     606    g_mysterious_dot_counter = 0;
     607
     608    assert(title != NULL);
     609    assert(b1 != NULL);
     610    assert(b2 != NULL);
     611    assert(b3 != NULL);
     612
     613    mr_asprintf(&blurb1, b1);
     614    mr_asprintf(&blurb2, b2);
     615    mr_asprintf(&blurb3, b3);
     616    mr_asprintf(&b1c, b1);
     617    center_string(b1c, 80);
     618    if (max_val <= 0) {
     619        max_val = 1;
     620    }
     621
     622    g_start_time = get_time();
     623    g_maximum_progress = max_val;
     624    g_current_progress = 0;
     625    strcpy(g_blurb_str_1, blurb1);
     626    strcpy(g_blurb_str_2, blurb3);
     627    strcpy(g_blurb_str_3, blurb2);
     628    if (g_text_mode) {
     629        mr_msg(0, blurb1);
     630        mr_msg(0, blurb2);
     631        mr_msg(0, blurb3);
     632    } else {
     633        g_blurb1 = newtLabel(2, 1, blurb1);
     634        g_blurb2 = newtLabel(2, 2, blurb3);
     635        g_blurb3 = newtLabel(2, 4, blurb2);
     636        //      newtOpenWindow (10, 4, 60, 11, title);
     637        newtCenteredWindow(60, 11, title);
     638        g_scale = newtScale(3, 6, 54, g_maximum_progress);
     639        g_progressForm = newtForm(NULL, NULL, 0);
     640        g_percentline = newtLabel(10, 9, "This is the percentline");
     641        g_timeline = newtLabel(10, 8, "This is the timeline");
     642        newtFormAddComponents(g_progressForm, g_percentline,
     643                              g_timeline, g_scale, g_blurb1, g_blurb3,
     644                              g_blurb2, NULL);
     645        newtPushHelpLine(b1c);
     646        newtRefresh();
     647    }
     648    update_progress_form_full(blurb1, blurb2, blurb3);
     649    mr_free(b1c);
     650    mr_free(blurb1);
     651    mr_free(blurb2);
     652    mr_free(blurb3);
     653}
     654
    690655
    691656/**
     
    693658 * @param prompt The message.
    694659 */
    695     void
    696      popup_and_OK(char *prompt) {
    697         int ch;
    698 
    699         assert_string_is_neither_NULL_nor_zerolength(prompt);
    700 
    701         mr_msg(0, prompt);
    702         if (g_text_mode) {
    703             printf
    704                 ("---promptpopup---1--- %s\r\n---promptpopup---Q--- [OK] ---\r\n--> ",
    705                  prompt);
    706             while (((ch = getchar()) != '\n') && (ch != EOF));
    707         } else {
    708             (void) popup_with_buttons(prompt, " OK ", "");
    709         }
    710     }
     660void popup_and_OK(char *prompt) {
     661    int ch;
     662
     663    assert_string_is_neither_NULL_nor_zerolength(prompt);
     664
     665    mr_msg(0, prompt);
     666    if (g_text_mode) {
     667        printf
     668            ("---promptpopup---1--- %s\r\n---promptpopup---Q--- [OK] ---\r\n--> ",
     669             prompt);
     670        while (((ch = getchar()) != '\n') && (ch != EOF));
     671    } else {
     672        (void) popup_with_buttons(prompt, _(" OK "), "");
     673    }
     674}
     675
    711676
    712677/**
     
    718683 * @return TRUE if the user pressed OK, FALSE if they pressed Cancel.
    719684 */
    720     bool popup_and_get_string(char *title, char *b, char *output,
    721                               int maxsize) {
    722 
    723         /*@ newt ************************************************************ */
    724         newtComponent myForm;
    725         newtComponent b_1;
    726         newtComponent b_2;
    727         newtComponent b_res;
    728         newtComponent text;
    729         newtComponent type_here;
    730 
    731         /*@ pointers ********************************************************* */
    732         char *entry_value;
    733 
    734         /*@ buffers ********************************************************** */
    735         char *blurb;
    736         char *original_contents;
    737 
    738         blurb = mr_malloc(MAX_NEWT_COMMENT_LEN);
    739         original_contents = mr_malloc(MAX_NEWT_COMMENT_LEN);
    740         assert_string_is_neither_NULL_nor_zerolength(title);
    741         assert(b != NULL);
    742         assert(output != NULL);
    743 
    744         if (g_text_mode) {
    745             printf
    746                 ("---promptstring---1--- %s\r\n---promptstring---2--- %s\r\n---promptstring---Q---\r\n-->  ",
    747                  title, b);
    748             (void) fgets(output, maxsize, stdin);
    749             if (output[strlen(output) - 1] == '\n')
    750                 output[strlen(output) - 1] = '\0';
    751             mr_free(blurb);
    752             mr_free(original_contents);
    753             return (TRUE);
    754         }
    755         strcpy(blurb, b);
    756         text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0);
    757         strcpy(original_contents, output);
    758         output[0] = '\0';
    759         type_here =
    760             newtEntry(2, newtTextboxGetNumLines(text) + 2,
    761                       original_contents, 50,
     685bool popup_and_get_string(char *title, char *b, char *output,
     686                        int maxsize) {
     687
     688    /*@ newt ************************************************************ */
     689    newtComponent myForm;
     690    newtComponent b_1;
     691    newtComponent b_2;
     692    newtComponent b_res;
     693    newtComponent text;
     694    newtComponent type_here;
     695
     696    /*@ pointers ********************************************************* */
     697    char *entry_value = NULL;
     698
     699    /*@ buffers ********************************************************** */
     700    char *blurb = NULL;
     701    char *original_contents = NULL;
     702    bool ret = TRUE;
     703
     704    assert_string_is_neither_NULL_nor_zerolength(title);
     705    assert(b != NULL);
     706    assert(output != NULL);
     707
     708    if (g_text_mode) {
     709        printf
     710            ("---promptstring---1--- %s\r\n---promptstring---2--- %s\r\n---promptstring---Q---\r\n-->  ",
     711             title, b);
     712        (void) fgets(output, maxsize, stdin);
     713        if (output[strlen(output) - 1] == '\n')
     714            output[strlen(output) - 1] = '\0';
     715        return(ret);
     716    }
     717    mr_asprintf(&blurb, b);
     718    text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0);
     719    mr_asprintf(&original_contents, output);
     720    output[0] = '\0';
     721    type_here =
     722        newtEntry(2, newtTextboxGetNumLines(text) + 2,
     723                  original_contents, 50,
    762724#ifdef __cplusplus
    763                       0, NEWT_FLAG_RETURNEXIT
     725                  0, NEWT_FLAG_RETURNEXIT
    764726#else
    765                       (void *) &entry_value, NEWT_FLAG_RETURNEXIT
     727                  (void *) &entry_value, NEWT_FLAG_RETURNEXIT
    766728#endif
    767             );
    768         b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, "  OK  ");
    769         b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, "Cancel");
    770         //  newtOpenWindow (8, 5, 54, newtTextboxGetNumLines (text) + 9, title);
    771         newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title);
    772         myForm = newtForm(NULL, NULL, 0);
    773         newtFormAddComponents(myForm, text, type_here, b_1, b_2, NULL);
    774         center_string(blurb, 80);
    775         newtPushHelpLine(blurb);
    776         b_res = newtRunForm(myForm);
    777         strcpy(output, entry_value);
    778         newtPopHelpLine();
    779         newtFormDestroy(myForm);
    780         newtPopWindow();
    781         if (b_res == b_2) {
    782             strcpy(output, original_contents);
    783             mr_free(blurb);
    784             mr_free(original_contents);
    785             return (FALSE);
    786         } else {
    787             mr_free(blurb);
    788             mr_free(original_contents);
    789             return (TRUE);
    790         }
    791     }
     729        );
     730    b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, _("  OK  "));
     731    b_2 = newtButton(18, newtTextboxGetNumLines(text) + 4, _("Cancel"));
     732    newtCenteredWindow(54, newtTextboxGetNumLines(text) + 9, title);
     733    myForm = newtForm(NULL, NULL, 0);
     734    newtFormAddComponents(myForm, text, type_here, b_1, b_2, NULL);
     735    center_string(blurb, 80);
     736    newtPushHelpLine(blurb);
     737    mr_free(blurb);
     738
     739    b_res = newtRunForm(myForm);
     740    strcpy(output, entry_value);
     741    newtPopHelpLine();
     742    if (b_res == b_2) {
     743        strcpy(output, original_contents);
     744        ret = FALSE;
     745    }
     746    newtFormDestroy(myForm);
     747    newtPopWindow();
     748    mr_free(original_contents);
     749    return(ret);
     750}
    792751
    793752
     
    799758 * @return TRUE if @p button1 was pushed, FALSE otherwise.
    800759 */
    801     bool popup_with_buttons(char *p, char *button1, char *button2) {
    802 
    803         /*@ buffers *********************************************************** */
    804         char *prompt, *tmp;
    805 
    806         /*@ newt ************************************************************** */
    807         newtComponent myForm;
    808         newtComponent b_1;
    809         newtComponent b_2;
    810         newtComponent b_res;
    811         newtComponent text;
    812 
    813         prompt = mr_malloc(MAX_NEWT_COMMENT_LEN);
    814         tmp = mr_malloc(MAX_NEWT_COMMENT_LEN);
    815         assert_string_is_neither_NULL_nor_zerolength(p);
    816         assert(button1 != NULL);
    817         assert(button2 != NULL);
    818         if (g_text_mode) {
    819             if (strlen(button2) == 0) {
    820                 printf("%s (%s) --> ", p, button1);
    821             } else {
    822                 printf("%s (%s or %s) --> ", p, button1, button2);
    823             }
    824             for (tmp[0] = '\0';
    825                  strcmp(tmp, button1) && (strlen(button2) == 0
    826                                           || strcmp(tmp, button2));) {
    827                 printf("--> ");
    828                 (void) fgets(tmp, MAX_NEWT_COMMENT_LEN, stdin);
    829             }
    830             if (!strcmp(tmp, button1)) {
    831                 mr_free(tmp);
    832                 mr_free(prompt);
    833                 return (TRUE);
    834             } else {
    835                 mr_free(tmp);
    836                 mr_free(prompt);
    837                 return (FALSE);
    838             }
    839         }
    840 
    841         strncpy(prompt, p, MAX_NEWT_COMMENT_LEN - 1);
    842         prompt[MAX_NEWT_COMMENT_LEN - 1] = '\0';
    843         text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0);
    844         b_1 =
    845             newtButton(20 -
    846                        ((button2[0] !=
    847                          '\0') ? strlen(button1) +
    848                         2 : strlen(button1) / 2),
    849                        newtTextboxGetNumLines(text) + 3, button1);
    850         if (button2[0] != '\0') {
    851             b_2 =
    852                 newtButton(24, newtTextboxGetNumLines(text) + 3, button2);
     760bool popup_with_buttons(char *p, char *button1, char *button2) {
     761
     762    /*@ buffers *********************************************************** */
     763    char *prompt = NULL;
     764    char *tmp = NULL;
     765
     766    /*@ newt ************************************************************** */
     767    newtComponent myForm;
     768    newtComponent b_1;
     769    newtComponent b_2;
     770    newtComponent b_res;
     771    newtComponent text;
     772
     773    assert_string_is_neither_NULL_nor_zerolength(p);
     774    assert(button1 != NULL);
     775    assert(button2 != NULL);
     776
     777    if (g_text_mode) {
     778        if (strlen(button2) == 0) {
     779            printf("%s (%s) --> ", p, button1);
    853780        } else {
    854             b_2 = NULL;
    855         }
    856         //  newtOpenWindow (25, 5, 46, newtTextboxGetNumLines (text) + 7, "Alert");
    857         newtCenteredWindow(46, newtTextboxGetNumLines(text) + 7, "Alert");
    858         myForm = newtForm(NULL, NULL, 0);
    859         newtFormAddComponents(myForm, text, b_1, b_2, NULL);
    860         center_string(prompt, 80);
    861         newtPushHelpLine(prompt);
    862         b_res = newtRunForm(myForm);
    863         newtPopHelpLine();
    864         newtFormDestroy(myForm);
    865         newtPopWindow();
    866         if (b_res == b_1) {
     781            printf("%s (%s or %s) --> ", p, button1, button2);
     782        }
     783        malloc_string(tmp);
     784        for (tmp[0] = '\0';
     785             strcmp(tmp, button1) && (strlen(button2) == 0
     786                                      || strcmp(tmp, button2));) {
     787            printf("--> ");
     788            (void) fgets(tmp, MAX_NEWT_COMMENT_LEN, stdin);
     789        }
     790        if (!strcmp(tmp, button1)) {
    867791            mr_free(tmp);
    868             mr_free(prompt);
    869792            return (TRUE);
    870793        } else {
    871794            mr_free(tmp);
    872             mr_free(prompt);
    873795            return (FALSE);
    874796        }
    875797    }
    876798
    877 
     799    mr_asprintf(&prompt, p);
     800    text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0);
     801    b_1 =
     802        newtButton(20 -
     803                   ((button2[0] !=
     804                     '\0') ? strlen(button1) +
     805                    2 : strlen(button1) / 2),
     806                   newtTextboxGetNumLines(text) + 3, button1);
     807    if (button2[0] != '\0') {
     808        b_2 =
     809            newtButton(24, newtTextboxGetNumLines(text) + 3, button2);
     810    } else {
     811        b_2 = NULL;
     812    }
     813    //  newtOpenWindow (25, 5, 46, newtTextboxGetNumLines (text) + 7, "Alert");
     814    newtCenteredWindow(46, newtTextboxGetNumLines(text) + 7, _("Alert"));
     815    myForm = newtForm(NULL, NULL, 0);
     816    newtFormAddComponents(myForm, text, b_1, b_2, NULL);
     817    center_string(prompt, 80);
     818    newtPushHelpLine(prompt);
     819    mr_free(prompt);
     820
     821    b_res = newtRunForm(myForm);
     822    newtPopHelpLine();
     823    newtFormDestroy(myForm);
     824    newtPopWindow();
     825    if (b_res == b_1) {
     826        return (TRUE);
     827    } else {
     828        return (FALSE);
     829    }
     830}
    878831
    879832
     
    882835 * on the screen.
    883836 */
    884     void
    885      refresh_log_screen() {
    886 
    887         /*@ int *********************************************************** */
    888         int i = 0;
    889 
    890 
    891         if (g_text_mode || !err_log_lines) {
    892             return;
    893         }
    894         for (i = g_noof_log_lines - 1; i >= 0; i--) {
    895             newtDrawRootText(0, i + g_noof_rows - 1 - g_noof_log_lines,
    896                              "                                                                                ");
    897         }
    898         newtRefresh();
    899         for (i = g_noof_log_lines - 1; i >= 0; i--) {
    900             err_log_lines[i][79] = '\0';
    901             newtDrawRootText(0, i + g_noof_rows - 1 - g_noof_log_lines,
    902                             err_log_lines[i]);
    903         }
    904         newtRefresh();
    905     }
     837void refresh_log_screen(void) {
     838
     839    /*@ int *********************************************************** */
     840    int i = 0;
     841
     842
     843    if (g_text_mode || !err_log_lines) {
     844        return;
     845    }
     846    for (i = g_noof_log_lines - 1; i >= 0; i--) {
     847        newtDrawRootText(0, i + g_noof_rows - 1 - g_noof_log_lines,
     848                         "                                                                                ");
     849    }
     850    newtRefresh();
     851
     852    for (i = g_noof_log_lines - 1; i >= 0; i--) {
     853        err_log_lines[i][79] = '\0';
     854        newtDrawRootText(0, i + g_noof_rows - 1 - g_noof_log_lines,
     855                        err_log_lines[i]);
     856    }
     857    newtRefresh();
     858}
    906859
    907860
     
    910863 * only allocate some memory.
    911864 */
    912     void
    913      setup_newt_stuff() {
    914 
    915         /*@ int *********************************************************** */
    916         int i = 0;
    917         int cols;
    918 
    919         if (!g_text_mode) {
    920             newtInit();
    921             newtCls();
    922             newtPushHelpLine
    923                 ("Welcome to Mondo Rescue, by Dev Team and the Internet. All rights reversed.");
    924             /*  newtDrawRootText(28,0,"Welcome to Mondo Rescue"); */
    925             newtDrawRootText(18, 0, WELCOME_STRING);
    926             newtRefresh();
    927             newtGetScreenSize(&cols, &g_noof_rows);
    928             g_noof_log_lines = (g_noof_rows / 5) + 1;
    929         }
    930 
    931         err_log_lines =
    932             (char **) mr_malloc(sizeof(char *) * g_noof_log_lines);
    933         if (!err_log_lines) {
    934             fatal_error("Out of memory");
    935         }
    936 
    937         for (i = 0; i < g_noof_log_lines; i++) {
    938             err_log_lines[i] = (char *) mr_malloc(MAX_NEWT_COMMENT_LEN);
    939             if (!err_log_lines[i]) {
    940                 fatal_error("Out of memory");
     865void setup_newt_stuff(void) {
     866
     867    /*@ int *********************************************************** */
     868    int i = 0;
     869    int cols;
     870
     871    if (!g_text_mode) {
     872        newtInit();
     873        newtCls();
     874        newtPushHelpLine
     875            (_("Welcome to Mondo Rescue, by Dev Team and the Internet. All rights reversed."));
     876        newtDrawRootText(18, 0, WELCOME_STRING);
     877        newtRefresh();
     878        newtGetScreenSize(&cols, &g_noof_rows);
     879        g_noof_log_lines = (g_noof_rows / 5) + 1;
     880    }
     881
     882    err_log_lines =
     883        (char **) mr_malloc(sizeof(char *) * g_noof_log_lines);
     884
     885    for (i = 0; i < g_noof_log_lines; i++) {
     886        err_log_lines[i] = (char *) mr_malloc(MAX_NEWT_COMMENT_LEN);
     887        err_log_lines[i][0] = '\0';
     888    }
     889}
     890
     891
     892/**
     893 * Update the evalcall form to show <tt>num</tt> %.
     894 * @param num The numerator of the ratio.
     895 */
     896void update_evalcall_form(int num) {
     897
     898    /*@ long ************************************************************ */
     899    long current_time = 0L;
     900    long time_taken = 0L;
     901    long time_total_est = 0L;
     902    long time_remaining = 0L;
     903
     904    /*@ buffers ********************************************************** */
     905    char *timeline_str = NULL;
     906    char *pcline_str = NULL;
     907    char *taskprogress = NULL;
     908    char *tmp1 = NULL;
     909
     910    /*@ int ************************************************************** */
     911    int percentage = 0;
     912    int i = 0;
     913    int j = 0;
     914
     915    if (num < 1) {
     916        percentage = 1;
     917    } else {
     918        percentage = (int) trunc(num);
     919    }
     920
     921    current_time = get_time();
     922    time_taken = current_time - g_isoform_starttime;
     923    if (num) {
     924        time_total_est = time_taken * 100 / num;
     925        time_remaining = time_total_est - time_taken;
     926    } else {
     927        time_remaining = 0;
     928    }
     929    if (!g_text_mode) {
     930        newtLabelSetText(g_isoform_header, g_isoform_header_str);
     931    }
     932    g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27;
     933    if ((percentage < 3 && g_isoform_old_progress < 3)
     934        || percentage > g_isoform_old_progress) {
     935        g_isoform_old_progress = percentage;
     936        mr_asprintf(&timeline_str,
     937                 _("%2ld:%02ld taken            %2ld:%02ld remaining"),
     938                 time_taken / 60, time_taken % 60, time_remaining / 60,
     939                 time_remaining % 60);
     940        if (percentage < 3) {
     941            mr_asprintf(&pcline_str, " Working");
     942            for (j = 0; j < g_mysterious_dot_counter; j++) {
     943                mr_strcat(pcline_str, ".");
    941944            }
    942         }
    943 
    944         for (i = 0; i < g_noof_log_lines; i++) {
    945             err_log_lines[i][0] = '\0';
    946         }
    947     }
    948 
    949 
    950 /**
    951  * Update the evalcall form to show (<tt>num</tt>/<tt>denom</tt>)*100 %.
    952  * @param num The numerator of the ratio.
    953  * @param denom The denomenator of the ratio.
    954  */
    955     void
    956      update_evalcall_form_ratio(int num, int denom) {
    957 
    958         /*@ long ************************************************************ */
    959         long current_time = 0;
    960         long time_taken = 0;
    961         long time_total_est = 0;
    962         long time_remaining = 0;
    963 
    964         /*@ buffers ********************************************************** */
    965         char *timeline_str;
    966         char *pcline_str;
    967         char *taskprogress;
    968 
    969         /*@ int ************************************************************** */
    970         int percentage = 0;
    971         int i = 0;
    972         int j = 0;
    973 
    974         malloc_string(timeline_str);
    975         malloc_string(pcline_str);
    976         malloc_string(taskprogress);
    977         timeline_str[0] = '\0';
    978 //  log_it("update_eval_call_form called");
    979         if (num * 100 < denom) {
    980             percentage = 1;
     945            /* BERLIOS: 27 should be a parameter */
     946            for (; j < 27; j++) {
     947                mr_strcat(pcline_str, " ");
     948            }
     949            mr_asprintf(&tmp1, " %c", special_dot_char(g_mysterious_dot_counter));
     950            mr_strcat(pcline_str, tmp1);
     951            mr_free(tmp1);
    981952        } else {
    982             percentage = (num * 100 + denom / 2) / denom;
    983         }
    984 
    985         current_time = get_time();
    986         time_taken = current_time - g_isoform_starttime;
    987         if (num) {
    988             time_total_est = time_taken * denom / num;
    989             time_remaining = time_total_est - time_taken;
     953            mr_asprintf(&pcline_str,
     954                     _(" %3d%% done              %3d%% to go"),
     955                     percentage, 100 - percentage);
     956        }
     957        if (g_text_mode) {
     958            mr_asprintf(&taskprogress, "TASK:  [");
     959            for (i = 0; i < percentage; i += 5) {
     960                mr_strcat(taskprogress, "*");
     961            }
     962            for (; i < 100; i += 5) {
     963                mr_strcat(taskprogress, ".");
     964            }
     965            if (percentage >= 3) {
     966                mr_asprintf(&tmp1,
     967                        "] %3d%% done; %2ld:%02ld to go", percentage,
     968                        time_remaining / 60, time_remaining % 60);
     969                mr_strcat(taskprogress, tmp1);
     970                mr_free(tmp1);
     971                printf("---evalcall---1--- %s\r\n",
     972                       g_isoform_header_str);
     973                printf("---evalcall---2--- %s\r\n", taskprogress);
     974                printf("---evalcall---E---\r\n");
     975                mr_free(taskprogress);
     976            }
    990977        } else {
    991             time_remaining = 0;
    992         }
    993         if (!g_text_mode) {
    994             newtLabelSetText(g_isoform_header, g_isoform_header_str);
    995         }
    996         g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27;
    997         if ((percentage < 3 && g_isoform_old_progress < 3)
    998             || percentage > g_isoform_old_progress) {
    999             g_isoform_old_progress = percentage;
    1000             sprintf(timeline_str,
    1001                     "%2ld:%02ld taken            %2ld:%02ld remaining",
    1002                     time_taken / 60, time_taken % 60, time_remaining / 60,
    1003                     time_remaining % 60);
    1004             if (percentage < 3) {
    1005                 sprintf(pcline_str, " Working");
    1006                 for (j = 0; j < g_mysterious_dot_counter; j++) {
    1007                     strcat(pcline_str, ".");
    1008                 }
    1009                 for (; j < 27; j++) {
    1010                     strcat(pcline_str, " ");
    1011                 }
    1012                 sprintf(pcline_str + strlen(pcline_str), " %c",
    1013                         special_dot_char(g_mysterious_dot_counter));
    1014             } else {
    1015                 sprintf(pcline_str, " %3d%% done              %3d%% to go",
    1016                         percentage, 100 - percentage);
     978            newtScaleSet(g_isoform_scale,
     979                         (unsigned long long) percentage);
     980            newtLabelSetText(g_isoform_pcline, pcline_str);
     981            if (percentage >= 3) {
     982                newtLabelSetText(g_isoform_timeline, timeline_str);
    1017983            }
    1018             if (g_text_mode) {
    1019                 sprintf(taskprogress, "TASK:  [");
    1020                 for (i = 0; i < percentage; i += 5) {
    1021                     strcat(taskprogress, "*");
    1022                 }
    1023                 for (; i < 100; i += 5) {
    1024                     strcat(taskprogress, ".");
    1025                 }
    1026                 if (percentage >= 3) {
    1027                     sprintf(taskprogress + strlen(taskprogress),
    1028                             "] %3d%% done; %2ld:%02ld to go", percentage,
    1029                             time_remaining / 60, time_remaining % 60);
    1030                     printf("---evalcall---1--- %s\r\n",
    1031                            g_isoform_header_str);
    1032                     printf("---evalcall---2--- %s\r\n", taskprogress);
    1033                     printf("---evalcall---E---\r\n");
    1034                 }
    1035             } else {
    1036                 newtScaleSet(g_isoform_scale,
    1037                              (unsigned long long) percentage);
    1038                 newtLabelSetText(g_isoform_pcline, pcline_str);
    1039                 if (percentage >= 3) {
    1040                     newtLabelSetText(g_isoform_timeline, timeline_str);
    1041                 }
    1042             }
    1043         }
    1044         if (!g_text_mode) {
    1045 //      log_it("refreshing");
    1046             newtRefresh();
    1047984        }
    1048985        mr_free(timeline_str);
    1049986        mr_free(pcline_str);
    1050         mr_free(taskprogress);
    1051     }
    1052 
    1053 
    1054 
    1055 /**
    1056  * Update the evalcall form to show @p curr %.
    1057  * @param curr The current amount of progress (percentage) in the evalcall form.
    1058  */
    1059     void
    1060      update_evalcall_form(int curr) {
    1061         update_evalcall_form_ratio(curr, 100);
    1062     }
    1063 
     987    }
     988    if (!g_text_mode) {
     989        newtRefresh();
     990    }
     991}
    1064992
    1065993
     
    1069997 * @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.
    1070998 */
    1071     void
    1072      update_progress_form(char *blurb3) {
    1073         /*  log_it("update_progress_form --- called"); */
    1074         if (g_current_progress == -999) {
    1075             /* 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."); */
    1076             return;
    1077         }
    1078         strcpy(g_blurb_str_2, blurb3);
    1079         update_progress_form_full(g_blurb_str_1, g_blurb_str_2,
    1080                                   g_blurb_str_3);
    1081     }
     999void update_progress_form(char *blurb3) {
     1000    if (g_current_progress == -999) {
     1001        return;
     1002    }
     1003    strcpy(g_blurb_str_2, blurb3);
     1004    update_progress_form_full(g_blurb_str_1, g_blurb_str_2,
     1005                              g_blurb_str_3);
     1006}
    10821007
    10831008
     
    10881013 * @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.
    10891014 */
    1090     void
    1091      update_progress_form_full(char *blurb1, char *blurb2, char *blurb3) {
    1092         /*@ long ***************************************************** */
    1093         long current_time = 0;
    1094         long time_taken = 0;
    1095         long time_remaining = 0;
    1096         long time_total_est = 0;
    1097 
    1098         /*@ int ******************************************************* */
    1099         int percentage = 0;
    1100         int i = 0;
    1101 
    1102         /*@ buffers *************************************************** */
    1103         char *percentline_str;
    1104         char *timeline_str;
    1105         char *taskprogress;
    1106         char *tmp;
    1107 
    1108 //  mr_msg(1, "'%s' '%s' '%s'", blurb1, blurb2, blurb3);
    1109         percentline_str = mr_malloc(MAX_NEWT_COMMENT_LEN);
    1110         timeline_str = mr_malloc(MAX_NEWT_COMMENT_LEN);
    1111         taskprogress = mr_malloc(MAX_NEWT_COMMENT_LEN);
    1112         malloc_string(tmp);
    1113         if (!g_text_mode) {
    1114             assert(blurb1 != NULL);
    1115             assert(blurb2 != NULL);
    1116             assert(blurb3 != NULL);
    1117             assert(g_timeline != NULL);
    1118         }
    1119 
    1120         percentline_str[0] = '\0';
    1121 
    1122         current_time = get_time();
    1123         time_taken = current_time - g_start_time;
    1124         if (g_maximum_progress == 0) {
    1125             percentage = 0;
    1126         } else {
    1127             if (g_current_progress > g_maximum_progress) {
    1128                 sprintf(tmp,
    1129                         "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld",
    1130                         blurb1, blurb2, blurb3, g_current_progress,
    1131                         g_maximum_progress);
    1132                 mr_msg(0, tmp);
    1133                 g_current_progress = g_maximum_progress;
    1134             }
    1135             percentage =
    1136                 (int) ((g_current_progress * 100L) / g_maximum_progress);
    1137         }
    1138         if (percentage < 1) {
    1139             percentage = 1;
     1015void update_progress_form_full(char *blurb1, char *blurb2, char *blurb3) {
     1016    /*@ long ***************************************************** */
     1017    long current_time = 0L;
     1018    long time_taken = 0L;
     1019    long time_remaining = 0L;
     1020    long time_total_est = 0L;
     1021
     1022    /*@ int ******************************************************* */
     1023    int percentage = 0;
     1024    int i = 0;
     1025
     1026    /*@ buffers *************************************************** */
     1027    char *percentline_str = NULL;
     1028    char *timeline_str = NULL;
     1029    char *taskprogress = NULL;
     1030    char *tmp = 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        printf(_("---progress-form---1--- %s\n"), blurb1);
     1078        printf(_("---progress-form---2--- %s\n"), blurb2);
     1079        printf(_("---progress-form---3--- %s\n"), blurb3);
     1080        printf(_("---progress-form---E---\n"));
     1081        mr_asprintf(&taskprogress, "TASK:  [");
     1082        for (i = 0; i < percentage; i += 5) {
     1083            mr_strcat(taskprogress, "*");
     1084        }
     1085        for (; i < 100; i += 5) {
     1086            mr_strcat(taskprogress, ".");
    11401087        }
    11411088        if (percentage > 100) {
    1142             percentage = 100;
    1143         }
    1144         if (g_current_progress) {
    1145             time_total_est =
    1146                 time_taken * (long) g_maximum_progress /
    1147                 (long) (g_current_progress);
    1148             time_remaining = time_total_est - time_taken;
    1149         } else {
    1150             time_remaining = 0;
    1151         }
    1152         g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27;
    1153         sprintf(timeline_str,
    1154                 "%2ld:%02ld taken               %2ld:%02ld remaining  ",
    1155                 time_taken / 60, time_taken % 60, time_remaining / 60,
    1156                 time_remaining % 60);
    1157         sprintf(percentline_str, " %3d%% done                 %3d%% to go",
    1158                 percentage, 100 - percentage);
    1159 
    1160         if (g_text_mode) {
    1161             printf("---progress-form---1--- %s\r\n", blurb1);
    1162             printf("---progress-form---2--- %s\r\n", blurb2);
    1163             printf("---progress-form---3--- %s\r\n", blurb3);
    1164             printf("---progress-form---E---\n");
    1165             sprintf(taskprogress, "TASK:  [");
    1166             for (i = 0; i < percentage; i += 5) {
    1167                 strcat(taskprogress, "*");
    1168             }
    1169             for (; i < 100; i += 5) {
    1170                 strcat(taskprogress, ".");
    1171             }
    1172             if (percentage > 100) {
    1173                 mr_msg(2, "percentage = %d", percentage);
    1174             }
    1175             sprintf(taskprogress + strlen(taskprogress),
    1176                     "] %3d%c", percentage, '%');
    1177             sprintf(taskprogress + strlen(taskprogress),
    1178                     " done; %2ld:%02ld to go",
    1179                     time_remaining / 60, time_remaining % 60);
    1180             printf("---progress-form---4--- %s\r\n", taskprogress);
    1181         } else {
    1182             center_string(blurb1, 54);
    1183             center_string(blurb2, 54);
    1184             center_string(blurb3, 54);
    1185             newtLabelSetText(g_blurb1, blurb1);
    1186             newtLabelSetText(g_blurb2, blurb3);
    1187             newtLabelSetText(g_blurb3, blurb2);
    1188             newtScaleSet(g_scale, (unsigned long long) g_current_progress);
    1189             if (percentage >= 2) {
    1190                 newtLabelSetText(g_timeline, timeline_str);
    1191             }
    1192             newtLabelSetText(g_percentline, percentline_str);
    1193             newtRefresh();
    1194         }
    1195         mr_free(percentline_str);
    1196         mr_free(timeline_str);
     1089            mr_msg(2, _("percentage = %d"), percentage);
     1090        }
     1091        mr_asprintf(&tmp,_("] %3d%c done; %2ld:%02ld to go"), percentage, '%',
     1092            time_remaining / 60, time_remaining % 60);
     1093        mr_strcat(taskprogress, tmp);
     1094        mr_free(tmp);
     1095        printf(_("---progress-form---4--- %s\n"), taskprogress);
    11971096        mr_free(taskprogress);
    1198         mr_free(tmp);
    1199     }
    1200 
    1201 
    1202 
    1203 
    1204 
    1205 
    1206 
    1207 
    1208 
    1209 
    1210 
    1211 
     1097    } else {
     1098        center_string(blurb1, 54);
     1099        center_string(blurb2, 54);
     1100        center_string(blurb3, 54);
     1101        newtLabelSetText(g_blurb1, blurb1);
     1102        newtLabelSetText(g_blurb2, blurb3);
     1103        newtLabelSetText(g_blurb3, blurb2);
     1104        newtScaleSet(g_scale, (unsigned long long) g_current_progress);
     1105        if (percentage >= 2) {
     1106            newtLabelSetText(g_timeline, timeline_str);
     1107        }
     1108        newtLabelSetText(g_percentline, percentline_str);
     1109        newtRefresh();
     1110    }
     1111    mr_free(percentline_str);
     1112    mr_free(timeline_str);
     1113}
    12121114
    12131115
     
    12201122 * @return The backup type chosen, or @c none if the user chose "Exit to shell".
    12211123 */
    1222     t_bkptype which_backup_media_type(bool restoring) {
    1223 
    1224         /*@ char ************************************************************ */
    1225         t_bkptype output;
    1226 
    1227 
    1228         /*@ newt ************************************************************ */
    1229         char *title_sz;
    1230         char *minimsg_sz;
    1231         static t_bkptype possible_bkptypes[] =
    1232             { none, cdr, cdrw, dvd, tape, cdstream, udev, nfs, iso };
    1233         static char *possible_responses[] =
    1234             { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev",
    1235 "nfs", "iso", NULL };
    1236         char *outstr;
    1237         t_bkptype backup_type;
    1238         int i;
    1239 
    1240         newtComponent b1;
    1241         newtComponent b2;
    1242         newtComponent b3;
    1243         newtComponent b4;
    1244         newtComponent b5;
    1245         newtComponent b6;
    1246         newtComponent b7;
    1247         newtComponent b8;
    1248         newtComponent b_res;
    1249         newtComponent myForm;
    1250 
    1251         title_sz = mr_malloc(MAX_NEWT_COMMENT_LEN);
    1252         minimsg_sz = mr_malloc(MAX_NEWT_COMMENT_LEN);
    1253         outstr = mr_malloc(MAX_NEWT_COMMENT_LEN);
    1254         if (g_text_mode) {
    1255             for (backup_type = none; backup_type == none;) {
    1256                 printf("Backup type (");
    1257                 for (i = 0; possible_responses[i]; i++) {
    1258                     printf("%c%s", (i == 0) ? '\0' : ' ',
    1259                            possible_responses[i]);
    1260                 }
    1261                 printf(")\n--> ");
    1262                 (void) fgets(outstr, MAX_NEWT_COMMENT_LEN, stdin);
    1263                 mr_strip_spaces(outstr);
    1264                 for (i = 0; possible_responses[i]; i++) {
    1265                     if (!strcmp(possible_responses[i], outstr)) {
    1266                         backup_type = possible_bkptypes[i];
    1267                     }
     1124t_bkptype which_backup_media_type(bool restoring) {
     1125
     1126    /*@ char ************************************************************ */
     1127    t_bkptype output;
     1128
     1129
     1130    /*@ newt ************************************************************ */
     1131    char *title_sz = NULL;
     1132    char *minimsg_sz = NULL;
     1133    static t_bkptype possible_bkptypes[] =
     1134        { none, cdr, cdrw, dvd, tape, cdstream, udev, nfs, iso, usb };
     1135    static char *possible_responses[] =
     1136        { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev",
     1137"nfs", "iso", "usb", NULL };
     1138    char *outstr = NULL;
     1139    t_bkptype backup_type;
     1140    int i = 0;
     1141
     1142    newtComponent b1;
     1143    newtComponent b2;
     1144    newtComponent b3;
     1145    newtComponent b4;
     1146    newtComponent b5;
     1147    newtComponent b6;
     1148    newtComponent b7;
     1149    newtComponent b8;
     1150    newtComponent b_res;
     1151    newtComponent myForm;
     1152
     1153    outstr = mr_malloc(MAX_NEWT_COMMENT_LEN);
     1154    if (g_text_mode) {
     1155        for (backup_type = none; backup_type == none;) {
     1156            printf(_("Backup type ("));
     1157            for (i = 0; possible_responses[i]; i++) {
     1158                printf("%c%s", (i == 0) ? '\0' : ' ',
     1159                       possible_responses[i]);
     1160            }
     1161            printf(")\n--> ");
     1162            (void) fgets(outstr, MAX_NEWT_COMMENT_LEN, stdin);
     1163            mr_strip_spaces(outstr);
     1164            for (i = 0; possible_responses[i]; i++) {
     1165                if (!strcmp(possible_responses[i], outstr)) {
     1166                    backup_type = possible_bkptypes[i];
    12681167                }
    12691168            }
    1270             mr_free(title_sz);
    1271             mr_free(minimsg_sz);
    1272             mr_free(outstr);
    1273             return (backup_type);
    1274         }
    1275         newtDrawRootText(18, 0, WELCOME_STRING);
    1276         if (restoring) {
    1277             strcpy(title_sz,
    1278                    "Please choose the backup media from which you want to read data.");
    1279             strcpy(minimsg_sz, "Read from:");
    1280         } else {
    1281             strcpy(title_sz,
    1282                    "Please choose the backup media to which you want to archive data.");
    1283             strcpy(minimsg_sz, "Backup to:");
    1284         }
    1285         newtPushHelpLine(title_sz);
    1286         //  newtOpenWindow (23, 3, 34, 17, minimsg_sz);
    1287         newtCenteredWindow(34, 17, minimsg_sz);
    1288         b1 = newtButton(1, 1, "CD-R disks ");
    1289         b2 = newtButton(17, 1, "CD-RW disks");
    1290         b3 = newtButton(1, 9, "Tape drive ");
    1291         b4 = newtButton(17, 5, "CD streamer");
    1292         b5 = newtButton(1, 5, " DVD disks ");
    1293         b6 = newtButton(17, 9, " NFS mount ");
    1294         b7 = newtButton(1, 13, " Hard disk ");
    1295         b8 = newtButton(17, 13, "    Exit   ");
    1296         myForm = newtForm(NULL, NULL, 0);
    1297         newtFormAddComponents(myForm, b1, b5, b3, b7, b2, b4, b6, b8,
    1298                               NULL);
    1299         b_res = newtRunForm(myForm);
    1300         newtFormDestroy(myForm);
    1301         newtPopWindow();
    1302         if (b_res == b1) {
    1303             output = cdr;
    1304         } else if (b_res == b2) {
    1305             output = cdrw;
    1306         } else if (b_res == b3) {
    1307             output = tape;
    1308         } else if (b_res == b4) {
    1309             output = cdstream;
    1310         } else if (b_res == b5) {
    1311             output = dvd;
    1312         } else if (b_res == b6) {
    1313             output = nfs;
    1314         } else if (b_res == b7) {
    1315             output = iso;
    1316         } else {
    1317             output = none;
    1318         }
    1319         newtPopHelpLine();
    1320         mr_free(title_sz);
    1321         mr_free(minimsg_sz);
     1169        }
    13221170        mr_free(outstr);
    1323         return (output);
    1324     }
    1325 
    1326 
     1171        return (backup_type);
     1172    }
     1173    newtDrawRootText(18, 0, WELCOME_STRING);
     1174    if (restoring) {
     1175        mr_asprintf(&title_sz,
     1176                 _("Please choose the backup media from which you want to read data."));
     1177        mr_asprintf(&minimsg_sz, _("Read from:"));
     1178    } else {
     1179        mr_asprintf(&title_sz,
     1180                 _("Please choose the backup media to which you want to archive data."));
     1181        mr_asprintf(&minimsg_sz, _("Backup to:"));
     1182    }
     1183    newtPushHelpLine(title_sz);
     1184    mr_free(title_sz);
     1185
     1186    //  newtOpenWindow (23, 3, 34, 17, minimsg_sz);
     1187    newtCenteredWindow(34, 17, minimsg_sz);
     1188    mr_free(minimsg_sz);
     1189
     1190    /* BERLIOS: USB ?? */
     1191    b1 = newtButton(1, 1, _("CD-R disks "));
     1192    b2 = newtButton(17, 1, _("CD-RW disks"));
     1193    b3 = newtButton(1, 9, _("Tape drive "));
     1194    b4 = newtButton(17, 5, _("CD streamer"));
     1195    b5 = newtButton(1, 5, _(" DVD disks "));
     1196    b6 = newtButton(17, 9, _(" NFS mount "));
     1197    b7 = newtButton(1, 13, _(" Hard disk "));
     1198    b8 = newtButton(17, 13, _("    Exit   "));
     1199    myForm = newtForm(NULL, NULL, 0);
     1200    newtFormAddComponents(myForm, b1, b5, b3, b7, b2, b4, b6, b8,
     1201                          NULL);
     1202    b_res = newtRunForm(myForm);
     1203    newtFormDestroy(myForm);
     1204    newtPopWindow();
     1205    if (b_res == b1) {
     1206        output = cdr;
     1207    } else if (b_res == b2) {
     1208        output = cdrw;
     1209    } else if (b_res == b3) {
     1210        output = tape;
     1211    } else if (b_res == b4) {
     1212        output = cdstream;
     1213    } else if (b_res == b5) {
     1214        output = dvd;
     1215    } else if (b_res == b6) {
     1216        output = nfs;
     1217    } else if (b_res == b7) {
     1218        output = iso;
     1219    } else {
     1220        output = none;
     1221    }
     1222    newtPopHelpLine();
     1223    mr_free(outstr);
     1224    return (output);
     1225}
    13271226
    13281227
     
    13321231 * @return The compression level (0-9) chosen, or -1 for "Exit".
    13331232 */
    1334     int
    1335      which_compression_level() {
    1336 
    1337         /*@ char ************************************************************ */
    1338         int output = none;
    1339 
    1340 
    1341         /*@ newt ************************************************************ */
    1342 
    1343         newtComponent b1;
    1344         newtComponent b2;
    1345         newtComponent b3;
    1346         newtComponent b4;
    1347         newtComponent b5;
    1348         newtComponent b_res;
    1349         newtComponent myForm;
    1350 
    1351         newtDrawRootText(18, 0, WELCOME_STRING);
    1352         newtPushHelpLine
    1353             ("   Please specify the level of compression that you want.");
    1354         //  newtOpenWindow (23, 3, 34, 13, "How much compression?");
    1355         newtCenteredWindow(34, 13, "How much compression?");
    1356         b1 = newtButton(4, 1, "Maximum");
    1357         b2 = newtButton(18, 1, "Average");
    1358         b3 = newtButton(4, 5, "Minumum");
    1359         b4 = newtButton(18, 5, " None  ");
    1360         b5 = newtButton(4, 9, "         Exit        ");
    1361         myForm = newtForm(NULL, NULL, 0);
    1362         newtFormAddComponents(myForm, b1, b3, b2, b4, b5, NULL);
    1363         b_res = newtRunForm(myForm);
    1364         newtFormDestroy(myForm);
    1365         newtPopWindow();
    1366         if (b_res == b1) {
    1367             output = 9;
    1368         } else if (b_res == b2) {
    1369             output = 4;
    1370         } else if (b_res == b3) {
    1371             output = 1;
    1372         } else if (b_res == b4) {
    1373             output = 0;
    1374         } else if (b_res == b5) {
    1375             output = -1;
    1376         }
    1377         newtPopHelpLine();
    1378         return (output);
    1379     }
    1380 
    1381 
    1382 
     1233int which_compression_level(void) {
     1234
     1235    /*@ char ************************************************************ */
     1236    int output = none;
     1237
     1238    /*@ newt ************************************************************ */
     1239    newtComponent b1;
     1240    newtComponent b2;
     1241    newtComponent b3;
     1242    newtComponent b4;
     1243    newtComponent b5;
     1244    newtComponent b_res;
     1245    newtComponent myForm;
     1246
     1247    newtDrawRootText(18, 0, WELCOME_STRING);
     1248    newtPushHelpLine
     1249        (_("   Please specify the level of compression that you want."));
     1250    //  newtOpenWindow (23, 3, 34, 13, "How much compression?");
     1251    newtCenteredWindow(34, 13, _("How much compression?"));
     1252    b1 = newtButton(4, 1, _("Maximum"));
     1253    b2 = newtButton(18, 1, _("Average"));
     1254    b3 = newtButton(4, 5, _("Minimum"));
     1255    b4 = newtButton(18, 5, _(" None  "));
     1256    b5 = newtButton(4, 9, _("         Exit        "));
     1257    myForm = newtForm(NULL, NULL, 0);
     1258    newtFormAddComponents(myForm, b1, b3, b2, b4, b5, NULL);
     1259    b_res = newtRunForm(myForm);
     1260    newtFormDestroy(myForm);
     1261    newtPopWindow();
     1262    if (b_res == b1) {
     1263        output = 9;
     1264    } else if (b_res == b2) {
     1265        output = 4;
     1266    } else if (b_res == b3) {
     1267        output = 1;
     1268    } else if (b_res == b4) {
     1269        output = 0;
     1270    } else if (b_res == b5) {
     1271        output = -1;
     1272    }
     1273    newtPopHelpLine();
     1274    return (output);
     1275}
    13831276
    13841277
     
    13891282 * @param source_file The file containing a list of filenames to load into @p filelist.
    13901283 */
    1391     int load_filelist_into_array(struct s_filelist *filelist,
     1284int load_filelist_into_array(struct s_filelist *filelist,
    13921285                                 char *source_file) {
    1393         int i;
    1394         bool done;
    1395         char *tmp;
    1396         FILE *fin;
    1397         struct s_filelist_entry dummy_fle;
    1398 
    1399         malloc_string(tmp);
    1400         assert(filelist != NULL);
    1401         assert_string_is_neither_NULL_nor_zerolength(source_file);
    1402 
    1403         iamhere("entering");
    1404         if (!(fin = fopen(source_file, "r"))) {
    1405             log_OS_error(source_file);
    1406             mr_msg(2, "Can't open %s; therefore, cannot popup list",
    1407                     source_file);
    1408             mr_free(tmp);
    1409             return (1);
    1410         }
    1411         mr_msg(2, "Loading %s", source_file);
    1412         for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM;
    1413              filelist->entries++) {
    1414           god_i_hate_gotos:
    1415             if (feof(fin)) {
    1416                 break;
     1286    int i;
     1287    bool done;
     1288    char *tmp = NULL;
     1289    size_t n = 0;
     1290    FILE *fin = NULL;
     1291    struct s_filelist_entry dummy_fle;
     1292
     1293    assert(filelist != NULL);
     1294    assert_string_is_neither_NULL_nor_zerolength(source_file);
     1295
     1296    iamhere("entering");
     1297    if (!(fin = fopen(source_file, "r"))) {
     1298        log_OS_error(source_file);
     1299        mr_msg(2, "Can't open %s; therefore, cannot popup list",
     1300                source_file);
     1301        return (1);
     1302    }
     1303    mr_msg(2, "Loading %s", source_file);
     1304    for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM;
     1305         filelist->entries++) {
     1306      god_i_hate_gotos:
     1307        if (feof(fin)) {
     1308            break;
     1309        }
     1310        mr_getline(&tmp, &n, fin);
     1311        i = (int) strlen(tmp);
     1312        if (i < 2) {
     1313            goto god_i_hate_gotos;
     1314        }
     1315        if (tmp[i - 1] < 32) {
     1316            tmp[--i] = '\0';
     1317        }
     1318        if (i < 2) {
     1319            goto god_i_hate_gotos;
     1320        }
     1321        if (!does_file_exist(tmp)) {
     1322            goto god_i_hate_gotos;
     1323        }
     1324        filelist->el[filelist->entries].severity =
     1325            severity_of_difference(tmp, NULL);
     1326        strcpy(filelist->el[filelist->entries].filename, tmp);
     1327        if (feof(fin)) {
     1328            break;
     1329        }
     1330    }
     1331    mr_free(tmp);
     1332
     1333    paranoid_fclose(fin);
     1334    if (filelist->entries >= ARBITRARY_MAXIMUM) {
     1335        log_to_screen(_("Arbitrary limits suck, man!"));
     1336        return (1);
     1337    }
     1338    for (done = FALSE; !done;) {
     1339        done = TRUE;
     1340        for (i = 0; i < filelist->entries - 1; i++) {
     1341            if (filelist->el[i].severity < filelist->el[i + 1].severity
     1342                || (filelist->el[i].severity ==
     1343                    filelist->el[i + 1].severity
     1344                    && strcmp(filelist->el[i].filename,
     1345                              filelist->el[i + 1].filename) > 0)) {
     1346                memcpy((void *) &dummy_fle,
     1347                       (void *) &(filelist->el[i]),
     1348                       sizeof(struct s_filelist_entry));
     1349                memcpy((void *) &(filelist->el[i]),
     1350                       (void *) &(filelist->el[i + 1]),
     1351                       sizeof(struct s_filelist_entry));
     1352                memcpy((void *) &(filelist->el[i + 1]),
     1353                       (void *) &dummy_fle,
     1354                       sizeof(struct s_filelist_entry));
     1355                mr_msg(2, "Swapping %s and %s",
     1356                        filelist->el[i].filename,
     1357                        filelist->el[i + 1].filename);
     1358                done = FALSE;
    14171359            }
    1418             (void) fgets(tmp, MAX_NEWT_COMMENT_LEN, fin);
    1419             i = (int) strlen(tmp);
    1420             if (i < 2) {
    1421                 goto god_i_hate_gotos;
    1422             }
    1423             if (tmp[i - 1] < 32) {
    1424                 tmp[--i] = '\0';
    1425             }
    1426             if (i < 2) {
    1427                 goto god_i_hate_gotos;
    1428             }
    1429             if (!does_file_exist(tmp)) {
    1430                 goto god_i_hate_gotos;
    1431             }
    1432             filelist->el[filelist->entries].severity =
    1433                 severity_of_difference(tmp, NULL);
    1434             strcpy(filelist->el[filelist->entries].filename, tmp);
    1435             if (feof(fin)) {
    1436                 break;
    1437             }
    1438         }
    1439         paranoid_fclose(fin);
    1440         if (filelist->entries >= ARBITRARY_MAXIMUM) {
    1441             log_to_screen("Arbitrary limits suck, man!");
    1442             mr_free(tmp);
    1443             return (1);
    1444         }
    1445         for (done = FALSE; !done;) {
    1446             done = TRUE;
    1447             for (i = 0; i < filelist->entries - 1; i++) {
    1448 //          if (strcmp(filelist->el[i].filename, filelist->el[i+1].filename) > 0)
    1449                 if (filelist->el[i].severity < filelist->el[i + 1].severity
    1450                     || (filelist->el[i].severity ==
    1451                         filelist->el[i + 1].severity
    1452                         && strcmp(filelist->el[i].filename,
    1453                                   filelist->el[i + 1].filename) > 0)) {
    1454                     memcpy((void *) &dummy_fle,
    1455                            (void *) &(filelist->el[i]),
    1456                            sizeof(struct s_filelist_entry));
    1457                     memcpy((void *) &(filelist->el[i]),
    1458                            (void *) &(filelist->el[i + 1]),
    1459                            sizeof(struct s_filelist_entry));
    1460                     memcpy((void *) &(filelist->el[i + 1]),
    1461                            (void *) &dummy_fle,
    1462                            sizeof(struct s_filelist_entry));
    1463                     mr_msg(2, "Swapping %s and %s",
    1464                             filelist->el[i].filename,
    1465                             filelist->el[i + 1].filename);
    1466                     done = FALSE;
    1467                 }
    1468             }
    1469         }
    1470         mr_free(tmp);
    1471         iamhere("leaving");
    1472         return (0);
    1473     }
    1474 
     1360        }
     1361    }
     1362    iamhere("leaving");
     1363    return (0);
     1364}
    14751365
    14761366
     
    14811371 * @note The returned value points to static storage that will be overwritten with each call.
    14821372 */
    1483     char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
    1484         static char comment[100];
    1485         char *tmp;
    1486 
    1487         iamhere("entering");
    1488         malloc_string(tmp);
    1489         assert(flentry != NULL);
    1490         if (flentry->severity == 0) {
    1491             strcpy(tmp, "0   ");
    1492         } else if (flentry->severity == 1) {
    1493             strcpy(tmp, "low ");
    1494         } else if (flentry->severity == 2) {
    1495             strcpy(tmp, "med ");
    1496         } else {
    1497             strcpy(tmp, "high");
    1498         }
    1499         strcat(tmp, "  ");
    1500         strncat(tmp, flentry->filename, 100);
     1373char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
     1374    static char comment[100];
     1375    char *tmp = NULL;
     1376
     1377    iamhere("entering");
     1378    malloc_string(tmp);
     1379    assert(flentry != NULL);
     1380    if (flentry->severity == 0) {
     1381        mr_asprintf(&tmp, "0     %s", flentry->filename);
     1382    } else if (flentry->severity == 1) {
     1383        mr_asprintf(&tmp, "low   %s", flentry->filename);
     1384    } else if (flentry->severity == 2) {
     1385        mr_asprintf(&tmp, "med   %s", flentry->filename);
     1386    } else {
     1387        mr_asprintf(&tmp, "high  %s", flentry->filename);
     1388    }
     1389    if (strlen(tmp) > 98) {
    15011390        tmp[98] = '\0';
    1502         strcpy(comment, tmp);
    1503         mr_free(tmp);
    1504         iamhere("leaving");
    1505         return (comment);
    1506     }
    1507 
    1508 
    1509 
     1391    }
     1392    strcpy(comment, tmp);
     1393    mr_free(tmp);
     1394    iamhere("leaving");
     1395    return(comment);
     1396}
    15101397
    15111398
     
    15161403 */
    15171404    void popup_changelist_from_file(char *source_file) {
    1518         char *reason;
     1405        char *reason = NULL;
    15191406        newtComponent myForm;
    15201407        newtComponent bClose;
     
    15251412
    15261413        /*@ ???? ************************************************************ */
    1527         void *curr_choice;
     1414        void *curr_choice = NULL;
    15281415        void *keylist[ARBITRARY_MAXIMUM];
    15291416
     
    15331420
    15341421        /*@ long ************************************************************ */
    1535         long i = 0;
    1536         long lng = 0;
     1422        long i = 0L;
     1423        long lng = 0L;
    15371424
    15381425        /*@ buffers ********************************************************* */
    1539         char *tmp;
    1540         char *differ_sz;
    1541 
    1542         struct s_filelist *filelist;
    1543         malloc_string(reason);
    1544         tmp = mr_malloc(5000);
    1545         malloc_string(differ_sz);
     1426        char *tmp = NULL;
     1427        char *differ_sz = NULL;
     1428        struct s_filelist *filelist = NULL;
     1429
    15461430        assert_string_is_neither_NULL_nor_zerolength(source_file);
    15471431        if (g_text_mode) {
    15481432            mr_msg(2, "Text mode. Therefore, no popup list.");
    1549             goto free_to_go;
     1433            return;
    15501434        }
    15511435        mr_msg(2, "Examining file %s", source_file);
     
    15541438        if (lng < 1) {
    15551439            mr_msg(2, "No lines in file. Therefore, no popup list.");
    1556             mr_free(reason);
    1557             goto free_to_go;
     1440            return;
    15581441        } else if (lng >= ARBITRARY_MAXIMUM) {
    15591442            mr_msg(2, "Too many files differ for me to list.");
    1560             goto free_to_go;
     1443            return;
    15611444        }
    15621445
     
    15691452            mr_msg(2, "Can't open %s; therefore, cannot popup list",
    15701453                    source_file);
    1571             mr_free(reason);
    15721454            return;
    15731455        }
     
    15821464                                   keylist[i]);
    15831465        }
    1584         sprintf(differ_sz,
    1585                 "  %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.",
    1586                 i);
     1466        mr_asprintf(&differ_sz,
     1467                 _("  %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list."),
     1468                 i);
    15871469        newtPushHelpLine(differ_sz);
    1588         bClose = newtCompactButton(10, 15, " Close  ");
    1589         bSelect = newtCompactButton(30, 15, " Select ");
    1590         sprintf(tmp, "%-10s               %-20s", "Priority", "Filename");
     1470        mr_free(differ_sz);
     1471
     1472        bClose = newtCompactButton(10, 15, _(" Close  "));
     1473        bSelect = newtCompactButton(30, 15, _(" Select "));
     1474        mr_asprintf(&tmp, "%-10s               %-20s", _("Priority"),
     1475                 _("Filename"));
    15911476        headerMsg = newtLabel(2, 1, tmp);
    1592         newtOpenWindow(5, 4, 70, 16, "Non-matching files");
     1477        mr_free(tmp);
     1478
     1479        newtOpenWindow(5, 4, 70, 16, _("Non-matching files"));
    15931480        myForm = newtForm(NULL, NULL, 0);
    15941481        newtFormAddComponents(myForm, headerMsg, fileListbox, bClose,
     
    16041491                     i++);
    16051492                if (i == filelist->entries && filelist->entries > 0) {
    1606                     log_to_screen("I don't know what that button does!");
     1493                    log_to_screen(_("I don't know what that button does!"));
    16071494                } else {
    16081495                    currline = i;
     
    16101497                        severity_of_difference(filelist->el[currline].
    16111498                                               filename, reason);
    1612                         sprintf(tmp, "%s --- %s",
    1613                                 filelist->el[currline].filename, reason);
     1499                        mr_asprintf(&tmp, "%s --- %s",
     1500                                 filelist->el[currline].filename, reason);
    16141501                        popup_and_OK(tmp);
     1502                        mr_free(tmp);
    16151503                    }
    16161504                }
     
    16201508        newtPopWindow();
    16211509        newtPopHelpLine();
    1622       free_to_go:
    1623         mr_free(reason);
    1624         mr_free(tmp);
    1625         mr_free(differ_sz);
    16261510        return;
    16271511    }
Note: See TracChangeset for help on using the changeset viewer.