Ignore:
Timestamp:
Feb 11, 2007, 12:02:57 PM (12 years ago)
Author:
bruno
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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.