Changeset 2315 in MondoRescue
- Timestamp:
- Aug 18, 2009, 2:29:18 PM (16 years ago)
- Location:
- branches/2.2.10/mondo/src/common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-fork.c
r2296 r2315 101 101 102 102 /*@ buffers *** */ 103 char *midway_call, *ultimate_call, *tmp, *incoming, *old_stderr; 103 char *midway_call = NULL; 104 char *ultimate_call = NULL; 105 char *tmp = NULL; 106 char *incoming, *old_stderr; 104 107 105 108 char *cd_number_str = NULL; … … 113 116 log_msg(3, "Starting"); 114 117 assert(bkpinfo != NULL); 115 // BERLIOS: doesn't work even if the string is correct !116 //assert_string_is_neither_NULL_nor_zerolength(basic_call);117 118 assert_string_is_neither_NULL_nor_zerolength(isofile); 118 119 assert_string_is_neither_NULL_nor_zerolength(logstub); 119 if (!(midway_call = malloc(1200))) {120 fatal_error("Cannot malloc midway_call");121 }122 if (!(ultimate_call = malloc(1200))) {123 fatal_error("Cannot malloc ultimate_call");124 }125 if (!(tmp = malloc(1200))) {126 fatal_error("Cannot malloc tmp");127 }128 120 malloc_string(incoming); 129 121 malloc_string(old_stderr); … … 139 131 140 132 mr_asprintf(&cd_number_str, "%d", cd_no); 141 resolve_naff_tokens(midway_call, tmp1, isofile, "_ISO_"); 142 resolve_naff_tokens(tmp, midway_call, cd_number_str, "_CD#_"); 133 log_msg(4, "basic call = '%s'", tmp1); 134 midway_call = resolve_naff_tokens(tmp1, isofile, "_ISO_"); 135 mr_free(tmp1); 136 137 log_msg(4, "midway_call = '%s'", midway_call); 138 tmp = resolve_naff_tokens(midway_call, cd_number_str, "_CD#_"); 143 139 mr_free(cd_number_str); 144 145 resolve_naff_tokens(ultimate_call, tmp, MONDO_LOGFILE, "_ERR_"); 146 log_msg(4, "basic call = '%s'", tmp1); 147 log_msg(4, "midway_call = '%s'", midway_call); 140 mr_free(midway_call); 141 148 142 log_msg(4, "tmp = '%s'", tmp); 143 ultimate_call = resolve_naff_tokens(tmp, MONDO_LOGFILE, "_ERR_"); 144 mr_free(tmp); 145 149 146 log_msg(4, "ultimate call = '%s'", ultimate_call); 150 147 mr_asprintf(&command, "%s >> %s", ultimate_call, MONDO_LOGFILE); 148 mr_free(ultimate_call); 151 149 152 150 log_to_screen … … 181 179 } 182 180 if (retval) { 183 log_msg(2, "Basic call '%s' returned an error.", tmp1);184 popup_and_OK("Press ENTER to continue.");185 181 popup_and_OK("mkisofs and/or cdrecord returned an error. CD was not created"); 186 182 } … … 192 188 } 193 189 mr_free(command); 194 mr_free(tmp1);195 paranoid_free(midway_call);196 paranoid_free(ultimate_call);197 paranoid_free(tmp);198 190 paranoid_free(incoming); 199 191 paranoid_free(old_stderr); -
branches/2.2.10/mondo/src/common/libmondo-string-EXT.h
r1647 r2315 16 16 extern char *number_of_disks_as_string(int noof_disks, char *label); 17 17 extern char *number_to_text(int i); 18 extern void resolve_naff_tokens(char *output, char *ip, char *value, 19 char *token); 18 extern char *resolve_naff_tokens(char *ip, char *value, char *token); 20 19 extern char *slice_fname(long bigfileno, long sliceno, char *path, 21 20 char *s); -
branches/2.2.10/mondo/src/common/libmondo-string.c
r2314 r2315 501 501 /** 502 502 * Replace all occurences of @p token with @p value while copying @p ip to @p output. 503 * @param ip The input string containing zero or more <tt>token</tt>s. 503 * @param ip The input string containing zero or more <tt>token</tt>s. The string will be altered by this function 504 504 * @param output The output string written with the <tt>token</tt>s replaced by @p value. 505 505 * @param token The token to be relaced with @p value. 506 506 * @param value The value to replace @p token. 507 507 */ 508 void resolve_naff_tokens(char *output,char *ip, char *value, char *token)508 char *resolve_naff_tokens(char *ip, char *value, char *token) 509 509 { 510 510 /*@ buffers *** */ 511 char * input;511 char *output = NULL; 512 512 513 513 /*@ pointers * */ 514 char *p; 515 516 input = malloc(2000); 517 // BERLIOS: seems to cause invalid errors 518 //assert_string_is_neither_NULL_nor_zerolength(ip); 514 char *p = NULL; /* points to token to modify */ 515 char *q = NULL; /* points to start of string/new string */ 516 519 517 assert_string_is_neither_NULL_nor_zerolength(token); 520 518 assert(value != NULL); 521 519 522 strcpy(output, ip); /* just in case the token doesn't appear in string at all */ 523 for (strcpy(input, ip); strstr(input, token); strcpy(input, output)) { 524 strcpy(output, input); 525 p = strstr(output, token); 520 q = ip; 521 while ((p = strstr(q, token) != NULL)) { 526 522 *p = '\0'; 527 strcat(output, value); 528 p = strstr(input, token) + strlen(token); 529 strcat(output, p); 530 } 531 paranoid_free(input); 523 if (output) { 524 mr_strcat(output, "%s%s", q, value); 525 } else { 526 mr_asprintf(&output, "%s%s", q, value); 527 } 528 p++; 529 q = p; 530 } 531 if (output) { 532 mr_strcat(output, "%s", q); 533 } else { 534 /* just in case the token doesn't appear in string at all */ 535 mr_asprintf(&output, "%s", q); 536 } 537 return(output); 532 538 } 533 539 … … 1085 1091 /*@ int *********************************************** */ 1086 1092 int percentage; 1093 int j; 1087 1094 1088 1095 /*@ buffers ******************************************* */ -
branches/2.2.10/mondo/src/common/libmondo-string.h
r1647 r2315 14 14 char *number_of_disks_as_string(int noof_disks, char *label); 15 15 char *number_to_text(int i); 16 void resolve_naff_tokens(char *output,char *ip, char *value, char *token);16 char *resolve_naff_tokens(char *ip, char *value, char *token); 17 17 char *slice_fname(long bigfileno, long sliceno, char *path, char *s); 18 18 int special_dot_char(int i);
Note:
See TracChangeset
for help on using the changeset viewer.