Changeset 1133 in MondoRescue for branches/stable/mondo
- Timestamp:
- Feb 11, 2007, 12:02:57 PM (18 years ago)
- Location:
- branches/stable/mondo/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/include/mr_file.h
r1100 r1133 17 17 /* functions (public methods) */ 18 18 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 24 extern FILE *mr_fopen_int(const char *path, const char *mode,int line, char *file); 25 extern FILE *mr_fprintf_int(FILE *stream,int line, char *file, const char *fmt, ...); 26 extern void mr_fclose_int(FILE *fd, int line, char *file); 27 extern void mr_mkdir_int(const char *pathname, mode_t mode, int line, char *file); 23 28 24 29 #endif /* MR_FILE_H */ -
branches/stable/mondo/src/include/mr_mem.h
r1104 r1133 18 18 19 19 #define mr_free(x) mr_free_int((void **)&x,__LINE__,__FILE__) 20 #define mr_allocstr(x,y) mr_allocstr_int(x, 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, 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__) 23 23 #define mr_malloc(x) mr_malloc_int((size_t)x,__LINE__,__FILE__) 24 24 -
branches/stable/mondo/src/lib/mr_conf.c
r1064 r1133 364 364 365 365 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); 368 368 break; 369 369 370 370 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); 373 373 break; 374 374 … … 390 390 391 391 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 19 19 /*open and read file: each call must be coupled with mr_conf_close 20 20 function: return 0 if success*/ 21 FILE *mr_fopen (const char *path, const char *mode) {21 FILE *mr_fopen_int(const char *path, const char *mode,int line, char *file) { 22 22 FILE *fd = NULL; 23 23 24 24 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); 26 26 mr_exit(-1,"Exiting"); 27 27 } … … 29 29 } 30 30 31 void mr_fprintf (FILE *fd, const char *fmt, ...) {31 void mr_fprintf_int(FILE *fd, int line, char *file, const char *fmt, ...) { 32 32 33 33 va_list args; 34 34 35 35 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"); 37 38 } 38 39 va_start(args,fmt); 39 40 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"); 41 43 } 42 44 va_end(args); 43 45 } 44 46 45 void mr_fclose (FILE *fd) {47 void mr_fclose_int(FILE **fd, int line, char *file) { 46 48 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"); 49 52 } 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"); 52 56 } 53 fd = NULL; 57 if (fclose(*fd) < 0) { 58 mr_msg(1,line,file,"Unable to close File Descriptor"); 59 } 60 *fd = NULL; 54 61 } 55 62 56 void mr_mkdir (const char *pathname, mode_t mode) {63 void mr_mkdir_int(const char *pathname, mode_t mode, int line, char *file) { 57 64 58 65 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); 60 67 mr_exit(-1,"Exiting"); 61 68 } -
branches/stable/mondo/src/lib/mr_mem.c
r1104 r1133 35 35 *allocated = NULL; 36 36 } 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..."); 38 38 mr_exit(-1,"Attempt to reference NULL pointer"); 39 39 } … … 47 47 ret = malloc(size); 48 48 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..."); 50 50 mr_exit(-1,"Unable to alloc memory in mr_malloc"); 51 51 } … … 60 60 ret = getline(lineptr,n,stream); 61 61 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..."); 63 63 mr_exit(-1,"Unable to alloc memory in mr_getline"); 64 64 } … … 74 74 res = vasprintf(strp, fmt, args); 75 75 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..."); 77 77 mr_exit(-1,"Unable to alloc memory in mr_asprintf"); 78 78 } -
branches/stable/mondo/src/lib/mr_msg.c
r1132 r1133 53 53 * but through other functions 54 54 * 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 55 57 */ 56 58 void mr_msg_int(int debug, int line, const char *file, const char *fmt, ...) { … … 78 80 } 79 81 va_start(args,fmt); 80 if (vfprintf(fout, fmt, args ) < 0) {82 if (vfprintf(fout, fmt, args, "\n") < 0) { 81 83 fprintf(stderr,"Unable to print to %s\n",mr_logfile); 82 84 }
Note:
See TracChangeset
for help on using the changeset viewer.