Changeset 2377


Ignore:
Timestamp:
Sep 9, 2009, 1:03:53 PM (9 years ago)
Author:
bruno
Message:
  • Remove some fixed strings again
Location:
branches/2.2.10/mondo/src/common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-string.c

    r2356 r2377  
    868868 * @return The severity (1-3).
    869869 */
    870 int severity_of_difference(char *fn, char *out_reason)
    871 {
     870int severity_of_difference(char *fn, char *out_reason) {
     871
    872872    int sev;
    873873    char *reason = NULL;
  • branches/2.2.10/mondo/src/common/newt-specific.c

    r2376 r2377  
    230230        }
    231231        if (g_current_progress == -999) {
    232             log_msg(2,
    233                     "Trying to close the progress form when it ain't open!");
     232            log_msg(2, "Trying to close the progress form when it ain't open!");
    234233            return;
    235234        }
     
    278277 * @note This function never returns.
    279278 */
    280     void
    281      fatal_error(char *error_string) {
     279void fatal_error(char *error_string) {
     280
    282281        /*@ buffers ***************************************************** */
    283282        char *command = NULL;
     
    364363 * @note This function never returns.
    365364 */
    366     void finish(int signal) {
     365void finish(int signal) {
    367366
    368367        char *command = NULL;
     
    473472 * @note The message is also written to the logfile.
    474473 */
    475     void
    476      log_to_screen(const char *fmt, ...) {
     474void log_to_screen(const char *fmt, ...) {
    477475
    478476        /*@ int ************************************************************** */
     
    530528 * @param output The string to write.
    531529 */
    532     void
    533      mvaddstr_and_log_it(int y, int x, char *output) {
     530void mvaddstr_and_log_it(int y, int x, char *output) {
     531
    534532        assert_string_is_neither_NULL_nor_zerolength(output);
    535533        log_msg(0, output);
     
    549547 * @param ttl The title to use for the evalcall form.
    550548 */
    551     void
    552      open_evalcall_form(char *ttl) {
     549void open_evalcall_form(char *ttl) {
    553550
    554551        /*@ buffers ********************************************************* */
     
    603600 * @param max_val The maximum amount of progress (number of filesets, etc.)
    604601 */
    605     void
    606      open_progress_form(char *title, char *b1, char *b2, char *b3,
    607                         long max_val) {
     602void open_progress_form(char *title, char *b1, char *b2, char *b3, long max_val) {
    608603
    609604        /*@ buffers ********************************************************* */
     
    616611        g_mysterious_dot_counter = 0;
    617612
    618         malloc_string(blurb1);
    619         malloc_string(blurb2);
    620         malloc_string(blurb3);
    621613        malloc_string(b1c);
    622614
     
    626618        assert(b3 != NULL);
    627619
    628         strcpy(blurb1,  b1);
    629         strcpy(blurb2,  b2);
    630         strcpy(blurb3,  b3);
     620        mr_asprintf(blurb1,  "%s", b1);
     621        mr_asprintf(blurb2,  "%s", b2);
     622        mr_asprintf(blurb3,  "%s", b3);
     623
    631624        strcpy(b1c, b1);
    632625        center_string(b1c, 80);
     
    649642            g_blurb2 = newtLabel(2, 2, blurb3);
    650643            g_blurb3 = newtLabel(2, 4, blurb2);
    651             //      newtOpenWindow (10, 4, 60, 11, title);
    652644            newtCenteredWindow(60, 11, title);
    653645            g_scale = newtScale(3, 6, 54, g_maximum_progress);
     
    655647            g_percentline = newtLabel(10, 9, "This is the percentline");
    656648            g_timeline = newtLabel(10, 8, "This is the timeline");
    657             newtFormAddComponents(g_progressForm, g_percentline,
    658                                   g_timeline, g_scale, g_blurb1, g_blurb3,
    659                                   g_blurb2, NULL);
     649            newtFormAddComponents(g_progressForm, g_percentline, g_timeline, g_scale, g_blurb1, g_blurb3, g_blurb2, NULL);
    660650            newtPushHelpLine(b1c);
    661651            newtRefresh();
     
    672662 * @param prompt The message.
    673663 */
    674     void
    675      popup_and_OK(char *prompt) {
     664void popup_and_OK(char *prompt) {
     665
    676666        char ch;
    677667
     
    680670        log_msg(0, prompt);
    681671        if (g_text_mode) {
    682             printf
    683                 ("---promptpopup---1--- %s\n---promptpopup---Q--- [OK] ---\n--> ",
    684                  prompt);
     672            printf("---promptpopup---1--- %s\n---promptpopup---Q--- [OK] ---\n--> ", prompt);
    685673            while (((ch = getchar()) != '\n') && (ch != EOF));
    686674        } else {
     
    696684 * @return output string if the user pressed OK, NULL if they pressed Cancel.
    697685 */
    698     char *popup_and_get_string(char *title, char *b, char *input) {
     686char *popup_and_get_string(char *title, char *b, char *input) {
    699687
    700688        /*@ newt ************************************************************ */
     
    731719        mr_asprintf(blurb, "%s", b);
    732720        text = newtTextboxReflowed(2, 1, blurb, 48, 5, 5, 0);
    733         type_here =
    734             newtEntry(2, newtTextboxGetNumLines(text) + 2,
    735                       input, 50,
     721        type_here = newtEntry(2, newtTextboxGetNumLines(text) + 2, input, 50,
    736722#ifdef __cplusplus
    737723                      0, NEWT_FLAG_RETURNEXIT
     
    768754 * @return TRUE if @p button1 was pushed, FALSE otherwise.
    769755 */
    770     bool popup_with_buttons(char *p, char *button1, char *button2) {
     756bool popup_with_buttons(char *p, char *button1, char *button2) {
    771757
    772758        /*@ buffers *********************************************************** */
     
    808794        prompt[MAX_NEWT_COMMENT_LEN - 1] = '\0';
    809795        text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0);
    810         b_1 =
    811             newtButton(20 -
    812                        ((button2[0] !=
    813                          '\0') ? strlen(button1) +
    814                         2 : strlen(button1) / 2),
    815                        newtTextboxGetNumLines(text) + 3, button1);
     796        b_1 = newtButton(20 - ((button2[0] != '\0') ? strlen(button1) + 2 : strlen(button1) / 2), newtTextboxGetNumLines(text) + 3, button1);
    816797        if (button2[0] != '\0') {
    817             b_2 =
    818                 newtButton(24, newtTextboxGetNumLines(text) + 3, button2);
     798            b_2 = newtButton(24, newtTextboxGetNumLines(text) + 3, button2);
    819799        } else {
    820800            b_2 = NULL;
    821801        }
    822         //  newtOpenWindow (25, 5, 46, newtTextboxGetNumLines (text) + 7, "Alert");
    823802        newtCenteredWindow(46, newtTextboxGetNumLines(text) + 7, "Alert");
    824803        myForm = newtForm(NULL, NULL, 0);
     
    846825 * on the screen.
    847826 */
    848     void
    849      refresh_log_screen() {
     827void refresh_log_screen() {
    850828
    851829        /*@ int *********************************************************** */
     
    874852 * only allocate some memory.
    875853 */
    876     void
    877      setup_newt_stuff() {
     854void setup_newt_stuff() {
    878855
    879856        /*@ int *********************************************************** */
     
    908885 * @param denom The denomenator of the ratio.
    909886 */
    910     void
    911      update_evalcall_form_ratio(int num, int denom) {
     887void update_evalcall_form_ratio(int num, int denom) {
    912888
    913889        /*@ long ************************************************************ */
     
    1001977 * @param curr The current amount of progress (percentage) in the evalcall form.
    1002978 */
    1003     void
    1004      update_evalcall_form(int curr) {
     979void update_evalcall_form(int curr) {
     980
    1005981        update_evalcall_form_ratio(curr, 100);
    1006     }
     982}
    1007983
    1008984
     
    1013989 * @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.
    1014990 */
    1015     void
    1016      update_progress_form(char *blurb3) {
     991void update_progress_form(char *blurb3) {
     992
    1017993        if (g_current_progress == -999) {
    1018994            return;
    1019995        }
    1020996        strcpy(g_blurb_str_2, blurb3);
    1021         update_progress_form_full(g_blurb_str_1, g_blurb_str_2,
    1022                                   g_blurb_str_3);
    1023     }
     997        update_progress_form_full(g_blurb_str_1, g_blurb_str_2, g_blurb_str_3);
     998}
    1024999
    10251000
     
    10301005 * @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.
    10311006 */
    1032     void
    1033      update_progress_form_full(char *blurb1, char *blurb2, char *blurb3) {
     1007void update_progress_form_full(char *blurb1, char *blurb2, char *blurb3) {
     1008
    10341009        /*@ long ***************************************************** */
    10351010        long current_time = 0L;
     
    11361111 * @return The backup type chosen, or @c none if the user chose "Exit to shell".
    11371112 */
    1138     t_bkptype which_backup_media_type(bool restoring) {
     1113t_bkptype which_backup_media_type(bool restoring) {
    11391114
    11401115        /*@ char ************************************************************ */
     
    11451120        char *title_sz = NULL;
    11461121        char *minimsg_sz = NULL;
    1147         static t_bkptype possible_bkptypes[] =
    1148             { none, cdr, cdrw, dvd, tape, cdstream, udev, nfs, iso };
    1149         static char *possible_responses[] =
    1150             { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev",
    1151 "nfs", "iso", NULL };
     1122        static t_bkptype possible_bkptypes[] = { none, cdr, cdrw, dvd, tape, cdstream, udev, nfs, iso };
     1123        static char *possible_responses[] = { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev", "nfs", "iso", NULL };
    11521124        char *outstr = NULL;
    11531125        t_bkptype backup_type;
     
    12401212 * @return The compression level (0-9) chosen, or -1 for "Exit".
    12411213 */
    1242     int
    1243      which_compression_level() {
     1214int which_compression_level() {
    12441215
    12451216        /*@ char ************************************************************ */
     
    12581229
    12591230        newtDrawRootText(18, 0, WELCOME_STRING);
    1260         newtPushHelpLine
    1261             ("   Please specify the level of compression that you want.");
    1262         //  newtOpenWindow (23, 3, 34, 13, "How much compression?");
     1231        newtPushHelpLine("   Please specify the level of compression that you want.");
    12631232        newtCenteredWindow(34, 13, "How much compression?");
    12641233        b1 = newtButton(4, 1, "Maximum");
     
    12971266 * @param source_file The file containing a list of filenames to load into @p filelist.
    12981267 */
    1299     int load_filelist_into_array(struct s_filelist *filelist,
    1300                                  char *source_file) {
     1268int load_filelist_into_array(struct s_filelist *filelist, char *source_file) {
     1269
    13011270        int i;
    13021271        int j = 0;
     
    13261295
    13271296        log_msg(2, "Loading %s", source_file);
    1328         for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM; filelist->entries++) {
    1329           god_i_hate_gotos:
     1297        for (filelist->entries = 0; filelist->entries <= ARBITRARY_MAXIMUM; ) {
    13301298            if (tmp != NULL) {
    13311299                mr_free(tmp);
     
    13371305            i = (int) strlen(tmp);
    13381306            if (i < 2) {
    1339                 goto god_i_hate_gotos;
     1307                continue;
    13401308            }
    13411309            if (tmp[i - 1] < 32) {
     
    13431311            }
    13441312            if (i < 2) {
    1345                 goto god_i_hate_gotos;
     1313                continue;
    13461314            }
    13471315            if (!does_file_exist(tmp) && !feof(fin)) {
    13481316                j++;
    13491317                fprintf(fout, "%s\n", tmp);
    1350 
    1351                 goto god_i_hate_gotos;
     1318                continue;
    13521319            }
    13531320            filelist->el[filelist->entries].severity = severity_of_difference(tmp, NULL);
     
    13561323                break;
    13571324            }
     1325            filelist->entries++;
    13581326        }
    13591327        mr_free(tmp);
     
    13981366
    13991367
    1400 
    14011368/**
    14021369 * Generate a pretty string based on @p flentry.
     
    14051372 * @note The returned value points to static storage that will be overwritten with each call.
    14061373 */
    1407     char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
    1408         static char comment[100];
     1374char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
    14091375        char *tmp = NULL;
    14101376
    1411         log_it("entering");
     1377        log_msg(8, "entering");
    14121378        assert(flentry != NULL);
    14131379        if (flentry->severity == 0) {
     
    14201386            mr_asprintf(tmp, "high");
    14211387        }
    1422         mr_strcat(tmp, "  ");
    1423         mr_strcat(tmp, flentry->filename);
    1424         strncpy(comment, tmp, 99);
    1425         paranoid_free(tmp);
    1426 
    1427         log_it("leaving");
    1428         return (comment);
    1429     }
    1430 
    1431 
    1432 
     1388        mr_strcat(tmp, "  %s", flentry->filename);
     1389
     1390        log_msg(8, "leaving");
     1391        return (tmp);
     1392    }
    14331393
    14341394
     
    14381398 * @param source_file The file containing a list of changed files.
    14391399 */
    1440     void popup_changelist_from_file(char *source_file) {
     1400void popup_changelist_from_file(char *source_file) {
     1401
    14411402        char *reason;
    14421403        newtComponent myForm;
     
    14891450            return;
    14901451        }
    1491         log_msg(2, "%d files loaded into filelist array",
    1492                 filelist->entries);
     1452        log_msg(2, "%d files loaded into filelist array", filelist->entries);
    14931453        for (i = 0; i < filelist->entries; i++) {
    14941454            keylist[i] = (void *) i;
    1495             newtListboxAppendEntry(fileListbox,
    1496                                    filelist_entry_to_string(&
    1497                                                             (filelist->
    1498                                                              el[i])),
    1499                                    keylist[i]);
     1455            tmp = filelist_entry_to_string(&(filelist->el[i])), keylist[i];
     1456            newtListboxAppendEntry(fileListbox, tmp);
     1457            mr_free(tmp);
    15001458        }
    15011459        mr_asprintf(differ_sz, "  %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", i);
     
    15111469        newtOpenWindow(5, 4, 70, 16, "Non-matching files");
    15121470        myForm = newtForm(NULL, NULL, 0);
    1513         newtFormAddComponents(myForm, headerMsg, fileListbox, bClose,
    1514                               bSelect, NULL);
     1471        newtFormAddComponents(myForm, headerMsg, fileListbox, bClose, bSelect, NULL);
    15151472
    15161473        malloc_string(reason);
     
    15541511
    15551512
    1556 void wait_until_software_raids_are_prepped(char *mdstat_file,
    1557                                            int wait_for_percentage);
     1513void wait_until_software_raids_are_prepped(char *mdstat_file, int wait_for_percentage);
Note: See TracChangeset for help on using the changeset viewer.