Changeset 783 in MondoRescue for trunk/mondo/mondo/common/newt-specific.c


Ignore:
Timestamp:
Aug 31, 2006, 5:09:20 PM (18 years ago)
Author:
Bruno Cornec
Message:
  • Massive rewrite continues for memory management.
  • main structure should now have all parameters allocated dynamically
  • new lib libmr.a + dir + build process reviewed to support it.
  • new include subdir to host external definitions of the new lib
  • code now compiles. Still one remaining link issues for mondorestore. This should allow for some tests soon.

(goal is to separate completely reviewed code and functions and provide clean interfaces)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/mondo/common/newt-specific.c

    r764 r783  
    1414
    1515#include <unistd.h>
     16#include <math.h>
    1617
    1718#include "my-stuff.h"
     
    2829//static char cvsid[] = "$Id$";
    2930
    30     extern pid_t g_mastermind_pid;
    31     extern char *g_tmpfs_mountpt;
    32     extern char *g_mondo_home;
    33 
    34     extern void set_signals(int);
     31extern pid_t g_mastermind_pid;
     32extern char *g_tmpfs_mountpt;
     33extern char *g_mondo_home;
     34
     35extern void set_signals(int);
    3536
    3637/**
     
    4142 * Whether we are currently in a nested call of fatal_error().
    4243 */
    43     bool g_exiting = FALSE;
    44 
    45     newtComponent g_timeline = NULL,    ///< The line of the progress form that shows the time elapsed/remaining
    46         g_percentline = NULL,   ///< The line of the progress form that shows the percent completed/remaining
    47         g_scale = NULL,         ///< The progress bar component in the progress form
    48         g_progressForm = NULL,  ///< The progress form component itself
    49         g_blurb1 = NULL,        ///< The component for line 1 of the blurb in the progress form
    50         g_blurb2 = NULL,        ///< The component for line 2 of the blurb in the progress form
    51         g_blurb3 = NULL,        ///< The component for line 3 (updated continuously) of the blurb in the progress form
    52         g_label = NULL;         ///< ????? @bug ?????
     44bool g_exiting = FALSE;
     45
     46newtComponent g_timeline = NULL,    ///< The line of the progress form that shows the time elapsed/remaining
     47    g_percentline = NULL,   ///< The line of the progress form that shows the percent completed/remaining
     48    g_scale = NULL,         ///< The progress bar component in the progress form
     49    g_progressForm = NULL,  ///< The progress form component itself
     50    g_blurb1 = NULL,        ///< The component for line 1 of the blurb in the progress form
     51    g_blurb2 = NULL,        ///< The component for line 2 of the blurb in the progress form
     52    g_blurb3 = NULL,        ///< The component for line 3 (updated continuously) of the blurb in the progress form
     53    g_label = NULL;         ///< ????? @bug ?????
    5354
    5455/**
    5556 * Padding above the Newt components, to overcome bugs in Newt.
    5657 */
    57     char **err_log_lines = NULL,    ///< The list of log lines to show on the screen.
    58         *g_blurb_str_1,         ///< The string for line 1 of the blurb in the progress form
    59         *g_blurb_str_2,         ///< The string for line 2 of the blurb in the progress form
    60         *g_blurb_str_3;         ///< The string for line 3 (updated continuously) of the blurb in the progress form
     58char **err_log_lines = NULL,    ///< The list of log lines to show on the screen.
     59    *g_blurb_str_1,         ///< The string for line 1 of the blurb in the progress form
     60    *g_blurb_str_2,         ///< The string for line 2 of the blurb in the progress form
     61    *g_blurb_str_3;         ///< The string for line 3 (updated continuously) of the blurb in the progress form
    6162    newtComponent g_isoform_main = NULL,    ///< The evalcall form component itself
    62         g_isoform_header = NULL,    ///< The component for the evalcall form title
    63         g_isoform_scale = NULL, ///< The progress bar component in the evalcall form
    64         g_isoform_timeline = NULL,  ///< The line of the evalcall form that shows the time elapsed/remaining
    65         g_isoform_pcline = NULL;    ///< The line of the evalcall form that shows the percent completed/remaining
    66     long g_isoform_starttime;   ///< The time (in seconds since the epoch) that the evalcall form was opened.
    67     int g_isoform_old_progress = -1;    ///< The most recent progress update of the evalcall form (percent).
    68     char *g_isoform_header_str; ///< The string for the evalcall form title.
    69     int g_mysterious_dot_counter;   ///< The counter for the twirling baton (/ | \\ - ...) on percentage less than 3
    70     int g_noof_log_lines = 6;   ///< The number of lines to show in the log at the bottom of the screen.
    71     int g_noof_rows = 25;       ///< The number of rows on the screen.
    72 
    73     int g_currentY = 3;         ///< The row to write background progress messages to. Incremented each time a message is written.
    74     extern int g_current_media_number;
     63    g_isoform_header = NULL,    ///< The component for the evalcall form title
     64    g_isoform_scale = NULL, ///< The progress bar component in the evalcall form
     65    g_isoform_timeline = NULL,  ///< The line of the evalcall form that shows the time elapsed/remaining
     66    g_isoform_pcline = NULL;    ///< The line of the evalcall form that shows the percent completed/remaining
     67long g_isoform_starttime;   ///< The time (in seconds since the epoch) that the evalcall form was opened.
     68int g_isoform_old_progress = -1;    ///< The most recent progress update of the evalcall form (percent).
     69char *g_isoform_header_str; ///< The string for the evalcall form title.
     70int g_mysterious_dot_counter;   ///< The counter for the twirling baton (/ | \\ - ...) on percentage less than 3
     71int g_noof_log_lines = 6;   ///< The number of lines to show in the log at the bottom of the screen.
     72int g_noof_rows = 25;       ///< The number of rows on the screen.
     73
     74int g_currentY = 3;         ///< The row to write background progress messages to. Incremented each time a message is written.
     75extern int g_current_media_number;
    7576    pid_t g_main_pid = 0;       ///< The PID of the main Mondo process.
    76     long g_maximum_progress = 999;  ///< The maximum amount of progress (100%) for the currently opened progress form.
    77     long g_current_progress = -999; ///< The current amount of progress (filelist #, etc.) for the currently opened progress form.
    78     long g_start_time = 0;      ///< The time (in seconds since the epoch) that the progress form was opened.
    79     bool g_text_mode = TRUE;    ///< If FALSE, use a newt interface; if TRUE, use an ugly (but more compatible) dumb terminal interface.
    80     bool g_called_by_xmondo = FALSE;    ///< @bug Unneeded w/current XMondo.
    81     char *g_erase_tmpdir_and_scratchdir;    ///< The command to run to erase the tmpdir and scratchdir at the end of Mondo.
    82     char *g_selfmounted_isodir; ///< Holds the NFS mountpoint if mounted via mondoarchive.
     77long g_maximum_progress = 999;  ///< The maximum amount of progress (100%) for the currently opened progress form.
     78long g_current_progress = -999; ///< The current amount of progress (filelist #, etc.) for the currently opened progress form.
     79long g_start_time = 0;      ///< The time (in seconds since the epoch) that the progress form was opened.
     80bool g_text_mode = TRUE;    ///< If FALSE, use a newt interface; if TRUE, use an ugly (but more compatible) dumb terminal interface.
     81bool g_called_by_xmondo = FALSE;    ///< @bug Unneeded w/current XMondo.
     82char *g_erase_tmpdir_and_scratchdir;    ///< The command to run to erase the tmpdir and scratchdir at the end of Mondo.
     83char *g_selfmounted_isodir = NULL;  ///< Holds the NFS mountpoint if mounted via mondoarchive.
    8384
    8485/* @} - end of globalGroup */
     
    8687//int g_fd_in=-1, g_fd_out=-1;
    8788
    88     void popup_and_OK(char *);
     89void popup_and_OK(char *);
    8990
    9091
     
    280281        kill_anything_like_this("ntfsclone");
    281282        sync();
    282         asprintf(&tmp, "umount %s", g_tmpfs_mountpt);
    283         chdir("/");
    284         for (i = 0; i < 10 && run_program_and_log_output(tmp, 5); i++) {
    285             log_msg(2, "Waiting for child processes to terminate");
    286             sleep(1);
    287             run_program_and_log_output(tmp, 5);
    288         }
    289         paranoid_free(tmp);
     283        if (g_tmpfs_mountpt != NULL) {
     284            asprintf(&tmp, "umount %s", g_tmpfs_mountpt);
     285            chdir("/");
     286            for (i = 0; i < 10 && run_program_and_log_output(tmp, 5); i++) {
     287                log_msg(2, "Waiting for child processes to terminate");
     288                sleep(1);
     289                run_program_and_log_output(tmp, 5);
     290            }
     291            paranoid_free(tmp);
     292        }
    290293
    291294        if (g_erase_tmpdir_and_scratchdir) {
     
    298301            asprintf(&command, "rmdir %s", g_selfmounted_isodir);
    299302            run_program_and_log_output(command, 5);
     303            paranoid_free(g_selfmounted_isodir);
    300304        }
    301305
     
    356360            asprintf(&command, "rmdir %s", g_selfmounted_isodir);
    357361            run_program_and_log_output(command, 1);
     362            paranoid_free(g_selfmounted_isodir);
    358363        }
    359364//  iamhere("foo");
     
    469474
    470475        if (err_log_lines) {
    471             paranoid_free(&err_log_lines[0]);
     476            paranoid_free(err_log_lines[0]);
    472477            for (i = 1; i < g_noof_log_lines; i++) {
    473478                err_log_lines[i - 1] = err_log_lines[i];
     
    676681
    677682        /*@ pointers ********************************************************* */
    678         char *entry_value = NULL;
     683        char **entry_value = NULL;
    679684
    680685        /*@ buffers ********************************************************** */
     
    702707            newtEntry(2, newtTextboxGetNumLines(text) + 2,
    703708                      output, 50,
    704                       &entry_value, NEWT_FLAG_RETURNEXIT
     709                      entry_value, NEWT_FLAG_RETURNEXIT
    705710            );
    706711        b_1 = newtButton(6, newtTextboxGetNumLines(text) + 4, _("  OK  "));
     
    721726            // Copy entry_value before destroying the form
    722727            // clearing potentially output before
    723             paranoid_alloc(output,entry_value);
     728            paranoid_alloc(output,*entry_value);
    724729        }
    725730        newtFormDestroy(myForm);
Note: See TracChangeset for help on using the changeset viewer.