- From: Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>
- Date: Thu, 3 Jun 1999 10:55:54 +0200
- To: www-lib@w3.org
Since it's used for xdvi from the TeX-suite, I decided to install the
libwww library system-wide so it can also be used for other applications.
With version 5.2.8, this gave me the following problems:
1) System-wide implies that it's available for at least 5 architectures
(HPUX, Solaris, Digital Unix, SGI, and Linux). However, the wwwconf.h
include file is architecture-dependent, so I have to install all the
include files in an architecture-dependent directory, which is possible
thanks to libwww-config. But first of all, this is a waste of disk
space, since all the other include files are the same. Furthermore
"libwww-config --cflags" does not include the directory where
xmlparse.h is installed (which wasn't a problem when all was installed
in default include directory), so the libwww-config program must be
modified to include this directory as well.
2) HTLibInit sets the environment variable TMPDIR to "" (which is not the
same as unsetting it, as the comment claims) so the function tempnam
(in HTGetTmpFileName) does not get confused. However this assumes that
HTGetTmpFileName is the only user of TMPDIR, which is not at all
evident since this is part of a library which can be linked to any other
kind of program. In fact I ran into this problem using xdvi, which
calls a script mktexpk containing "TEMPDIR=${TMPDIR-/tmp}/mt$$.tmp". If
TMPDIR is set to "", this results in an unusable TEMPDIR = /mt$$.tmp.
In my opinion, the correct way to do it, is to change TMPDIR only
locally in HTGetTmpFileName and I hope that someone can make the
appropriate changes. Below you find the patches I tried as a
suggestion, please feel free to use any part of it you like.
Best regards,
Luc Van Eycken
-------------------------8<-------------------------8<-------------------------
*** w3c-libwww-5.2.8/Library/src/HTLib.c.orig Wed Mar 31 21:48:21 1999
--- w3c-libwww-5.2.8/Library/src/HTLib.c Wed Jun 2 15:04:47 1999
***************
*** 156,166 ****
tzset();
#endif
- /* If we are using tempnam() then unset any TMPDIR env var */
- #ifdef HAVE_TEMPNAM
- putenv("TMPDIR=");
- #endif
-
/* Create a default user profile and initialize it */
UserProfile = HTUserProfile_new(HT_DEFAULT_USER, NULL);
HTUserProfile_localize(UserProfile);
--- 156,161 ----
*** w3c-libwww-5.2.8/Library/src/HTInet.c.orig Tue Feb 23 00:29:44 1999
--- w3c-libwww-5.2.8/Library/src/HTInet.c Wed Jun 2 15:10:42 1999
***************
*** 592,610 ****
*/
PUBLIC char * HTGetTmpFileName (const char * abs_dir)
{
#ifdef HAVE_TEMPNAM
#ifdef __CYGWIN__
! return tempnam(abs_dir, "");
#else
! return tempnam(abs_dir, NULL);
#endif /* __CYGWIN__ */
#else
/*
** This is only approx. as we don't know if this file exists or not.
** Hopefully, tempnam() exists on enough platforms so that this is not
** a problem.
*/
- char * result = NULL;
char * offset = NULL;
if (!(result = (char *) HT_MALLOC((abs_dir ? strlen(abs_dir) : 0) +
HT_MAX_TMPNAM + 2)))
--- 592,626 ----
*/
PUBLIC char * HTGetTmpFileName (const char * abs_dir)
{
+ char * result = NULL;
#ifdef HAVE_TEMPNAM
+ static char * envtmpdir = NULL;
+ size_t len = 0;
+ if (abs_dir && *abs_dir) {
+ char * tmpdir = getenv("TMPDIR");
+ if (tmpdir)
+ len = strlen(tmpdir);
+ if (len) {
+ if (!(envtmpdir = (char *) HT_REALLOC(envtmpdir, len + 8)))
+ HT_OUTOFMEM("HTGetTmpFileName");
+ strcpy(envtmpdir, "TMPDIR=");
+ strcpy(envtmpdir + 7, tmpdir);
+ putenv("TMPDIR=");
+ }
+ }
#ifdef __CYGWIN__
! result = tempnam(abs_dir, "");
#else
! result = tempnam(abs_dir, NULL);
#endif /* __CYGWIN__ */
+ if (len)
+ putenv(envtmpdir);
#else
/*
** This is only approx. as we don't know if this file exists or not.
** Hopefully, tempnam() exists on enough platforms so that this is not
** a problem.
*/
char * offset = NULL;
if (!(result = (char *) HT_MALLOC((abs_dir ? strlen(abs_dir) : 0) +
HT_MAX_TMPNAM + 2)))
***************
*** 639,646 ****
#endif
offset = result;
}
- return result;
#endif /* HAVE_TEMPNAM */
}
/*
--- 655,662 ----
#endif
offset = result;
}
#endif /* HAVE_TEMPNAM */
+ return result;
}
/*
Received on Thursday, 3 June 1999 04:55:58 UTC