Changeset 2421 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-fork.c
- Timestamp:
- Sep 24, 2009, 3:50:38 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-fork.c
r2420 r2421 8 8 #include "my-stuff.h" 9 9 #include "mr_mem.h" 10 #include "mr_str.h" 10 11 #include "mondostructures.h" 11 12 #include "libmondo-fork.h" … … 39 40 char *result = NULL; 40 41 char *tmpf = NULL; 42 char *newcall = NULL; 43 char *tmp = NULL; 41 44 42 45 /*@ pointers **************************************************** */ 43 FILE *fin ;46 FILE *fin = NULL; 44 47 45 48 /*@******************************************************************** */ … … 47 50 assert_string_is_neither_NULL_nor_zerolength(call); 48 51 49 mr_asprintf(tmpf, "%s/cpgll.out", bkpinfo-> scratchdir);50 mr_ strcat(call, " > %s", tmpf);51 log_msg(4, "Calling command: %s", call);52 mr_asprintf(tmpf, "%s/cpgll.out", bkpinfo->tmpdir); 53 mr_asprintf(newcall, "%s > %s", call, tmpf); 54 log_msg(4, "Calling command: %s", newcall); 52 55 /* By default return an empty string in any case */ 53 56 mr_asprintf(result, ""); 54 57 55 system(call); 56 if ((fin = fopen(ftmp, "r"))) { 58 system(newcall); 59 mr_free(newcall); 60 61 if ((fin = fopen(tmpf, "r"))) { 57 62 while (!feof(fin)) { 58 mr_getline(result, fin); 59 log_msg(9, "Loop result: %s", result); 60 } 61 log_msg(4, "Final Result: %s", result); 63 mr_getline(tmp, fin); 64 mr_chomp(tmp); 65 /* In case of extreme debug ;-) 66 log_msg(9, "Loop result: ***%s***", tmp); 67 */ 68 /* There is empty contant at the end of the file that needs to be skiped */ 69 if (strlen(tmp) > 0) { 70 mr_free(result); 71 mr_asprintf(result, "%s", tmp); 72 } 73 mr_free(tmp); 74 } 75 log_msg(4, "Result: %s", result); 62 76 mr_strip_spaces(result); 63 77 paranoid_pclose(fin); 64 78 } else { 65 log_OS_error("Unable to popen call"); 66 } 67 mr_free(ftmp) 68 log_msg(4, "Returns: %s", result); 79 log_OS_error("Unable to open resulting file"); 80 } 81 mr_free(tmpf); 69 82 return(result); 70 83 }
Note:
See TracChangeset
for help on using the changeset viewer.