diff options
| author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-08-26 16:03:15 +0200 |
|---|---|---|
| committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-08-26 16:03:15 +0200 |
| commit | 5a4dc02ee0297c6b0f0fa690b8fc5d2d40e2c6d6 (patch) | |
| tree | 2cff321dde93a36a357886fd75e820c8a122dacb | |
| parent | 0b5f2179ae0998ea370cef0328f1cabd2338d249 (diff) | |
| download | abrt-5a4dc02ee0297c6b0f0fa690b8fc5d2d40e2c6d6.tar.gz abrt-5a4dc02ee0297c6b0f0fa690b8fc5d2d40e2c6d6.tar.xz abrt-5a4dc02ee0297c6b0f0fa690b8fc5d2d40e2c6d6.zip | |
spawn.cpp -> spawn.c
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
| -rw-r--r-- | inc/abrtlib.h | 9 | ||||
| -rw-r--r-- | lib/utils/Makefile.am | 2 | ||||
| -rw-r--r-- | lib/utils/spawn.c (renamed from lib/utils/spawn.cpp) | 32 |
3 files changed, 28 insertions, 15 deletions
diff --git a/inc/abrtlib.h b/inc/abrtlib.h index 6d66bb6c..43d93899 100644 --- a/inc/abrtlib.h +++ b/inc/abrtlib.h @@ -106,11 +106,6 @@ int xatoi(const char *numstr); * dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc */ int xatoi_u(const char *numstr); -#ifdef __cplusplus -} -#endif - - enum { EXECFLG_INPUT = 1 << 0, EXECFLG_OUTPUT = 1 << 1, @@ -135,6 +130,10 @@ char *run_in_shell_and_save_output(int flags, const char *cmd, const char *dir, size_t *size_p); +#ifdef __cplusplus +} +#endif + unsigned long long monotonic_ns(void); unsigned long long monotonic_us(void); diff --git a/lib/utils/Makefile.am b/lib/utils/Makefile.am index 92250811..5bacd991 100644 --- a/lib/utils/Makefile.am +++ b/lib/utils/Makefile.am @@ -20,7 +20,7 @@ libABRTUtils_la_SOURCES = \ daemon.c \ skip_whitespace.c \ xatonum.c numtoa.cpp \ - spawn.cpp \ + spawn.c \ stringops.cpp \ dirsize.cpp \ DebugDump.cpp \ diff --git a/lib/utils/spawn.cpp b/lib/utils/spawn.c index dace7d4b..068f4ac7 100644 --- a/lib/utils/spawn.cpp +++ b/lib/utils/spawn.c @@ -5,16 +5,26 @@ */ #include "abrtlib.h" -using namespace std; - -static string concat_str_vector(char **strings) +static char *concat_str_vector(char **strings) { - string result; - while (*strings) { - result += *strings++; - if (*strings) - result += ' '; + if (!strings[0]) + return xzalloc(1); // returns "" + + unsigned len = 0; + char **spp = strings; + while (*spp) + len += strlen(*spp++) + 1; + + char *result = xmalloc(len); + + char *r = result; + spp = strings; + while (*spp) { + r = stpcpy(r, *spp++); + *r++ = ' '; } + *--r = '\0'; + return result; } @@ -79,7 +89,11 @@ pid_t fork_execv_on_steroids(int flags, } /* This should be done BEFORE stderr redirect */ - VERB1 log("Executing: %s", concat_str_vector(argv).c_str()); + VERB1 { + char *r = concat_str_vector(argv); + log("Executing: %s", r); + free(r); + } if (flags & EXECFLG_ERR2OUT) { /* Want parent to see errors in the same stream */ |
