[PATCH libXfont] Eliminate calls back to X server or font server functions by name

Keith Packard keithp at keithp.com
Wed Sep 2 00:15:06 PDT 2015


This eliminates the weak symbol adventures and makes all of the calls
back to the X server or Font server go through a table of functions
instead, clarifying the required API.

As this is a rather major change to the API for the library, it now
installs itself as libXfont_2 instead of libXfont, and the package
config file is now xfont_2.pc.

All of the installed headers remain the same as the original library;
there's now a new include file, libxfont_2.h, which defines the X
server and Font server interfaces.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 Makefile.am                    |   7 +-
 configure.ac                   |   4 +-
 include/X11/fonts/bufio.h      |   2 +-
 include/X11/fonts/fontmisc.h   |   2 +-
 include/X11/fonts/libxfont_2.h |  81 +++++++++++++
 include/libxfontint.h          |  90 +++++++++++++++
 src/FreeType/ft.h              |   2 -
 src/FreeType/ftenc.c           |   1 +
 src/FreeType/ftfuncs.c         |   1 +
 src/FreeType/fttools.c         |   1 +
 src/FreeType/xttcap.c          |   1 +
 src/Makefile.am                |   8 +-
 src/bitmap/bdfread.c           |   1 +
 src/bitmap/bdfutils.c          |   1 +
 src/bitmap/bitmap.c            |   1 +
 src/bitmap/bitmapfunc.c        |   1 +
 src/bitmap/bitmaputil.c        |   1 +
 src/bitmap/bitscale.c          |   4 +-
 src/bitmap/fontink.c           |   1 +
 src/bitmap/pcfread.c           |   1 +
 src/bitmap/pcfwrite.c          |   7 +-
 src/bitmap/snfread.c           |   1 +
 src/builtins/dir.c             |   1 +
 src/builtins/file.c            |   1 +
 src/builtins/fonts.c           |   1 +
 src/builtins/fpe.c             |  36 +++---
 src/builtins/render.c          |   1 +
 src/fc/fsconvert.c             |   1 +
 src/fc/fserve.c                |  44 ++++----
 src/fc/fserve.h                |   9 --
 src/fc/fsio.c                  |   1 +
 src/fc/fstrans.c               |   2 +
 src/fontfile/bitsource.c       |   1 +
 src/fontfile/bufio.c           |   3 +-
 src/fontfile/bunzip2.c         |   1 +
 src/fontfile/catalogue.c       |  36 +++---
 src/fontfile/decompress.c      |   1 +
 src/fontfile/defaults.c        |   1 +
 src/fontfile/dirfile.c         |   1 +
 src/fontfile/fileio.c          |   1 +
 src/fontfile/filewr.c          |   1 +
 src/fontfile/fontdir.c         |   1 +
 src/fontfile/fontencc.c        |   3 +-
 src/fontfile/fontfile.c        |  36 +++---
 src/fontfile/fontscale.c       |   1 +
 src/fontfile/gunzip.c          |   1 +
 src/fontfile/register.c        |   1 +
 src/fontfile/renderers.c       |   3 +-
 src/stubs/Makefile.am          |  19 +---
 src/stubs/atom.c               | 234 ++++++++++++++++++++++++++++++++++++++
 src/stubs/cauthgen.c           |  15 ---
 src/stubs/csignal.c            |  15 ---
 src/stubs/delfntcid.c          |  14 ---
 src/stubs/errorf.c             |  14 ---
 src/stubs/findoldfnt.c         |  15 ---
 src/stubs/getcres.c            |  15 ---
 src/stubs/getdefptsize.c       |  15 ---
 src/stubs/getnewfntcid.c       |  15 ---
 src/stubs/gettime.c            |  15 ---
 src/stubs/initfshdl.c          |  16 ---
 src/stubs/libxfontstubs.c      | 169 ++++++++++++++++++++++++++++
 src/stubs/regfpefunc.c         |  32 ------
 src/stubs/rmfshdl.c            |  16 ---
 src/stubs/servclient.c         |  19 ----
 src/stubs/setfntauth.c         |  15 ---
 src/stubs/stfntcfnt.c          |  15 ---
 src/stubs/stubs.h              |  88 ---------------
 src/stubs/stubsinit.c          |  82 --------------
 src/util/Makefile.am           |   1 -
 src/util/atom.c                | 250 -----------------------------------------
 src/util/fontaccel.c           |   1 +
 src/util/fontnames.c           |   1 +
 src/util/fontutil.c            |   1 +
 src/util/fontxlfd.c            |   1 +
 src/util/format.c              |   1 +
 src/util/miscutil.c            |  23 +---
 src/util/patcache.c            |   1 +
 src/util/private.c             |   1 +
 src/util/utilbitmap.c          |   1 +
 xfont.pc.in                    |  13 ---
 xfont_2.pc.in                  |  13 +++
 81 files changed, 738 insertions(+), 816 deletions(-)
 create mode 100644 include/X11/fonts/libxfont_2.h
 create mode 100644 include/libxfontint.h
 create mode 100644 src/stubs/atom.c
 delete mode 100644 src/stubs/cauthgen.c
 delete mode 100644 src/stubs/csignal.c
 delete mode 100644 src/stubs/delfntcid.c
 delete mode 100644 src/stubs/errorf.c
 delete mode 100644 src/stubs/findoldfnt.c
 delete mode 100644 src/stubs/getcres.c
 delete mode 100644 src/stubs/getdefptsize.c
 delete mode 100644 src/stubs/getnewfntcid.c
 delete mode 100644 src/stubs/gettime.c
 delete mode 100644 src/stubs/initfshdl.c
 create mode 100644 src/stubs/libxfontstubs.c
 delete mode 100644 src/stubs/regfpefunc.c
 delete mode 100644 src/stubs/rmfshdl.c
 delete mode 100644 src/stubs/servclient.c
 delete mode 100644 src/stubs/setfntauth.c
 delete mode 100644 src/stubs/stfntcfnt.c
 delete mode 100644 src/stubs/stubs.h
 delete mode 100644 src/stubs/stubsinit.c
 delete mode 100644 src/util/atom.c
 delete mode 100644 xfont.pc.in
 create mode 100644 xfont_2.pc.in

diff --git a/Makefile.am b/Makefile.am
index 7ec3188..cf8c9df 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,13 +35,18 @@ libXfontinclude_HEADERS = \
 	include/X11/fonts/fontutil.h \
 	include/X11/fonts/fontxlfd.h \
 	include/X11/fonts/pcf.h      \
+	include/X11/fonts/libxfont_2.h \
 	src/FreeType/ft.h	     \
 	src/FreeType/ftfuncs.h
+
+noinst_HEADERS = \
+	include/libxfontint.h
+
 nodist_libXfontinclude_HEADERS = \
 	include/X11/fonts/fontconf.h
 
 pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = xfont.pc
+pkgconfig_DATA = xfont_2.pc
 
 MAINTAINERCLEANFILES = ChangeLog INSTALL
 
diff --git a/configure.ac b/configure.ac
index 7cb6bdf..cc27079 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@
 
 # Initialize Autoconf
 AC_PREREQ([2.60])
-AC_INIT([libXfont], [1.5.1],
+AC_INIT([libXfont], [2.0.0],
 	[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXfont])
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS([config.h include/X11/fonts/fontconf.h])
@@ -232,5 +232,5 @@ AC_CONFIG_FILES([Makefile
 		src/fc/Makefile
 		src/util/Makefile
 		src/stubs/Makefile
-		xfont.pc])
+		xfont_2.pc])
 AC_OUTPUT
diff --git a/include/X11/fonts/bufio.h b/include/X11/fonts/bufio.h
index e7a9f4a..387533d 100644
--- a/include/X11/fonts/bufio.h
+++ b/include/X11/fonts/bufio.h
@@ -66,7 +66,7 @@ extern BufFilePtr BufFilePushBZIP2 ( BufFilePtr );
 #endif
 extern int BufFileClose ( BufFilePtr, int );
 extern int BufFileRead ( BufFilePtr, char*, int );
-extern int BufFileWrite ( BufFilePtr, char*, int );
+extern int BufFileWrite ( BufFilePtr, const char*, int );
 
 #define BufFileGet(f)	((f)->left-- ? *(f)->bufp++ : ((f)->eof = (*(f)->input) (f)))
 #define BufFilePut(c,f)	(--(f)->left ? *(f)->bufp++ = ((unsigned char)(c)) : (*(f)->output) ((unsigned char)(c),f))
diff --git a/include/X11/fonts/fontmisc.h b/include/X11/fonts/fontmisc.h
index d3926a7..06e49f5 100644
--- a/include/X11/fonts/fontmisc.h
+++ b/include/X11/fonts/fontmisc.h
@@ -54,7 +54,7 @@ in this Software without prior written authorization from The Open Group.
 
 extern Atom MakeAtom ( const char *string, unsigned len, int makeit );
 extern int ValidAtom ( Atom atom );
-extern char *NameForAtom (Atom atom);
+extern const char *NameForAtom (Atom atom);
 
 #define lowbit(x) ((x) & (~(x) + 1))
 
