a tiny fix to Python hooks in INN

Ilya Etingof ilya at glas.net
Fri Dec 3 09:12:35 UTC 1999


OK, I'm attaching a fix with putenv() based setenv().

> putenv is the standardized function under POSIX, IIRC.  I'd rather see INN
> modified to use the standard functions than to add replacements for
> functions that have near-exact equivalents.


-- Attached file included as plaintext by Listar --
-- File: inn-1999-11-24_03-01.fix

*** configure.in%	Tue Nov 23 04:31:37 1999
--- configure.in	Thu Dec  2 00:56:52 1999
***************
*** 489,495 ****
      py_libs=`grep '^LIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
      py_libc=`grep '^LIBC=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
      py_libm=`grep '^LIBM=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
!     PYTHON_LIB="-L$py_libdir/config $py_libs $py_libc $py_libm -lpython$py_ver"
      PYTHON_LIB=`echo $PYTHON_LIB | sed -e 's/[ \\t]*/ /g'`
      AC_MSG_RESULT($py_libdir)
  else
--- 489,497 ----
      py_libs=`grep '^LIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
      py_libc=`grep '^LIBC=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
      py_libm=`grep '^LIBM=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
!     py_liblocalmod=`grep '^LOCALMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
!     py_libbasemod=`grep '^BASEMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'`
!     PYTHON_LIB="-L$py_libdir/config $py_libs $py_libc $py_libm -lpython$py_ver $py_liblocalmod $py_libbasemod"
      PYTHON_LIB=`echo $PYTHON_LIB | sed -e 's/[ \\t]*/ /g'`
      AC_MSG_RESULT($py_libdir)
  else
***************
*** 802,808 ****
  
  dnl If we can't find any of the following, we have replacements for them.
  AC_REPLACE_FUNCS(getopt inet_aton inet_ntoa pread pwrite strcasecmp \
!                  strdup strerror strspn)
  
  MISSING_OBJ="$LIBOBJS"
  MISSING_SRC=`echo "$MISSING_OBJ" | sed 's/\.o/.c/g'`
--- 804,810 ----
  
  dnl If we can't find any of the following, we have replacements for them.
  AC_REPLACE_FUNCS(getopt inet_aton inet_ntoa pread pwrite strcasecmp \
!                  strdup strerror strspn setenv)
  
  MISSING_OBJ="$LIBOBJS"
  MISSING_SRC=`echo "$MISSING_OBJ" | sed 's/\.o/.c/g'`
*** lib/setenv.c%	Fri Dec  3 12:00:58 1999
--- lib/setenv.c	Fri Dec  3 11:57:26 1999
***************
*** 0 ****
--- 1,45 ----
+ /*  $Revision$
+ **
+ **  This is a plug-in replacement for setenv() libc function which is
+ **  native to BSD 4.3 so it may not be supported on SysV systems.
+ **
+ **  Written by Ilya Etingof <ilya at glas.net>, 1999.
+ **
+ */
+ 
+ #include <stdlib.h>
+ 
+ /*
+ ** Set environment variable either overriding existing value
+ ** or leaving the old one depending of the overwrite flag.
+ */
+ int setenv(const char *name, const char *value, int overwrite)
+ {
+ 	char	*arg;
+ 	int	result;
+ 
+ 	/* Check variable existance */
+ 	if (!overwrite && getenv(name) != NULL)
+ 	{
+ 		/* Won't override */
+ 		return 0;
+ 	}
+ 
+ 	/* Allocate memory for argument buffer */
+ 	if ((arg = malloc(strlen(name)+strlen(value)+2)) == NULL)
+ 	{
+ 		return -1;
+ 	}
+ 
+ 	/* Format putenv() argument */
+ 	strcpy(arg, name); strcat(arg, "="); strcat(arg, value);
+ 
+ 	/*
+ 	 * Put variable into environment. This leaves memory used by previous
+ 	 * variable=value pair unfreed. :(
+ 	 */
+ 	result = putenv(arg);
+ 
+ 	/* Return result */
+ 	return result;
+ }



More information about the inn-workers mailing list