Changeset 1168 in MondoRescue
- Timestamp:
- Feb 15, 2007, 12:27:39 AM (18 years ago)
- Location:
- branches/stable
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-archive.c
r1164 r1168 1245 1245 if=/dev/urandom bs=16 count=1 2> /dev/null | \ 1246 1246 hexdump | tr -s ' ' '0' | head -n1")); 1247 strip_spaces(g_serial_string);1247 mr_strip_spaces(g_serial_string); 1248 1248 strcat(g_serial_string, "...word."); 1249 1249 mr_msg(2, "g_serial_string = '%s'", g_serial_string); -
branches/stable/mondo/src/common/libmondo-devices.c
r1166 r1168 19 19 #include "mr_mem.h" 20 20 #include "mr_msg.h" 21 #include "mr_str.h" 21 22 22 23 #include <sys/ioctl.h> … … 1108 1109 1109 1110 FILE *pin = NULL; 1110 bool retval ;1111 bool retval = FALSE; 1111 1112 size_t n = 0; 1112 1113 assert_string_is_neither_NULL_nor_zerolength(format); … … 1127 1128 if (!pin) { 1128 1129 log_OS_error("Unable to read good formats"); 1129 retval = FALSE;1130 1130 } else { 1131 1131 mr_getline(&good_formats, &n , pin); … … 1133 1133 log_OS_error("Cannot pclose good formats"); 1134 1134 } 1135 strip_spaces(good_formats);1135 mr_strip_spaces(good_formats); 1136 1136 // " ntfs 7 " -- um, cheating much? :) 1137 1137 mr_asprintf(&tmp, " %s swap lvm raid ntfs 7 ",good_formats); … … 1141 1141 if (strstr(good_formats, format_sz)) { 1142 1142 retval = TRUE; 1143 } else {1144 retval = FALSE;1145 1143 } 1146 1144 mr_free(good_formats); … … 1704 1702 // check whether already mounted - we better remove 1705 1703 // surrounding spaces and trailing '/' for this 1706 /* BERLIOS: Useless 1707 strip_spaces(bkpinfo->nfs_mount); 1708 */ 1704 mr_strip_spaces(bkpinfo->nfs_mount); 1709 1705 if (bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] == '/') 1710 1706 bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] = '\0'; … … 1768 1764 mr_free(tmp); 1769 1765 // check whether writable - we better remove surrounding spaces for this 1770 strip_spaces(bkpinfo->nfs_remote_dir);1766 mr_strip_spaces(bkpinfo->nfs_remote_dir); 1771 1767 mr_asprintf(&command, "echo hi > '%s/%s/.dummy.txt'", bkpinfo->isodir, 1772 1768 bkpinfo->nfs_remote_dir); … … 1786 1782 mr_free(tmp); 1787 1783 // check whether writable - we better remove surrounding space s for this 1788 strip_spaces(bkpinfo->nfs_remote_dir);1784 mr_strip_spaces(bkpinfo->nfs_remote_dir); 1789 1785 1790 1786 mr_free(command); … … 2293 2289 for (mr_getline(¤t_drive, &n, pdrives); !feof(pdrives); 2294 2290 mr_getline(¤t_drive, &n, pdrives)) { 2295 strip_spaces(current_drive);2291 mr_strip_spaces(current_drive); 2296 2292 log_it("looking at drive %s's MBR", current_drive); 2297 2293 if (does_string_exist_in_boot_block(current_drive, "GRUB")) { -
branches/stable/mondo/src/common/libmondo-fork.c
r1151 r1168 5 5 #include "mr_mem.h" 6 6 #include "mr_msg.h" 7 #include "mr_str.h" 8 7 9 #include "mondostructures.h" 8 10 #include "libmondo-fork.h" … … 55 57 log_OS_error("Unable to popen call"); 56 58 } 57 strip_spaces(result);59 mr_strip_spaces(result); 58 60 mr_free(tmp); 59 61 return (result); … … 246 248 } 247 249 /* end of patch */ 248 strip_spaces(incoming);250 mr_strip_spaces(incoming); 249 251 if ((res == 0 && log_if_success) 250 252 || (res != 0 && log_if_failure)) { -
branches/stable/mondo/src/common/libmondo-raid.c
r1123 r1168 442 442 for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin); 443 443 fgets(incoming, MAX_STR_LEN - 1, fin)) { 444 strip_spaces(incoming);444 mr_strip_spaces(incoming); 445 445 p = strchr(incoming, ' '); 446 446 if (strlen(incoming) < 3 || incoming[0] == '#' || !p) { -
branches/stable/mondo/src/common/libmondo-string-EXT.h
r831 r1168 27 27 extern int strcmp_inc_numbers(char *stringA, char *stringB); 28 28 extern char *strip_afio_output_line(char *input); 29 extern void strip_spaces(char *in_out);30 29 extern char *trim_empty_quotes(char *incoming); 31 30 extern char *truncate_to_drive_name(char *partition); -
branches/stable/mondo/src/common/libmondo-string.c
r1148 r1168 9 9 #include "my-stuff.h" 10 10 #include "mr_mem.h" 11 #include "mr_str.h" 12 11 13 #include "mondostructures.h" 12 14 #include "libmondo-string.h" … … 98 100 for (p = in_out; *p == ' '; p++); 99 101 strcpy(scratch, p); 100 strip_spaces (scratch);102 mr_strip_spaces (scratch); 101 103 len = (int) strlen(scratch); 102 104 mid = width / 2; … … 737 739 738 740 739 740 /**741 * Remove all characters whose ASCII value is less than or equal to 32742 * (spaces and control characters) from both sides of @p in_out.743 * @param in_out The string to strip spaces/control characters from (modified).744 */745 void strip_spaces(char *in_out)746 {747 /*@ buffers ***************************************************** */748 char *tmp = NULL;749 750 /*@ pointers **************************************************** */751 char *p;752 753 /*@ int ******************************************************** */754 int i;755 int j;756 int original_incoming_length;757 758 /*@ end vars *************************************************** */759 760 assert(in_out != NULL);761 original_incoming_length = (int)strlen(in_out);762 763 for (i = 0; (in_out[i] <= ' ' || in_out[i] == '\t' || in_out[i] == '\r')764 && i < original_incoming_length ; i++);765 for (j = 0; in_out[i] > ' ' && in_out[i] != '\t' && in_out[i] != '\r'766 && i < original_incoming_length ; i++, j++) {767 in_out[j] = in_out[i];768 }769 in_out[j] = '\0';770 771 /* BERLIOS: Old code772 malloc_string(tmp);773 strcpy(tmp, in_out + i);774 for (i = (int) strlen(tmp); i > 0 && tmp[i - 1] <= 32; i--);775 tmp[i] = '\0';776 for (i = 0; i < original_incoming_length && MAX_STR_LEN; i++) {777 in_out[i] = ' ';778 }779 in_out[i] = '\0';780 i = 0;781 p = tmp;782 while (*p != '\0') {783 in_out[i] = *p;784 p++;785 in_out[i + 1] = '\0';786 if (in_out[i] < 32 && i > 0) {787 if (in_out[i] == 8) {788 i--;789 } else if (in_out[i] == 9) {790 in_out[i++] = ' ';791 } else if (in_out[i] == '\r') // added 1st October 2003 -- FIXME792 {793 strcpy(tmp, in_out + i);794 strcpy(in_out, tmp);795 i = -1;796 continue;797 } else if (in_out[i] == '\t') {798 for (i++; i % 5; i++);799 } else if (in_out[i] >= 10 && in_out[i] <= 13) {800 break;801 } else {802 i--;803 }804 } else {805 i++;806 }807 }808 in_out[i] = '\0';809 mr_free(tmp);810 */811 }812 813 814 741 /** 815 742 * If there are double quotes "" around @p incoming then remove them. -
branches/stable/mondo/src/common/libmondo-string.h
r831 r1168 22 22 int strcmp_inc_numbers(char *stringA, char *stringB); 23 23 char *strip_afio_output_line(char *input); 24 void strip_spaces(char *in_out);25 24 char *trim_empty_quotes(char *incoming); 26 25 char *truncate_to_drive_name(char *partition); -
branches/stable/mondo/src/common/newt-specific.c
r1123 r1168 21 21 #include "mr_mem.h" 22 22 #include "mr_msg.h" 23 #include "mr_str.h" 24 23 25 #include "mondostructures.h" 24 26 #include "newt-specific.h" … … 466 468 (void) fgets(err_log_lines[i], MAX_NEWT_COMMENT_LEN, 467 469 fin); 468 strip_spaces(err_log_lines[i]);470 mr_strip_spaces(err_log_lines[i]); 469 471 if (!strncmp(err_log_lines[i], "root:", 5)) { 470 472 strcpy(tmp, err_log_lines[i] + 6); … … 1259 1261 printf(")\n--> "); 1260 1262 (void) fgets(outstr, MAX_NEWT_COMMENT_LEN, stdin); 1261 strip_spaces(outstr);1263 mr_strip_spaces(outstr); 1262 1264 for (i = 0; possible_responses[i]; i++) { 1263 1265 if (!strcmp(possible_responses[i], outstr)) { -
branches/stable/mondo/src/include/mr_str.h
r1087 r1168 14 14 extern inline char *mr_stresc(char *instr, char *toesc, const char escchr); 15 15 extern inline char *mr_date(void); 16 extern inline void mr_strip_spaces(char *in_out); 16 17 17 18 #endif /* MR_STR_H */ -
branches/stable/mondo/src/lib/mr_str.c
r1087 r1168 116 116 } 117 117 118 119 /** 120 * Remove all characters whose ASCII value is less than or equal to 32 121 * (spaces and control characters) from both sides of @p in_out. 122 * @param in_out The string to strip spaces/control characters from (modified). 123 */ 124 void mr_strip_spaces(char *in_out) 125 { 126 /*@ int ******************************************************** */ 127 int i; 128 int j; 129 size_t length; 130 131 /*@ end vars *************************************************** */ 132 133 if (in_out == NULL) { 134 return; 135 } 136 length = strlen(in_out); 137 138 /* Skip initial spaces and special chars */ 139 for (i = 0; in_out[i] <= ' ' && i < (int)length ; i++); 140 /* Shift the string to the begining */ 141 for (j = 0; i < (int)length ; i++, j++) { 142 in_out[j] = in_out[i]; 143 } 144 /* Skip final spaces and special chars */ 145 for (i = (int)strlen(in_out) - 1; in_out[i] <= ' ' && i >= 0 ; i--); 146 147 /* The string now ends after that char */ 148 i++; 149 in_out[i] = '\0'; 150 } -
branches/stable/mondo/src/mondorestore/mondo-restore.c
r1166 r1168 14 14 #include <pthread.h> 15 15 #include "my-stuff.h" 16 #include "../common/mondostructures.h" 17 #include "../common/libmondo.h" 16 #include "mr_mem.h" 17 #include "mr_msg.h" 18 #include "mr_str.h" 19 20 #include "mondostructures.h" 21 #include "libmondo.h" 18 22 #include "mr-externs.h" 19 23 #include "mondo-restore.h" 20 24 #include "mondo-rstr-compare-EXT.h" 21 25 #include "mondo-rstr-tools-EXT.h" 22 #include "mr_mem.h"23 #include "mr_msg.h"24 26 25 27 extern void twenty_seconds_til_yikes(void); … … 1239 1241 newtDrawRootText(0, g_noof_rows - 2, tmp); 1240 1242 newtRefresh(); 1241 strip_spaces(tmp);1243 mr_strip_spaces(tmp); 1242 1244 update_progress_form(tmp); 1243 1245 } … … 1491 1493 newtRefresh(); 1492 1494 } 1493 strip_spaces(tmp);1495 mr_strip_spaces(tmp); 1494 1496 update_progress_form(tmp); 1495 1497 if (current_slice_number == 0) { -
branches/stable/mondo/src/mondorestore/mondo-rstr-newt.c
r1125 r1168 5 5 #include "mr_mem.h" 6 6 #include "mr_msg.h" 7 #include "mr_str.h" 7 8 8 9 extern char *g_mondo_cfg_file; // where m*ndo-restore.cfg (the config file) is stored … … 215 216 strcpy(size_str, size_here); 216 217 // log_it ("Originals = %s,%s,%s,%s", device_str, mountpoint_str, format_str, size_str); 217 strip_spaces(device_str);218 strip_spaces(mountpoint_str);219 strip_spaces(format_str);220 strip_spaces(size_str);218 mr_strip_spaces(device_str); 219 mr_strip_spaces(mountpoint_str); 220 mr_strip_spaces(format_str); 221 mr_strip_spaces(size_str); 221 222 // log_it ("Modified = %s,%s,%s,%s", device_str, mountpoint_str, format_str, size_str); 222 223 if (b_res == bOK) { … … 278 279 ("Add variable", "Enter the name of the variable to add", sz_out, 279 280 MAX_STR_LEN)) { 280 strip_spaces(sz_out);281 mr_strip_spaces(sz_out); 281 282 items = raidrec->additional_vars.entries; 282 283 for (i = 0; … … 498 499 return; 499 500 } 500 strip_spaces(tmp);501 mr_strip_spaces(tmp); 501 502 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 502 503 strcpy(sz, tmp); … … 552 553 return; 553 554 } 554 strip_spaces(tmp);555 mr_strip_spaces(tmp); 555 556 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 556 557 strcpy(sz, tmp); … … 1231 1232 b_res = newtRunForm(myForm); 1232 1233 strcpy(device_str, device_here); 1233 strip_spaces(device_str);1234 mr_strip_spaces(device_str); 1234 1235 strcpy(mountpoint_str, mountpoint_here); 1235 strip_spaces(mountpoint_str);1236 mr_strip_spaces(mountpoint_str); 1236 1237 strcpy(format_str, format_here); 1237 strip_spaces(format_str);1238 mr_strip_spaces(format_str); 1238 1239 if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB) 1239 1240 && strstr(device_used_to_be, RAID_DEVICE_STUB) … … 1251 1252 && strcmp(mountlist->el[currline].mountpoint, "image")) { 1252 1253 strcpy(size_str, size_here); 1253 strip_spaces(size_str);1254 mr_strip_spaces(size_str); 1254 1255 } else { 1255 1256 sprintf(size_str, "%ld", … … 1898 1899 raidrec->additional_vars.el[lino].label, sz_out); 1899 1900 if (popup_and_get_string(header, comment, sz_out, MAX_STR_LEN)) { 1900 strip_spaces(sz_out);1901 mr_strip_spaces(sz_out); 1901 1902 strcpy(raidrec->additional_vars.el[lino].value, sz_out); 1902 1903 } … … 2306 2307 "At what path on this device can the ISO files be found?", 2307 2308 isodir_path, MAX_STR_LEN / 4)) { 2308 strip_spaces(isodir_device);2309 strip_spaces(isodir_format);2310 strip_spaces(isodir_path);2309 mr_strip_spaces(isodir_device); 2310 mr_strip_spaces(isodir_format); 2311 mr_strip_spaces(isodir_path); 2311 2312 log_it("%d - BBB - isodir_path = %s", isodir_path); 2312 2313 return (TRUE); -
branches/stable/mondo/src/mondorestore/mondo-rstr-newt.h
r1103 r1168 19 19 20 20 #include "my-stuff.h" 21 #include "../common/mondostructures.h" 22 #include "../common/libmondo.h" 21 #include "mr_str.h" 22 23 #include "mondostructures.h" 24 #include "libmondo.h" 23 25 #ifdef __FreeBSD__ 24 26 #define raid_device_record vinum_volume … … 44 46 extern long get_phys_size_of_drive(char *); 45 47 extern bool is_this_device_mounted(char *); 46 extern void strip_spaces(char *);47 48 extern void initialize_raidrec(struct raid_device_record *); 48 49 extern int make_list_of_drives(struct mountlist_itself *, -
branches/stable/mondo/src/mondorestore/mondo-rstr-tools.c
r1166 r1168 6 6 #include <pthread.h> 7 7 #include "my-stuff.h" 8 #include "../common/mondostructures.h" 9 #include "../common/libmondo.h" 8 #include "mr_mem.h" 9 #include "mr_msg.h" 10 #include "mr_str.h" 11 12 #include "mondostructures.h" 13 #include "libmondo.h" 10 14 #include "mr-externs.h" 11 15 //#include "mondo-restore.h" 12 16 //#include "mondo-rstr-compare-EXT.h" 13 17 #include "mondo-rstr-tools.h" 14 #include "mr_mem.h"15 #include "mr_msg.h"16 18 17 19 extern bool g_sigpipe_caught; … … 110 112 for (fgets(incoming_ptr, MAX_STR_LEN, fin); 111 113 !feof(fin); fgets(incoming_ptr, MAX_STR_LEN, fin)) { 112 strip_spaces(incoming_ptr);114 mr_strip_spaces(incoming_ptr); 113 115 114 116 if (incoming[0] == '\0') { -
branches/stable/mondo/src/mondorestore/mr-externs.h
r684 r1168 71 71 extern int read_header_block_from_stream(long long *, char *, int *); 72 72 extern void save_filelist(struct s_node *, char *); 73 extern void strip_spaces(char *);74 73 extern int strcmp_inc_numbers(char *, char *); 75 74 extern char *slice_fname(long, long, char *, char *); -
branches/stable/monitas/from-mondo.c
r353 r1168 6 6 7 7 #include "structs.h" 8 #include "mr_str.h" 8 9 9 10 … … 13 14 bool does_file_exist (char *); 14 15 int make_hole_for_file (char *); 15 void strip_spaces(char*);16 16 17 17 … … 53 53 pclose (fin); 54 54 } 55 strip_spaces (result);55 mr_strip_spaces (result); 56 56 return (result); 57 57 } … … 124 124 incoming[i]='\0'; 125 125 */ 126 strip_spaces (incoming);126 mr_strip_spaces (incoming); 127 127 log_it (debug, incoming); 128 128 } … … 204 204 } 205 205 206 207 208 209 210 211 212 213 214 /*************************************************************************215 * strip_spaces() -- Hugo Rabson *216 * rewitten Stefan Huebner *217 * *218 * Purpose: remove leading whitespaces and control characters, replace *219 * TABs by SPACES, remove previous char when followed with BS,*220 * skip control chars, terminate string with '\0' when CR or *221 * NL is detected *222 * afterwards remove trailing whitespace *223 * Called by: *224 * Returns: *225 *************************************************************************/226 void227 strip_spaces (char *in_out)228 {229 char *r, *w;230 r = w = in_out; // initialize read and write pointer231 232 while ( *r && *r <= ' ' )233 ++r; // skip leading whitespace and control chars234 235 for ( ; *r ; ++r ) // until end of existing string do:236 {237 if (*r == '\t') // TAB238 { *w++ = ' '; // write SPACE instead239 continue; }240 if (*r == (char) 8) // BACKSPACE241 { if (w > in_out) --w; // remove previous character (if any ;-)242 continue; }243 if (*r == '\n' || *r == '\r') // CR and LF244 break; // terminate copying245 if (*r < ' ') // Control chars246 continue; // are ignored (skipped)247 *w++ = *r; // all other chars are copied248 }249 // all characters are copied250 *w = '\0'; // terminate the copied string251 for (--w; w>in_out && *w == ' '; --w)252 *w = '\0'; // remove trailing whitespaces253 return;254 /** buffers ******************************************************/255 // char tmp[MAX_STR_LEN+1];256 257 /** pointers *****************************************************/258 // char *p;259 260 /** int *********************************************************/261 // int i;262 263 /** end vars ****************************************************/264 /* for (i = 0; in_out[i] <= ' ' && i < strlen (in_out); i++);265 strcpy (tmp, in_out + i);266 for (i = strlen (tmp); i>0 && tmp[i - 1] <= 32; i--);267 tmp[i] = '\0';268 for (i = 0; i < 80; i++)269 {270 in_out[i] = ' ';271 }272 in_out[i] = '\0';273 i = 0;274 p = tmp;275 while (*p != '\0')276 {277 in_out[i] = *(p++);278 in_out[i + 1] = '\0';279 if (in_out[i] < 32 && i > 0)280 {281 if (in_out[i] == 8)282 {283 i--;284 }285 else if (in_out[i] == 9)286 {287 in_out[i++] = ' ';288 }289 else if (in_out[i] == '\t')290 {291 for (i++; i % 5; i++);292 }293 else if (in_out[i] >= 10 && in_out[i] <= 13)294 {295 break;296 }297 else298 {299 i--;300 }301 }302 else303 {304 i++;305 }306 }307 in_out[i] = '\0';308 */309 /* for(i=strlen(in_out); i>0 && in_out[i-1]<=32; i--) {in_out[i-1]='\0';} */310 }311 312 313 314 315 316 317 318 319 320 321
Note:
See TracChangeset
for help on using the changeset viewer.