diff --git a/include/X11/fonts/libxfont_2.h b/include/X11/fonts/libxfont_2.h
new file mode 100644
index 0000000..bcf53f6
--- /dev/null
+++ b/include/X11/fonts/libxfont_2.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright © 2015 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _LIBXFONT_H_
+#define _LIBXFONT_H_
+
+#include	<stdarg.h>
+#include	<X11/Xfuncproto.h>
+
+#define FONT_FPE_FUNCS_VERSION	1
+
+typedef struct _font_fpe_funcs {
+	int		version;
+	NameCheckFunc	name_func;
+	InitFpeFunc	init_func;
+	FreeFpeFunc	free_func;
+	ResetFpeFunc	reset_func;
+	OpenFontFunc	open_func;
+	CloseFontFunc	close_func;
+	ListFontsFunc	list_func;
+	StartLfwiFunc	start_lfwi_func;
+	NextLfwiFunc	next_lfwi_func;
+	WakeupFpeFunc	wakeup_func;
+	ClientDiedFunc	client_died;
+	LoadGlyphsFunc	load_glyphs;
+	StartLaFunc	start_list_alias_func;
+	NextLaFunc	next_list_alias_func;
+	SetPathFunc	set_path_func;
+} font_fpe_funcs_rec, *font_fpe_funcs_ptr;
+
+#define FONT_CLIENT_FUNCS_VERSION	1
+
+typedef struct _font_client_funcs {
+	int			version;
+	int			(*client_auth_generation)(ClientPtr client);
+	Bool			(*client_signal)(ClientPtr client);
+	void			(*delete_font_client_id)(Font id);
+	void			(*verrorf)(const char *f, va_list ap) _X_ATTRIBUTE_PRINTF(1,0);
+	FontPtr			(*find_old_font)(FSID id);
+	FontResolutionPtr	(*get_client_resolutions)(int *num);
+	int			(*get_default_point_size)(void);
+	Font			(*get_new_font_client_id)(void);
+	uint32_t		(*get_time_in_millis)(void);
+	int			(*init_fs_handlers)(FontPathElementPtr fpe,
+						    BlockHandlerProcPtr block_handler);
+	int			(*register_fpe_funcs)(const font_fpe_funcs_rec *funcs);
+	void			(*remove_fs_handlers)(FontPathElementPtr fpe,
+						      BlockHandlerProcPtr block_handler,
+						      Bool all );
+	void			*(*get_server_client)(void);
+	int			(*set_font_authorizations)(char **authorizations,
+							   int *authlen, void *client);
+	int			(*store_font_client_font)(FontPtr pfont, Font id);
+	Atom			(*make_atom)(const char *string, unsigned len, int makeit);
+	int			(*valid_atom)(Atom atom);
+	const char		*(*name_for_atom)(Atom atom);
+	unsigned long		(*get_server_generation)(void);
+} font_client_funcs_rec, *font_client_funcs_ptr;
+
+extern void	font_register_client_funcs(font_client_funcs_rec const *client_funcs);
+
+#endif /* _LIBXFONT_H_ */
diff --git a/include/libxfontint.h b/include/libxfontint.h
new file mode 100644
index 0000000..d690631
--- /dev/null
+++ b/include/libxfontint.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright © 2015 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _LIBXFONTINT_H_
+#define _LIBXFONTINT_H_
+
+#define client_auth_generation __libxfont__client_auth_generation
+#define ClientSignal __libxfont__ClientSignal
+#define DeleteFontClientID __libxfont__DeleteFontClientID
+#define ErrorF __libxfont__ErrorF
+#define find_old_font __libxfont__find_old_font
+#define GetClientResolutions __libxfont__GetClientResolutions
+#define GetDefaultPointSize __libxfont__GetDefaultPointSize
+#define GetNewFontClientID __libxfont__GetNewFontClientID
+#define GetTimeInMillis  __libxfont__GetTimeInMillis 
+#define init_fs_handlers __libxfont__init_fs_handlers
+#define remove_fs_handlers __libxfont__remove_fs_handlers
+#define __GetServerClient __libxfont____GetServerClient
+#define set_font_authorizations __libxfont__set_font_authorizations
+#define StoreFontClientFont __libxfont__StoreFontClientFont
+#define MakeAtom __libxfont__MakeAtom
+#define ValidAtom __libxfont__ValidAtom
+#define NameForAtom __libxfont__NameForAtom
+
+#include	<X11/fonts/FS.h>
+#include	<X11/fonts/FSproto.h>
+#include	<X11/X.h>
+#include	<X11/Xos.h>
+#include	<X11/fonts/fontmisc.h>
+#include	<X11/fonts/fontstruct.h>
+#include	<X11/fonts/fontutil.h>
+#include	<X11/fonts/fontproto.h>
+#include	<errno.h>
+#include	<limits.h>
+#include	<stdint.h>
+
+#include <X11/fonts/libxfont_2.h>
+
+#ifndef LIBXFONT_SKIP_ERRORF
+void
+ErrorF(const char *f, ...)  _X_ATTRIBUTE_PRINTF(1,2);
+#endif
+
+FontPtr
+find_old_font(FSID id);
+
+unsigned long
+GetTimeInMillis (void);
+
+int
+register_fpe_funcs(const font_fpe_funcs_rec *funcs);
+
+void *
+__GetServerClient(void);
+
+int
+set_font_authorizations(char **authorizations, int *authlen, ClientPtr client);
+
+unsigned long
+__GetServerGeneration (void);
+
+Atom
+__libxfont_internal__MakeAtom(const char *string, unsigned len, int makeit);
+
+int
+__libxfont_internal__ValidAtom(Atom atom);
+
+const char *
+__libxfont_internal__NameForAtom(Atom atom);
+
+#endif /* _LIBXFONTINT_H_ */
diff --git a/src/FreeType/ft.h b/src/FreeType/ft.h
index 8cf31d4..7fa86b0 100644
--- a/src/FreeType/ft.h
+++ b/src/FreeType/ft.h
@@ -82,6 +82,4 @@ unsigned FTRemap(FT_Face face, FTMappingPtr, unsigned code);
 int FTtoXReturnCode(int);
 int FTGetEnglishName(FT_Face, int, char *, int);
 
-extern void ErrorF(const char*, ...);
-
 #endif /* _FT_H_ */
diff --git a/src/FreeType/ftenc.c b/src/FreeType/ftenc.c
index 9e31d75..dfa5cab 100644
--- a/src/FreeType/ftenc.c
+++ b/src/FreeType/ftenc.c
@@ -23,6 +23,7 @@ THE SOFTWARE.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <string.h>
 
 #include <X11/fonts/fntfilst.h>
diff --git a/src/FreeType/ftfuncs.c b/src/FreeType/ftfuncs.c
index a4969d1..77344cd 100644
--- a/src/FreeType/ftfuncs.c
+++ b/src/FreeType/ftfuncs.c
@@ -29,6 +29,7 @@ THE SOFTWARE.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fontmisc.h>
 
 #include <string.h>
diff --git a/src/FreeType/fttools.c b/src/FreeType/fttools.c
index 8c5d08e..7c0bd9b 100644
--- a/src/FreeType/fttools.c
+++ b/src/FreeType/fttools.c
@@ -24,6 +24,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fontmisc.h>
 #include <ctype.h>
 #include <string.h>
diff --git a/src/FreeType/xttcap.c b/src/FreeType/xttcap.c
index cee752e..c6be080 100644
--- a/src/FreeType/xttcap.c
+++ b/src/FreeType/xttcap.c
@@ -41,6 +41,7 @@ static char const * const releaseID =
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fontmisc.h>
 #include <string.h>
 #include <ctype.h>
diff --git a/src/Makefile.am b/src/Makefile.am
index 33fd135..363a3ba 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -19,7 +19,7 @@
 #  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 #  PERFORMANCE OF THIS SOFTWARE.
 
-lib_LTLIBRARIES = libXfont.la
+lib_LTLIBRARIES = libXfont_2.la
 
 AM_CFLAGS = $(OS_CFLAGS) $(CWARNFLAGS)
 
@@ -58,11 +58,11 @@ SUBDIRS=\
 	$(FONTFILE_DIR) $(FREETYPE_DIR) $(BITMAP_DIR) \
 	$(BUILTINS_DIR) $(FC_DIR) $(UTIL_DIR) $(STUBS_DIR)
 
-libXfont_la_LIBADD = \
+libXfont_2_la_LIBADD = \
 	$(FONTFILE_LIB) $(FREETYPE_LIB) $(BITMAP_LIB) \
 	$(BUILTINS_LIB) $(FC_LIB) $(UTIL_LIB) $(STUBS_LIB) \
 	$(FREETYPE_LIBS) $(Z_LIBS) $(MATH_LIBS) $(XFONT_LIBS)
 
-libXfont_la_SOURCES = dummy.c
+libXfont_2_la_SOURCES = dummy.c
 
-libXfont_la_LDFLAGS = -version-number 1:4:1 -no-undefined
+libXfont_2_la_LDFLAGS = -version-number 2:0:0 -no-undefined
diff --git a/src/bitmap/bdfread.c b/src/bitmap/bdfread.c
index eccd7b7..1689a3b 100644
--- a/src/bitmap/bdfread.c
+++ b/src/bitmap/bdfread.c
@@ -52,6 +52,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #include <ctype.h>
 #include <X11/fonts/fntfilst.h>
diff --git a/src/bitmap/bdfutils.c b/src/bitmap/bdfutils.c
index 288148b..91069ed 100644
--- a/src/bitmap/bdfutils.c
+++ b/src/bitmap/bdfutils.c
@@ -52,6 +52,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #include <ctype.h>
 #include <stdio.h>
diff --git a/src/bitmap/bitmap.c b/src/bitmap/bitmap.c
index 0a379eb..a780506 100644
--- a/src/bitmap/bitmap.c
+++ b/src/bitmap/bitmap.c
@@ -31,6 +31,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #include <X11/fonts/fntfilst.h>
 #include <X11/fonts/bitmap.h>
diff --git a/src/bitmap/bitmapfunc.c b/src/bitmap/bitmapfunc.c
index 8c6b3d8..3087e47 100644
--- a/src/bitmap/bitmapfunc.c
+++ b/src/bitmap/bitmapfunc.c
@@ -31,6 +31,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #include <X11/fonts/fntfilst.h>
 #include <X11/fonts/bitmap.h>
diff --git a/src/bitmap/bitmaputil.c b/src/bitmap/bitmaputil.c
index 0a1c87e..232729f 100644
--- a/src/bitmap/bitmaputil.c
+++ b/src/bitmap/bitmaputil.c
@@ -29,6 +29,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #include <X11/fonts/fntfilst.h>
 #include <X11/fonts/bitmap.h>
