changeset 1267:69501f98669d

[project @ 1995-04-20 19:10:05 by jwe] Initial revision
author jwe
date Thu, 20 Apr 1995 19:10:05 +0000
parents e1ddfb12566d
children 76a0c05089d4
files kpathsea/absolute.h kpathsea/acconfig.h kpathsea/c-ctype.h kpathsea/c-dir.h kpathsea/c-errno.h kpathsea/c-fopen.h kpathsea/c-limits.h kpathsea/c-memstr.h kpathsea/c-minmax.h kpathsea/c-namemx.h kpathsea/c-pathch.h kpathsea/c-pathmx.h kpathsea/c-proto.h kpathsea/c-stat.h kpathsea/c-std.h kpathsea/c-unistd.h kpathsea/c-vararg.h kpathsea/cnf.h kpathsea/concatn.h kpathsea/config.h kpathsea/db.h kpathsea/debug.h kpathsea/default.h kpathsea/expand.h kpathsea/fn.h kpathsea/fontmap.h kpathsea/getopt.h kpathsea/getpagesize.h kpathsea/hash.h kpathsea/lib.h kpathsea/line.h kpathsea/magstep.h kpathsea/pathsearch.h kpathsea/proginit.h kpathsea/progname.h kpathsea/readable.h kpathsea/str-list.h kpathsea/str-llist.h kpathsea/systypes.h kpathsea/tex-file.h kpathsea/tex-glyph.h kpathsea/tex-make.h kpathsea/tilde.h kpathsea/truncate.h kpathsea/types.h kpathsea/variable.h kpathsea/xopendir.h kpathsea/xstat.h
diffstat 48 files changed, 2573 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/kpathsea/absolute.h
@@ -0,0 +1,31 @@
+/* absolute.h: Declare absolute filename predicate.
+
+Copyright (C) 1993, 94 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_ABSOLUTE_H
+#define KPATHSEA_ABSOLUTE_H
+
+#include <kpathsea/types.h>
+#include <kpathsea/c-proto.h>
+
+
+/* True if FILENAME is absolute (/foo) or, if RELATIVE_OK is true,
+   explicitly relative (./foo, ../foo), else false (foo).  */
+
+extern boolean kpse_absolute_p P2H(const_string filename, boolean relative_ok);
+
+#endif /* not KPATHSEA_ABSOLUTE_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/acconfig.h
@@ -0,0 +1,18 @@
+/* acconfig.h -- used by autoheader when generating c-auto.h.in.  */
+
+/* Define if your putenv doesn't waste space when the same environment
+   variable is assigned more than once, with different (malloced)
+   values.  This is true only on NetBSD/FreeBSD, as far as I know. See
+   xputenv.c.  */
+#undef SMART_PUTENV
+
+/* Define if you are using GNU libc or otherwise have global variables
+   `program_invocation_name' and `program_invocation_short_name'.  */
+#undef HAVE_PROGRAM_INVOCATION_NAME
+
+/* Define if you get clashes concerning wchar_t, between X's include
+   files and system includes.  */
+#undef FOIL_X_WCHAR_T
+
+/* Define if you have SIGIO, F_SETOWN, and FASYNC.  */
+#undef HAVE_SIGIO
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-ctype.h
@@ -0,0 +1,81 @@
+/* c-ctype.h: ASCII-safe versions of the <ctype.h> macros.
+
+Copyright (C) 1992 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_C_CTYPE_H
+#define KPATHSEA_C_CTYPE_H
+
+#include <ctype.h>
+
+/* Be sure we have `isascii'.  */
+#ifndef isascii
+#define isascii(c) 1
+#endif
+
+#define ISALNUM(c) (isascii (c) && isalnum(c))
+#define ISALPHA(c) (isascii (c) && isalpha(c))
+#define ISASCII isascii
+#define ISCNTRL(c) (isascii (c) && iscntrl(c))
+#define ISDIGIT(c) (isascii (c) && isdigit (c))
+#define ISGRAPH(c) (isascii (c) && isgraph(c))
+#define ISLOWER(c) (isascii (c) && islower(c))
+#define ISPRINT(c) (isascii (c) && isprint(c))
+#define ISPUNCT(c) (isascii (c) && ispunct(c))
+#define ISSPACE(c) (isascii (c) && isspace(c))
+#define ISUPPER(c) (isascii (c) && isupper(c))
+#define ISXDIGIT(c) (isascii (c) && isxdigit(c))
+#define TOASCII toascii
+#define TOLOWER(c) (ISUPPER (c) ? tolower (c) : (c))
+#define TOUPPER(c) (ISLOWER (c) ? toupper (c) : (c))
+
+/* This isn't part of the usual <ctype.h>, but it's useful sometimes.  */
+#ifndef isblank
+#define isblank(c) ((c) == ' ' || (c) == '\t')
+#endif
+
+
+/* Here's why this mess is necessary:
+
+From: meyering@cs.utexas.edu (Jim Meyering)
+Date: Wed, 25 Nov 1992 09:52:33 -0600
+Subject: ss-921123: using isascii with <ctype.h> macros
+
+  Yesterday some cursory regression testing found that GNU od
+  (in an upcoming release of textutils) generated incorrect output
+  when run on an SGI indigo because isprint ('\377') returned true.
+  Of course, '\377' is not a printing character;  the problem lay
+  in using isprint without first making sure its integer argument
+  corresponded to an ascii code.
+
+  MORAL: always guard uses of ctype macros with isascii if it's available.
+  An obvious alternative is to avoid <ctype.h> and define and use your
+  own versions of the ctype macros.
+
+  A pretty clean approach to using <ctype.h> and isascii was
+  suggested by David MacKenzie:
+
+  #ifndef isascii
+  #define isascii(c) 1
+  #endif
+
+  #define ISDIGIT(c) (isascii (c) && isdigit (c))
+  #define ISPRINT(c) (isascii (c) && isprint (c))
+  ...
+
+  then, use ISDIGIT, etc. instead of isdigit, etc.  */
+  
+#endif /* not KPATHSEA_C_CTYPE_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-dir.h
@@ -0,0 +1,44 @@
+/* c-dir.h: directory headers.
+
+Copyright (C) 1992, 93, 94 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_C_DIR_H
+#define KPATHSEA_C_DIR_H
+
+/* Use struct dirent instead of struct direct.  */
+#ifdef HAVE_DIRENT_H
+#include <dirent.h>
+#define NAMLEN(dirent) strlen ((dirent)->d_name)
+#else /* not DIRENT */
+#define dirent direct
+#define NAMLEN(dirent) ((dirent)->d_namlen)
+
+#ifdef HAVE_SYS_NDIR_H
+#include <sys/ndir.h>
+#endif
+
+#ifdef HAVE_SYS_DIR_H
+#include <sys/dir.h>
+#endif
+
+#ifdef HAVE_NDIR_H
+#include <ndir.h>
+#endif
+
+#endif /* not DIRENT */
+
+#endif /* not KPATHSEA_C_DIR_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-errno.h
@@ -0,0 +1,27 @@
+/* c-errno.h: <errno.h> and the errno variable.
+
+Copyright (C) 1992 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_C_ERRNO_H
+#define KPATHSEA_C_ERRNO_H
+
+#include <errno.h>
+#ifndef errno
+extern int errno;
+#endif
+
+#endif /* not KPATHSEA_C_ERRNO_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-fopen.h
@@ -0,0 +1,57 @@
+/* c-fopen.h: how to open files with fopen.
+
+Copyright (C) 1992, 94 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef C_FOPEN_H
+#define C_FOPEN_H
+
+/* How to open a text file:  */
+#ifndef FOPEN_A_MODE
+#define FOPEN_A_MODE "a"
+#endif
+
+#ifndef FOPEN_R_MODE
+#define FOPEN_R_MODE "r"
+#endif
+
+#ifndef FOPEN_W_MODE
+#define FOPEN_W_MODE "w"
+#endif
+
+/* How to open a binary file for reading:  */
+#ifndef FOPEN_RBIN_MODE
+#if defined (VMS) || defined (DOS) || defined (VMCMS)
+#define	FOPEN_RBIN_MODE	"rb"
+#else
+#define	FOPEN_RBIN_MODE	"r"
+#endif /* not (VM/CMS or DOS or VMS) */
+#endif /* not FOPEN_RBIN_MODE */
+
+/* How to open a binary file for writing:  */
+#ifndef FOPEN_WBIN_MODE
+#ifdef DOS
+#define FOPEN_WBIN_MODE "wb"
+#else
+#ifdef VMCMS
+#define FOPEN_WBIN_MODE "wb, lrecl=1024, recfm=f"
+#else
+#define	FOPEN_WBIN_MODE	"w"
+#endif /* not VM/CMS */
+#endif /* not DOS */
+#endif /* not FOPEN_WBIN_MODE */
+
+#endif /* not C_FOPEN_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-limits.h
@@ -0,0 +1,34 @@
+/* c-limits.h: include the system parameter file.
+
+Copyright (C) 1992, 93 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef C_LIMITS_H
+#define C_LIMITS_H
+
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#else
+#include <kpathsea/systypes.h>
+#include <sys/param.h>
+#endif
+
+/* Some systems may have the floating-point limits in the above.  */
+#if defined (HAVE_FLOAT_H) && !defined (FLT_MAX)
+#include <float.h>
+#endif
+
+#endif /* not C_LIMITS_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-memstr.h
@@ -0,0 +1,80 @@
+/* c-memstr.h: memcpy, strchr, etc.
+
+Copyright (C) 1992, 93, 94 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_C_MEMSTR_H
+#define KPATHSEA_C_MEMSTR_H
+
+/* <X11/Xfuncs.h> tries to declare bcopy etc., which can only conflict.  */
+#define _XFUNCS_H_
+
+/* Just to be complete, we make both the system V/ANSI and the BSD
+   versions of the string functions available.  */
+#if defined (STDC_HEADERS) || defined (HAVE_STRING_H)
+#define SYSV /* so <X11/Xos.h> knows not to include <strings.h> */
+#include <string.h>
+
+/* An ANSI string.h and pre-ANSI memory.h might conflict.  */
+#if !defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
+#include <memory.h>
+#endif /* not STDC_HEADERS and HAVE_MEMORY_H */
+
+/* Do not define these if we are not STDC_HEADERS, because in that
+   case X11/Xos.h defines `strchr' to be `index'. */
+#ifdef STDC_HEADERS
+/* Let's hope that if index/rindex are defined, they're defined to the
+   right thing.  */
+#ifndef index
+#define index strchr
+#endif
+#ifndef rindex
+#define rindex strrchr
+#endif
+#endif /* STDC_HEADERS */
+
+#ifndef HAVE_BCOPY
+#ifndef bcmp
+#define bcmp(s1, s2, len) memcmp ((s1), (s2), (len))
+#endif
+#ifndef bcopy
+#define bcopy(from, to, len) memcpy ((to), (from), (len))
+#endif
+#ifndef bzero
+#define bzero(s, len) memset ((s), 0, (len))
+#endif
+#endif /* not HAVE_BCOPY */
+
+#else /* not (STDC_HEADERS or HAVE_STRING_H) */
+
+#include <strings.h>
+
+#ifndef strchr
+#define strchr index
+#endif
+#ifndef strrchr
+#define strrchr rindex
+#endif
+
+#define memcmp(s1, s2, n) bcmp ((s1), (s2), (n))
+#define memcpy(to, from, len) bcopy ((from), (to), (len))
+
+extern char *strtok ();
+extern char *strstr ();
+
+#endif /* not (STDC_HEADERS or HAVE_STRING_H) */
+
+#endif /* not KPATHSEA_C_MEMSTR_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-minmax.h
@@ -0,0 +1,84 @@
+/* c-minmax.h: define INT_MIN, etc.  Assume a 32-bit machine if the
+   values aren't defined.
+
+Copyright (C) 1992, 93 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_C_MINMAX_H
+#define KPATHSEA_C_MINMAX_H
+
+#include <kpathsea/c-limits.h>
+
+/* Declared in <limits.h> on ANSI C systems.  If the system doesn't
+   define it, we use the minimum ANSI values -- except for `int'; we
+   assume 32-bit integers.  */
+
+#ifndef SCHAR_MIN
+#define SCHAR_MIN (-127)
+#endif
+#ifndef SCHAR_MAX
+#define SCHAR_MAX 128
+#endif
+#ifndef UCHAR_MAX
+#define UCHAR_MAX 255
+#endif
+
+#ifndef SHRT_MIN
+#define SHRT_MIN (-32767)
+#endif
+#ifndef SHRT_MAX
+#define SHRT_MAX 32767
+#endif
+#ifndef USHRT_MAX
+#define USHRT_MAX 65535
+#endif
+
+#ifndef INT_MIN
+#define INT_MIN (-2147483647)
+#endif
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+#ifndef UINT_MAX
+#define UINT_MAX 4294967295
+#endif
+
+#ifndef LONG_MIN
+#define LONG_MIN INT_MIN
+#endif
+#ifndef LONG_MAX
+#define LONG_MAX INT_MAX
+#endif
+#ifndef ULONG_MAX
+#define ULONG_MAX UINT_MAX
+#endif
+
+/* Declared in <float.h> on ANSI C systems.  */
+#ifndef DBL_MIN
+#define DBL_MIN 1e-37
+#endif
+#ifndef DBL_MAX
+#define DBL_MAX 1e+37
+#endif
+
+#ifndef FLT_MIN
+#define FLT_MIN 1e-37
+#endif
+#ifndef FLT_MAX
+#define FLT_MAX 1e+37
+#endif
+
+#endif /* not KPATHSEA_C_MINMAX_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-namemx.h
@@ -0,0 +1,36 @@
+/* c-namemx.h: define NAME_MAX, the maximum length of a single
+   component in a filename.  No such limit may exist, or may vary
+   depending on the filesystem.
+
+Copyright (C) 1992, 93 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_C_NAME_MX_H
+#define KPATHSEA_C_NAME_MX_H
+
+#include <kpathsea/c-limits.h>
+
+/* Most likely the system will truncate filenames if it is not POSIX,
+   and so we can use the BSD value here.  */
+#ifndef _POSIX_NAME_MAX
+#define _POSIX_NAME_MAX 255
+#endif
+
+#ifndef NAME_MAX
+#define NAME_MAX _POSIX_NAME_MAX
+#endif
+
+#endif /* not KPATHSEA_C_NAME_MX_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-pathch.h
@@ -0,0 +1,76 @@
+/* c-pathch.h: define the characters which separate components of
+   filenames and environment variable paths.
+
+Copyright (C) 1992, 93 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef C_PATHCH_H
+#define C_PATHCH_H
+
+/* What separates filename components?  */
+#ifndef DIR_SEP
+#ifdef VMS
+#define DIR_SEP ':'
+#define DIR_SEP_STRING ":"
+#else
+#ifdef DOS
+#define DIR_SEP '\\'
+#define DIR_SEP_STRING "\\"
+/* On DOS, it's good to allow both \ and / between directories.  */
+#define IS_DIR_SEP(ch) ((ch) == DIR_SEP || (ch) == '/')
+#else
+#ifdef VMCMS
+#define DIR_SEP ' '
+#define DIR_SEP_STRING " "
+#else
+#define DIR_SEP '/'
+#define DIR_SEP_STRING "/"
+#endif /* not VM/CMS */
+#endif /* not DOS */
+#endif /* not VMS */
+#endif /* not PATH_SEP */
+
+#ifndef IS_DIR_SEP
+#define IS_DIR_SEP(ch) ((ch) == DIR_SEP)
+#endif
+
+
+/* What separates elements in environment variable path lists?  */
+#ifndef ENV_SEP
+#ifdef VMS
+#define ENV_SEP ','
+#define ENV_SEP_STRING ","
+#else
+#ifdef DOS
+#define ENV_SEP ';'
+#define ENV_SEP_STRING ";"
+#else
+#ifdef VMCMS
+#define ENV_SEP ' '
+#define ENV_SEP_STRING " "
+#else
+#define ENV_SEP ':'
+#define ENV_SEP_STRING ":"
+#endif /* not VM/CMS */
+#endif /* not DOS */
+#endif /* not VMS */
+#endif /* not ENV_SEP */
+
+#ifndef IS_ENV_SEP
+#define IS_ENV_SEP(ch) ((ch) == ENV_SEP)
+#endif
+
+#endif /* not C_PATHCH_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-pathmx.h
@@ -0,0 +1,42 @@
+/* c-pathmx.h: define PATH_MAX, the maximum length of a filename.
+   Since no such limit may exist, it's preferable to dynamically grow
+   filenames as needed.
+
+Copyright (C) 1992, 93 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_C_PATH_MX_H
+#define KPATHSEA_C_PATH_MX_H
+
+#include <kpathsea/c-limits.h>
+
+/* Cheat and define this as a manifest constant no matter what, instead
+   of using pathconf.  I forget why we want to do this.  */
+
+#ifndef _POSIX_PATH_MAX
+#define _POSIX_PATH_MAX 255
+#endif
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX _POSIX_PATH_MAX
+#endif
+#endif /* not PATH_MAX */
+
+
+#endif /* not KPATHSEA_C_PATH_MAX_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-proto.h
@@ -0,0 +1,66 @@
+/* c-proto.h: macros to include or discard prototypes.
+
+Copyright (C) 1992, 93 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_C_PROTO_H
+#define KPATHSEA_C_PROTO_H
+
+/* These macros munge function declarations to make them work in both
+   cases.  The P?H macros are used for declarations, the P?C for
+   definitions.  Cf. <ansidecl.h> from the GNU C library.  P1H(void)
+   also works for definitions of routines which take no args.  */
+
+#if __STDC__
+
+#define P1H(p1) (p1)
+#define P2H(p1,p2) (p1, p2)
+#define P3H(p1,p2,p3) (p1, p2, p3)
+#define P4H(p1,p2,p3,p4) (p1, p2, p3, p4)
+#define P5H(p1,p2,p3,p4,p5) (p1, p2, p3, p4, p5)
+#define P6H(p1,p2,p3,p4,p5,p6) (p1, p2, p3, p4, p5, p6)
+
+#define P1C(t1,n1)(t1 n1)
+#define P2C(t1,n1, t2,n2)(t1 n1, t2 n2)
+#define P3C(t1,n1, t2,n2, t3,n3)(t1 n1, t2 n2, t3 n3)
+#define P4C(t1,n1, t2,n2, t3,n3, t4,n4)(t1 n1, t2 n2, t3 n3, t4 n4)
+#define P5C(t1,n1, t2,n2, t3,n3, t4,n4, t5,n5) \
+  (t1 n1, t2 n2, t3 n3, t4 n4, t5 n5)
+#define P6C(t1,n1, t2,n2, t3,n3, t4,n4, t5,n5, t6,n6) \
+  (t1 n1, t2 n2, t3 n3, t4 n4, t5 n5, t6 n6)
+
+#else /* not __STDC__ */
+
+#define P1H(p1) ()
+#define P2H(p1, p2) ()
+#define P3H(p1, p2, p3) ()
+#define P4H(p1, p2, p3, p4) ()
+#define P5H(p1, p2, p3, p4, p5) ()
+#define P6H(p1, p2, p3, p4, p5, p6) ()
+
+#define P1C(t1,n1) (n1) t1 n1;
+#define P2C(t1,n1, t2,n2) (n1,n2) t1 n1; t2 n2;
+#define P3C(t1,n1, t2,n2, t3,n3) (n1,n2,n3) t1 n1; t2 n2; t3 n3;
+#define P4C(t1,n1, t2,n2, t3,n3, t4,n4) (n1,n2,n3,n4) \
+  t1 n1; t2 n2; t3 n3; t4 n4;
+#define P5C(t1,n1, t2,n2, t3,n3, t4,n4, t5,n5) (n1,n2,n3,n4,n5) \
+  t1 n1; t2 n2; t3 n3; t4 n4; t5 n5;
+#define P6C(t1,n1, t2,n2, t3,n3, t4,n4, t5,n5, t6,n6) (n1,n2,n3,n4,n5,n6) \
+  t1 n1; t2 n2; t3 n3; t4 n4; t5 n5; t6 n6;
+
+#endif /* not __STDC__ */
+
+#endif /* not KPATHSEA_C_PROTO_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-stat.h
@@ -0,0 +1,56 @@
+/* c-stat.h: declarations for using stat(2).
+
+Copyright (C) 1993 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_STAT_H
+#define KPATHSEA_STAT_H
+
+#include <kpathsea/systypes.h>
+#include <sys/stat.h>
+
+/* POSIX predicates for testing file attributes.  */
+
+#if !defined (S_ISBLK) && defined (S_IFBLK)
+#define	S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+#endif
+#if !defined (S_ISCHR) && defined (S_IFCHR)
+#define	S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+#endif
+#if !defined (S_ISDIR) && defined (S_IFDIR)
+#define	S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+#if !defined (S_ISREG) && defined (S_IFREG)
+#define	S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#endif
+#if !defined (S_ISFIFO) && defined (S_IFIFO)
+#define	S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+#endif
+#if !defined (S_ISLNK) && defined (S_IFLNK)
+#define	S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+#endif
+#if !defined (S_ISSOCK) && defined (S_IFSOCK)
+#define	S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+#endif
+#if !defined (S_ISMPB) && defined (S_IFMPB) /* V7 */
+#define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
+#define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
+#endif
+#if !defined (S_ISNWK) && defined (S_IFNWK) /* HP/UX */
+#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
+#endif
+
+#endif /* not KPATHSEA_STAT_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-std.h
@@ -0,0 +1,100 @@
+/* c-std.h: the first header files.
+
+Copyright (C) 1992, 93, 94 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_C_STD_H
+#define KPATHSEA_C_STD_H
+
+/* Header files that essentially all of our sources need, and
+   that all implementations have.  We include these first, to help with
+   NULL being defined multiple times.  */
+#include <math.h>
+#include <stdio.h>
+
+/* Be sure we have constants from <unistd.h>.  */
+#include <kpathsea/c-unistd.h>
+
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+/* Include <stdlib.h> before <stddef.h>, to help avoid NULL
+   redefinitions on some systems.  (We don't include <stddef.h>
+   ourselves any more, but FYI.)  */
+#else
+/* It's impossible to say for sure what the system will deign to put in
+   <stdlib.h>, but let's hope it's at least these.  */
+extern char *getenv ();
+
+#ifndef ALLOC_RETURN_TYPE
+#ifdef DOS
+#define ALLOC_RETURN_TYPE void
+#else
+#define ALLOC_RETURN_TYPE char
+#endif /* not DOS */
+#endif /* not ALLOC_RETURN_TYPE */
+
+#ifndef _MALLOC_INTERNAL
+/* Don't bother to declare these if we are compiling gmalloc.c itself.  */
+extern ALLOC_RETURN_TYPE *calloc (), *malloc (), *realloc ();
+#endif
+
+#endif /* not STDC_HEADERS */
+
+/* SunOS 4.1.1 gets STDC_HEADERS defined, but it doesn't provide
+   EXIT_FAILURE.  So far no system has defined one of EXIT_FAILURE and
+   EXIT_SUCCESS without the other.  */
+#ifndef EXIT_SUCCESS
+#ifdef VMS
+#define EXIT_SUCCESS 1
+#define EXIT_FAILURE 0
+#else
+#define EXIT_SUCCESS 0
+#define EXIT_FAILURE 1
+#endif
+#endif /* not EXIT_SUCCESS */
+
+/* strchr vs. index, memcpy vs. bcopy, etc.  */
+#include <kpathsea/c-memstr.h>
+
+/* Error numbers and errno declaration.  */
+#include <kpathsea/c-errno.h>
+
+/* Numeric minima and maxima.  */
+#include <kpathsea/c-minmax.h>
+
+/* Assertions are too useful to not make generally available.  */
+#ifdef HAVE_ASSERT_H
+#include <assert.h>
+#else
+#define assert(expr) /* as nothing */
+#endif
+
+#ifdef VMS
+#include <unixlib.h>
+#include <unixio.h>
+#else
+/* `popen' and `pclose' are part of POSIX.2, not POSIX.1.  So
+   STDC_HEADERS isn't enough.  */
+extern FILE *popen ();
+extern int pclose ();
+#endif
+
+#ifndef hypot
+/* hypot appears not to have made it into POSIX.2, even.  */
+extern double hypot ();
+#endif
+
+#endif /* not KPATHSEA_C_STD_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-unistd.h
@@ -0,0 +1,53 @@
+/* c-unistd.h: ensure we have constants from <unistd.h>.  Included from
+   c-std.h.
+
+Copyright (C) 1992, 93 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_C_UNISTD_H
+#define KPATHSEA_C_UNISTD_H
+
+/* <unistd.h> is allowed to depend on <sys/types.h>.  */
+#include <kpathsea/systypes.h>
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <kpathsea/c-std.h>
+
+/* For fseek.  */
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+#endif /* not SEEK_SET */
+
+/* For access.  */
+#ifndef F_OK
+#define F_OK 0
+#define X_OK 1
+#define W_OK 2
+#define R_OK 4
+#endif /* not F_OK */
+
+#ifndef STDIN_FILENO
+#define STDIN_FILENO    0
+#define STDOUT_FILENO   1
+#define STDERR_FILENO   2
+#endif /* not STDIN_FILENO */
+
+#endif /* not KPATHSEA_C_UNISTD_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/c-vararg.h
@@ -0,0 +1,61 @@
+/* c-vararg.h: Top layer for stdarg and varargs.
+
+Copyright (C) 1993 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef C_VARARG_H
+#define C_VARARG_H
+
+/* See `kpathsea/init-path.c' for an example of use.  The idea is to say
+   PVAR1(type1, parameter1, ap) in the function header, and then end
+   the function with two }}'s.  We do this to avoid having to specify
+   the argument list (with types) twice -- once in the function header,
+   and once in a (hypothetical) VA_START1.  */
+
+#if __STDC__
+#include <stdarg.h>
+
+#define PVAR1H(p1) (p1, ...)
+#define PVAR2H(p1, p2) (p1, p2, ...)
+#define PVAR3H(p1, p2, p3) (p1, p2, p3, ...)
+
+#define PVAR1C(t1, n1,  ap) \
+  (t1 n1, ...) { va_list ap; va_start (ap, n1);
+#define PVAR2C(t1, n1,  t2, n2,  ap) \
+  (t1 n1, t2 n2, ...) { va_list ap; va_start (ap, n2);
+#define PVAR3C(t1, n1,  t2, n2,  t3, n3,  ap) \
+  (t1 n1, t2 n2, t3 n3, ...) { va_list ap; va_start (ap, n3);
+
+#else /* not __STDC__ */
+#include <varargs.h>
+
+#define PVAR1H(p1) ()
+#define PVAR2H(p1, p2) ()
+#define PVAR3H(p1, p2, p3) ()
+
+#define PVAR1C(t1, n1,  ap) \
+  (va_alist) va_dcl { t1 n1; va_list ap; va_start (ap); \
+                      n1 = va_arg (ap, t1);
+#define PVAR2C(t1, n1,  t2, n2,  ap) \
+  (va_alist) va_dcl { t1 n1; t2 n2; va_list ap; va_start (ap); \
+                      n1 = va_arg (ap, t1); n2 = va_arg (ap, t2);
+#define PVAR3C(t1, n1,  t2, n2,  t3, n3,  ap) \
+  (va_alist) va_dcl { t1 n1; t2 n2; t3 n3; va_list ap; va_start (ap); \
+                      n1 = va_arg (ap, t1); n2 = va_arg (ap, t2); \
+                      n3 = va_arg (ap, t3);
+#endif /* not __STDC__ */
+
+#endif /* not C_VARARG_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/cnf.h
@@ -0,0 +1,31 @@
+/* cnf.h: runtime config files.
+
+Copyright (C) 1994 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_CNF_H
+#define KPATHSEA_CNF_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+/* Return the value in the last-read cnf file for VAR, or NULL if none.
+   On the first call, also read all the cnf files in the path (and
+   initialize the path) named the `program' member of the
+   `kpse_cnf_format' element of `kpse_format_info'.  */
+extern string kpse_cnf_get P1H(const_string var);
+
+#endif /* not KPATHSEA_CNF_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/concatn.h
@@ -0,0 +1,35 @@
+/* concatn.h: concatenate a variable number of strings.
+   This is a separate include file only because I don't see the point of
+   having every source file include <c-vararg.h>.  The declarations for
+   the other concat routines are in lib.h.
+
+Copyright (C) 1993 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_CONCATN_H
+#define KPATHSEA_CONCATN_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/c-vararg.h>
+#include <kpathsea/types.h>
+
+/* Concatenate a null-terminated list of strings and return the result
+   in malloc-allocated memory.  */
+extern string concatn PVAR1H(const_string str1);
+
+#endif /* not KPATHSEA_CONCATN_H */
+
+
new file mode 100644
--- /dev/null
+++ b/kpathsea/config.h
@@ -0,0 +1,50 @@
+/* config.h: master configuration file, included first by all compilable
+   source files (not headers).
+
+Copyright (C) 1993 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_CONFIG_H
+#define KPATHSEA_CONFIG_H
+
+/* System dependencies that are figured out by `configure'.  If we are
+   compiling standalone, we get our c-auto.h.  Otherwise, the package
+   containing us must provide this (unless it can somehow generate ours
+   from c-auto.h.in).  We use <...> instead of "..." so that the current
+   cpp directory (i.e., kpathsea/) won't be searched. */
+#include <c-auto.h>
+
+/* ``Standard'' system headers.  */
+#include <kpathsea/c-std.h>
+
+/* Macros to discard or keep prototypes.  */
+#include <kpathsea/c-proto.h>
+
+/* Our own definitions of supposedly always-useful stuff.  */
+#include <kpathsea/lib.h>
+#include <kpathsea/types.h>
+
+/* Support extra runtime tracing.  */
+#include <kpathsea/debug.h>
+
+/* If you want to find subdirectories in a directory with non-Unix
+   semantics (specifically, if a directory with no subdirectories does
+   not have exactly two links), define this.  */
+#if !defined (DOS) && !defined (VMS) && !defined (VMCMS)
+#define UNIX_ST_NLINK
+#endif /* not DOS and not VMS and not VMCMS */
+
+#endif /* not KPATHSEA_CONFIG_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/db.h
@@ -0,0 +1,53 @@
+/* db.h: lookups in an externally built db file.
+
+Copyright (C) 1994 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_DB_H
+#define KPATHSEA_DB_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+#include <kpathsea/str-list.h>
+
+/* It's not an error if this doesn't exist; we just go ahead and search
+   the actual directories.  See the `Filename database' node in the
+   kpathsea documentation for details. The variable reference here is
+   expanded by kpathsea. This lets you have different databases for
+   different TeX hierarchies (only one at a time, though!) without
+   having to change anything.  */
+#ifndef KPSE_DB_DIR
+#define KPSE_DB_DIR "$TEXMF"
+#endif
+#ifndef KPSE_DB_NAME
+#define KPSE_DB_NAME "ls-R"
+#endif
+
+/* The expansion of DB_DIR; set by `read_files' in cnf.c, used by
+   `elt_in_db' in pathsearch.c.  */
+extern string kpse_db_dir;
+
+/* Return list of matches for NAME in the ls-R file matching PATH.  If
+   ALL is set, return (null-terminated list) of all matches, else just
+   the first.  If no matches, return a pointer to an empty list.  If the
+   database can't be read, returns NULL.  */
+extern str_list_type *kpse_db_search P3H(const_string name, 
+                                         const_string path, boolean all);
+
+/* Insert the filename FNAME into the database.  */
+extern void db_insert P1H(const_string fname);
+
+#endif /* not KPATHSEA_DB_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/debug.h
@@ -0,0 +1,72 @@
+/* debug.h: Runtime tracing.
+
+Copyright (C) 1993, 94 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_DEBUG_H
+#define KPATHSEA_DEBUG_H
+
+/* If NO_DEBUG is defined, skip all this.  */
+#ifndef NO_DEBUG
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/c-std.h>
+#include <kpathsea/types.h>
+
+/* OK, we'll have tracing support.  */
+#define DEBUG
+
+/* Bit vector defining what we should trace.  */
+extern unsigned kpathsea_debug;
+
+/* Set a bit.  */
+#define KPSE_DEBUG_SET(bit) kpathsea_debug |= 1 << (bit)
+
+/* Test if a bit is on.  */
+#define KPSE_DEBUG_P(bit) (kpathsea_debug & (1 << (bit)))
+
+#define KPSE_DEBUG_STAT 0		/* stat calls */
+#define KPSE_DEBUG_HASH 1		/* hash lookups */
+#define KPSE_DEBUG_FOPEN 2		/* fopen/fclose calls */
+#define KPSE_DEBUG_PATHS 3		/* search path initializations */
+#define KPSE_DEBUG_EXPAND 4		/* path element expansion */
+#define KPSE_DEBUG_SEARCH 5		/* searches */
+
+/* A printf for the debugging.  */
+#define DEBUGF_START() do { fputs ("kdebug:", stderr)
+#define DEBUGF_END()        fflush (stderr); } while (0)
+
+#define DEBUGF(str)							\
+  DEBUGF_START (); fputs (str, stderr); DEBUGF_END ()
+#define DEBUGF1(str, e1)						\
+  DEBUGF_START (); fprintf (stderr, str, e1); DEBUGF_END ()
+#define DEBUGF2(str, e1, e2)						\
+  DEBUGF_START (); fprintf (stderr, str, e1, e2); DEBUGF_END ()
+#define DEBUGF3(str, e1, e2, e3)					\
+  DEBUGF_START (); fprintf (stderr, str, e1, e2, e3); DEBUGF_END ()
+#define DEBUGF4(str, e1, e2, e3, e4)					\
+  DEBUGF_START (); fprintf (stderr, str, e1, e2, e3, e4); DEBUGF_END ()
+
+#undef fopen
+#define fopen kpse_fopen_trace
+extern FILE *fopen P2H(const_string filename, const_string mode);
+#undef fclose
+#define fclose kpse_fclose_trace
+extern int fclose P1H(FILE *);
+
+#endif /* not NO_DEBUG */
+
+#endif /* not KPATHSEA_DEBUG_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/default.h
@@ -0,0 +1,32 @@
+/* default.h: Declare default path expander.
+
+Copyright (C) 1993, 94 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_DEFAULT_H
+#define KPATHSEA_DEFAULT_H
+
+#include <kpathsea/types.h>
+#include <kpathsea/c-proto.h>
+
+
+/* Replace a leading or trailing or doubled : in PATH with DFLT.  If
+   no extra colons, return PATH.  Only one extra colon is replaced.
+   DFLT may not be NULL.  */
+
+extern string kpse_expand_default P2H(const_string path, const_string dflt);
+
+#endif /* not KPATHSEA_DEFAULT_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/expand.h
@@ -0,0 +1,35 @@
+/* expand.h: general expansion.
+
+Copyright (C) 1993, 94 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_EXPAND_H
+#define KPATHSEA_EXPAND_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+/* Call kpse_var_expand and kpse_tilde_expand (in that order).  Result
+   is always in fresh memory, even if no expansions were done.  */
+extern string kpse_expand P1H(const_string s);
+
+/* Call `kpse_expand' on each element of the result; return the final
+   expansion (always in fresh memory, even if no expansions were
+   done).  We don't call `kpse_expand_default' because there is a whole
+   sequence of defaults to run through; see `kpse_init_format'.  */
+extern string kpse_path_expand P1H(const_string path);
+
+#endif /* not KPATHSEA_EXPAND_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/fn.h
@@ -0,0 +1,67 @@
+/* fn.h: arbitrarily long filenames (or just strings).
+
+Copyright (C) 1993 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_FN_H
+#define KPATHSEA_FN_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+/* Arbitrarily long filenames; it's inconvenient to use obstacks here,
+   because we want to maintain a null terminator.  Also used for
+   dynamically growing strings even when the null byte isn't necessary,
+   e.g., in `variable.c', since I don't want to pass obstacks around
+   everywhere, and one can't free parts of an obstack arbitrarily.  */
+
+typedef struct
+{
+  string str;
+  unsigned allocated;
+  unsigned length; /* includes the terminating null byte, if any */
+} fn_type;
+
+#define FN_STRING(fn) ((fn).str)
+#define FN_ALLOCATED(fn) ((fn).allocated)
+#define FN_LENGTH(fn) ((fn).length)
+
+
+/* Create a new empty fn.  */
+extern fn_type fn_init P1H(void);
+
+/* Create a new fn from the first LEN characters from S and a null.  */
+extern fn_type fn_copy0 P2H(const_string s,  unsigned len);
+
+/* Free what's been allocated.  Can also just free the string if it's
+   been extracted out.  Fatal error if nothing allocated in F.  */
+extern void fn_free P1H(fn_type *f);
+
+/* Append the character C to the fn F.  Don't append trailing null.  */
+extern void fn_1grow P2H(fn_type *f, char c);
+
+/* Append LENGTH bytes from SOURCE to F.  */
+extern void fn_grow P3H(fn_type *f, address source, unsigned length);
+
+/* Concatenate the component S to the fn F.  Assumes string currently in
+   F is null terminated.  */
+extern void fn_str_grow P2H(fn_type *f, const_string s);
+
+/* Add a null to F's string at position LOC, and update its length.
+   Fatal error if LOC is past the end of the string.  */
+extern void fn_shrink_to P2H(fn_type *f, unsigned loc);
+
+#endif /* not KPATHSEA_FN_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/fontmap.h
@@ -0,0 +1,37 @@
+/* fontmap.h: declarations for reading a file to define additional font names.
+
+Copyright (C) 1993, 94 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef FONTMAP_H
+#define FONTMAP_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/hash.h>
+#include <kpathsea/types.h>
+
+
+/* Parse the file `texfonts.map' in each of the directories in PATH and
+   return the resulting structure.  Entries in earlier files override
+   later files.  */
+extern hash_table_type map_create P1H(const_string path);
+
+
+/* Look up KEY in MAP, and return a null-terminated list of all matching
+   entries.  If none, return NULL.  */
+extern string *map_lookup P2H(hash_table_type map, const_string key);
+
+#endif /* not FONTMAP_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/getopt.h
@@ -0,0 +1,129 @@
+/* Declarations for getopt.
+   Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef _GETOPT_H
+#define _GETOPT_H 1
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/* For communication from `getopt' to the caller.
+   When `getopt' finds an option that takes an argument,
+   the argument value is returned here.
+   Also, when `ordering' is RETURN_IN_ORDER,
+   each non-option ARGV-element is returned here.  */
+
+extern char *optarg;
+
+/* Index in ARGV of the next element to be scanned.
+   This is used for communication to and from the caller
+   and for communication between successive calls to `getopt'.
+
+   On entry to `getopt', zero means this is the first call; initialize.
+
+   When `getopt' returns EOF, this is the index of the first of the
+   non-option elements that the caller should itself scan.
+
+   Otherwise, `optind' communicates from one call to the next
+   how much of ARGV has been scanned so far.  */
+
+extern int optind;
+
+/* Callers store zero here to inhibit the error message `getopt' prints
+   for unrecognized options.  */
+
+extern int opterr;
+
+/* Set to an option character which was unrecognized.  */
+
+extern int optopt;
+
+/* Describe the long-named options requested by the application.
+   The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
+   of `struct option' terminated by an element containing a name which is
+   zero.
+
+   The field `has_arg' is:
+   no_argument		(or 0) if the option does not take an argument,
+   required_argument	(or 1) if the option requires an argument,
+   optional_argument 	(or 2) if the option takes an optional argument.
+
+   If the field `flag' is not NULL, it points to a variable that is set
+   to the value given in the field `val' when the option is found, but
+   left unchanged if the option is not found.
+
+   To have a long-named option do something other than set an `int' to
+   a compiled-in constant, such as set a value from `optarg', set the
+   option's `flag' field to zero and its `val' field to a nonzero
+   value (the equivalent single-letter option character, if there is
+   one).  For long options that have a zero `flag' field, `getopt'
+   returns the contents of the `val' field.  */
+
+struct option
+{
+#if defined (__STDC__) && __STDC__
+  const char *name;
+#else
+  char *name;
+#endif
+  /* has_arg can't be an enum because some compilers complain about
+     type mismatches in all the code that assumes it is an int.  */
+  int has_arg;
+  int *flag;
+  int val;
+};
+
+/* Names for the values of the `has_arg' field of `struct option'.  */
+
+#define	no_argument		0
+#define required_argument	1
+#define optional_argument	2
+
+#if defined (__STDC__) && __STDC__
+#ifdef __GNU_LIBRARY__
+/* Many other libraries have conflicting prototypes for getopt, with
+   differences in the consts, in stdlib.h.  To avoid compilation
+   errors, only prototype getopt for the GNU C library.  */
+extern int getopt (int argc, char *const *argv, const char *shortopts);
+#else /* not __GNU_LIBRARY__ */
+extern int getopt ();
+#endif /* __GNU_LIBRARY__ */
+extern int getopt_long (int argc, char *const *argv, const char *shortopts,
+		        const struct option *longopts, int *longind);
+extern int getopt_long_only (int argc, char *const *argv,
+			     const char *shortopts,
+		             const struct option *longopts, int *longind);
+
+/* Internal only.  Users should not call this directly.  */
+extern int _getopt_internal (int argc, char *const *argv,
+			     const char *shortopts,
+		             const struct option *longopts, int *longind,
+			     int long_only);
+#else /* not __STDC__ */
+extern int getopt ();
+extern int getopt_long ();
+extern int getopt_long_only ();
+
+extern int _getopt_internal ();
+#endif /* __STDC__ */
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif /* _GETOPT_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/getpagesize.h
@@ -0,0 +1,35 @@
+/* Emulate getpagesize on systems that lack it.  */
+
+#ifndef HAVE_GETPAGESIZE
+
+#ifdef VMS
+#define getpagesize() 512
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef _SC_PAGESIZE
+#define getpagesize() sysconf(_SC_PAGESIZE)
+#else
+
+#include <sys/param.h>
+
+#ifdef EXEC_PAGESIZE
+#define getpagesize() EXEC_PAGESIZE
+#else
+#ifdef NBPG
+#define getpagesize() NBPG * CLSIZE
+#ifndef CLSIZE
+#define CLSIZE 1
+#endif /* no CLSIZE */
+#else /* no NBPG */
+#ifdef NBPC
+#define getpagesize() NBPC
+#endif /* NBPC */
+#endif /* no NBPG */
+#endif /* no EXEC_PAGESIZE */
+#endif /* no _SC_PAGESIZE */
+
+#endif /* not HAVE_GETPAGESIZE */
new file mode 100644
--- /dev/null
+++ b/kpathsea/hash.h
@@ -0,0 +1,61 @@
+/* hash.h: declarations for a hash table.
+
+Copyright (C) 1994 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef HASH_H
+#define HASH_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+
+/* A single (key,value) pair.  */
+typedef struct hash_element_struct
+{
+  const_string key;
+  const_string value;
+  struct hash_element_struct *next;
+} hash_element_type;
+
+/* The usual arrangement of buckets initialized to null.  */
+typedef struct
+{
+  hash_element_type **buckets;
+  unsigned size;
+} hash_table_type;
+
+#ifdef DEBUG
+/* How to print the hash results when debugging.  */
+extern boolean kpse_debug_hash_lookup_int;
+#endif
+
+/* Create a hash table of size SIZE.  */
+extern hash_table_type hash_create P1H(unsigned size);
+
+/* Insert the (KEY,VALUE) association into TABLE.  KEY may have more
+   than one VALUE.  Neither KEY nor VALUE is copied.  */
+extern void hash_insert P3H(hash_table_type *table,  const_string key,
+                            const_string value);
+
+/* Look up KEY in MAP, and return NULL-terminated list of all matching
+   values (not copies), in insertion order.  If none, return NULL.  */
+extern string *hash_lookup P2H(hash_table_type table, const_string key);
+
+/* Print TABLE to stdout.  */
+extern void hash_print P1H(hash_table_type table);
+
+#endif /* not HASH_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/lib.h
@@ -0,0 +1,154 @@
+/* lib.h: declarations for common, low-level routines in kpathsea.
+
+Copyright (C) 1992, 93, 94 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_LIB_H
+#define KPATHSEA_LIB_H
+
+#include <kpathsea/types.h>
+
+/* Define common sorts of messages.  */
+
+/* This should be called only after a system call fails.  Don't exit
+   with status `errno', because that might be 256, which would mean
+   success (exit statuses are truncated to eight bits).  */
+#define FATAL_PERROR(s) do { perror (s); exit (EXIT_FAILURE); } while (0)
+
+
+#define START_FATAL() do { fputs ("fatal: ", stderr)
+#define END_FATAL() fputs (".\n", stderr); exit (1); } while (0)
+
+#define FATAL(str)							\
+  START_FATAL (); fputs (str, stderr); END_FATAL ()
+#define FATAL1(str, e1)							\
+  START_FATAL (); fprintf (stderr, str, e1); END_FATAL ()
+#define FATAL2(str, e1, e2)						\
+  START_FATAL (); fprintf (stderr, str, e1, e2); END_FATAL ()
+#define FATAL3(str, e1, e2, e3)						\
+  START_FATAL (); fprintf (stderr, str, e1, e2, e3); END_FATAL ()
+#define FATAL4(str, e1, e2, e3, e4)					\
+  START_FATAL (); fprintf (stderr, str, e1, e2, e3, e4); END_FATAL ()
+#define FATAL6(str, e1, e2, e3, e4, e5, e6)				\
+  START_FATAL (); fprintf (stderr, str, e1, e2, e3, e4, e5, e6); END_FATAL ()
+
+
+#define START_WARNING() do { fputs ("warning: ", stderr)
+#define END_WARNING() fputs (".\n", stderr); fflush (stderr); } while (0)
+
+#define WARNING(str)							\
+  START_WARNING (); fputs (str, stderr); END_WARNING ()
+#define WARNING1(str, e1)						\
+  START_WARNING (); fprintf (stderr, str, e1); END_WARNING ()
+#define WARNING2(str, e1, e2)						\
+  START_WARNING (); fprintf (stderr, str, e1, e2); END_WARNING ()
+#define WARNING3(str, e1, e2, e3)					\
+  START_WARNING (); fprintf (stderr, str, e1, e2, e3); END_WARNING ()
+#define WARNING4(str, e1, e2, e3, e4)					\
+  START_WARNING (); fprintf (stderr, str, e1, e2, e3, e4); END_WARNING ()
+
+
+/* I find this easier to read.  */
+#define STREQ(s1, s2) (strcmp (s1, s2) == 0)
+
+/* This is the maximum number of numerals that result when a 64-bit
+   integer is converted to a string, plus one for a trailing null byte,
+   plus one for a sign.  */
+#define MAX_INT_LENGTH 21
+
+/* If the environment variable TEST is set, return it; otherwise,
+   DEFAULT.  This is useful for paths that use more than one envvar.  */
+#define ENVVAR(test, default) (getenv (test) ? (test) : (default))
+
+/* Return a fresh copy of S1 followed by S2, et al.  */
+extern string concat P2H(const_string s1, const_string s2);
+extern string concat3 P3H(const_string, const_string, const_string);
+/* `concatn' is declared in its own include file, to avoid pulling in
+   all the varargs stuff.  */
+
+/* A fresh copy of just S.  */
+extern string xstrdup P1H(const_string s);
+
+/* Convert all lowercase characters in S to uppercase.  */
+extern string uppercasify P1H(const_string s);
+
+/* Convert the integer I to a string.  */
+extern string itoa P1H(int i);
+
+/* True if FILENAME1 and FILENAME2 are the same file.  If stat fails on
+   either name, return false, no error message.
+   Cf. `SAME_FILE_P' in xstat.h.  */
+extern boolean same_file_p P2H(const_string filename1, const_string filename2);
+
+#ifndef HAVE_BASENAME
+/* Return NAME with any leading path stripped off.  This returns a
+   pointer into NAME.  */
+extern const_string basename P1H(const_string name);
+#endif /* not HAVE_BASENAME */
+
+/* If NAME has a suffix, return a pointer to its first character (i.e.,
+   the one after the `.'); otherwise, return NULL.  */
+extern string find_suffix P1H(const_string name);
+
+/* Return NAME with any suffix removed.  */
+extern string remove_suffix P1H(const_string name);
+
+/* Return S with the suffix SUFFIX, removing any suffix already present.
+   For example, `make_suffix ("/foo/bar.baz", "karl")' returns
+   `/foo/bar.karl'.  Returns a string allocated with malloc.  */
+extern string make_suffix P2H(const_string s,  const_string suffix);
+
+/* Return NAME with STEM_PREFIX prepended to the stem. For example,
+   `make_prefix ("/foo/bar.baz", "x")' returns `/foo/xbar.baz'.
+   Returns a string allocated with malloc.  */
+extern string make_prefix P2H(string stem_prefix, string name);
+
+/* If NAME has a suffix, simply return it; otherwise, return
+   `NAME.SUFFIX'.  */
+extern string extend_filename P2H(const_string name, const_string suffix);
+
+/* Call putenv with the string `VAR=VALUE' and abort on error.  */
+extern void xputenv P2H(const_string var, const_string value);
+extern void xputenv_int P2H(const_string var, int value);
+
+/* Returns true if FN is a directory or a symlink to a directory.  */
+extern boolean dir_p P1H(const_string fn);
+
+/* If FN is a readable directory, return the number of links it has.
+   Otherwise, return -1.  */
+extern int dir_links P1H(const_string fn);
+
+/* Like their stdio counterparts, but abort on error, after calling
+   perror(3) with FILENAME as its argument.  */
+extern FILE *xfopen P2H(const_string filename, const_string mode);
+extern void xfclose P2H(FILE *, const_string filename);
+extern void xfseek P4H(FILE *, long, int, string filename);
+extern unsigned long xftell P2H(FILE *, string filename);
+
+
+/* These call the corresponding function in the standard library, and
+   abort if those routines fail.  Also, `xrealloc' calls `xmalloc' if
+   OLD_ADDRESS is null.  */
+extern address xmalloc P1H(unsigned size);
+extern address xrealloc P2H(address old_address, unsigned new_size);
+extern address xcalloc P2H(unsigned nelem, unsigned elsize);
+
+/* (Re)Allocate N items of type T using xmalloc/xrealloc.  */
+#define XTALLOC(n, t) ((t *) xmalloc ((n) * sizeof (t)))
+#define XTALLOC1(t) XTALLOC (1, t)
+#define XRETALLOC(addr, n, t) ((addr) = (t *) xrealloc (addr, (n) * sizeof(t)))
+
+#endif /* not KPATHSEA_LIB_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/line.h
@@ -0,0 +1,31 @@
+/* line.h: read an arbitrary-length input line.
+
+Copyright (C) 1992 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef LINE_H
+#define LINE_H
+
+#include <stdio.h>
+#include <kpathsea/types.h>
+
+
+/* Return NULL if we are at EOF, else the next line of F.  The newline
+   character at the end of string is removed.  The string is allocated
+   with malloc.  */
+extern string read_line P1H(FILE *f);
+
+#endif /* not LINE_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/magstep.h
@@ -0,0 +1,45 @@
+/* magstep.h: declaration for magstep fixing.
+
+Copyright (C) 1994 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_MAGSTEP_H
+#define KPATHSEA_MAGSTEP_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+/* If DPI is close enough to some magstep of BDPI, return the true dpi
+   value, and the magstep found (or zero) in M_RET (if
+   non-null). ``Close enough'' means within one pixel.
+   
+   M_RET is slightly encoded: the least significant bit is on for a
+   half-magstep, off otherwise.  Thus, a returned M_RET of 1 means
+   \magstephalf, i.e., sqrt(1.2), i.e., 1.09544.  Put another way,
+   return twice the number of magsteps.
+   
+   In practice, this matters for magstephalf.  Floating-point computation
+   with the fixed-point DVI representation leads to 328 (for BDPI ==
+   300); specifying `at 11pt' yields 330; the true \magstephalf is 329
+   (that's what you get if you run Metafont with mag:=magstep(.5)).
+   
+   The time to call this is after you read the font spec from the DVI
+   file, but before you look up any files -- do the usual floating-point
+   computations, and then fix up the result.  */
+
+extern unsigned kpse_magstep_fix P3H(unsigned dpi, unsigned bdpi, int *m_ret);
+
+#endif /* not KPATHSEA_MAGSTEP_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/pathsearch.h
@@ -0,0 +1,71 @@
+/* pathsearch.h: generic path searching.
+
+Copyright (C) 1993, 94 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_PATHSEARCH_H
+#define KPATHSEA_PATHSEARCH_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/str-llist.h>
+#include <kpathsea/types.h>
+
+/* If PATH is non-null, return its first element (as defined by
+   IS_ENV_SEP).  If it's NULL, return the next element in the previous
+   path, a la strtok.  Leading, trailing, or doubled colons result in
+   the empty string.  When at the end of PATH, return NULL.  In any
+   case, return a pointer to an area that may be overwritten on
+   subsequent calls.  */
+extern string kpse_path_element P1H(const_string path);
+
+
+/* Given a path element ELT, return a pointer to a NULL-terminated list
+   of the corresponding (existing) directory or directories, with
+   trailing slashes, or NULL.  If ELT is the empty string, check the
+   current working directory.
+   
+   It's up to the caller to expand ELT.  This is because this routine is
+   most likely only useful to be called from `kpse_path_search', which
+   has already assumed expansion has been done.  */
+extern str_llist_type *kpse_element_dirs P1H(const_string elt);
+
+
+/* Call `kpse_expand' on NAME.  If the result is an absolute or
+   explicitly relative filename, check whether it is a readable
+   (regular) file.
+   
+   Otherwise, look in each of the directories specified in PATH (also do
+   tilde and variable expansion on elements in PATH), using a prebuilt
+   db (see db.h) if it's relevant for a given path element.
+   
+   If the prebuilt db doesn't exist, or if MUST_EXIST is true and NAME
+   isn't found in the prebuilt db, look on the filesystem.  (I.e., if
+   MUST_EXIST is false, and NAME isn't found in the db, do *not* look on
+   the filesystem.)
+   
+   The caller must expand PATH. This is because it makes more sense to
+   do this once, in advance, instead of for every search using it.
+   
+   In any case, return the complete filename if found, otherwise NULL.  */
+extern string kpse_path_search P3H(const_string path, const_string name,
+                                   boolean must_exist);
+
+
+/* Like `kpse_path_search' with MUST_EXIST true, but return a list of
+   all the filenames (or NULL if none), instead of taking the first.  */
+extern string *kpse_all_path_search P2H(const_string path, const_string name);
+
+#endif /* not KPATHSEA_PATHSEARCH_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/proginit.h
@@ -0,0 +1,34 @@
+/* proginit.h: declarations for DVI driver initializations.
+
+Copyright (C) 1994, 95 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_PROGINIT_H
+#define KPATHSEA_PROGINIT_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+
+/* Common initializations for DVI drivers -- check for `PREFIX'SIZES and
+   `PREFIX'FONTS environment variables, setenv MAKETEX_MODE to MODE,
+   etc., etc.  See the source.  */
+
+extern void
+kpse_init_prog P5H(const_string prefix,  unsigned dpi,  const_string mode,
+                   boolean make_tex_pk,  const_string fallback);
+
+#endif /* not KPATHSEA_PROGINIT_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/progname.h
@@ -0,0 +1,35 @@
+/* progname.h: Declarations for argv[0] equivalents.
+
+Copyright (C) 1994 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_PROGNAME_H
+#define KPATHSEA_PROGNAME_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+extern string program_invocation_name;
+extern string program_invocation_short_name;
+
+
+/* Set the two variables above (if they're not predefined) to a copy of
+   ARGV0 and everything in ARGV0 after the last directory separator,
+   respectively.  */
+
+extern void kpse_set_progname P1H(const_string argv0);
+
+#endif /* not KPATHSEA_PROGNAME_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/readable.h
@@ -0,0 +1,31 @@
+/* readable.h: Is a file readable?
+
+Copyright (C) 1993 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_READABLE_H
+#define KPATHSEA_READABLE_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+/* If NAME is readable and is a regular file, return it.  If the error is
+   ENAMETOOLONG, truncate any too-long path components, and if the
+   result is a readable file, return that.  Otherwise return NULL.  */
+   
+extern string kpse_readable_file P1H(const_string name);
+
+#endif /* not KPATHSEA_READABLE_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/str-list.h
@@ -0,0 +1,54 @@
+/* str-list.h: Declarations for string lists.
+
+Copyright (C) 1993, 94 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_STR_LIST_H
+#define KPATHSEA_STR_LIST_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+
+/* Lists of strings; used for, e.g., directory lists.  */
+
+typedef struct
+{
+  unsigned length;
+  string *list;
+} str_list_type;
+
+#define STR_LIST_LENGTH(l) ((l).length)
+#define STR_LIST(l) ((l).list)
+#define STR_LIST_ELT(l, n) STR_LIST (l)[n]
+#define STR_LIST_LAST_ELT(l) STR_LIST_ELT (l, STR_LIST_LENGTH (l) - 1)
+
+/* Return a new, empty, list.  */
+extern str_list_type str_list_init P1H(void);
+
+/* Append the string S to the list L.  It's up to the caller to not
+   deallocate S; we don't copy it.  Also up to the caller to terminate
+   the list with a null entry.  */
+extern void str_list_add P2H(str_list_type *l, string s);
+
+/* Append all the elements from MORE to TARGET.  */
+extern void str_list_concat P2H(str_list_type * target, str_list_type more);
+
+/* Free the space for the list elements (but not the list elements
+   themselves).  */
+extern void str_list_free P1H(str_list_type *l);
+
+#endif /* not KPATHSEA_STR_LIST_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/str-llist.h
@@ -0,0 +1,56 @@
+/* str-llist.h: A linked list of strings,
+
+It's pretty disgusting that both this and str-list exist; the reason is
+that C cannot express iterators very well, and I don't want to change
+all the for loops right now.
+
+Copyright (C) 1993, 94 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef STR_LLIST_H
+#define STR_LLIST_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+
+/* It's a little bizarre to be using the same type for the list and the
+   elements of the list, but no reason not to in this case, I think --
+   we never need a NULL string in the middle of the list, and an extra
+   NULL/NULL element always at the end is inconsequential.  */
+
+struct str_llist_elt
+{
+  string str;
+  boolean moved;
+  struct str_llist_elt *next;
+};
+typedef struct str_llist_elt str_llist_elt_type;
+typedef struct str_llist_elt *str_llist_type;
+
+#define STR_LLIST(sl) ((sl).str)
+#define STR_LLIST_MOVED(sl) ((sl).moved)
+#define STR_LLIST_NEXT(sl) ((sl).next)
+
+
+/* Add the new string E to the end of the list L.  */
+extern void str_llist_add P2H(str_llist_type *l, string e);
+
+/* Reorganize L so that E is below only other elements that have already
+   been moved.  Set `moved' member for E.  */
+extern void str_llist_float P2H(str_llist_type *l, str_llist_elt_type *e);
+
+#endif /* not STR_LLIST_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/systypes.h
@@ -0,0 +1,30 @@
+/* c-systypes.h: include <sys/types.h>.  It's too bad we need this file,
+   but some systems don't protect <sys/types.h> from multiple
+   inclusions, and I'm not willing to put up with that.
+
+Copyright (C) 1993 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef C_SYSTYPES_H
+#define C_SYSTYPES_H
+
+#include <sys/types.h>
+
+/* This is the symbol that X uses to determine if <sys/types.h> has been
+   read, so we define it.  */
+#define __TYPES__
+
+#endif /* not C_SYSTYPES_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/tex-file.h
@@ -0,0 +1,120 @@
+/* tex-file.h: find files in a particular format.
+
+Copyright (C) 1993, 94 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_TEX_FILE_H
+#define KPATHSEA_TEX_FILE_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+
+/* If non-NULL, try looking for this if can't find the real font.  */
+extern const_string kpse_fallback_font;
+
+
+/* If non-NULL, check these if can't find (within a few percent of) the
+   given resolution.  List must end with a zero element.  */
+extern unsigned *kpse_fallback_resolutions;
+
+/* This initializes the fallback resolution list.  If ENVVAR
+   is set, it is used; otherwise, the envvar `TEXSIZES' is looked at; if
+   that's not set either, a compile-time default is used.  */
+extern void kpse_init_fallback_resolutions P1H(string envvar);
+
+
+/* If non-null, used instead of the usual envvar/path defaults, e.g.,
+   set to `getenv ("XDVIFONTS")'.  */
+extern string kpse_font_override_path;
+
+/* We put the glyphs first so we don't waste space in an array.  A new
+   format here must be accompanied by a new initialization
+   abbreviation below and a new entry in `tex-make.c'.  */
+typedef enum
+{
+  kpse_gf_format,
+  kpse_pk_format,
+  kpse_any_glyph_format,	/* ``any'' meaning anything above */
+  kpse_base_format, 
+  kpse_bib_format, 
+  kpse_bst_format, 
+  kpse_cnf_format,
+  kpse_fmt_format,
+  kpse_mf_format, 
+  kpse_mfpool_format, 
+  kpse_pict_format,
+  kpse_tex_format,
+  kpse_texpool_format,
+  kpse_tfm_format, 
+  kpse_vf_format,
+  kpse_dvips_config_format,
+  kpse_dvips_header_format,
+  kpse_last_format /* one past last index */
+} kpse_file_format_type;
+
+
+/* For each file format, we record the following information.  The main
+   thing that is not part of this structure is the environment variable
+   lists above. They are used directly in tex-file.c. We could
+   incorporate them here, but it would complicate the code a bit. We
+   could also do it via variable expansion, but not now, maybe not ever:
+   ${PKFONTS-${TEXFONTS-/usr/local/lib/texmf/fonts//}}.  */
+
+typedef struct
+{
+  const_string type;		/* Human-readable description.  */
+  const_string path;		/* The search path to use.  */
+  const_string raw_path;	/* Pre-$~ (but post-default) expansion.  */
+  const_string path_source;	/* Where the path started from.  */
+  boolean font_override_p;	/* Use kpse_font_override_path?  */
+  const_string client_path;	/* E.g., from dvips's config.ps.  */
+  const_string cnf_path;	/* From our texmf.cnf.  */
+  const_string default_path;	/* If all else fails.  */
+  const_string suffix;		/* For kpse_find_file to append, or NULL.  */
+  boolean suffix_search_only;	/* Only search if the suffix is present?  */
+  const_string program;		/* ``MakeTeXPK'', etc.  */
+  const_string program_args;	/* Args to the `program'.  */
+  boolean program_enabled_p;	/* Invoke the `program'?  */
+} kpse_format_info_type;
+
+/* The sole variable of that type, indexed by `kpse_file_format_type'.
+   Initialized by calls to `kpse_find_file' for `kpse_init_format'.  */
+extern kpse_format_info_type kpse_format_info[];
+
+
+/* Initialize the info for the given format.  This is called
+   automatically by `kpse_find_file', but the glyph searching (for
+   example) can't use that function, so make it available.  */
+extern const_string kpse_init_format P1H(kpse_file_format_type);
+
+/* If FORMAT has a non-null `suffix' member, concatenate NAME "." and it
+   and call `kpse_path_search' with the result and the other arguments.
+   If that fails, try just NAME.  */
+extern string kpse_find_file P3H(const_string name,  
+                            kpse_file_format_type format,  boolean must_exist);
+
+/* Here are some abbreviations.  */
+#define kpse_find_pict(name) kpse_find_file (name, kpse_pict_format, true)
+#define kpse_find_tex(name)  kpse_find_file (name, kpse_tex_format, true)
+#define kpse_find_tfm(name)  kpse_find_file (name, kpse_tfm_format, true)
+
+/* The `false' is correct for DVI translators, which should clearly not
+   require vf files for every font (e.g., cmr10.vf).  But it's wrong for
+   VF translators, such as vftovp.  */
+#define kpse_find_vf(name) kpse_find_file (name, kpse_vf_format, false)
+
+#endif /* not KPATHSEA_TEX_FILE_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/tex-glyph.h
@@ -0,0 +1,78 @@
+/* tex-glyph.h: look for a TeX glyph font (GF or PK).
+
+Copyright (C) 1993 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_TEX_GLYPH_H
+#define KPATHSEA_TEX_GLYPH_H
+
+#include <kpathsea/tex-file.h>
+
+
+/* This type describes the origination of a glyph font.  */
+
+typedef enum
+{
+  kpse_glyph_source_normal,  /* the searched-for font: already existed */
+  kpse_glyph_source_alias,   /* : was an alias for an existing file */
+  kpse_glyph_source_maketex, /* : was created on the fly */
+  kpse_glyph_source_fallback /* : wasn't found, but the fallback font was */
+} kpse_glyph_source_type;
+
+
+typedef struct
+{
+  string name;			/* font name found */
+  unsigned dpi;			/* size found, for glyphs */
+  kpse_file_format_type format;	/* glyph format found */
+  kpse_glyph_source_type source;	/* where we found it */
+} kpse_glyph_file_type;		
+
+#define KPSE_GLYPH_FILE_NAME(f) ((f).name)
+#define KPSE_GLYPH_FILE_DPI(f) ((f).dpi)
+#define KPSE_GLYPH_FILE_FORMAT(f) ((f).format)
+#define KPSE_GLYPH_FILE_SOURCE(f) ((f).source)
+
+
+/* Search first for the font named FONT_NAME at resolution DPI in the
+   glyph format FORMAT (see `try_size' for details of format searching).
+   Then try resolutions within KPSE_BITMAP_TOLERANCE of DPI.  Then try
+   the resolutions in `kpse_fallback_sizes', then within the tolerance
+   of each of those.  Then if FONT_NAME is an alias defined in a
+   texfonts.map do all the above for its real name.  Then try the above
+   for kpse_fallback_name.  Then fail.  Return either the filename
+   found, or NULL.  Also return information about the file found in
+   *GLYPH_FILE.  */
+extern string kpse_find_glyph P4H(const_string font_name, unsigned dpi, 
+                                  kpse_file_format_type format,
+                                  kpse_glyph_file_type *glyph_file);
+
+/* Look for a specific format only.  */
+#define kpse_find_pk(font_name, dpi, glyph_file) \
+  kpse_find_glyph (font_name, dpi, kpse_pk_format, glyph_file)
+#define kpse_find_gf(font_name, dpi, glyph_file) \
+  kpse_find_glyph (font_name, dpi, kpse_gf_format, glyph_file)
+
+
+/* Defines how far away a pixel file can be found from its stated size.
+   The DVI standard says any resolution within 0.2% of the stated size
+   is ok, but we are more forgiving.  */
+#define KPSE_BITMAP_TOLERANCE(r) ((r) / 500.0 + 1)
+
+/* Check whether DPI1 is within KPSE_BITMAP_TOLERANCE of DPI2. */
+extern boolean kpse_bitmap_tolerance P2H(double dpi1, double dpi2);
+
+#endif /* not KPATHSEA_TEX_GLYPH_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/tex-make.h
@@ -0,0 +1,39 @@
+/* tex-make.h: declarations for executing external scripts.
+
+Copyright (C) 1993, 94 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_TEX_MAKE_H
+#define KPATHSEA_TEX_MAKE_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/tex-file.h>
+#include <kpathsea/types.h>
+
+
+/* Says whether to throw away stderr output from the MakeTeX... scripts,
+   or let it be seen.  */
+extern boolean kpse_make_tex_discard_errors;
+
+
+/* Run a program to create a file named by BASE_FILE in format FORMAT.
+   Return the full filename to it, or NULL.  Any other information about
+   the file is passed through environment variables.  See the MakeTeXPK
+   stuff in `tex-make.c' for an example. */
+extern string kpse_make_tex P2H(kpse_file_format_type format,
+                                const_string base_file);
+
+#endif /* not KPATHSEA_TEX_MAKE_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/tilde.h
@@ -0,0 +1,31 @@
+/* tilde.h: Declare tilde expander.
+
+Copyright (C) 1993 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_TILDE_H
+#define KPATHSEA_TILDE_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+
+/* Replace a leading ~ or ~name in FILENAME with getenv ("HOME") or
+   name's home directory, respectively.  FILENAME may not be null.  */
+
+extern string kpse_tilde_expand P1H(const_string filename);
+
+#endif /* not KPATHSEA_TILDE_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/truncate.h
@@ -0,0 +1,30 @@
+/* truncate.h: truncate too-long components in a filename.
+
+Copyright (C) 1993 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_TRUNCATE_H
+#define KPATHSEA_TRUNCATE_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+/* Truncate any component in NAME longer than the system NAME_MAX, and
+   return the result as a malloced string.  If none, return a copy of
+   NAME.  */
+extern string kpse_truncate_filename P1H(const_string name);
+
+#endif /* not KPATHSEA_TRUNCATE_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/types.h
@@ -0,0 +1,43 @@
+/* types.h: general types.
+
+Copyright (C) 1993 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_TYPES_H
+#define KPATHSEA_TYPES_H
+
+/* Booleans.  */
+typedef enum { false = 0, true = 1 } boolean;
+
+/* The X11 library defines `FALSE' and `TRUE', and so we only want to
+   define them if necessary.  */
+#ifndef FALSE
+#define FALSE false
+#define TRUE true
+#endif /* FALSE */
+
+/* The usual null-terminated string.  */
+typedef char *string;
+
+/* A pointer to constant data.  (ANSI says `const string' is
+   `char const *', which is a constant pointer, which is not what we
+   typically want.)  */
+typedef const char *const_string;
+
+/* A generic pointer.  */
+typedef void *address;
+
+#endif /* not KPATHSEA_TYPES_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/variable.h
@@ -0,0 +1,36 @@
+/* variable.h: Declare variable expander.
+
+Copyright (C) 1993 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_VARIABLE_H
+#define KPATHSEA_VARIABLE_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+
+/* Expand $VAR and ${VAR} references in SRC, returning the (always
+   dynamically-allocated) result.  An unterminated ${ or any other
+   character following $ produce error messages, and that part of SRC is
+   ignored.  In the $VAR form, the variable name consists of consecutive
+   letters, digits, and underscores.  In the ${VAR} form, the variable
+   name consists of whatever is between the braces.  In any case,
+   ``expansion'' just means calling `getenv'; if the variable is not
+   set, the expansion is the empty string.  */
+extern string kpse_var_expand P1H(const_string src);
+
+#endif /* not KPATHSEA_VARIABLE_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/xopendir.h
@@ -0,0 +1,30 @@
+/* xopendir.h: Checked directory operations.
+
+Copyright (C) 1994 Karl Berry.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_XDIR_H
+#define KPATHSEA_XDIR_H
+
+#include <kpathsea/c-dir.h>
+#include <kpathsea/c-proto.h>
+#include <kpathsea/types.h>
+
+/* Like opendir and closedir, but abort on error.  */
+extern DIR *xopendir P1H(string dirname);
+extern void xclosedir P1H(DIR *);
+
+#endif /* not KPATHSEA_XDIR_H */
new file mode 100644
--- /dev/null
+++ b/kpathsea/xstat.h
@@ -0,0 +1,42 @@
+/* xstat.h: stat with error checking.
+
+Copyright (C) 1992, 93, 94 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+#ifndef KPATHSEA_XSTAT_H
+#define KPATHSEA_XSTAT_H
+
+#include <kpathsea/c-proto.h>
+#include <kpathsea/c-stat.h>
+#include <kpathsea/types.h>
+
+/* Two files are indistinguishable if they are on the same device
+   and have the same inode.  This checks two stat buffers for that.  Cf.
+   the `same_file_p' routine in file-p.c, declared in kpathlib.h.  */
+#define SAME_FILE_P(s1, s2) \
+  ((s1).st_ino == (s2).st_ino && (s1).st_dev == (s2).st_dev)
+
+/* Does stat(2) on PATH, and aborts if the stat fails.  */
+extern struct stat xstat P1H(const_string path);
+
+/* Ditto, for lstat(2) (except that lstat might not exist).  */
+#ifdef S_ISLNK
+extern struct stat xlstat P1H(const_string path);
+#else
+#define xlstat xstat
+#endif
+
+#endif /* not KPATHSEA_XSTAT_H */