Changeset 1133 in MondoRescue


Ignore:
Timestamp:
Feb 11, 2007, 12:02:57 PM (17 years ago)
Author:
Bruno Cornec
Message:

mr_msg used low level with a debug value of 1 (0 doesn't print enough info)
mr_file reviewed to also have low level debug functions

Location:
branches/stable/mondo/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/include/mr_file.h

    r1100 r1133  
    1717/* functions (public methods) */
    1818
    19 extern FILE *mr_fopen(const char *path, const char *mode);
    20 extern FILE *mr_fprintf(FILE *stream, const char *fmt, ...);
    21 extern void mr_fclose(FILE *fd);
    22 extern void mr_mkdir(const char *pathname, mode_t mode);
     19#define mr_fopen(x,y)           mr_fopen_int((const char *)x, (const char *)y,__LINE__,__FILE__)
     20#define mr_fprintf(x,y,args...) mr_fprintf_int(x,__LINE__,__FILE__,y,## args)
     21#define mr_fclose(x)            mr_fclose_int((FILE **)&fd, __LINE__,__FILE__)
     22#define mr_mkdir(x)             mr_mkdir_int((const char *)pathname,(mode_t)mode,__LINE__,__FILE__)
     23
     24extern FILE *mr_fopen_int(const char *path, const char *mode,int line, char *file);
     25extern FILE *mr_fprintf_int(FILE *stream,int line, char *file, const char *fmt, ...);
     26extern void mr_fclose_int(FILE *fd, int line, char *file);
     27extern void mr_mkdir_int(const char *pathname, mode_t mode, int line, char *file);
    2328
    2429#endif                          /* MR_FILE_H */
  • branches/stable/mondo/src/include/mr_mem.h

    r1104 r1133  
    1818
    1919#define mr_free(x) mr_free_int((void **)&x,__LINE__,__FILE__)
    20 #define mr_allocstr(x,y) mr_allocstr_int(x, y,__LINE__,__FILE__)
    21 #define mr_asprintf(x,y,args...) mr_asprintf_int(x,__LINE__,__FILE__, y, ## args)
    22 #define mr_getline(x,y,z) mr_getline_int(x, y,z,__LINE__,__FILE__)
     20#define mr_allocstr(x,y) mr_allocstr_int(x,y,__LINE__,__FILE__)
     21#define mr_asprintf(x,y,args...) mr_asprintf_int(x,__LINE__,__FILE__,y,## args)
     22#define mr_getline(x,y,z) mr_getline_int(x,y,z,__LINE__,__FILE__)
    2323#define mr_malloc(x) mr_malloc_int((size_t)x,__LINE__,__FILE__)
    2424
  • branches/stable/mondo/src/lib/mr_conf.c

    r1064 r1133  
    364364
    365365        case MRCONF_FIELD_NOT_FOUND:
    366             mr_msg(1,"%s %s \"%s\"\n", MRCONF_STR_ERROR, MRCONF_STR_FIELD_NOT_FOUND, add_line);
    367             mr_msg(1,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_SET_TO_ZERO);
     366            mr_msg(0,"%s %s \"%s\"\n", MRCONF_STR_ERROR, MRCONF_STR_FIELD_NOT_FOUND, add_line);
     367            mr_msg(0,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_SET_TO_ZERO);
    368368            break;
    369369
    370370        case MRCONF_FIELD_NO_VALUE:
    371             mr_msg(1,"%s %s \"%s\"\n", MRCONF_STR_ERROR, MRCONF_STR_FIELD_NO_VALUE, add_line);
    372             mr_msg(1,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_IGNORE);
     371            mr_msg(0,"%s %s \"%s\"\n", MRCONF_STR_ERROR, MRCONF_STR_FIELD_NO_VALUE, add_line);
     372            mr_msg(0,"%s %s\n", MRCONF_STR_WARNING, MRCONF_STR_IGNORE);
    373373            break;
    374374
     
    390390
    391391        default:
    392             mr_msg(1,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_DEFAULT_ERROR);
    393             break;
    394         }
    395     }
    396 }
     392            mr_msg(0,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_DEFAULT_ERROR);
     393            break;
     394        }
     395    }
     396}
  • branches/stable/mondo/src/lib/mr_file.c

    r1100 r1133  
    1919/*open and read file: each call must be coupled with mr_conf_close
    2020  function: return 0 if success*/
    21 FILE *mr_fopen(const char *path, const char *mode) {
     21FILE *mr_fopen_int(const char *path, const char *mode,int line, char *file) {
    2222    FILE *fd = NULL;
    2323
    2424    if ((fd = fopen(path, mode)) == NULL) {
    25         mr_msg(0,"Unable to open %s",path);
     25        mr_msg(1,line,file,"Unable to open %s",path);
    2626        mr_exit(-1,"Exiting");
    2727    }
     
    2929}
    3030
    31 void mr_fprintf(FILE *fd, const char *fmt, ...) {
     31void mr_fprintf_int(FILE *fd, int line, char *file, const char *fmt, ...) {
    3232   
    3333    va_list args;
    3434
    3535    if (fd == NULL) {
    36         mr_log_exit(-1,"fd is NULL.\nShould NOT happen.\nExiting");
     36        mr_msg(1,line,file,"fd is NULL.\nShould NOT happen.");
     37        mr_exit(-1,"Exiting");
    3738    }
    3839    va_start(args,fmt);
    3940    if (vfprintf(fd, fmt, args) < 0) {
    40         mr_msg(0,"Unable to print '%s'",args);
     41        mr_msg(1,line,file,"Unable to print to fd");
     42        mr_exit(-1,"Exiting");
    4143    }
    4244    va_end(args);
    4345}
    4446
    45 void mr_fclose(FILE *fd) {
     47void mr_fclose_int(FILE **fd, int line, char *file) {
    4648
    47     if (fd == NULL) {
    48         mr_log_exit(-1,"fd is NULL.\nShould NOT happen.\nExiting");
     49    if (**fd == NULL) {
     50        mr_msg(1,line,file,"fd is NULL.\nShould NOT happen.");
     51        mr_exit(-1,"Exiting");
    4952    }
    50     if (fclose(fd) < 0) {
    51         mr_msg(0,"Unable to close fd");
     53    if (*fd == NULL) {
     54        mr_msg(1,line,file,"File descriptor is NULL.\nShould NOT happen.");
     55        mr_exit(-1,"Exiting");
    5256    }
    53     fd = NULL;
     57    if (fclose(*fd) < 0) {
     58        mr_msg(1,line,file,"Unable to close File Descriptor");
     59    }
     60    *fd = NULL;
    5461}
    5562
    56 void mr_mkdir(const char *pathname, mode_t mode) {
     63void mr_mkdir_int(const char *pathname, mode_t mode, int line, char *file) {
    5764
    5865    if (mkdir(pathname,mode) != 0) {
    59         mr_msg("Unable to create directory %s",pathname);
     66        mr_msg(1,line,file,"Unable to create directory %s",pathname);
    6067        mr_exit(-1,"Exiting");
    6168    }
  • branches/stable/mondo/src/lib/mr_mem.c

    r1104 r1133  
    3535        *allocated = NULL;
    3636    } else {
    37         mr_msg_int(0,line,file,"Attempt to reference NULL pointer\nExiting...");
     37        mr_msg_int(1,line,file,"Attempt to reference NULL pointer\nExiting...");
    3838        mr_exit(-1,"Attempt to reference NULL pointer");
    3939    }
     
    4747    ret = malloc(size);
    4848    if (ret == NULL) {
    49         mr_msg_int(0,line,file,"Unable to alloc memory in mr_malloc\nExiting...");
     49        mr_msg_int(1,line,file,"Unable to alloc memory in mr_malloc\nExiting...");
    5050        mr_exit(-1,"Unable to alloc memory in mr_malloc");
    5151    }
     
    6060    ret = getline(lineptr,n,stream);
    6161    if (ret == -1) {
    62         mr_msg_int(0,line,file,"Unable to alloc memory in mr_getline\nExiting...",line,file);
     62        mr_msg_int(1,line,file,"Unable to alloc memory in mr_getline\nExiting...");
    6363        mr_exit(-1,"Unable to alloc memory in mr_getline");
    6464    }
     
    7474    res = vasprintf(strp, fmt, args);
    7575    if (res == -1) {
    76         mr_msg_int(0,line,file,"Unable to alloc memory in mr_asprintf\nExiting...",line,file);
     76        mr_msg_int(1,line,file,"Unable to alloc memory in mr_asprintf\nExiting...");
    7777        mr_exit(-1,"Unable to alloc memory in mr_asprintf");
    7878    }
  • branches/stable/mondo/src/lib/mr_msg.c

    r1132 r1133  
    5353 * but through other functions
    5454 * fmt needs to be just before ...
     55 * debug should be >0 to have file and line printed (real debug)
     56 * If =0 it's an informative log message
    5557 */
    5658void mr_msg_int(int debug, int line, const char *file, const char *fmt, ...) {
     
    7880        }
    7981        va_start(args,fmt);
    80         if (vfprintf(fout, fmt, args) < 0) {
     82        if (vfprintf(fout, fmt, args, "\n") < 0) {
    8183            fprintf(stderr,"Unable to print to %s\n",mr_logfile);
    8284        }
Note: See TracChangeset for help on using the changeset viewer.