Changeset 1074 in MondoRescue for trunk/mondo/src/lib/mr_conf.c
- Timestamp:
- Jan 25, 2007, 4:18:12 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.