Ignore:
Timestamp:
May 13, 2006, 8:47:23 PM (18 years ago)
Author:
bcornec
Message:

Stable is reverted to r436 (2.0.7) to put it in line with 2.0.8 and start from there over

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/mondo/common/libmondo-tools.c

    r538 r541  
    174174#include "my-stuff.h"
    175175#include "mondostructures.h"
     176#include "lib-common-externs.h"
    176177#include "libmondo-tools.h"
    177 #include "newt-specific-EXT.h"
     178#include "libmondo-gui-EXT.h"
    178179#include "libmondo-files-EXT.h"
    179180#include "libmondo-fork-EXT.h"
     
    270271        newtSuspend();
    271272#endif
    272     printf(_("ASSERTION FAILED: `%s'\n"), exp);
    273     printf(_("\tat %s:%d in %s\n\n"), file, line, function);
    274     printf(_("(I)gnore, ignore (A)ll, (D)ebug, a(B)ort, or (E)xit? "));
     273    printf("ASSERTION FAILED: `%s'\n", exp);
     274    printf("\tat %s:%d in %s\n\n", file, line, function);
     275    printf("(I)gnore, ignore (A)ll, (D)ebug, a(B)ort, or (E)xit? ");
    275276    do {
    276277        is_valid = TRUE;
     
    299300        case '\n':
    300301            printf
    301                 (_("(I)gnore, ignore (A)ll, (D)ebug, a(B)ort, or (E)xit? "));
     302                ("(I)gnore, ignore (A)ll, (D)ebug, a(B)ort, or (E)xit? ");
    302303            break;
    303304        default:
    304305            is_valid = FALSE;
    305             printf(_("Invalid choice.\n"));
     306            printf("Invalid choice.\n");
    306307            break;
    307308        }
     
    472473#endif
    473474}
     475
     476
     477/**
     478 * Log a trace message to the trace file.
     479 * @bug This function seems orphaned. Please remove.
     480 */
     481void log_trace(char *o)
     482{
     483    /*@ pointers **************************************************** */
     484    FILE *fout;
     485
     486    /*@ buffers ***************************************************** */
     487    char output[MAX_STR_LEN];
     488
     489    /*@ int    ****************************************************** */
     490    int i;
     491
     492    /*@ end vars *************************************************** */
     493
     494    if (o[0] == '\0') {
     495        return;
     496    }
     497    strcpy(output, o);
     498    i = (int) strlen(output);
     499    if (i <= 0) {
     500        return;
     501    }
     502    if (output[i - 1] < 32) {
     503        output[i - 1] = '\0';
     504    }
     505    if (g_text_mode
     506        /* && !strstr(last_line_of_file(MONDO_LOGFILE),output) */ ) {
     507        printf("%s\n", output);
     508    }
     509
     510    fout = fopen(MONDO_TRACEFILE, "a");
     511    if (fout) {
     512        fprintf(fout, "%s\n", output);
     513        paranoid_fclose(fout);
     514    } else {
     515        log_OS_error("Cannot write to tracefile");
     516    }
     517}
     518
     519
     520
    474521
    475522
     
    923970        strcpy(bkpinfo->isodir, "/");
    924971    } else {
    925         strcpy(bkpinfo->isodir, "/var/cache/mondo/iso");
     972        strcpy(bkpinfo->isodir, "/root/images/mondo");
    926973    }
    927974    strcpy(bkpinfo->prefix, STD_PREFIX);
     
    10221069    if (atol(tmp) < 35000) {
    10231070        retval++;
    1024         log_to_screen(_("You must have at least 32MB of RAM to use Mondo."));
     1071        log_to_screen("You must have at least 32MB of RAM to use Mondo.");
    10251072    }
    10261073    if (atol(tmp) < 66000) {
    10271074        log_to_screen
    1028             (_("WARNING! You have very little RAM. Please upgrade to 64MB or more."));
    1029     }
    1030 #endif
    1031 
    1032     if ((Lres = free_space_on_given_partition("/var/cache/mondo")) == -1) /* {
     1075            ("WARNING! You have very little RAM. Please upgrade to 64MB or more.");
     1076    }
     1077#endif
     1078
     1079    if ((Lres = free_space_on_given_partition("/root")) == -1) {
    10331080        Lres = free_space_on_given_partition("/");
    10341081    }
    1035     */
    10361082    log_it("Free space on given partition = %ld MB", Lres);
    10371083
    10381084    if (Lres < 50) {
    1039         fatal_error("Your /var/cache/mondo partition has <50MB free. Please adjust your partition table to something saner.");
     1085        run_program_and_log_output
     1086            ("rm -Rf /root/images/mindi; mkdir -p /home/root/images/mindi; mkdir -p /root/images; ln -sf /home/root/images/mindi /root/images/mindi",
     1087             3);
     1088        //      fatal_error("Your / (or /root) partition has <50MB free. Please adjust your partition table to something saner.");
    10401089    }
    10411090
     
    10511100        ("grep ramdisk /proc/devices", FALSE)) {
    10521101        if (!ask_me_yes_or_no
    1053             (_("Your kernel has no ramdisk support. That's mind-numbingly stupid but I'll allow it if you're planning to use a failsafe kernel. Are you?")))
     1102            ("Your kernel has no ramdisk support. That's mind-numbingly stupid but I'll allow it if you're planning to use a failsafe kernel. Are you?"))
    10541103        {
    10551104            //          retval++;
    10561105            log_to_screen
    1057                 (_("It looks as if your kernel lacks ramdisk and initrd support."));
     1106                ("It looks as if your kernel lacks ramdisk and initrd support.");
    10581107            log_to_screen
    1059                 (_("I'll allow you to proceed but FYI, if I'm right, your kernel is broken."));
     1108                ("I'll allow you to proceed but FYI, if I'm right, your kernel is broken.");
    10601109        }
    10611110    }
     
    10791128        !run_program_and_log_output
    10801129        ("mount | grep -w dos | grep -v /dev/fd | grep -v nexdisk", 0)) {
    1081         log_to_screen(_("I think you have a Windows 9x partition."));
     1130        log_to_screen("I think you have a Windows 9x partition.");
    10821131        retval += whine_if_not_found("parted");
    10831132#ifndef __IA64__
     
    10851134        // retval +=
    10861135        if (!find_home_of_exe("ms-sys")) {
    1087             log_to_screen(_("Please install ms-sys just in case."));
     1136            log_to_screen("Please install ms-sys just in case.");
    10881137        }
    10891138#endif
     
    10951144        } else {
    10961145            log_to_screen
    1097                 (_("Your system lacks the 'cmp' binary. I'll create a dummy cmp for you."));
     1146                ("Your system lacks the 'cmp' binary. I'll create a dummy cmp for you.");
    10981147            if (run_program_and_log_output
    10991148                ("cp -f `which true` /usr/bin/cmp", 0)) {
     
    11101159        if (strstr(tmp, "autofs")) {
    11111160            log_to_screen
    1112                 (_("Your CD-ROM is mounted via autofs. I therefore cannot tell"));
     1161                ("Your CD-ROM is mounted via autofs. I therefore cannot tell");
    11131162            log_to_screen
    1114                 (_("if a CD actually is inserted. If a CD is inserted, please"));
    1115             log_to_screen(_("eject it. Thank you."));
     1163                ("if a CD actually is inserted. If a CD is inserted, please");
     1164            log_to_screen("eject it. Thank you.");
    11161165            log_it
    11171166                ("Ignoring autofs CD-ROM 'mount' since we hope nothing's in it.");
     
    11391188            retval++;
    11401189            log_to_screen
    1141                 (_("Please find out what happened to /etc/modules.conf"));
     1190                ("Please find out what happened to /etc/modules.conf");
    11421191        }
    11431192    }
     
    11521201
    11531202    if (run_program_and_log_output("mindi -V", 1)) {
    1154         log_to_screen(_("Could not ascertain mindi's version number."));
     1203        log_to_screen("Could not ascertain mindi's version number.");
    11551204        log_to_screen
    1156             (_("You have not installed Mondo and/or Mindi properly."));
    1157         log_to_screen(_("Please uninstall and reinstall them both."));
     1205            ("You have not installed Mondo and/or Mindi properly.");
     1206        log_to_screen("Please uninstall and reinstall them both.");
    11581207        fatal_error("Please reinstall Mondo and Mindi.");
    11591208    }
     
    11611210        ("mindi --makemountlist /tmp/mountlist.txt.test", 5)) {
    11621211        log_to_screen
    1163             (_("Mindi --makemountlist /tmp/mountlist.txt.test failed for some reason."));
     1212            ("Mindi --makemountlist /tmp/mountlist.txt.test failed for some reason.");
    11641213        log_to_screen
    1165             (_("Please run that command by hand and examine /var/log/mindi.log"));
     1214            ("Please run that command by hand and examine /var/log/mindi.log");
    11661215        log_to_screen
    1167             (_("for more information. Perhaps your /etc/fstab file is insane."));
     1216            ("for more information. Perhaps your /etc/fstab file is insane.");
    11681217        log_to_screen
    1169             (_("Perhaps Mindi's MakeMountlist() subroutine has a bug. We'll see."));
     1218            ("Perhaps Mindi's MakeMountlist() subroutine has a bug. We'll see.");
    11701219        retval++;
    11711220    }
     
    11741223        && !does_file_exist("/etc/raidtab")) {
    11751224        log_to_screen
    1176             (_("You have RAID partitions but no /etc/raidtab - creating one from /proc/mdstat"));
     1225            ("You have RAID partitions but no /etc/raidtab - creating one from /proc/mdstat");
    11771226        create_raidtab_from_mdstat("/etc/raidtab", "/proc/mdstat");
    11781227    }
    11791228
    11801229    if (retval) {
    1181         mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
     1230        mvaddstr_and_log_it(g_currentY++, 74, "Failed.");
    11821231    } else {
    1183         mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
     1232        mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    11841233    }
    11851234    return (retval);
     
    14431492}
    14441493
     1494
     1495/**
     1496 * The standard log_debug_msg() (log_msg() also due to a macro). Writes some describing
     1497 * information to the logfile.
     1498 */
     1499void standard_log_debug_msg(int debug_level, const char *szFile,
     1500                            const char *szFunction, int nLine,
     1501                            const char *fmt, ...)
     1502{
     1503    va_list args;
     1504    int i;
     1505    static int depth = 0;
     1506    char *tmp;
     1507    FILE *fout;
     1508
     1509    if (depth > 5) {
     1510        depth--;
     1511        return;
     1512    }
     1513    depth++;
     1514
     1515    malloc_string(tmp);
     1516
     1517    if (debug_level <= g_loglevel) {
     1518        va_start(args, fmt);
     1519        if (!(fout = fopen(MONDO_LOGFILE, "a"))) {
     1520            return;
     1521        }                       // fatal_error("Failed to openout to logfile - sheesh..."); }
     1522
     1523        // add tabs to distinguish log levels
     1524        if (debug_level > 0) {
     1525            for (i = 1; i < debug_level; i++)
     1526                fprintf(fout, "\t");
     1527            if (getpid() == g_main_pid)
     1528                fprintf(fout, "[Main] %s->%s#%d: ", szFile, szFunction,
     1529                        nLine);
     1530            else if (getpid() == g_buffer_pid && g_buffer_pid > 0)
     1531                fprintf(fout, "[Buff] %s->%s#%d: ", szFile, szFunction,
     1532                        nLine);
     1533            else
     1534                fprintf(fout, "[TH=%d] %s->%s#%d: ", getpid(), szFile,
     1535                        szFunction, nLine);
     1536        }
     1537        vfprintf(fout, fmt, args);
     1538
     1539        // do not slow down the progran if standard debug level
     1540        // must be enabled: if no flush, the log won't be up-to-date if there
     1541        // is a segfault
     1542        //if (g_dwDebugLevel != 1)
     1543
     1544        va_end(args);
     1545        fprintf(fout, "\n");
     1546        paranoid_fclose(fout);
     1547    }
     1548    depth--;
     1549    paranoid_free(tmp);
     1550}
     1551
     1552/**
     1553 * Function pointer to the @c log_debug_msg function to use. Points to standard_log_debug_msg() by default.
     1554 */
     1555void (*log_debug_msg) (int, const char *, const char *, int, const char *,
     1556                       ...) = standard_log_debug_msg;
     1557
     1558
    14451559/**
    14461560 * If @p y, malloc @p x, else free @p x.
     
    14721586        paranoid_free(g_magicdev_command);
    14731587    }
     1588
     1589    /*
     1590       char**list_of_arrays[] = {
     1591       &g_boot_mountpt,
     1592       &g_mondo_home,
     1593       &g_tmpfs_mountpt,
     1594       &g_erase_tmpdir_and_scratchdir,
     1595       &g_serial_string,
     1596       &g_magicdev_command,
     1597       NULL};
     1598
     1599       char**ppcurr;
     1600       int i;
     1601
     1602       for(i=0;list_of_arrays[i];i++)
     1603       {
     1604       log_msg(5, "Allocating %d", i);
     1605       ppcurr = list_of_arrays[i];
     1606       if (mal)
     1607       { *ppcurr = malloc(MAX_STR_LEN); }
     1608       else
     1609       {
     1610       if (*ppcurr)
     1611       {
     1612       free(*ppcurr);
     1613       }
     1614       }
     1615       }
     1616       log_msg(5, "Returning");
     1617     */
    14741618}
    14751619
Note: See TracChangeset for help on using the changeset viewer.