diff --git a/src/bitmap/bitscale.c b/src/bitmap/bitscale.c
index c9af4c0..22747a9 100644
--- a/src/bitmap/bitscale.c
+++ b/src/bitmap/bitscale.c
@@ -33,6 +33,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #include <X11/fonts/fntfilst.h>
 #include <X11/fonts/bitmap.h>
@@ -43,9 +44,6 @@ from The Open Group.
 #define   MAX(a,b)    (((a)>(b)) ? a : b)
 #endif
 
-/* Should get this from elsewhere */
-extern unsigned long __GetServerGeneration(void);
-
 static void bitmapUnloadScalable (FontPtr pFont);
 static void ScaleBitmap ( FontPtr pFont, CharInfoPtr opci,
 			  CharInfoPtr pci, double *inv_xform,
diff --git a/src/bitmap/fontink.c b/src/bitmap/fontink.c
index f4898da..ea915e4 100644
--- a/src/bitmap/fontink.c
+++ b/src/bitmap/fontink.c
@@ -33,6 +33,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #include <X11/fonts/fntfilst.h>
 #include <X11/fonts/bitmap.h>
diff --git a/src/bitmap/pcfread.c b/src/bitmap/pcfread.c
index 34eeeb7..69af059 100644
--- a/src/bitmap/pcfread.c
+++ b/src/bitmap/pcfread.c
@@ -33,6 +33,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #include <X11/fonts/fntfilst.h>
 #include <X11/fonts/bitmap.h>
diff --git a/src/bitmap/pcfwrite.c b/src/bitmap/pcfwrite.c
index 0874c4b..61ae83d 100644
--- a/src/bitmap/pcfwrite.c
+++ b/src/bitmap/pcfwrite.c
@@ -33,6 +33,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #include <X11/fonts/fntfilst.h>
 #include <X11/fonts/bitmap.h>
@@ -43,7 +44,7 @@ from The Open Group.
 static CARD32  current_position;
 
 static int
-pcfWrite(FontFilePtr file, char *b, int c)
+pcfWrite(FontFilePtr file, const char *b, int c)
 {
     current_position += c;
     return FontFileWrite(file, b, c);
@@ -189,7 +190,7 @@ pcfPutAccel(FontFilePtr file, CARD32 format, FontInfoPtr pFontInfo)
 
 #define CanCompressMetrics(min,max) (CanCompressMetric(min) && CanCompressMetric(max))
 
-static char *
+static const char *
 pcfNameForAtom(Atom a)
 {
     return NameForAtom(a);
@@ -218,7 +219,7 @@ pcfWriteFont(FontPtr pFont, FontFilePtr file)
     int         header_size;
     FontPropPtr offsetProps;
     int         prop_pad = 0;
-    char       *atom_name;
+    const char  *atom_name;
     int         glyph;
     CARD32      offset;
 
diff --git a/src/bitmap/snfread.c b/src/bitmap/snfread.c
index da362c8..452b99d 100644
--- a/src/bitmap/snfread.c
+++ b/src/bitmap/snfread.c
@@ -52,6 +52,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #include <ctype.h>
 #include <X11/fonts/fntfilst.h>
diff --git a/src/builtins/dir.c b/src/builtins/dir.c
index 0225bfc..bda5647 100644
--- a/src/builtins/dir.c
+++ b/src/builtins/dir.c
@@ -24,6 +24,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include "builtin.h"
 
 static BuiltinDirPtr
diff --git a/src/builtins/file.c b/src/builtins/file.c
index 93527c1..3cfcf0c 100644
--- a/src/builtins/file.c
+++ b/src/builtins/file.c
@@ -24,6 +24,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <string.h>
 #include "builtin.h"
 
diff --git a/src/builtins/fonts.c b/src/builtins/fonts.c
index 3892178..bb593d7 100644
--- a/src/builtins/fonts.c
+++ b/src/builtins/fonts.c
@@ -24,6 +24,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include "builtin.h"
 
 static const char file_cursor[] = {
diff --git a/src/builtins/fpe.c b/src/builtins/fpe.c
index 4f5d4cf..207ff51 100644
--- a/src/builtins/fpe.c
+++ b/src/builtins/fpe.c
@@ -24,6 +24,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include    <X11/fonts/fntfilst.h>
 #include "builtin.h"
 
@@ -65,24 +66,29 @@ BuiltinFreeFPE (FontPathElementPtr fpe)
     return Successful;
 }
 
+static const font_fpe_funcs_rec builtin_fpe_funcs = {
+	.version = FONT_FPE_FUNCS_VERSION,
+	.name_func = BuiltinNameCheck,
+	.init_func = BuiltinInitFPE,
+	.free_func = BuiltinFreeFPE,
+	.reset_func = BuiltinResetFPE,
+	.open_func = FontFileOpenFont,
+	.close_func = FontFileCloseFont,
+	.list_func = FontFileListFonts,
+	.start_lfwi_func = FontFileStartListFontsWithInfo,
+	.next_lfwi_func = FontFileListNextFontWithInfo,
+	.wakeup_func = (WakeupFpeFunc) 0,
+	.client_died = (ClientDiedFunc) 0,
+	.load_glyphs = (LoadGlyphsFunc) 0,
+	.start_list_alias_func = (StartLaFunc) 0,
+	.next_list_alias_func = (NextLaFunc) 0,
+	.set_path_func = (SetPathFunc) 0
+};
+
 void
 BuiltinRegisterFpeFunctions(void)
 {
     BuiltinRegisterFontFileFunctions ();
 
-    font_file_type = RegisterFPEFunctions(BuiltinNameCheck,
-					  BuiltinInitFPE,
-					  BuiltinFreeFPE,
-					  BuiltinResetFPE,
-					  FontFileOpenFont,
-					  FontFileCloseFont,
-					  FontFileListFonts,
-					  FontFileStartListFontsWithInfo,
-					  FontFileListNextFontWithInfo,
-					  (WakeupFpeFunc) 0,
-					  (ClientDiedFunc) 0,
-					  (LoadGlyphsFunc) 0,
-					  (StartLaFunc) 0,
-					  (NextLaFunc) 0,
-					  (SetPathFunc) 0);
+    font_file_type = register_fpe_funcs(&builtin_fpe_funcs);
 }
diff --git a/src/builtins/render.c b/src/builtins/render.c
index 2be0053..7676c87 100644
--- a/src/builtins/render.c
+++ b/src/builtins/render.c
@@ -24,6 +24,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include    <X11/fonts/fntfilst.h>
 #include    <X11/fonts/fontutil.h>
 #include    <X11/fonts/pcf.h>
diff --git a/src/fc/fsconvert.c b/src/fc/fsconvert.c
index 18b0c0d..312bacb 100644
--- a/src/fc/fsconvert.c
+++ b/src/fc/fsconvert.c
@@ -28,6 +28,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include        <X11/X.h>
 #include 	<X11/Xtrans/Xtrans.h>
 #include	<X11/Xpoll.h>
diff --git a/src/fc/fserve.c b/src/fc/fserve.c
index 92b0d53..cccd76f 100644
--- a/src/fc/fserve.c
+++ b/src/fc/fserve.c
@@ -53,6 +53,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #ifdef WIN32
 #define _WILLWINSOCK_
@@ -71,6 +72,7 @@ in this Software without prior written authorization from The Open Group.
 #include	<X11/fonts/fontutil.h>
 #include	<errno.h>
 #include	<limits.h>
+#include	<X11/fonts/libxfont.h>
 
 #include	<time.h>
 #define Time_t time_t
@@ -101,8 +103,6 @@ in this Software without prior written authorization from The Open Group.
 /* Somewhat arbitrary limit on maximum reply size we'll try to read. */
 #define MAX_REPLY_LENGTH	((64 * 1024 * 1024) >> 2)
 
-extern void ErrorF(const char *f, ...);
-
 static int fs_read_glyphs ( FontPathElementPtr fpe, FSBlockDataPtr blockrec );
 static int fs_read_list ( FontPathElementPtr fpe, FSBlockDataPtr blockrec );
 static int fs_read_list_info ( FontPathElementPtr fpe,
@@ -2160,11 +2160,6 @@ fs_send_load_glyphs(pointer client, FontPtr pfont,
     return Suspended;
 }
 
-
-extern pointer __GetServerClient(void);	/* This could be any number that
-				   doesn't conflict with existing
-				   client values. */
-
 static int
 _fs_load_glyphs(pointer client, FontPtr pfont, Bool range_flag,
 		unsigned int nchars, int item_size, unsigned char *data)
@@ -3395,22 +3390,27 @@ _fs_free_conn (FSFpePtr conn)
  * called at server init time
  */
 
+static const font_fpe_funcs_rec fs_fpe_funcs = {
+	.version = FONT_FPE_FUNCS_VERSION,
+	.name_func = fs_name_check,
+	.init_func = fs_init_fpe,
+	.free_func = fs_free_fpe,
+	.reset_func = fs_reset_fpe,
+	.open_func = fs_open_font,
+	.close_func = fs_close_font,
+	.list_func = fs_list_fonts,
+	.start_lfwi_func = fs_start_list_with_info,
+	.next_lfwi_func = fs_next_list_with_info,
+	.wakeup_func = fs_wakeup,
+	.client_died = fs_client_died,
+	.load_glyphs = _fs_load_glyphs,
+	.start_list_alias_func = (StartLaFunc) 0,
+	.next_list_alias_func = (NextLaFunc) 0,
+	.set_path_func = (SetPathFunc) 0
+};
+
 void
 fs_register_fpe_functions(void)
 {
-    RegisterFPEFunctions(fs_name_check,
-			 fs_init_fpe,
-			 fs_free_fpe,
-			 fs_reset_fpe,
-			 fs_open_font,
-			 fs_close_font,
-			 fs_list_fonts,
-			 fs_start_list_with_info,
-			 fs_next_list_with_info,
-			 fs_wakeup,
-			 fs_client_died,
-			 _fs_load_glyphs,
-			 NULL,
-			 NULL,
-			 NULL);
+    register_fpe_funcs(&fs_fpe_funcs);
 }
diff --git a/src/fc/fserve.h b/src/fc/fserve.h
index 502e201..27c12a7 100644
--- a/src/fc/fserve.h
+++ b/src/fc/fserve.h
@@ -79,13 +79,4 @@ extern FontPtr fs_create_font (FontPathElementPtr   fpe,
 
 extern int fs_load_all_glyphs ( FontPtr pfont );
 
-/*
- * These should be declared elsewhere, but I'm concerned that moving them
- * would cause problems building other pieces
- */
-extern FontPtr find_old_font (Font id);
-extern int  set_font_authorizations (char **a, int *len, pointer client);
-extern long   GetTimeInMillis (void);
-
-
 #endif				/* _FSERVE_H_ */
diff --git a/src/fc/fsio.c b/src/fc/fsio.c
index 4deab88..3be81ed 100644
--- a/src/fc/fsio.c
+++ b/src/fc/fsio.c
@@ -29,6 +29,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #ifdef WIN32
 #define _WILLWINSOCK_
diff --git a/src/fc/fstrans.c b/src/fc/fstrans.c
index 24fceee..902ef36 100644
--- a/src/fc/fstrans.c
+++ b/src/fc/fstrans.c
@@ -23,6 +23,8 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#define LIBXFONT_SKIP_ERRORF
+#include "libxfontint.h"
 #define FONT_t
 #define TRANS_CLIENT
 #include <X11/Xtrans/transport.c>
diff --git a/src/fontfile/bitsource.c b/src/fontfile/bitsource.c
index c73f41f..3a6a20f 100644
--- a/src/fontfile/bitsource.c
+++ b/src/fontfile/bitsource.c
@@ -31,6 +31,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fntfilst.h>
 
 BitmapSourcesRec	FontFileBitmapSources;
diff --git a/src/fontfile/bufio.c b/src/fontfile/bufio.c
index d8d4f29..de06e1a 100644
--- a/src/fontfile/bufio.c
+++ b/src/fontfile/bufio.c
@@ -34,6 +34,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/Xos.h>
 #include <X11/fonts/fontmisc.h>
 #include <X11/fonts/bufio.h>
@@ -184,7 +185,7 @@ BufFileRead (BufFilePtr f, char *b, int n)
 }
 
 int
-BufFileWrite (BufFilePtr f, char *b, int n)
+BufFileWrite (BufFilePtr f, const char *b, int n)
 {
     int	    cnt;
     cnt = n;
diff --git a/src/fontfile/bunzip2.c b/src/fontfile/bunzip2.c
index 4078796..34065f8 100644
--- a/src/fontfile/bunzip2.c
+++ b/src/fontfile/bunzip2.c
@@ -29,6 +29,7 @@
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#include "libxfontint.h"
 
 #include <X11/fonts/fontmisc.h>
 #include <X11/fonts/bufio.h>
diff --git a/src/fontfile/catalogue.c b/src/fontfile/catalogue.c
index 81a1e13..41fb0b4 100644
--- a/src/fontfile/catalogue.c
+++ b/src/fontfile/catalogue.c
@@ -27,6 +27,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 
 #ifdef HAVE_READLINK
 #include <X11/fonts/fntfilst.h>
@@ -450,24 +451,29 @@ CatalogueListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
     return ret;
 }
 
+static const font_fpe_funcs_rec catalogue_fpe_funcs = {
+	.version = FONT_FPE_FUNCS_VERSION,
+	.name_func = CatalogueNameCheck,
+	.init_func = CatalogueInitFPE,
+	.free_func = CatalogueFreeFPE,
+	.reset_func = CatalogueResetFPE,
+	.open_func = CatalogueOpenFont,
+	.close_func = CatalogueCloseFont,
+	.list_func = CatalogueListFonts,
+	.start_lfwi_func = CatalogueStartListFontsWithInfo,
+	.next_lfwi_func = CatalogueListNextFontWithInfo,
+	.wakeup_func = (WakeupFpeFunc) 0,
+	.client_died = (ClientDiedFunc) 0,
+	.load_glyphs = (LoadGlyphsFunc) 0,
+	.start_list_alias_func = CatalogueStartListFontsAndAliases,
+	.next_list_alias_func = CatalogueListNextFontOrAlias,
+	.set_path_func = FontFileEmptyBitmapSource,
+};
+
 void
 CatalogueRegisterLocalFpeFunctions (void)
 {
-    RegisterFPEFunctions(CatalogueNameCheck,
-			 CatalogueInitFPE,
-			 CatalogueFreeFPE,
-			 CatalogueResetFPE,
-			 CatalogueOpenFont,
-			 CatalogueCloseFont,
-			 CatalogueListFonts,
-			 CatalogueStartListFontsWithInfo,
-			 CatalogueListNextFontWithInfo,
-			 NULL,
-			 NULL,
-			 NULL,
-			 CatalogueStartListFontsAndAliases,
-			 CatalogueListNextFontOrAlias,
-			 FontFileEmptyBitmapSource);
+    register_fpe_funcs(&catalogue_fpe_funcs);
 }
 
 #endif /* HAVE_READLINK */
diff --git a/src/fontfile/decompress.c b/src/fontfile/decompress.c
index 20971df..42e7aa0 100644
--- a/src/fontfile/decompress.c
+++ b/src/fontfile/decompress.c
@@ -51,6 +51,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fontmisc.h>
 #include <X11/fonts/bufio.h>
 
diff --git a/src/fontfile/defaults.c b/src/fontfile/defaults.c
index 1ad7d7c..62b4dd5 100644
--- a/src/fontfile/defaults.c
+++ b/src/fontfile/defaults.c
@@ -31,6 +31,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include    <X11/X.h>
 #include    <X11/Xproto.h>
 
diff --git a/src/fontfile/dirfile.c b/src/fontfile/dirfile.c
index 38ced75..04cfa40 100644
--- a/src/fontfile/dirfile.c
+++ b/src/fontfile/dirfile.c
@@ -37,6 +37,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fntfilst.h>
 #include <stdio.h>
 #include <sys/types.h>
diff --git a/src/fontfile/fileio.c b/src/fontfile/fileio.c
index d44cecd..074ebcb 100644
--- a/src/fontfile/fileio.c
+++ b/src/fontfile/fileio.c
@@ -31,6 +31,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fntfilio.h>
 #include <X11/Xos.h>
 #ifndef O_BINARY
diff --git a/src/fontfile/filewr.c b/src/fontfile/filewr.c
index 859a0be..2431784 100644
--- a/src/fontfile/filewr.c
+++ b/src/fontfile/filewr.c
@@ -31,6 +31,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fntfilio.h>
 #include <X11/Xos.h>
 #ifndef O_BINARY
diff --git a/src/fontfile/fontdir.c b/src/fontfile/fontdir.c
index 7271603..f4f704d 100644
--- a/src/fontfile/fontdir.c
+++ b/src/fontfile/fontdir.c
@@ -31,6 +31,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include    <X11/fonts/fntfilst.h>
 #include    <X11/keysym.h>
 
diff --git a/src/fontfile/fontencc.c b/src/fontfile/fontencc.c
index 4bdb495..b5c684b 100644
--- a/src/fontfile/fontencc.c
+++ b/src/fontfile/fontencc.c
@@ -30,11 +30,10 @@ THE SOFTWARE.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fontenc.h>
 #include <X11/fonts/fontencc.h>
 
-extern void ErrorF(const char *f, ...);
-
 char *
 font_encoding_from_xlfd(const char * name, int length)
 {
diff --git a/src/fontfile/fontfile.c b/src/fontfile/fontfile.c
index 05a9610..97adbcf 100644
--- a/src/fontfile/fontfile.c
+++ b/src/fontfile/fontfile.c
@@ -31,6 +31,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fntfilst.h>
 #include <X11/keysym.h>
 #ifdef WIN32
@@ -1115,22 +1116,27 @@ FontFileListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
     return ret;
 }
 
+static const font_fpe_funcs_rec fontfile_fpe_funcs = {
+	.version = FONT_FPE_FUNCS_VERSION,
+	.name_func = FontFileNameCheck,
+	.init_func = FontFileInitFPE,
+	.free_func = FontFileFreeFPE,
+	.reset_func = FontFileResetFPE,
+	.open_func = FontFileOpenFont,
+	.close_func = FontFileCloseFont,
+	.list_func = FontFileListFonts,
+	.start_lfwi_func = FontFileStartListFontsWithInfo,
+	.next_lfwi_func = FontFileListNextFontWithInfo,
+	.wakeup_func = (WakeupFpeFunc) 0,
+	.client_died = (ClientDiedFunc) 0,
+	.load_glyphs = (LoadGlyphsFunc) 0,
+	.start_list_alias_func = FontFileStartListFontsAndAliases,
+	.next_list_alias_func = FontFileListNextFontOrAlias,
+	.set_path_func = FontFileEmptyBitmapSource,
+};
+
 void
 FontFileRegisterLocalFpeFunctions (void)
 {
-    RegisterFPEFunctions(FontFileNameCheck,
-			 FontFileInitFPE,
-			 FontFileFreeFPE,
-			 FontFileResetFPE,
-			 FontFileOpenFont,
-			 FontFileCloseFont,
-			 FontFileListFonts,
-			 FontFileStartListFontsWithInfo,
-			 FontFileListNextFontWithInfo,
-			 NULL,
-			 NULL,
-			 NULL,
-			 FontFileStartListFontsAndAliases,
-			 FontFileListNextFontOrAlias,
-			 FontFileEmptyBitmapSource);
+    register_fpe_funcs(&fontfile_fpe_funcs);
 }
diff --git a/src/fontfile/fontscale.c b/src/fontfile/fontscale.c
index a21802f..bbc8e10 100644
--- a/src/fontfile/fontscale.c
+++ b/src/fontfile/fontscale.c
@@ -31,6 +31,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include    <X11/fonts/fntfilst.h>
 #include <math.h>
 
diff --git a/src/fontfile/gunzip.c b/src/fontfile/gunzip.c
index 84a4eaf..36f020a 100644
--- a/src/fontfile/gunzip.c
+++ b/src/fontfile/gunzip.c
@@ -5,6 +5,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fontmisc.h>
 #include <X11/fonts/bufio.h>
 #include <zlib.h>
diff --git a/src/fontfile/register.c b/src/fontfile/register.c
index 4faeb8f..c3c8972 100644
--- a/src/fontfile/register.c
+++ b/src/fontfile/register.c
@@ -29,6 +29,7 @@ in this Software without prior written authorization from The Open Group.
 #else
 #define XFONT_BITMAP 1
 #endif
+#include "libxfontint.h"
 
 #include <X11/fonts/fontmisc.h>
 #include <X11/fonts/fntfilst.h>
diff --git a/src/fontfile/renderers.c b/src/fontfile/renderers.c
index bbcd466..d0c4064 100644
--- a/src/fontfile/renderers.c
+++ b/src/fontfile/renderers.c
@@ -31,8 +31,8 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fntfilst.h>
-extern void ErrorF(const char *f, ...);
 
 static FontRenderersRec	renderers;
 
@@ -40,7 +40,6 @@ static FontRenderersRec	renderers;
  * XXX Maybe should allow unregistering renders. For now, just clear the
  * list at each new generation.
  */
-extern unsigned long __GetServerGeneration(void);
 static unsigned long rendererGeneration = 0;
 
 Bool
diff --git a/src/stubs/Makefile.am b/src/stubs/Makefile.am
index 7eb16d4..65950cc 100644
--- a/src/stubs/Makefile.am
+++ b/src/stubs/Makefile.am
@@ -6,20 +6,5 @@ AM_CFLAGS = $(XFONT_CFLAGS) $(OS_CFLAGS) $(CWARNFLAGS)
 noinst_LTLIBRARIES = libstubs.la
 
 libstubs_la_SOURCES = 		\
-	cauthgen.c		\
-	csignal.c		\
-	delfntcid.c		\
-	errorf.c		\
-	findoldfnt.c		\
-	getcres.c		\
-	getdefptsize.c		\
-	getnewfntcid.c		\
-	gettime.c		\
-	initfshdl.c		\
-	regfpefunc.c		\
-	rmfshdl.c		\
-	servclient.c		\
-	setfntauth.c		\
-	stfntcfnt.c		\
-	stubsinit.c		\
-	stubs.h
+	atom.c			\
+	libxfontstubs.c
diff --git a/src/stubs/atom.c b/src/stubs/atom.c
new file mode 100644
index 0000000..61ee85c
--- /dev/null
+++ b/src/stubs/atom.c
@@ -0,0 +1,234 @@
+/*
+
+Copyright 1990, 1994, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author:  Keith Packard, MIT X Consortium
+ */
+
+/* lame atom replacement routines for font applications */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "libxfontint.h"
+#include <X11/fonts/fontmisc.h>
+
+typedef struct _AtomList {
+    char		*name;
+    int			len;
+    int			hash;
+    Atom		atom;
+} AtomListRec, *AtomListPtr;
+
+static AtomListPtr  *hashTable;
+
+static int	    hashSize, hashUsed;
+static int	    hashMask;
+static int	    rehash;
+
+static AtomListPtr  *reverseMap;
+static int	    reverseMapSize;
+static Atom	    lastAtom;
+
+static int
+Hash(const char *string, int len)
+{
+    int	h;
+
+    h = 0;
+    while (len--)
+	h = (h << 3) ^ *string++;
+    if (h < 0)
+	return -h;
+    return h;
+}
+
+static int
+ResizeHashTable (void)
+{
+    int		newHashSize;
+    int		newHashMask;
+    AtomListPtr	*newHashTable;
+    int		i;
+    int		h;
+    int		newRehash;
+    int		r;
+
+    if (hashSize == 0)
+	newHashSize = 1024;
+    else
+	newHashSize = hashSize * 2;
+    newHashTable = calloc (newHashSize, sizeof (AtomListPtr));
+    if (!newHashTable) {
+	fprintf(stderr, "ResizeHashTable(): Error: Couldn't allocate"
+		" newHashTable (%ld)\n",
+		newHashSize * (unsigned long)sizeof (AtomListPtr));
+	return FALSE;
+    }
+    newHashMask = newHashSize - 1;
+    newRehash = (newHashMask - 2);
+    for (i = 0; i < hashSize; i++)
+    {
+	if (hashTable[i])
+	{
+	    h = (hashTable[i]->hash) & newHashMask;
+	    if (newHashTable[h])
+	    {
+		r = hashTable[i]->hash % newRehash | 1;
+		do {
+		    h += r;
+		    if (h >= newHashSize)
+			h -= newHashSize;
+		} while (newHashTable[h]);
+	    }
+	    newHashTable[h] = hashTable[i];
+	}
+    }
+    free (hashTable);
+    hashTable = newHashTable;
+    hashSize = newHashSize;
+    hashMask = newHashMask;
+    rehash = newRehash;
+    return TRUE;
+}
+
+static int
+ResizeReverseMap (void)
+{
+    AtomListPtr *newMap;
+    int newMapSize;
+
+    if (reverseMapSize == 0)
+	newMapSize = 1000;
+    else
+	newMapSize = reverseMapSize * 2;
+    newMap = realloc (reverseMap, newMapSize * sizeof (AtomListPtr));
+    if (newMap == NULL) {
+	fprintf(stderr, "ResizeReverseMap(): Error: Couldn't reallocate"
+		" reverseMap (%ld)\n",
+		newMapSize * (unsigned long)sizeof(AtomListPtr));
+	return FALSE;
+    }
+    reverseMap = newMap;
+    reverseMapSize = newMapSize;
+    return TRUE;
+}
+
+static int
+NameEqual (const char *a, const char *b, int l)
+{
+    while (l--)
+	if (*a++ != *b++)
+	    return FALSE;
+    return TRUE;
+}
+
+Atom
+__libxfont_internal__MakeAtom(const char *string, unsigned len, int makeit)
+{
+    AtomListPtr	a;
+    int		hash;
+    int		h = 0;
+    int		r;
+
+    hash = Hash (string, len);
+    if (hashTable)
+    {
+    	h = hash & hashMask;
+	if (hashTable[h])
+	{
+	    if (hashTable[h]->hash == hash && hashTable[h]->len == len &&
+	    	NameEqual (hashTable[h]->name, string, len))
+	    {
+	    	return hashTable[h]->atom;
+	    }
+	    r = (hash % rehash) | 1;
+	    for (;;)
+	    {
+		h += r;
+		if (h >= hashSize)
+		    h -= hashSize;
+		if (!hashTable[h])
+		    break;
+		if (hashTable[h]->hash == hash && hashTable[h]->len == len &&
+		    NameEqual (hashTable[h]->name, string, len))
+		{
+		    return hashTable[h]->atom;
+		}
+	    }
+    	}
+    }
+    if (!makeit)
+	return None;
+    a = malloc (sizeof (AtomListRec) + len + 1);
+    if (a == NULL) {
+	fprintf(stderr, "MakeAtom(): Error: Couldn't allocate AtomListRec"
+		" (%ld)\n", (unsigned long)sizeof (AtomListRec) + len + 1);
+	return None;
+    }
+    a->name = (char *) (a + 1);
+    a->len = len;
+    strncpy (a->name, string, len);
+    a->name[len] = '\0';
+    a->atom = ++lastAtom;
+    a->hash = hash;
+    if (hashUsed >= hashSize / 2)
+    {
+	ResizeHashTable ();
+	h = hash & hashMask;
+	if (hashTable[h])
+	{
+	    r = (hash % rehash) | 1;
+	    do {
+		h += r;
+		if (h >= hashSize)
+		    h -= hashSize;
+	    } while (hashTable[h]);
+	}
+    }
+    hashTable[h] = a;
+    hashUsed++;
+    if (reverseMapSize <= a->atom) {
+	if (!ResizeReverseMap())
+	    return None;
+    }
+    reverseMap[a->atom] = a;
+    return a->atom;
+}
+
+int
+__libxfont_internal__ValidAtom(Atom atom)
+{
+    return (atom != None) && (atom <= lastAtom);
+}
+
+const char *
+__libxfont_internal__NameForAtom(Atom atom)
+{
+    if (atom != None && atom <= lastAtom)
+	return reverseMap[atom]->name;
+    return NULL;
+}
diff --git a/src/stubs/cauthgen.c b/src/stubs/cauthgen.c
deleted file mode 100644
index 10086e4..0000000
--- a/src/stubs/cauthgen.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak client_auth_generation
-#endif
-
-weak int
-client_auth_generation(ClientPtr client)
-{
-    OVERRIDE_SYMBOL(client_auth_generation, client);
-    return 0;
-}
diff --git a/src/stubs/csignal.c b/src/stubs/csignal.c
deleted file mode 100644
index dd88b3d..0000000
--- a/src/stubs/csignal.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak ClientSignal
-#endif
-
-weak Bool
-ClientSignal(ClientPtr client)
-{
-    OVERRIDE_SYMBOL(ClientSignal,client);
-    return True;
-}
diff --git a/src/stubs/delfntcid.c b/src/stubs/delfntcid.c
deleted file mode 100644
index 8113b9f..0000000
--- a/src/stubs/delfntcid.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak DeleteFontClientID
-#endif
-
-weak void
-DeleteFontClientID(Font id)
-{
-    OVERRIDE_SYMBOL(DeleteFontClientID, id);
-}
diff --git a/src/stubs/errorf.c b/src/stubs/errorf.c
deleted file mode 100644
index d2de6c6..0000000
--- a/src/stubs/errorf.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak ErrorF
-#endif
-
-weak void
-ErrorF(const char *f, ...)
-{
-    OVERRIDE_VA_SYMBOL(VErrorF, f);
-}
diff --git a/src/stubs/findoldfnt.c b/src/stubs/findoldfnt.c
deleted file mode 100644
index c73279e..0000000
--- a/src/stubs/findoldfnt.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak find_old_font
-#endif
-
-weak FontPtr
-find_old_font(FSID id)
-{
-    OVERRIDE_SYMBOL(find_old_font, id);
-    return (FontPtr)NULL;
-}
diff --git a/src/stubs/getcres.c b/src/stubs/getcres.c
deleted file mode 100644
index 27a9180..0000000
--- a/src/stubs/getcres.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak GetClientResolutions
-#endif
-
-weak FontResolutionPtr
-GetClientResolutions(int *num)
-{
-  OVERRIDE_SYMBOL(GetClientResolutions, num);
-  return (FontResolutionPtr) 0;
-}
diff --git a/src/stubs/getdefptsize.c b/src/stubs/getdefptsize.c
deleted file mode 100644
index 50c1b18..0000000
--- a/src/stubs/getdefptsize.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak GetDefaultPointSize
-#endif
-
-weak int
-GetDefaultPointSize(void)
-{
-    OVERRIDE_SYMBOL(GetDefaultPointSize);
-    return 0;
-}
diff --git a/src/stubs/getnewfntcid.c b/src/stubs/getnewfntcid.c
deleted file mode 100644
index d31ccf1..0000000
--- a/src/stubs/getnewfntcid.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak GetNewFontClientID
-#endif
-
-weak Font
-GetNewFontClientID(void)
-{
-    OVERRIDE_SYMBOL(GetNewFontClientID);
-    return (Font)0;
-}
diff --git a/src/stubs/gettime.c b/src/stubs/gettime.c
deleted file mode 100644
index 1b20f62..0000000
--- a/src/stubs/gettime.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak GetTimeInMillis
-#endif
-
-weak unsigned long
-GetTimeInMillis (void)
-{
-    OVERRIDE_SYMBOL(GetTimeInMillis);
-    return 0;
-}
diff --git a/src/stubs/initfshdl.c b/src/stubs/initfshdl.c
deleted file mode 100644
index e1c0b24..0000000
--- a/src/stubs/initfshdl.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak init_fs_handlers
-#endif
-
-weak int
-init_fs_handlers(FontPathElementPtr fpe,
-                 BlockHandlerProcPtr block_handler)
-{
-  OVERRIDE_SYMBOL(init_fs_handlers, fpe, block_handler);
-  return Successful;
-}
diff --git a/src/stubs/libxfontstubs.c b/src/stubs/libxfontstubs.c
new file mode 100644
index 0000000..f72caec
--- /dev/null
+++ b/src/stubs/libxfontstubs.c
@@ -0,0 +1,169 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include	"libxfontint.h"
+
+static font_client_funcs_rec const *_f;
+
+int
+client_auth_generation(ClientPtr client)
+{
+    if (_f)
+	return _f->client_auth_generation(client);
+    return 0;
+}
+
+Bool
+ClientSignal(ClientPtr client)
+{
+    if (_f)
+	return _f->client_signal(client);
+    return TRUE;
+}
+
+void
+DeleteFontClientID(Font id)
+{
+    if (_f)
+	_f->delete_font_client_id(id);
+}
+
+void
+ErrorF(const char *f, ...)
+{
+    if (_f) {
+	va_list	ap;
+	va_start(ap, f);
+	_f->verrorf(f, ap);
+	va_end(ap);
+    }
+}
+
+FontPtr
+find_old_font(FSID id)
+{
+    if (_f)
+	return _f->find_old_font(id);
+    return (FontPtr)NULL;
+}
+
+FontResolutionPtr
+GetClientResolutions(int *num)
+{
+    if (_f)
+	return _f->get_client_resolutions(num);
+    return (FontResolutionPtr) 0;
+}
+
+int
+GetDefaultPointSize(void)
+{
+    if (_f)
+	return _f->get_default_point_size();
+    return 12;
+}
+
+Font
+GetNewFontClientID(void)
+{
+    if (_f)
+	return _f->get_new_font_client_id();
+    return (Font)0;
+}
+
+unsigned long
+GetTimeInMillis (void)
+{
+    if (_f)
+	return _f->get_time_in_millis();
+    return 0;
+}
+
+int
+init_fs_handlers(FontPathElementPtr fpe,
+                 BlockHandlerProcPtr block_handler)
+{
+    if (_f)
+	return _f->init_fs_handlers(fpe, block_handler);
+    return Successful;
+}
+
+int
+register_fpe_funcs(const font_fpe_funcs_rec *funcs)
+{
+    if (_f)
+	return _f->register_fpe_funcs(funcs);
+    return 0;
+}
+
+void
+remove_fs_handlers(FontPathElementPtr fpe,
+                   BlockHandlerProcPtr blockHandler,
+                   Bool all)
+{
+    if (_f)
+	_f->remove_fs_handlers(fpe, blockHandler, all);
+}
+
+void *
+__GetServerClient(void)
+{
+    if (_f)
+	return _f->get_server_client();
+    return NULL;
+}
+
+int
+set_font_authorizations(char **authorizations, int *authlen, ClientPtr client)
+{
+    if (_f)
+	return _f->set_font_authorizations(authorizations, authlen, client);
+    return 0;
+}
+
+int
+StoreFontClientFont(FontPtr pfont, Font id)
+{
+    if (_f)
+	return _f->store_font_client_font(pfont, id);
+    return 0;
+}
+
+Atom
+MakeAtom(const char *string, unsigned len, int makeit)
+{
+    if (_f && _f->make_atom)
+	return _f->make_atom(string, len, makeit);
+    return __libxfont_internal__MakeAtom(string, len, makeit);
+}
+
+int
+ValidAtom(Atom atom)
+{
+    if (_f && _f->valid_atom)
+	return _f->valid_atom(atom);
+    return __libxfont_internal__ValidAtom(atom);
+}
+
+const char *
+NameForAtom(Atom atom)
+{
+    if (_f && _f->name_for_atom)
+	return _f->name_for_atom(atom);
+    return __libxfont_internal__NameForAtom(atom);
+}
+
+unsigned long
+__GetServerGeneration (void)
+{
+    if (_f)
+	return _f->get_server_generation();
+    return 1;
+}
+
+void
+font_register_client_funcs(font_client_funcs_rec const *client_funcs)
+{
+    _f = client_funcs;
+}
diff --git a/src/stubs/regfpefunc.c b/src/stubs/regfpefunc.c
deleted file mode 100644
index ae12a01..0000000
--- a/src/stubs/regfpefunc.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak RegisterFPEFunctions
-#endif
-
-weak int
-RegisterFPEFunctions(NameCheckFunc name_func,
-		     InitFpeFunc init_func,
-		     FreeFpeFunc free_func,
-		     ResetFpeFunc reset_func,
-		     OpenFontFunc open_func,
-		     CloseFontFunc close_func,
-		     ListFontsFunc list_func,
-		     StartLfwiFunc start_lfwi_func,
-		     NextLfwiFunc next_lfwi_func,
-		     WakeupFpeFunc wakeup_func,
-		     ClientDiedFunc client_died,
-		     LoadGlyphsFunc load_glyphs,
-		     StartLaFunc start_list_alias_func,
-		     NextLaFunc next_list_alias_func,
-		     SetPathFunc set_path_func)
-{
-    OVERRIDE_SYMBOL(RegisterFPEFunctions, name_func, init_func, free_func,
-                    reset_func, open_func, close_func, list_func, start_lfwi_func,
-                    next_lfwi_func, wakeup_func, client_died, load_glyphs,
-                    start_list_alias_func, next_list_alias_func, set_path_func);
-    return 0;
-}
diff --git a/src/stubs/rmfshdl.c b/src/stubs/rmfshdl.c
deleted file mode 100644
index 22a3091..0000000
--- a/src/stubs/rmfshdl.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak remove_fs_handlers
-#endif
-
-weak void
-remove_fs_handlers(FontPathElementPtr fpe,
-                   BlockHandlerProcPtr blockHandler,
-                   Bool all)
-{
-    OVERRIDE_SYMBOL(remove_fs_handlers, fpe, blockHandler, all);
-}
diff --git a/src/stubs/servclient.c b/src/stubs/servclient.c
deleted file mode 100644
index f85e08e..0000000
--- a/src/stubs/servclient.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak serverClient
-#endif
-
-weak void *serverClient = 0;
-
-void *__GetServerClient(void);
-
-void *
-__GetServerClient(void)
-{
-   OVERRIDE_DATA(serverClient);
-   return serverClient;
-}
diff --git a/src/stubs/setfntauth.c b/src/stubs/setfntauth.c
deleted file mode 100644
index 371807e..0000000
--- a/src/stubs/setfntauth.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak set_font_authorizations
-#endif
-
-weak int
-set_font_authorizations(char **authorizations, int *authlen, ClientPtr client)
-{
-    OVERRIDE_SYMBOL(set_font_authorizations, authorizations, authlen, client);
-    return 0;
-}
diff --git a/src/stubs/stfntcfnt.c b/src/stubs/stfntcfnt.c
deleted file mode 100644
index d490988..0000000
--- a/src/stubs/stfntcfnt.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "stubs.h"
-
-#ifdef __SUNPRO_C
-#pragma weak StoreFontClientFont
-#endif
-
-weak int
-StoreFontClientFont(FontPtr pfont, Font id)
-{
-    OVERRIDE_SYMBOL(StoreFontClientFont, pfont, id);
-    return 0;
-}
diff --git a/src/stubs/stubs.h b/src/stubs/stubs.h
deleted file mode 100644
index 7d499d5..0000000
--- a/src/stubs/stubs.h
+++ /dev/null
@@ -1,88 +0,0 @@
-#include <stdio.h>
-#include <X11/fonts/fntfilst.h>
-#include <X11/fonts/font.h>
-
-#ifndef True
-#define True (-1)
-#endif
-#ifndef False
-#define False (0)
-#endif
-
-/* this probably works for Mach-O too, but probably not for PE */
-#if (defined(__APPLE__) || defined(__ELF__)) && defined(__GNUC__) && (__GNUC__ >= 3)
-#define weak __attribute__((weak))
-#else
-#define weak
-#ifndef __SUNPRO_C /* Sun compilers use #pragma weak in .c files instead */
-#define NO_WEAK_SYMBOLS
-#endif
-#endif
-
-#if defined(NO_WEAK_SYMBOLS) && defined(PIC)
-#include <stdarg.h>
-extern int _font_init_stubs(void);
-#define OVERRIDE_DATA(sym) \
-    _font_init_stubs(); \
-    if (__ptr_##sym && __ptr_##sym != &sym) \
-      sym = *__ptr_##sym
-#define OVERRIDE_SYMBOL(sym,...) \
-    _font_init_stubs(); \
-    if (__##sym && __##sym != sym) \
-      return (*__##sym)(__VA_ARGS__)
-#define OVERRIDE_VA_SYMBOL(sym,f) \
-    va_list _args; \
-    _font_init_stubs(); \
-    va_start(_args, f); \
-    if (__##sym) \
-      (*__##sym)(f, _args); \
-    va_end(_args)
-
-int (*__client_auth_generation)(ClientPtr);
-Bool (*__ClientSignal)(ClientPtr);
-void (*__DeleteFontClientID)(Font);
-void (*__VErrorF)(const char *, va_list);
-FontPtr (*__find_old_font)(FSID);
-FontResolutionPtr (*__GetClientResolutions)(int *);
-int (*__GetDefaultPointSize)(void);
-Font (*__GetNewFontClientID)(void);
-unsigned long (*__GetTimeInMillis)(void);
-int (*__init_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr);
-int (*__RegisterFPEFunctions)(NameCheckFunc, InitFpeFunc, FreeFpeFunc,
-     ResetFpeFunc, OpenFontFunc, CloseFontFunc, ListFontsFunc,
-     StartLfwiFunc, NextLfwiFunc, WakeupFpeFunc, ClientDiedFunc,
-     LoadGlyphsFunc, StartLaFunc, NextLaFunc, SetPathFunc);
-void (*__remove_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr, Bool);
-void **__ptr_serverClient;
-int (*__set_font_authorizations)(char **, int *, ClientPtr);
-int (*__StoreFontClientFont)(FontPtr, Font);
-Atom (*__MakeAtom)(const char *, unsigned, int);
-int (*__ValidAtom)(Atom);
-char *(*__NameForAtom)(Atom);
-unsigned long *__ptr_serverGeneration;
-void (*__register_fpe_functions)(void);
-#else /* NO_WEAK_SYMBOLS && PIC */
-#define OVERRIDE_DATA(sym)
-#define OVERRIDE_SYMBOL(sym,...)
-#define OVERRIDE_VA_SYMBOL(sym,f)
-#endif
-
-/* This is really just a hack for now... __APPLE__ really should be using
- * the weak symbols route above, but it's causing an as-yet unresolved issue,
- * so we're instead building with flat_namespace.
- */
-#ifdef __APPLE__
-#undef weak
-#define weak
-#endif
-
-extern FontPtr find_old_font ( FSID id );
-extern int set_font_authorizations ( char **authorizations,
-				     int *authlen,
-				     ClientPtr client );
-
-extern unsigned long GetTimeInMillis (void);
-
-extern void ErrorF(const char *format, ...);
-
-/* end of file */
diff --git a/src/stubs/stubsinit.c b/src/stubs/stubsinit.c
deleted file mode 100644
index fc52332..0000000
--- a/src/stubs/stubsinit.c
+++ /dev/null
@@ -1,82 +0,0 @@
-#include "stubs.h"
-
-#if defined(NO_WEAK_SYMBOLS) && defined(PIC)
-
-#ifdef WIN32
-#include <X11/Xwindows.h>
-#define DLOPEN_SELF() GetModuleHandle(NULL)
-#define DLSYM(h,f) GetProcAddress(h,f)
-#else
-#include <dlfcn.h>
-#define DLOPEN_SELF() dlopen(NULL, RTLD_LOCAL)
-#define DLSYM(h,f) dlsym(h, f)
-#endif
-
-int (*__client_auth_generation)(ClientPtr) = NULL;
-Bool (*__ClientSignal)(ClientPtr) = NULL;
-void (*__DeleteFontClientID)(Font) = NULL;
-void (*__VErrorF)(const char *, va_list) = NULL;
-FontPtr (*__find_old_font)(FSID) = NULL;
-FontResolutionPtr (*__GetClientResolutions)(int *) = NULL;
-int (*__GetDefaultPointSize)(void) = NULL;
-Font (*__GetNewFontClientID)(void) = NULL;
-unsigned long (*__GetTimeInMillis)(void) = NULL;
-int (*__init_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr) = NULL;
-int (*__RegisterFPEFunctions)(NameCheckFunc, InitFpeFunc, FreeFpeFunc,
-     ResetFpeFunc, OpenFontFunc, CloseFontFunc, ListFontsFunc,
-     StartLfwiFunc, NextLfwiFunc, WakeupFpeFunc, ClientDiedFunc,
-     LoadGlyphsFunc, StartLaFunc, NextLaFunc, SetPathFunc) = NULL;
-void (*__remove_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr, Bool) = NULL;
-void **__ptr_serverClient = NULL;
-int (*__set_font_authorizations)(char **, int *, ClientPtr) = NULL;
-int (*__StoreFontClientFont)(FontPtr, Font) = NULL;
-Atom (*__MakeAtom)(const char *, unsigned, int) = NULL;
-int (*__ValidAtom)(Atom) = NULL;
-char *(*__NameForAtom)(Atom) = NULL;
-unsigned long *__ptr_serverGeneration = NULL;
-void (*__register_fpe_functions)(void) = NULL;
-
-#define INIT_SYMBOL(sym) \
-  if (!__##sym) \
-   __##sym = (typeof(__##sym)) DLSYM(handle, #sym)
-#define INIT_DATA(sym) \
-  if (!__ptr_##sym) \
-   __ptr_##sym = (typeof(__ptr_##sym)) DLSYM(handle, #sym)
-
-int
-_font_init_stubs (void)
-{
-  static int inited = FALSE;
-  static void *handle = NULL;
-
-  if (inited)
-    return inited;
-  if (!handle)
-    handle = DLOPEN_SELF();
-
-  INIT_SYMBOL(client_auth_generation);
-  INIT_SYMBOL(ClientSignal);
-  INIT_SYMBOL(DeleteFontClientID);
-  INIT_SYMBOL(VErrorF);
-  INIT_SYMBOL(find_old_font);
-  INIT_SYMBOL(GetClientResolutions);
-  INIT_SYMBOL(GetDefaultPointSize);
-  INIT_SYMBOL(GetNewFontClientID);
-  INIT_SYMBOL(GetTimeInMillis);
-  INIT_SYMBOL(init_fs_handlers);
-  INIT_SYMBOL(RegisterFPEFunctions);
-  INIT_SYMBOL(remove_fs_handlers);
-  INIT_SYMBOL(set_font_authorizations);
-  INIT_SYMBOL(StoreFontClientFont);
-  INIT_SYMBOL(MakeAtom);
-  INIT_SYMBOL(ValidAtom);
-  INIT_SYMBOL(NameForAtom);
-  INIT_SYMBOL(register_fpe_functions);
-  INIT_DATA(serverClient);
-  INIT_DATA(serverGeneration);
-
-  inited = TRUE;
-  return inited;
-}
-
-#endif /* NO_WEAK_SYMBOLS && PIC */
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 32a8f37..d802b59 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -7,7 +7,6 @@ AM_CFLAGS = $(XFONT_CFLAGS) $(OS_CFLAGS) $(CWARNFLAGS)
 noinst_LTLIBRARIES = libutil.la
 
 libutil_la_SOURCES = 		\
-	atom.c			\
 	fontaccel.c		\
 	fontnames.c		\
 	fontutil.c		\
diff --git a/src/util/atom.c b/src/util/atom.c
deleted file mode 100644
index 5f7f1c6..0000000
--- a/src/util/atom.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
-
-Copyright 1990, 1994, 1998  The Open Group
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-*/
-
-/*
- * Author:  Keith Packard, MIT X Consortium
- */
-
-/* lame atom replacement routines for font applications */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/fonts/fontmisc.h>
-#include "stubs.h"
-
-typedef struct _AtomList {
-    char		*name;
-    int			len;
-    int			hash;
-    Atom		atom;
-} AtomListRec, *AtomListPtr;
-
-static AtomListPtr  *hashTable;
-
-static int	    hashSize, hashUsed;
-static int	    hashMask;
-static int	    rehash;
-
-static AtomListPtr  *reverseMap;
-static int	    reverseMapSize;
-static Atom	    lastAtom;
-
-static int
-Hash(const char *string, int len)
-{
-    int	h;
-
-    h = 0;
-    while (len--)
-	h = (h << 3) ^ *string++;
-    if (h < 0)
-	return -h;
-    return h;
-}
-
-static int
-ResizeHashTable (void)
-{
-    int		newHashSize;
-    int		newHashMask;
-    AtomListPtr	*newHashTable;
-    int		i;
-    int		h;
-    int		newRehash;
-    int		r;
-
-    if (hashSize == 0)
-	newHashSize = 1024;
-    else
-	newHashSize = hashSize * 2;
-    newHashTable = calloc (newHashSize, sizeof (AtomListPtr));
-    if (!newHashTable) {
-	fprintf(stderr, "ResizeHashTable(): Error: Couldn't allocate"
-		" newHashTable (%ld)\n",
-		newHashSize * (unsigned long)sizeof (AtomListPtr));
-	return FALSE;
-    }
-    newHashMask = newHashSize - 1;
-    newRehash = (newHashMask - 2);
-    for (i = 0; i < hashSize; i++)
-    {
-	if (hashTable[i])
-	{
-	    h = (hashTable[i]->hash) & newHashMask;
-	    if (newHashTable[h])
-	    {
-		r = hashTable[i]->hash % newRehash | 1;
-		do {
-		    h += r;
-		    if (h >= newHashSize)
-			h -= newHashSize;
-		} while (newHashTable[h]);
-	    }
-	    newHashTable[h] = hashTable[i];
-	}
-    }
-    free (hashTable);
-    hashTable = newHashTable;
-    hashSize = newHashSize;
-    hashMask = newHashMask;
-    rehash = newRehash;
-    return TRUE;
-}
-
-static int
-ResizeReverseMap (void)
-{
-    AtomListPtr *newMap;
-    int newMapSize;
-
-    if (reverseMapSize == 0)
-	newMapSize = 1000;
-    else
-	newMapSize = reverseMapSize * 2;
-    newMap = realloc (reverseMap, newMapSize * sizeof (AtomListPtr));
-    if (newMap == NULL) {
-	fprintf(stderr, "ResizeReverseMap(): Error: Couldn't reallocate"
-		" reverseMap (%ld)\n",
-		newMapSize * (unsigned long)sizeof(AtomListPtr));
-	return FALSE;
-    }
-    reverseMap = newMap;
-    reverseMapSize = newMapSize;
-    return TRUE;
-}
-
-static int
-NameEqual (const char *a, const char *b, int l)
-{
-    while (l--)
-	if (*a++ != *b++)
-	    return FALSE;
-    return TRUE;
-}
-
-#ifdef __SUNPRO_C
-#pragma weak MakeAtom
-#endif
-
-weak Atom
-MakeAtom(const char *string, unsigned len, int makeit)
-{
-    AtomListPtr	a;
-    int		hash;
-    int		h = 0;
-    int		r;
-
-    OVERRIDE_SYMBOL(MakeAtom, string, len, makeit);
-
-    hash = Hash (string, len);
-    if (hashTable)
-    {
-    	h = hash & hashMask;
-	if (hashTable[h])
-	{
-	    if (hashTable[h]->hash == hash && hashTable[h]->len == len &&
-	    	NameEqual (hashTable[h]->name, string, len))
-	    {
-	    	return hashTable[h]->atom;
-	    }
-	    r = (hash % rehash) | 1;
-	    for (;;)
-	    {
-		h += r;
-		if (h >= hashSize)
-		    h -= hashSize;
-		if (!hashTable[h])
-		    break;
-		if (hashTable[h]->hash == hash && hashTable[h]->len == len &&
-		    NameEqual (hashTable[h]->name, string, len))
-		{
-		    return hashTable[h]->atom;
-		}
-	    }
-    	}
-    }
-    if (!makeit)
-	return None;
-    a = malloc (sizeof (AtomListRec) + len + 1);
-    if (a == NULL) {
-	fprintf(stderr, "MakeAtom(): Error: Couldn't allocate AtomListRec"
-		" (%ld)\n", (unsigned long)sizeof (AtomListRec) + len + 1);
-	return None;
-    }
-    a->name = (char *) (a + 1);
-    a->len = len;
-    strncpy (a->name, string, len);
-    a->name[len] = '\0';
-    a->atom = ++lastAtom;
-    a->hash = hash;
-    if (hashUsed >= hashSize / 2)
-    {
-	ResizeHashTable ();
-	h = hash & hashMask;
-	if (hashTable[h])
-	{
-	    r = (hash % rehash) | 1;
-	    do {
-		h += r;
-		if (h >= hashSize)
-		    h -= hashSize;
-	    } while (hashTable[h]);
-	}
-    }
-    hashTable[h] = a;
-    hashUsed++;
-    if (reverseMapSize <= a->atom) {
-	if (!ResizeReverseMap())
-	    return None;
-    }
-    reverseMap[a->atom] = a;
-    return a->atom;
-}
-
-#ifdef __SUNPRO_C
-#pragma weak ValidAtom
-#endif
-
-weak int
-ValidAtom(Atom atom)
-{
-    OVERRIDE_SYMBOL(ValidAtom, atom);
-    return (atom != None) && (atom <= lastAtom);
-}
-
-#ifdef __SUNPRO_C
-#pragma weak NameForAtom
-#endif
-
-weak char *
-NameForAtom(Atom atom)
-{
-    OVERRIDE_SYMBOL(NameForAtom, atom);
-    if (atom != None && atom <= lastAtom)
-	return reverseMap[atom]->name;
-    return NULL;
-}
diff --git a/src/util/fontaccel.c b/src/util/fontaccel.c
index db03e73..c8395c4 100644
--- a/src/util/fontaccel.c
+++ b/src/util/fontaccel.c
@@ -33,6 +33,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include    <X11/fonts/fontmisc.h>
 #include    <X11/fonts/fontstruct.h>
 #include    <X11/fonts/fontutil.h>
diff --git a/src/util/fontnames.c b/src/util/fontnames.c
index ceafce5..dd50f2b 100644
--- a/src/util/fontnames.c
+++ b/src/util/fontnames.c
@@ -34,6 +34,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include	<X11/fonts/fontmisc.h>
 #include	<X11/fonts/fontstruct.h>
 
diff --git a/src/util/fontutil.c b/src/util/fontutil.c
index 2c5ea6f..7b69c33 100644
--- a/src/util/fontutil.c
+++ b/src/util/fontutil.c
@@ -33,6 +33,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include    <X11/fonts/fontmisc.h>
 #include    <X11/fonts/fontstruct.h>
 #include    <X11/fonts/FSproto.h>
diff --git a/src/util/fontxlfd.c b/src/util/fontxlfd.c
index 974128e..c8f9596 100644
--- a/src/util/fontxlfd.c
+++ b/src/util/fontxlfd.c
@@ -33,6 +33,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include	<X11/fonts/fontmisc.h>
 #include	<X11/fonts/fontstruct.h>
 #include	<X11/fonts/fontxlfd.h>
diff --git a/src/util/format.c b/src/util/format.c
index c1f9762..0baeb3a 100644
--- a/src/util/format.c
+++ b/src/util/format.c
@@ -53,6 +53,7 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include	<X11/fonts/FSproto.h>
 #include	<X11/fonts/font.h>
 #include	<X11/fonts/fontstruct.h>
diff --git a/src/util/miscutil.c b/src/util/miscutil.c
index 61c9d11..e015972 100644
--- a/src/util/miscutil.c
+++ b/src/util/miscutil.c
@@ -29,38 +29,19 @@ from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/Xosdefs.h>
 #include <stdlib.h>
 #include <X11/fonts/fontmisc.h>
-#include "stubs.h"
 
 #define XK_LATIN1
 #include    <X11/keysymdef.h>
 
-
-#ifdef __SUNPRO_C
-#pragma weak serverGeneration
-#pragma weak register_fpe_functions
-#endif
-
 extern void BuiltinRegisterFpeFunctions(void);
 
-/* make sure everything initializes themselves at least once */
-weak unsigned long serverGeneration = 1;
-
-unsigned long __GetServerGeneration (void);
-
-unsigned long
-__GetServerGeneration (void)
-{
-  OVERRIDE_DATA(serverGeneration);
-  return serverGeneration;
-}
-
-weak void
+void
 register_fpe_functions (void)
 {
-    OVERRIDE_SYMBOL(register_fpe_functions);
     BuiltinRegisterFpeFunctions();
     FontFileRegisterFpeFunctions();
 #ifdef XFONT_FC
diff --git a/src/util/patcache.c b/src/util/patcache.c
index 2101015..29e2d75 100644
--- a/src/util/patcache.c
+++ b/src/util/patcache.c
@@ -31,6 +31,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include    <X11/fonts/fontmisc.h>
 #include    <X11/fonts/fontstruct.h>
 
diff --git a/src/util/private.c b/src/util/private.c
index e55e193..f4f2d57 100644
--- a/src/util/private.c
+++ b/src/util/private.c
@@ -31,6 +31,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include    <X11/fonts/fontmisc.h>
 #include    <X11/fonts/fontstruct.h>
 
diff --git a/src/util/utilbitmap.c b/src/util/utilbitmap.c
index ec726b8..fe1c412 100644
--- a/src/util/utilbitmap.c
+++ b/src/util/utilbitmap.c
@@ -31,6 +31,7 @@ in this Software without prior written authorization from The Open Group.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "libxfontint.h"
 #include <X11/fonts/fontmisc.h>
 
 /* Utility functions for reformating font bitmaps */
diff --git a/xfont.pc.in b/xfont.pc.in
deleted file mode 100644
index f08dea0..0000000
--- a/xfont.pc.in
+++ /dev/null
@@ -1,13 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: Xfont
-Description: X font Library
-Version: @VERSION@
-Requires: xproto fontsproto
-Requires.private: fontenc @FREETYPE_REQUIRES@
-Cflags: -I${includedir}
-Libs: -L${libdir} -lXfont
-Libs.private: @Z_LIBS@ -lm
diff --git a/xfont_2.pc.in b/xfont_2.pc.in
new file mode 100644
index 0000000..8527d7f
--- /dev/null
+++ b/xfont_2.pc.in
@@ -0,0 +1,13 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Xfont_2
+Description: X font Library version 2
+Version: @VERSION@
+Requires: xproto fontsproto
+Requires.private: fontenc @FREETYPE_REQUIRES@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lXfont_2
+Libs.private: @Z_LIBS@ -lm
-- 
2.5.0



More information about the xorg-devel mailing list