Changeset 3858 in MondoRescue


Ignore:
Timestamp:
Mar 7, 2024, 12:52:46 AM (3 months ago)
Author:
Bruno Cornec
Message:

remove center_string function to keep only mr_center_string

Location:
branches/3.3/mondo/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/common/libmondo-archive.c

    r3856 r3858  
    29812981
    29822982    /*@ buffers ************************************************** */
    2983     char *tmp;
    2984 
    2985     malloc_string(tmp);
     2983    char *tmp = NULL;
     2984
    29862985    assert(bkpinfo != NULL);
    2987 
    2988 // I should really check if there are any slices or tarballs to be copied to CD-R(W)'s; the odds are approx. 1 in a million that there are no files here, so I'll just go ahead & make one more CD anyway
    2989 
    2990     sprintf(tmp, "Writing the final ISO");
     2986    // I should really check if there are any slices or tarballs to be copied to CD-R(W)'s; the odds are approx. 1 in a million that there are no files here, so I'll just go ahead & make one more CD anyway
     2987
     2988    tmp = mr_center_string("Writing the final ISO", 80);
    29912989    log_msg(2, tmp);
    2992     center_string(tmp, 80);
    29932990    if (!g_text_mode) {
    29942991        newtPushHelpLine(tmp);
    29952992    }
     2993    mr_free(tmp);
    29962994    res = write_iso_and_go_on(TRUE);
    29972995    if (!g_text_mode) {
     
    29992997    }
    30002998    log_msg(2, "Returning from writing final ISO (res=%d)", res);
    3001     paranoid_free(tmp);
    30022999    return (res);
    30033000}
  • branches/3.3/mondo/src/common/libmondo-fifo.c

    r3840 r3858  
    106106    }
    107107    if (bufsize) {
    108         mr_asprintf(g_call_to_buffer,
    109                 "buffer -m %d%c -p%d -B -s%ld -%c %s 2>> %s", bufsize, 'm',
     108        mr_asprintf(g_call_to_buffer, "buffer -m %d%c -p%d -B -s%ld -%c %s 2>> %s", bufsize, 'm',
    110109                (direction == 'r') ? 20 : 75, internal_tape_block_size,
    111110                keych, device, MONDO_LOGFILE);
  • branches/3.3/mondo/src/common/libmondo-string-EXT.h

    r3855 r3858  
    55extern char *build_partition_name(char *partition, const char *drive,
    66                                  int partno);
    7 extern void center_string(char *in_out, int width);
    87extern char *commarize(char *);
    98extern char *disklist_entry_to_string(struct list_of_disks *disklist,
  • branches/3.3/mondo/src/common/libmondo-string.c

    r3851 r3858  
    7373/**
    7474 * Pad a string on both sides so it appears centered.
    75  * @param in_out The string to be center-padded (modified).
     75 * @param in The string to be center-padded (modified).
    7676 * @param width The width of the final result.
    7777 */
     
    106106    return(out);
    107107}
    108 
    109 /**
    110  * Pad a string on both sides so it appears centered.
    111  * @param in_out The string to be center-padded (modified).
    112  * @param width The width of the final result.
    113  */
    114 void center_string(char *in_out, int width)
    115 {
    116     char scratch[MAX_STR_LEN];
    117     char *p;
    118     int i;                      /* purpose */
    119     int len;                    /* purpose */
    120     int mid;                    /* purpose */
    121     int x;                      /* purpose */
    122 
    123     assert(in_out != NULL);
    124     assert(width > 2);
    125 
    126     if (strlen(in_out) == 0) {
    127         return;
    128     }
    129     for (p = in_out; *p == ' '; p++);
    130     strcpy(scratch, p);
    131     strip_spaces(scratch);
    132     len = (int) strlen(scratch);
    133     mid = width / 2;
    134     x = mid - len / 2;
    135     for (i = 0; i < x; i++) {
    136         in_out[i] = ' ';
    137     }
    138     in_out[i] = '\0';
    139     strcat(in_out, scratch);
    140     for (i = x + len ; i < width - 1; i++) {
    141             in_out[i] = ' ';
    142         }
    143     in_out[i] = '\0';
    144 }
    145 
    146108
    147109/**
     
    235197 * @return The left-padded string.
    236198 * @note The returned string points to static storage that will be overwritten with each call.
    237  * @bug Why does center_string() modify its argument but leftpad_string() returns a modified copy?
    238199 */
    239200char *leftpad_string(char *incoming, int width)
  • branches/3.3/mondo/src/common/libmondo-string.h

    r3552 r3858  
    44
    55char *build_partition_name(char *partition, const char *drive, int partno);
    6 void center_string(char *in_out, int width);
    76char *commarize(char *);
    87char *disklist_entry_to_string(struct list_of_disks *disklist, int lino);
  • branches/3.3/mondo/src/common/libmondo-verify.h

    r1713 r3858  
    9191extern bool ask_me_yes_or_no(char *);
    9292extern char *calc_checksum_of_file(char *filename);
    93 extern void center_string(char *, int);
    9493extern void close_evalcall_form(void);
    9594extern int closein_tape();
  • branches/3.3/mondo/src/common/newt-specific-EXT.h

    r3852 r3858  
    2323extern void update_evalcall_form(int curr);
    2424extern void update_progress_form(char *blurb3);
    25 extern void update_progress_form_full(char *blurb1, char *blurb2,
    26                                       char *blurb3);
    27 
    28 
    29 
    30 
    3125
    3226extern t_bkptype which_backup_media_type(bool);
  • branches/3.3/mondo/src/common/newt-specific.c

    r3856 r3858  
    6161extern bool g_fail_immediately;
    6262
    63 /**
    64  * Padding below the Newt components, to overcome bugs in Newt.
    65  */
    66     char g_haharrrrr[500];
    67 
    68 
    6963    newtComponent g_timeline = NULL,    ///< The line of the progress form that shows the time elapsed/remaining
    7064        g_percentline = NULL,   ///< The line of the progress form that shows the percent completed/remaining
     
    7670        g_label = NULL;         ///< ????? @bug ?????
    7771
    78 /**
    79  * Padding above the Newt components, to overcome bugs in Newt.
    80  */
    81     char g_jim_lad_yarr[500];
    8272    char **err_log_lines = NULL,    ///< The list of log lines to show on the screen.
    8373        g_blurb_str_1[MAX_NEWT_COMMENT_LEN] = "",   ///< The string for line 1 of the blurb in the progress form
     
    9181    long g_isoform_starttime;   ///< The time (in seconds since the epoch) that the evalcall form was opened.
    9282    int g_isoform_old_progress = -1;    ///< The most recent progress update of the evalcall form (percent).
    93     char g_isoform_header_str[MAX_STR_LEN] = "                                                                                                               "; ///< The string for the evalcall form title.
     83    char g_isoform_header_str = NULL;   ///< The string for the evalcall form title.
    9484    int g_mysterious_dot_counter;   ///< The counter for the twirling baton (/ | \\ - ...) on percentage less than 3
    9585    int g_noof_log_lines = 6;   ///< The number of lines to show in the log at the bottom of the screen.
     
    446436        paranoid_free(bkpinfo);
    447437
     438        /* free global vars */
     439        mr_free(g_isoform_header_str);
     440
    448441        free_libmondo_global_strings();
    449442        free_newt_stuff();
     
    614607
    615608        assert(ttl != NULL);
    616         malloc_string(tmp);
    617         strcpy(g_isoform_header_str, ttl);
     609        //strcpy(g_isoform_header_str, ttl);
    618610        if (g_text_mode) {
    619611            log_msg(0, ttl);
    620612        } else {
    621             strcpy(tmp, ttl);
    622             center_string(tmp, 80);
     613            tmp = mr_center_string(ttl, 80);
    623614            newtPushHelpLine(tmp);
    624         }
    625         center_string(g_isoform_header_str, 36);
     615            mr_free(tmp);
     616        }
     617        mr_free(g_isoform_header_str);
     618        g_isoform_header_str = mr_center_string(ttl, 36);
    626619        g_isoform_starttime = get_time();
    627620        if (g_text_mode) {
     
    644637        }
    645638        update_evalcall_form(0);
    646         paranoid_free(tmp);
    647639    }
    648640
     
    661653
    662654        /*@ buffers ********************************************************* */
    663         char *b1c;
     655        char *b1c = NULL;
    664656        char *blurb1 = NULL;
    665657        char *blurb2 = NULL;
     
    668660        /*@ initialize ****************************************************** */
    669661        g_mysterious_dot_counter = 0;
    670 
    671         malloc_string(b1c);
    672662
    673663        assert(title != NULL);
     
    683673        strcpy(blurb3, b3);
    684674
    685         strcpy(b1c, b1);
    686         center_string(b1c, 80);
     675        b1c = mr_center_string(b1c, 80);
    687676        if (max_val <= 0) {
    688677            max_val = 1;
     
    714703        }
    715704        update_progress_form_full(blurb1, blurb2, blurb3);
    716         paranoid_free(b1c);
     705        mr_free(b1c);
    717706        paranoid_free(blurb1);
    718707        paranoid_free(blurb2);
     
    836825        }
    837826       
    838         blurb = malloc(MAX_NEWT_COMMENT_LEN);
    839         strcpy(blurb, b);
    840         text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0);
     827        text = newtTextboxReflowed(2, 1, b, 48, 5, 5, 0);
    841828        mr_asprintf(original_contents, "%s", output);
    842829        output[0] = '\0';
     
    853840        myForm = newtForm(NULL, NULL, 0);
    854841        newtFormAddComponents(myForm, text, type_here, b_1, b_2, NULL);
    855         center_string(blurb, 80);
     842        blurb = mr_center_string(b, 80);
    856843        newtPushHelpLine(blurb);
     844        mr_free(blurb);
    857845        b_res = newtRunForm(myForm);
    858846        strcpy(output, entry_value);
     
    860848        newtFormDestroy(myForm);
    861849        newtPopWindow();
    862         paranoid_free(blurb);
    863850
    864851        if (b_res == b_2) {
     
    916903        }
    917904
     905        /* not sure it's useful to shrink here
    918906        prompt = malloc(MAX_NEWT_COMMENT_LEN);
    919907        strncpy(prompt, p, MAX_NEWT_COMMENT_LEN - 1);
    920908        prompt[MAX_NEWT_COMMENT_LEN - 1] = '\0';
    921909        text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0);
     910        */
     911        text = newtTextboxReflowed(1, 1, p, 40, 5, 5, 0);
    922912        b_1 = newtButton(20 - ((button2[0] != '\0') ? strlen(button1) + 2 : strlen(button1) / 2), newtTextboxGetNumLines(text) + 3, button1);
    923913        if (button2[0] != '\0') {
     
    929919        myForm = newtForm(NULL, NULL, 0);
    930920        newtFormAddComponents(myForm, text, b_1, b_2, NULL);
    931         center_string(prompt, 80);
     921        prompt = mr_center_string(p, 80);
    932922        newtPushHelpLine(prompt);
     923        mr_free(prompt);
    933924        b_res = newtRunForm(myForm);
    934925        newtPopHelpLine();
     
    936927        newtPopWindow();
    937928        if (b_res == b_1) {
    938             paranoid_free(prompt);
    939929            return (TRUE);
    940930        } else {
    941             paranoid_free(prompt);
    942931            return (FALSE);
    943932        }
     
    11391128        long time_total_est = 0L;
    11401129
     1130        char *blurb1_str = NULL;
     1131        char *blurb2_str = NULL;
     1132        char *blurb3_str = NULL;
     1133
    11411134        /*@ int ******************************************************* */
    11421135        int percentage = 0;
     
    12011194            mr_asprintf(percentline_str, " %3d%% done                 %3d%% to go", percentage, 100 - percentage);
    12021195
    1203             center_string(blurb1, 54);
    1204             center_string(blurb2, 54);
    1205             center_string(blurb3, 54);
     1196            blurb1_str = mr_center_string(blurb1, 54);
     1197            blurb2_str = mr_center_string(blurb2, 54);
     1198            blurb3_str = mr_center_string(blurb3, 54);
    12061199            if (g_blurb1) {
    1207                 newtLabelSetText(g_blurb1, blurb1);
     1200                newtLabelSetText(g_blurb1, blurb1_str);
    12081201            }
    12091202            if (g_blurb2) {
    1210                 newtLabelSetText(g_blurb2, blurb3);
     1203                // Not a typo but ridiculous !
     1204                newtLabelSetText(g_blurb2, blurb3_str);
    12111205            }
    12121206            if (g_blurb3) {
    1213                 newtLabelSetText(g_blurb3, blurb2);
     1207                // Not a typo but ridiculous !
     1208                newtLabelSetText(g_blurb3, blurb2_str);
    12141209            }
    12151210            newtScaleSet(g_scale, (unsigned long long) g_current_progress);
     
    12231218            }
    12241219            mr_free(percentline_str);
     1220            mr_free(blurb1_str);
     1221            mr_free(blurb2_str);
     1222            mr_free(blurb3_str);
    12251223
    12261224            newtDrawForm(g_progressForm);
  • branches/3.3/mondo/src/mondorestore/mondo-rstr-newt.h

    r3158 r3858  
    3939extern long get_time(void);
    4040extern char *last_line_of_file(char *);
    41 extern void center_string(char *, int);
    4241extern bool does_file_exist(char *);
    4342extern void finish(int);
     
    181180void update_evalcall_form(int);
    182181void update_progress_form(char *);
    183 void update_progress_form_full(char *, char *, char *);
    184182char which_restore_mode(void);
    185183void write_variableINT_to_raid_var_line(struct raid_device_record *, int,
Note: See TracChangeset for help on using the changeset viewer.