On Sun, Mar 04, 2007 at 07:08:13AM +0200, Sami Liedes wrote: > I found it useful to allow preloading other libraries when using zzuf. > Here's a patch for that:
Argh, shouldn't do this when tired. Here's a patch that should work. Sami ------------------------------------------------------------ diff -ur zzuf-0.8.1/src/zzuf.c zzuf-0.8.1.sli/src/zzuf.c --- zzuf-0.8.1/src/zzuf.c 2007-03-02 01:51:54.000000000 +0200 +++ zzuf-0.8.1.sli/src/zzuf.c 2007-03-04 09:50:13.000000000 +0200 @@ -837,7 +837,7 @@ char buf[64]; #if defined HAVE_FORK static int const files[] = { DEBUG_FILENO, STDERR_FILENO, STDOUT_FILENO }; - char *libpath, *tmp; + char *libpath, *tmp, *old_preload, *new_preload; int pid, j, len = strlen(opts->oldargv[0]); # if defined __APPLE__ # define FILENAME "libzzuf.dylib" @@ -910,10 +910,31 @@ strcpy(tmp ? tmp + 1 : libpath, ".libs/" FILENAME EXTRAINFO); if(ret == 0) - setenv(PRELOAD, libpath, 1); + { + old_preload = getenv(PRELOAD); + if (!old_preload) + old_preload = ""; + new_preload = malloc(strlen(old_preload)+strlen(libpath)+2); + strcpy(new_preload, old_preload); + strcat(new_preload, ":"); + strcat(new_preload, libpath); + setenv(PRELOAD, new_preload, 1); + } else - setenv(PRELOAD, LIBDIR "/" FILENAME EXTRAINFO, 1); + { + old_preload = getenv(PRELOAD); + if (!old_preload) + old_preload = ""; + new_preload = + malloc(strlen(old_preload)+ + strlen(LIBDIR "/" FILENAME EXTRAINFO)+2); + strcpy(new_preload, old_preload); + strcat(new_preload, ":"); + strcat(new_preload, LIBDIR "/" FILENAME EXTRAINFO); + setenv(PRELOAD, new_preload, 1); + } free(libpath); + free(new_preload); if(execvp(opts->newargv[0], opts->newargv)) {
signature.asc
Description: Digital signature