Changeset 1074 in MondoRescue
- Timestamp:
- Jan 25, 2007, 4:18:12 PM (18 years ago)
- Location:
- trunk/mondo/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/libmondo-archive.c
r1046 r1074 3854 3854 3855 3855 /* mindi conf parameters also needed in mondo */ 3856 mr_asprintf(&command, "mindi - printvar IA64_BOOT_SIZE");3856 mr_asprintf(&command, "mindi --printvar IA64_BOOT_SIZE"); 3857 3857 fin = popen(command, "r"); 3858 3858 mr_getline(¶m, &n, fin); -
trunk/mondo/src/common/libmondo-verify.c
r1043 r1074 238 238 if (bkpinfo->use_lzo) { 239 239 mr_asprintf(&sz_exe, "lzop"); 240 else if (bkpinfo->use_gzip) {240 } else if (bkpinfo->use_gzip) { 241 241 strcpy(sz_exe, "gzip"); 242 242 } else if (bkpinfo->use_gzip) { -
trunk/mondo/src/common/newt-specific.c
r932 r1074 463 463 464 464 va_start(args, fmt); 465 mr_ vasprintf(&output, fmt, args);465 mr_asprintf(&output, fmt, args); 466 466 log_msg(0, output); 467 467 if (strlen(output) > 80) { -
trunk/mondo/src/include/mr_conf.h
r852 r1074 19 19 /*initialization and closing*/ 20 20 extern int mr_conf_open(const char *filename); 21 extern void mr_conf_close( );21 extern void mr_conf_close(void); 22 22 23 23 /*read integer number after string str in the current file*/ -
trunk/mondo/src/include/mr_err.h
r900 r1074 11 11 /* functions (public methods) */ 12 12 13 extern void mr_exit(int errorcode, const char *message);14 extern void mr_log_exit(int errorcode, const char *message);13 extern inline void mr_exit(int errorcode, const char *message); 14 extern inline void mr_log_exit(int errorcode, const char *message); 15 15 16 16 #endif /* MR_ERR_H */ -
trunk/mondo/src/include/mr_mem.h
r900 r1074 9 9 #define MR_MEM_H 10 10 11 #ifndef _GNU_SOURCE 12 #define _GNU_SOURCE 13 #endif 14 #include <stdarg.h> 15 11 16 /* functions (public methods) */ 12 17 13 extern void mr_free(char *allocated); 14 extern void mr_allocstr(char *alloc, const char *orig); 15 extern void mr_asprintf(char **alloc, const char *fmt, ...); 16 extern void mr_vasprintf(char **alloc, const char *fmt, va_list ap); 17 extern void mr_getline(char **lineptr, size_t *n, FILE *stream); 18 extern void *mr_malloc(size_t size); 18 extern inline void mr_free(char *allocated); 19 extern inline void mr_allocstr(char *alloc, const char *orig); 20 extern inline void mr_asprintf(char **alloc, const char *fmt, ...); 21 extern inline void mr_getline(char **lineptr, size_t *n, FILE *stream); 22 extern inline void *mr_malloc(size_t size); 19 23 20 24 #endif /* MR_MEM_H */ -
trunk/mondo/src/include/mr_msg.h
r900 r1074 9 9 #define MR_MSG_H 10 10 11 #ifndef _GNU_SOURCE 12 #define _GNU_SOURCE 13 #endif 14 #include <stdarg.h> 15 11 16 /* functions (public methods) */ 12 17 13 extern void _mr_msg(int debug, const char *file, const char *function, int line, const char *fmt, ...);14 15 #define mr_msg(level, format, args...) _mr_msg(level, __FILE__, __FUNCTION__, __LINE__, format, ## args) 18 extern inline void mr_msg(int debug, const char *fmt, ...); 19 extern void mr_msg_init(const char *configfile, int loglevel); 20 extern void mr_msg_close(void); 16 21 17 22 #endif /* MR_MSG_H */ -
trunk/mondo/src/include/mr_str.h
r900 r1074 11 11 /* functions (public methods) */ 12 12 13 extern char *mr_strtok(char *instr, const char *delims, int *lastpos);14 extern char *mr_stresc(char *instr, char *toesc, const char escchr);13 extern inline char *mr_strtok(char *instr, const char *delims, int *lastpos); 14 extern inline char *mr_stresc(char *instr, char *toesc, const char escchr); 15 15 16 16 #endif /* MR_STR_H */ -
trunk/mondo/src/include/my-stuff.h
r973 r1074 8 8 #define _MY_STUFF_H_ 9 9 10 /* BERLIOS11 #define HAVE_MALLOC 112 */13 14 10 // Extra info for ACLs and SELINUX users 15 11 #define STAR_ACL_SZ "-xfflags -acl" 16 //#define STAR_ACL_SZ "-xfflags" 17 //#define STAR_ACL_SZ "" 18 // Enable the first line and disable the second if you are a Fedora Core 2 user 12 13 /*The number of lines of log output to keep at the bottom of the screen.*/ 14 #define NOOF_ERR_LINES 6 15 16 #define paranoid_free(exp) mr_free(exp) 19 17 20 18 /** … … 53 51 54 52 #include <stdlib.h> 55 /* BERLIOS56 #ifndef __USE_FILE_OFFSET6457 #define __USE_FILE_OFFSET6458 #endif59 #ifndef __USE_LARGEFILE6460 #define __USE_LARGEFILE6461 #endif62 */63 53 #include <sys/stat.h> 64 54 #include <fcntl.h> … … 79 69 #endif 80 70 #include <assert.h> 81 82 /*83 #if defined(DEBUG) && !__cplusplus84 int count;85 char trace_log[255];86 char *trace_log_ptr;87 #endif88 */89 71 90 72 #define STD_PREFIX "mondorescue" … … 210 192 211 193 /** 212 * @c mkisofs command to generate a bootable CD using LILO, except for -o option and the directory to image.213 */214 // -b images/mindi-boot.2880.img215 216 /**217 * @c mkisofs command to generate a bootable CD using ELILO, except for -o option and the directory to image.218 */219 // -b images/mindi-boot.2880.img220 // Should replace 8192 by IA64_BOOT_SIZE221 222 /**223 194 * The stub name of the temporary ISO image to create, burn, and remove. 224 195 */ … … 332 303 #define VANILLA_SCSI_CDROM "/dev/cd0" 333 304 #define VANILLA_SCSI_TAPE "/dev/sa" 305 #define VANILLA_USB_DEVICE "/dev/tobegivenbyfreebsdguru" 334 306 #define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE "/dev/vinum/" 335 307 #define RAID_DEVICE_STUB DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE … … 341 313 #define VANILLA_SCSI_CDROM "/dev/scd0" 342 314 #define VANILLA_SCSI_TAPE "/dev/st" 315 #define VANILLA_USB_DEVICE "/dev/hda" 343 316 #define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE "/dev/md" 344 317 #define RAID_DEVICE_STUB DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE -
trunk/mondo/src/lib/mr_conf.c
r900 r1074 34 34 #define MRCONF_OPEN_OPENED 0xA 35 35 #define MRCONF_CALL_BUT_NOT_OPEN 0xB 36 #define MRCONF_STRING_QUOTE 0xC 36 37 37 38 /*setting flags*/ … … 56 57 #define MRCONF_STR_CLOSE_BUT_NOT_OPEN _("attempt to close mr_conf but it has not been opened yet") 57 58 #define MRCONF_STR_CALL_BUT_NOT_OPEN _("attempt to use mr_conf when it has not been opened yet") 59 #define MRCONF_STR_STRING_QUOTE _("string should be surrounded by quotes") 58 60 59 61 /*Flags of internal state*/ … … 66 68 static size_t mr_conf_filesize(const char *name); 67 69 static void mr_conf_error_msg(int error_code, const char *add_line); 68 static void mr_conf_remove_comments( );70 static void mr_conf_remove_comments(void); 69 71 static int mr_conf_check_int_flag(const int flag); 70 72 static void mr_conf_set_int_flag(const int flag); … … 112 114 113 115 /*allocate memory for the buffers */ 114 buffer = (char *) m alloc(sizeof(char) * (length + 1));116 buffer = (char *) mr_malloc(sizeof(char) * (length + 1)); 115 117 116 118 if (buffer == NULL) { … … 139 141 140 142 /*release all memory and prepare to the next possiable config file*/ 141 void mr_conf_close( ) {143 void mr_conf_close(void) { 142 144 /* if not opened => error */ 143 145 if (!mr_conf_check_int_flag(MRCONF_INTFLAG_OPEN)) { … … 233 235 mr_asprintf(&q, p); 234 236 237 if (*p != '"') { 238 mr_conf_error_msg(MRCONF_STRING_QUOTE, ""); 239 return (NULL); 240 } 241 p++; 242 235 243 /* trunk at first \n */ 236 244 r = index(q,'\n'); 245 r--; 246 if (*r != '"') { 247 mr_conf_error_msg(MRCONF_STRING_QUOTE, ""); 248 return (NULL); 249 } 250 r--; 237 251 238 252 size = r-q+1; 239 253 /*copy filtered data to the buffer */ 240 ret = (char *) m alloc(sizeof(char) * (size));254 ret = (char *) mr_malloc(sizeof(char) * (size)); 241 255 if (ret == NULL) { 242 256 mr_conf_error_msg(MRCONF_ALLOC_FAILED, ""); … … 249 263 } 250 264 251 ret[i] = (char) 0; /* and set its length */265 ret[i] = (char) 0; /* and set its length */ 252 266 mr_free(q); 253 267 … … 278 292 } 279 293 /* k is new buffer length now */ 280 tmp_buf = (char *) m alloc(sizeof(char) * (k + 1));294 tmp_buf = (char *) mr_malloc(sizeof(char) * (k + 1)); 281 295 if (tmp_buf == NULL) { 282 296 mr_conf_error_msg(MRCONF_ALLOC_FAILED, ""); … … 371 385 break; 372 386 387 case MRCONF_STRING_QUOTE: 388 mr_msg(0,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_STRING_QUOTE); 389 break; 390 373 391 default: 374 392 mr_msg(1,"%s %s\n", MRCONF_STR_ERROR, MRCONF_STR_DEFAULT_ERROR); -
trunk/mondo/src/lib/mr_err.c
r900 r1074 9 9 * Provided under the GPLv2 10 10 */ 11 12 #ifndef _GNU_SOURCE 13 #define _GNU_SOURCE 14 #endif 11 15 12 16 #include <stdio.h> … … 36 40 37 41 void mr_log_exit(int errorcode, const char *message) { 38 mr_msg(0, message);42 mr_msg(0, message); 39 43 mr_exit(errorcode, message); 40 44 } -
trunk/mondo/src/lib/mr_mem.c
r929 r1074 10 10 */ 11 11 12 #ifndef _GNU_SOURCE 13 #define _GNU_SOURCE 14 #endif 15 12 16 #include <stdio.h> 13 17 #include <stdlib.h> 14 #include <stdarg.h>15 18 16 19 #include "mr_err.h" … … 52 55 } 53 56 54 55 /* encapsulation function for vasprintf */56 void mr_vasprintf(char **strp, const char *fmt, va_list ap) {57 58 int res = 0;59 60 res = vasprintf(strp, fmt, ap);61 if (res == -1) {62 mr_log_exit(-1,"Unable to alloc memory in mr_vasprintf\nExiting...");63 }64 }65 66 57 /* encapsulation function for asprintf */ 67 58 void mr_asprintf(char **strp, const char *fmt, ...) { … … 70 61 va_list args; 71 62 72 va_start(args, 73 res = asprintf(strp, fmt, args);63 va_start(args,fmt); 64 res = vasprintf(strp, fmt, args); 74 65 if (res == -1) { 75 66 mr_log_exit(-1,"Unable to alloc memory in mr_asprintf\nExiting..."); -
trunk/mondo/src/lib/mr_msg.c
r900 r1074 10 10 */ 11 11 12 #ifndef _GNU_SOURCE 13 #define _GNU_SOURCE 14 #endif 12 15 #include <stdio.h> 13 16 #include <stdarg.h> 17 #include <stdlib.h> 14 18 15 19 static int mr_loglevel = 0; 16 20 static char *mr_logfile = NULL; 17 21 22 /* 23 * This function is in the lowest part of the tree 24 * It should not depend on any other function of the mr lib 25 */ 26 27 /* Cleanup function for messages */ 28 void mr_msg_close(void) { 29 free(mr_logfile); 30 mr_logfile = NULL; 31 mr_loglevel = 0; 32 } 33 18 34 /* Initialization function for messages */ 19 void mr_msg_init(void) { 35 void mr_msg_init(const char *configfile, int loglevel) { 36 FILE *fout = NULL; 37 int res = 0; 20 38 39 asprintf(&mr_logfile,configfile); 40 if ((fout = fopen(mr_logfile, "w")) == NULL) { 41 fprintf(stderr,"Unable to write to %s\n",mr_logfile); 42 fprintf(stderr,"Logging desactivated\n"); 43 mr_msg_close(); 44 } 45 if ((res = fclose(fout)) != 0) { 46 fprintf(stderr,"Unable to close %s\n",mr_logfile); 47 } 48 mr_loglevel = loglevel; 21 49 } 22 50 23 51 /* 24 52 * Function that log a message. Not called directly 25 * but through macros in mr_msg.h53 * but through other functions 26 54 */ 27 void _mr_msg(int debug, const char *file, const char *function, int line, const char *fmt, ...) {55 void mr_msg(int debug, const char *fmt, ...) { 28 56 29 va_list args;30 57 int i = 0; 31 58 int res = 0; 32 59 FILE *fout = NULL; 60 va_list args; 61 62 if (mr_logfile == NULL) { 63 return; 64 } 33 65 34 66 if (debug <= mr_loglevel) { 35 va_start(args, fmt); 36 if (!(fout = fopen(mr_logfile, "a"))) { 67 if ((fout = fopen(mr_logfile, "a")) == NULL) { 37 68 fprintf(stderr,"Unable to append to %s\n",mr_logfile); 38 69 return; … … 43 74 for (i = 1; i < debug; i++) 44 75 fprintf(fout, " "); 45 fprintf(fout, "%s->%s#%d: ", file, function, line);76 fprintf(fout, "%s->%s#%d: ", __FILE__, __FUNCTION__, __LINE__); 46 77 } 47 vfprintf(fout, fmt, args); 78 va_start(args,fmt); 79 if (vfprintf(fout, fmt, args) < 0) { 80 fprintf(stderr,"Unable to print to %s\n",mr_logfile); 81 } 82 va_end(args); 48 83 49 va_end(args);50 fprintf(fout, "\n");51 84 if ((res = fclose(fout)) != 0) { 52 85 fprintf(stderr,"Unable to close %s\n",mr_logfile); -
trunk/mondo/src/lib/mr_str.c
r969 r1074 8 8 #include <stdio.h> 9 9 #include <string.h> 10 11 #include "mr_mem.h" 10 12 11 13 /** … … 35 37 strptr += pos2; 36 38 pos1 = strcspn(strptr, delims); 37 token = malloc(sizeof(*token) * (pos1 + 1));39 token = (char *)mr_malloc(sizeof(*token) * (pos1 + 1)); 38 40 strncpy(token, strptr, pos1); 39 41 token[pos1] = '\0'; … … 80 82 inptr = instr; 81 83 82 retstr = (char *) m alloc(strlen(inptr) + cnt + 1);84 retstr = (char *) mr_malloc(strlen(inptr) + cnt + 1); 83 85 retptr = retstr; 84 86
Note:
See TracChangeset
for help on using the changeset viewer.