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

Matt Turner mattst88 at gmail.com
Wed Sep 2 11:44:31 PDT 2015


On Wed, Sep 2, 2015 at 12:15 AM, Keith Packard <keithp at keithp.com> wrote:
> 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>
> ---

Some whitespace fixes and a problem with an #include noted below.

>  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

Trailing space on this line

> +#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>

I don't know where this header is supposed to be (maybe it's supposed
to be libxfont_2.h?), but it's not there and causes a build failure.
Simply removing the #include lets it compile without warnings.

>
>  #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;

Space before tab on this line

> +       if (hashTable[h])
> +       {
> +           if (hashTable[h]->hash == hash && hashTable[h]->len == len &&
> +               NameEqual (hashTable[h]->name, string, len))

and this one

> +           {
> +               return hashTable[h]->atom;

and this one

> +           }
> +           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;
> +               }
> +           }
> +       }

and this one


More information about the xorg-devel mailing list