diff options
author | Keith Packard <keithp@keithp.com> | 2015-09-02 00:04:32 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2015-12-08 20:37:48 -0800 |
commit | 135fb032e940ce226c9feb13e6e903f3ecbc5eb0 (patch) | |
tree | b6cea9b925c7be27a13964924b7811823f52f2e2 | |
parent | eb67d10ae82b364a4324e96ce53baaa4e5e75f97 (diff) |
Eliminate calls back to X server or font server functions by name (v4)libXfont2-2.0.0
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 libXfont2 instead of libXfont, and the package
config file is now xfont2.pc.
All of the installed headers remain the same as the original library;
there's now a new include file, libxfont2.h, which defines the X
server and Font server interfaces.
This moves util/atom.c to stubs/atom.c and reformats that file, hence
the diff being larger than it would otherwise be.
v2: Rename to libXfont2 instead of libXfont_2 as suggested by Emil Velikov
Fix whitespace in stubs/atom.c, which was moved from util/
v3: Remove select masks from API. Expose single 'font_init' function
for all library initialization.
v4: Change name of distributed tarballs to libXfont2 as well
Signed-off-by: Keith Packard <keithp@keithp.com>
82 files changed, 981 insertions, 903 deletions
diff --git a/Makefile.am b/Makefile.am index 7ec3188..43ccd34 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,6 +23,9 @@ SUBDIRS=doc src libXfontincludedir = $(includedir)/X11/fonts libXfontinclude_HEADERS = \ + include/X11/fonts/libxfont2.h + +noinst_HEADERS = \ include/X11/fonts/bdfint.h \ include/X11/fonts/bitmap.h \ include/X11/fonts/bufio.h \ @@ -35,13 +38,15 @@ libXfontinclude_HEADERS = \ include/X11/fonts/fontutil.h \ include/X11/fonts/fontxlfd.h \ include/X11/fonts/pcf.h \ + include/libxfontint.h \ src/FreeType/ft.h \ src/FreeType/ftfuncs.h + nodist_libXfontinclude_HEADERS = \ include/X11/fonts/fontconf.h pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = xfont.pc +pkgconfig_DATA = xfont2.pc MAINTAINERCLEANFILES = ChangeLog INSTALL diff --git a/configure.ac b/configure.ac index dddef8a..0eb4c55 100644 --- a/configure.ac +++ b/configure.ac @@ -21,8 +21,8 @@ # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([libXfont], [1.5.1], - [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXfont]) +AC_INIT([libXfont2], [2.0.0], + [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libXfont2]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h include/X11/fonts/fontconf.h]) AC_CONFIG_MACRO_DIR([m4]) @@ -253,5 +253,5 @@ AC_CONFIG_FILES([Makefile src/fc/Makefile src/util/Makefile src/stubs/Makefile - xfont.pc]) + xfont2.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/fontutil.h b/include/X11/fonts/fontutil.h index ed55b89..6e71aa4 100644 --- a/include/X11/fonts/fontutil.h +++ b/include/X11/fonts/fontutil.h @@ -3,6 +3,7 @@ #include <X11/fonts/FSproto.h> +#if 0 extern int FontCouldBeTerminal(FontInfoPtr); extern int CheckFSFormat(fsBitmapFormat, fsBitmapFormatMask, int *, int *, int *, int *, int *); @@ -20,5 +21,6 @@ extern void InitGlyphCaching ( void ); extern void SetGlyphCachingMode ( int newmode ); extern int add_range ( fsRange *newrange, int *nranges, fsRange **range, Bool charset_subset ); +#endif #endif /* _FONTUTIL_H_ */ diff --git a/include/X11/fonts/libxfont2.h b/include/X11/fonts/libxfont2.h new file mode 100644 index 0000000..0ba7419 --- /dev/null +++ b/include/X11/fonts/libxfont2.h @@ -0,0 +1,163 @@ +/* + * 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 _LIBXFONT2_H_ +#define _LIBXFONT2_H_ + +#include <stdarg.h> +#include <stdint.h> +#include <X11/Xfuncproto.h> +#include <X11/fonts/font.h> + +#define XFONT2_FPE_FUNCS_VERSION 1 + +typedef int (*WakeupFpe) (FontPathElementPtr fpe); + +typedef struct _xfont2_fpe_funcs { + int version; + NameCheckFunc name_check; + InitFpeFunc init_fpe; + FreeFpeFunc free_fpe; + ResetFpeFunc reset_fpe; + OpenFontFunc open_font; + CloseFontFunc close_font; + ListFontsFunc list_fonts; + StartLfwiFunc start_list_fonts_with_info; + NextLfwiFunc list_next_font_with_info; + WakeupFpe wakeup_fpe; + ClientDiedFunc client_died; + LoadGlyphsFunc load_glyphs; + StartLaFunc start_list_fonts_and_aliases; + NextLaFunc list_next_font_or_alias; + SetPathFunc set_path_hook; +} xfont2_fpe_funcs_rec, *xfont2_fpe_funcs_ptr; + +typedef void (*FontBlockHandlerProcPtr) (void *timeout); + +typedef void (*FontFdHandlerProcPtr) (int fd, void *data); + +#define XFONT2_CLIENT_FUNCS_VERSION 1 + +typedef struct _xfont2_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, + FontBlockHandlerProcPtr block_handler); + int (*register_fpe_funcs)(const xfont2_fpe_funcs_rec *funcs); + void (*remove_fs_handlers)(FontPathElementPtr fpe, + FontBlockHandlerProcPtr 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); + int (*add_fs_fd)(int fd, FontFdHandlerProcPtr handler, void *data); + void (*remove_fs_fd)(int fd); + void (*adjust_fs_wait_for_delay)(void *wt, unsigned long newdelay); +} xfont2_client_funcs_rec, *xfont2_client_funcs_ptr; + +_X_EXPORT int +xfont2_init(xfont2_client_funcs_rec const *client_funcs); + +_X_EXPORT void +xfont2_query_glyph_extents(FontPtr pFont, CharInfoPtr *charinfo, + unsigned long count, ExtentInfoRec *info); + +_X_EXPORT Bool +xfont2_query_text_extents(FontPtr pFont, unsigned long count, + unsigned char *chars, ExtentInfoRec *info); + +_X_EXPORT Bool +xfont2_parse_glyph_caching_mode(char *str); + +_X_EXPORT void +xfont2_init_glyph_caching(void); + +_X_EXPORT void +xfont2_set_glyph_caching_mode(int newmode); + +_X_EXPORT FontNamesPtr +xfont2_make_font_names_record(unsigned size); + +_X_EXPORT void +xfont2_free_font_names(FontNamesPtr pFN); + +_X_EXPORT int +xfont2_add_font_names_name(FontNamesPtr names, + char *name, + int length); + +typedef struct _xfont2_pattern_cache *xfont2_pattern_cache_ptr; + +_X_EXPORT xfont2_pattern_cache_ptr +xfont2_make_font_pattern_cache(void); + +_X_EXPORT void +xfont2_free_font_pattern_cache(xfont2_pattern_cache_ptr cache); + +_X_EXPORT void +xfont2_empty_font_pattern_cache(xfont2_pattern_cache_ptr cache); + +_X_EXPORT void +xfont2_cache_font_pattern(xfont2_pattern_cache_ptr cache, + const char * pattern, + int patlen, + FontPtr pFont); + +_X_EXPORT FontPtr +xfont2_find_cached_font_pattern(xfont2_pattern_cache_ptr cache, + const char * pattern, + int patlen); + +_X_EXPORT void +xfont2_remove_cached_font_pattern(xfont2_pattern_cache_ptr cache, + FontPtr pFont); + +/* private.c */ + +_X_EXPORT int +xfont2_allocate_font_private_index (void); + +static inline void * +xfont2_font_get_private(FontPtr pFont, int n) +{ + if (n > pFont->maxPrivate) + return NULL; + return pFont->devPrivates[n]; +} + +_X_EXPORT Bool +xfont2_font_set_private(FontPtr pFont, int n, void *ptr); + +#endif /* _LIBXFONT2_H_ */ diff --git a/include/libxfontint.h b/include/libxfontint.h new file mode 100644 index 0000000..09772b6 --- /dev/null +++ b/include/libxfontint.h @@ -0,0 +1,130 @@ +/* + * 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_ + +#include <X11/fonts/FSproto.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 + +#define add_fs_fd __libxfont_add_fs_fd +#define remove_fs_fd __libxfont_remove_fs_fd +#define adjust_fs_wait_for_delay __libxfont_adjust_fs_wait_for_delay + +#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/libxfont2.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 xfont2_fpe_funcs_rec *funcs); + +void * +__GetServerClient(void); + +int +set_font_authorizations(char **authorizations, int *authlen, ClientPtr client); + +unsigned long +__GetServerGeneration (void); + +int add_fs_fd(int fd, FontFdHandlerProcPtr handler, void *data); + +void remove_fs_fd(int fd); + +void adjust_fs_wait_for_delay(void *wt, unsigned long newdelay); + +int +init_fs_handlers2(FontPathElementPtr fpe, + FontBlockHandlerProcPtr block_handler); + +void +remove_fs_handlers2(FontPathElementPtr fpe, + FontBlockHandlerProcPtr blockHandler, + Bool all); + +Atom +__libxfont_internal__MakeAtom(const char *string, unsigned len, int makeit); + +int +__libxfont_internal__ValidAtom(Atom atom); + +const char * +__libxfont_internal__NameForAtom(Atom atom); + +int +CheckFSFormat(fsBitmapFormat format, + fsBitmapFormatMask fmask, + int *bit_order, + int *byte_order, + int *scan, + int *glyph, + int *image); + +int +FontCouldBeTerminal(FontInfoPtr); + +void +FontComputeInfoAccelerators(FontInfoPtr); + +int +add_range (fsRange *newrange, int *nranges, fsRange **range, + Bool charset_subset); + +#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 df64f5e..bbd4db4 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 e30e0f9..f54f76c 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..03c704a 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 = libXfont2.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 = \ +libXfont2_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 +libXfont2_la_SOURCES = dummy.c -libXfont_la_LDFLAGS = -version-number 1:4:1 -no-undefined +libXfont2_la_LDFLAGS = -version-number 2:0:0 -no-undefined diff --git a/src/bitmap/bdfread.c b/src/bitmap/bdfread.c index f343eed..f2b1e22 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 438d197..253cb93 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 33871ae..dab1c44 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..e1b6973 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 xfont2_fpe_funcs_rec builtin_fpe_funcs = { + .version = XFONT2_FPE_FUNCS_VERSION, + .name_check = BuiltinNameCheck, + .init_fpe = BuiltinInitFPE, + .free_fpe = BuiltinFreeFPE, + .reset_fpe = BuiltinResetFPE, + .open_font = FontFileOpenFont, + .close_font = FontFileCloseFont, + .list_fonts = FontFileListFonts, + .start_list_fonts_with_info = FontFileStartListFontsWithInfo, + .list_next_font_with_info = FontFileListNextFontWithInfo, + .wakeup_fpe = 0, + .client_died = 0, + .load_glyphs = 0, + .start_list_fonts_and_aliases = 0, + .list_next_font_or_alias = 0, + .set_path_hook = 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..42c4028 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_ @@ -101,18 +102,14 @@ 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, FSBlockDataPtr blockrec ); -extern fd_set _fs_fd_mask; +static void fs_block_handler ( void *wt ); -static void fs_block_handler ( pointer data, OSTimePtr wt, - pointer LastSelectMask ); -static int fs_wakeup ( FontPathElementPtr fpe, unsigned long *mask ); +static int fs_wakeup ( FontPathElementPtr fpe ); /* * List of all FPEs @@ -147,7 +144,7 @@ static void _fs_close_server (FSFpePtr conn); static FSFpePtr -_fs_init_conn (const char *servername); +_fs_init_conn (const char *servername, FontPathElementPtr fpe); static int _fs_wait_connect (FSFpePtr conn); @@ -167,6 +164,9 @@ _fs_free_conn (FSFpePtr conn); static int fs_free_fpe(FontPathElementPtr fpe); +static void +fs_fd_handler(int fd, void *data); + /* * Font server access * @@ -305,12 +305,12 @@ fs_init_fpe(FontPathElementPtr fpe) if (*name == ':') name++; /* skip ':' */ - conn = _fs_init_conn (name); + conn = _fs_init_conn (name, fpe); if (!conn) err = AllocError; else { - err = init_fs_handlers (fpe, fs_block_handler); + err = init_fs_handlers2 (fpe, fs_block_handler); if (err != Successful) { _fs_free_conn (conn); @@ -383,7 +383,7 @@ fs_free_fpe(FontPathElementPtr fpe) } _fs_unmark_block (conn, conn->blockState); fs_close_conn(conn); - remove_fs_handlers(fpe, fs_block_handler, fs_fpes == 0); + remove_fs_handlers2(fpe, fs_block_handler, fs_fpes == 0); _fs_free_conn (conn); fpe->private = (pointer) 0; @@ -515,6 +515,24 @@ _fs_add_clients_depending(FSClientsDependingPtr *clients_depending, pointer clie return Suspended; } +static void +conn_start_listening(FSFpePtr conn) +{ + if (!conn->fs_listening) { + add_fs_fd(conn->fs_fd, fs_fd_handler, conn->fpe); + conn->fs_listening = TRUE; + } +} + +static void +conn_stop_listening(FSFpePtr conn) +{ + if (conn->fs_listening) { + remove_fs_fd(conn->fs_fd); + conn->fs_listening = FALSE; + } +} + /* * When a request is aborted due to a font server failure, * signal any depending clients to restart their dependant @@ -546,7 +564,7 @@ _fs_clean_aborted_blockrec(FSFpePtr conn, FSBlockDataPtr blockrec) FSBlockedListInfoPtr binfo; binfo = (FSBlockedListInfoPtr) blockrec->data; if (binfo->status == FS_LFWI_REPLY) - FD_SET(conn->fs_fd, &_fs_fd_mask); + conn_start_listening(conn); _fs_free_props (&binfo->info); } default: @@ -608,7 +626,7 @@ fs_get_reply (FSFpePtr conn, int *error) int ret; /* block if the connection is down or paused in lfwi */ - if (conn->fs_fd == -1 || !FD_ISSET (conn->fs_fd, &_fs_fd_mask)) + if (conn->fs_fd == -1 || !conn->fs_listening) { *error = FSIO_BLOCK; return 0; @@ -655,7 +673,7 @@ fs_reply_ready (FSFpePtr conn) { fsGenericReply *rep; - if (conn->fs_fd == -1 || !FD_ISSET (conn->fs_fd, &_fs_fd_mask)) + if (conn->fs_fd == -1 || !conn->fs_listening) return FALSE; if (fs_data_read (conn) < sizeof (fsGenericReply)) return FALSE; @@ -1300,15 +1318,12 @@ _fs_unmark_block (FSFpePtr conn, CARD32 mask) /* ARGSUSED */ static void -fs_block_handler(pointer data, OSTimePtr wt, pointer LastSelectMask) +fs_block_handler(void *wt) { - static struct timeval block_timeout; CARD32 now, earliest, wakeup; int soonest; FSFpePtr conn; - XFD_ORSET((fd_set *)LastSelectMask, (fd_set *)LastSelectMask, - &_fs_fd_mask); /* * Flush all pending output */ @@ -1320,14 +1335,7 @@ fs_block_handler(pointer data, OSTimePtr wt, pointer LastSelectMask) * Check for any fpe with a complete reply, set sleep time to zero */ if (fs_blockState & FS_COMPLETE_REPLY) - { - block_timeout.tv_sec = 0; - block_timeout.tv_usec = 0; - if (*wt == NULL) - *wt = &block_timeout; - else - **wt = block_timeout; - } + adjust_fs_wait_for_delay(wt, 0); /* * Walk through fpe list computing sleep time */ @@ -1368,12 +1376,7 @@ fs_block_handler(pointer data, OSTimePtr wt, pointer LastSelectMask) soonest = earliest - now; if (soonest < 0) soonest = 0; - block_timeout.tv_sec = soonest / 1000; - block_timeout.tv_usec = (soonest % 1000) * 1000; - if (*wt == NULL) - *wt = &block_timeout; - else if (soonest < (*wt)->tv_sec * 1000 + (*wt)->tv_usec / 1000) - **wt = block_timeout; + adjust_fs_wait_for_delay(wt, soonest); } } @@ -1460,11 +1463,11 @@ fs_read_reply (FontPathElementPtr fpe, pointer client) } } -static int -fs_wakeup(FontPathElementPtr fpe, unsigned long *mask) +static void +fs_fd_handler(int fd, void *data) { - fd_set *LastSelectMask = (fd_set *) mask; - FSFpePtr conn = (FSFpePtr) fpe->private; + FontPathElementPtr fpe = data; + FSFpePtr conn = (FSFpePtr) fpe->private; /* * Don't continue if the fd is -1 (which will be true when the @@ -1472,11 +1475,19 @@ fs_wakeup(FontPathElementPtr fpe, unsigned long *mask) */ if ((conn->blockState & FS_RECONNECTING)) _fs_check_reconnect (conn); - else if ((conn->blockState & FS_COMPLETE_REPLY) || - (conn->fs_fd != -1 && FD_ISSET(conn->fs_fd, LastSelectMask))) + else if ((conn->fs_fd != -1)) fs_read_reply (fpe, 0); +} + +static int +fs_wakeup(FontPathElementPtr fpe) +{ + FSFpePtr conn = (FSFpePtr) fpe->private; + if (conn->blockState & (FS_PENDING_REPLY|FS_BROKEN_CONNECTION|FS_BROKEN_WRITE)) _fs_do_blocked (conn); + if (conn->blockState & FS_COMPLETE_REPLY) + fs_read_reply (fpe, 0); #ifdef DEBUG { FSBlockDataPtr blockrec; @@ -2160,11 +2171,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) @@ -2392,7 +2398,7 @@ fs_read_list(FontPathElementPtr fpe, FSBlockDataPtr blockrec) err = BadFontName; break; } - err = AddFontNamesName(blist->names, data, length); + err = xfont2_add_font_names_name(blist->names, data, length); if (err != Successful) break; data += length; @@ -2621,7 +2627,7 @@ fs_read_list_info(FontPathElementPtr fpe, FSBlockDataPtr blockrec) /* disable this font server until we've processed this response */ _fs_unmark_block (conn, FS_COMPLETE_REPLY); - FD_CLR(conn->fs_fd, &_fs_fd_mask); + conn_stop_listening(conn); done: _fs_done_read (conn, rep->length << 2); return err; @@ -2724,7 +2730,7 @@ fs_next_list_with_info(pointer client, FontPathElementPtr fpe, *numFonts = binfo->remaining; /* Restart reply processing from this font server */ - FD_SET(conn->fs_fd, &_fs_fd_mask); + conn_start_listening(conn); if (fs_reply_ready (conn)) _fs_mark_block (conn, FS_COMPLETE_REPLY); @@ -2887,7 +2893,7 @@ _fs_check_connect (FSFpePtr conn) switch (ret) { case FSIO_READY: conn->fs_fd = _FontTransGetConnectionNumber (conn->trans_conn); - FD_SET (conn->fs_fd, &_fs_fd_mask); + conn_start_listening(conn); break; case FSIO_BLOCK: break; @@ -3228,7 +3234,7 @@ _fs_close_server (FSFpePtr conn) } if (conn->fs_fd >= 0) { - FD_CLR (conn->fs_fd, &_fs_fd_mask); + conn_stop_listening(conn); conn->fs_fd = -1; } conn->fs_conn_state = FS_CONN_UNCONNECTED; @@ -3362,7 +3368,7 @@ _fs_start_reconnect (FSFpePtr conn) static FSFpePtr -_fs_init_conn (const char *servername) +_fs_init_conn (const char *servername, FontPathElementPtr fpe) { FSFpePtr conn; @@ -3377,6 +3383,7 @@ _fs_init_conn (const char *servername) conn->servername = (char *) (conn + 1); conn->fs_conn_state = FS_CONN_UNCONNECTED; conn->fs_fd = -1; + conn->fpe = fpe; strcpy (conn->servername, servername); return conn; } @@ -3395,22 +3402,27 @@ _fs_free_conn (FSFpePtr conn) * called at server init time */ +static const xfont2_fpe_funcs_rec fs_fpe_funcs = { + .version = XFONT2_FPE_FUNCS_VERSION, + .name_check = fs_name_check, + .init_fpe = fs_init_fpe, + .free_fpe = fs_free_fpe, + .reset_fpe = fs_reset_fpe, + .open_font = fs_open_font, + .close_font = fs_close_font, + .list_fonts = fs_list_fonts, + .start_list_fonts_with_info = fs_start_list_with_info, + .list_next_font_with_info = fs_next_list_with_info, + .wakeup_fpe = fs_wakeup, + .client_died = fs_client_died, + .load_glyphs = _fs_load_glyphs, + .start_list_fonts_and_aliases = (StartLaFunc) 0, + .list_next_font_or_alias = (NextLaFunc) 0, + .set_path_hook = (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..a5fe5b0 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_ @@ -65,7 +66,6 @@ static int padlength[4] = {0, 3, 2, 1}; -fd_set _fs_fd_mask; static int _fs_resize (FSBufPtr buf, long size); diff --git a/src/fc/fsio.h b/src/fc/fsio.h index fa1e7d8..9d0255a 100644 --- a/src/fc/fsio.h +++ b/src/fc/fsio.h @@ -81,7 +81,9 @@ typedef struct _fs_buf { /* FS specific font FontPathElement data */ typedef struct _fs_fpe_data { FSFpePtr next; /* list of all active fs fpes */ + FontPathElementPtr fpe; /* Back pointer to FPE */ int fs_fd; /* < 0 when not running */ + Bool fs_listening; /* Listening for input */ int fs_conn_state; /* connection state */ int current_seq; char *servername; diff --git a/src/fc/fstrans.c b/src/fc/fstrans.c index 9b21864..66bc978 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..2087232 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 xfont2_fpe_funcs_rec catalogue_fpe_funcs = { + .version = XFONT2_FPE_FUNCS_VERSION, + .name_check = CatalogueNameCheck, + .init_fpe = CatalogueInitFPE, + .free_fpe = CatalogueFreeFPE, + .reset_fpe = CatalogueResetFPE, + .open_font = CatalogueOpenFont, + .close_font = CatalogueCloseFont, + .list_fonts = CatalogueListFonts, + .start_list_fonts_with_info = CatalogueStartListFontsWithInfo, + .list_next_font_with_info = CatalogueListNextFontWithInfo, + .wakeup_fpe = 0, + .client_died = 0, + .load_glyphs = 0, + .start_list_fonts_and_aliases = CatalogueStartListFontsAndAliases, + .list_next_font_or_alias = CatalogueListNextFontOrAlias, + .set_path_hook = 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..4ce2473 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> @@ -513,7 +514,7 @@ FontFileFindNamesInScalableDir(FontTablePtr table, FontNamePtr pat, int max, { name = &table->entries[i].name; if (newmax) *newmax = max - 1; - return AddFontNamesName(names, name->name, name->length); + return xfont2_add_font_names_name(names, name->name, name->length); } start = i; stop = i + 1; @@ -550,7 +551,7 @@ FontFileFindNamesInScalableDir(FontTablePtr table, FontNamePtr pat, int max, continue; } - ret = AddFontNamesName(names, fname->name.name, fname->name.length); + ret = xfont2_add_font_names_name(names, fname->name.name, fname->name.length); if (ret != Successful) goto bail; @@ -562,7 +563,7 @@ FontFileFindNamesInScalableDir(FontTablePtr table, FontNamePtr pat, int max, { names->length[names->nnames - 1] = -names->length[names->nnames - 1]; - ret = AddFontNamesName(names, fname->u.alias.resolved, + ret = xfont2_add_font_names_name(names, fname->u.alias.resolved, strlen(fname->u.alias.resolved)); if (ret != Successful) goto bail; 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..b2f1a6f 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 @@ -629,7 +630,7 @@ _FontFileAddScalableNames(FontNamesPtr names, FontNamesPtr scaleNames, Otherwise we're done. */ if (scaleNames->length[i] >= 0) { - (void) AddFontNamesName (names, nameChars, + (void) xfont2_add_font_names_name (names, nameChars, strlen (nameChars)); /* If our original pattern matches the name from the table and that name doesn't duplicate what @@ -641,7 +642,7 @@ _FontFileAddScalableNames(FontNamesPtr names, FontNamesPtr scaleNames, *max) { --*max; - (void) AddFontNamesName (names, scaleNames->names[i], + (void) xfont2_add_font_names_name (names, scaleNames->names[i], scaleNames->length[i]); } } @@ -655,11 +656,11 @@ _FontFileAddScalableNames(FontNamesPtr names, FontNamesPtr scaleNames, scaleNames->names[++i], &aliasName, vals)) { - (void) AddFontNamesName (names, nameChars, + (void) xfont2_add_font_names_name (names, nameChars, strlen (nameChars)); names->length[names->nnames - 1] = -names->length[names->nnames - 1]; - (void) AddFontNamesName (names, aliasName, + (void) xfont2_add_font_names_name (names, aliasName, strlen (aliasName)); /* If our original pattern matches the name from the table and that name doesn't duplicate what @@ -671,12 +672,12 @@ _FontFileAddScalableNames(FontNamesPtr names, FontNamesPtr scaleNames, *max) { --*max; - (void) AddFontNamesName (names, + (void) xfont2_add_font_names_name (names, scaleNames->names[i - 1], -scaleNames->length[i - 1]); names->length[names->nnames - 1] = -names->length[names->nnames - 1]; - (void) AddFontNamesName (names, aliasName, + (void) xfont2_add_font_names_name (names, aliasName, strlen (aliasName)); } } @@ -733,7 +734,7 @@ _FontFileListFonts (pointer client, FontPathElementPtr fpe, them to the output */ /* Scalable names... */ - scaleNames = MakeFontNamesRecord (0); + scaleNames = xfont2_make_font_names_record (0); if (!scaleNames) { if (ranges) free(ranges); @@ -747,10 +748,10 @@ _FontFileListFonts (pointer client, FontPathElementPtr fpe, _FontFileAddScalableNames(names, scaleNames, &lowerName, zeroChars, &vals, ranges, nranges, &max); - FreeFontNames (scaleNames); + xfont2_free_font_names (scaleNames); /* Scalable aliases... */ - scaleNames = MakeFontNamesRecord (0); + scaleNames = xfont2_make_font_names_record (0); if (!scaleNames) { if (ranges) free(ranges); @@ -764,7 +765,7 @@ _FontFileListFonts (pointer client, FontPathElementPtr fpe, _FontFileAddScalableNames(names, scaleNames, &lowerName, zeroChars, &vals, ranges, nranges, &max); - FreeFontNames (scaleNames); + xfont2_free_font_names (scaleNames); if (ranges) free(ranges); } @@ -811,7 +812,7 @@ FontFileStartListFonts(pointer client, FontPathElementPtr fpe, data = malloc (sizeof *data); if (!data) return AllocError; - data->names = MakeFontNamesRecord (0); + data->names = xfont2_make_font_names_record (0); if (!data->names) { free (data); @@ -821,7 +822,7 @@ FontFileStartListFonts(pointer client, FontPathElementPtr fpe, max, data->names, mark_aliases); if (ret != Successful) { - FreeFontNames (data->names); + xfont2_free_font_names (data->names); free (data); return ret; } @@ -1049,7 +1050,7 @@ FontFileListNextFontWithInfo(pointer client, FontPathElementPtr fpe, if (data->current == data->names->nnames) { - FreeFontNames (data->names); + xfont2_free_font_names (data->names); free (data); return BadFontName; } @@ -1085,7 +1086,7 @@ FontFileListNextFontOrAlias(pointer client, FontPathElementPtr fpe, if (data->current == data->names->nnames) { - FreeFontNames (data->names); + xfont2_free_font_names (data->names); free (data); return BadFontName; } @@ -1115,22 +1116,27 @@ FontFileListNextFontOrAlias(pointer client, FontPathElementPtr fpe, return ret; } +static const xfont2_fpe_funcs_rec fontfile_fpe_funcs = { + .version = XFONT2_FPE_FUNCS_VERSION, + .name_check = FontFileNameCheck, + .init_fpe = FontFileInitFPE, + .free_fpe = FontFileFreeFPE, + .reset_fpe = FontFileResetFPE, + .open_font = FontFileOpenFont, + .close_font = FontFileCloseFont, + .list_fonts = FontFileListFonts, + .start_list_fonts_with_info = FontFileStartListFontsWithInfo, + .list_next_font_with_info = FontFileListNextFontWithInfo, + .wakeup_fpe = 0, + .client_died = 0, + .load_glyphs = 0, + .start_list_fonts_and_aliases = FontFileStartListFontsAndAliases, + .list_next_font_or_alias = FontFileListNextFontOrAlias, + .set_path_hook = 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..82c8ca3 --- /dev/null +++ b/src/stubs/atom.c @@ -0,0 +1,224 @@ +/* + + 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..b083dd4 --- /dev/null +++ b/src/stubs/libxfontstubs.c @@ -0,0 +1,198 @@ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "libxfontint.h" + +static xfont2_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_handlers2(FontPathElementPtr fpe, + FontBlockHandlerProcPtr block_handler) +{ + if (_f) + return _f->init_fs_handlers(fpe, block_handler); + return Successful; +} + +int +register_fpe_funcs(const xfont2_fpe_funcs_rec *funcs) +{ + if (_f) + return _f->register_fpe_funcs(funcs); + return 0; +} + +void +remove_fs_handlers2(FontPathElementPtr fpe, + FontBlockHandlerProcPtr 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; +} + + +int +add_fs_fd(int fd, FontFdHandlerProcPtr handler, void *data) +{ + if (_f) + return _f->add_fs_fd(fd, handler, data); + return 0; +} + +void +remove_fs_fd(int fd) +{ + if (_f) + _f->remove_fs_fd(fd); +} + +void +adjust_fs_wait_for_delay(void *wt, unsigned long newdelay) +{ + if (_f) + _f->adjust_fs_wait_for_delay(wt, newdelay); +} + +int +xfont2_init(xfont2_client_funcs_rec const *client_funcs) +{ + _f = client_funcs; + + ResetFontPrivateIndex(); + + register_fpe_functions(); + + return Successful; +} 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 9e71806..0000000 --- a/src/stubs/stubs.h +++ /dev/null @@ -1,79 +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(__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) - -extern int (*__client_auth_generation)(ClientPtr); -extern Bool (*__ClientSignal)(ClientPtr); -extern void (*__DeleteFontClientID)(Font); -extern void (*__VErrorF)(const char *, va_list); -extern FontPtr (*__find_old_font)(FSID); -extern FontResolutionPtr (*__GetClientResolutions)(int *); -extern int (*__GetDefaultPointSize)(void); -extern Font (*__GetNewFontClientID)(void); -extern unsigned long (*__GetTimeInMillis)(void); -extern int (*__init_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr); -extern int (*__RegisterFPEFunctions)(NameCheckFunc, InitFpeFunc, FreeFpeFunc, - ResetFpeFunc, OpenFontFunc, CloseFontFunc, ListFontsFunc, - StartLfwiFunc, NextLfwiFunc, WakeupFpeFunc, ClientDiedFunc, - LoadGlyphsFunc, StartLaFunc, NextLaFunc, SetPathFunc); -extern void (*__remove_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr, Bool); -extern void **__ptr_serverClient; -extern int (*__set_font_authorizations)(char **, int *, ClientPtr); -extern int (*__StoreFontClientFont)(FontPtr, Font); -extern Atom (*__MakeAtom)(const char *, unsigned, int); -extern int (*__ValidAtom)(Atom); -extern char *(*__NameForAtom)(Atom); -extern unsigned long *__ptr_serverGeneration; -extern 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 - -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..b292480 100644 --- a/src/util/fontnames.c +++ b/src/util/fontnames.c @@ -34,11 +34,12 @@ 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> void -FreeFontNames(FontNamesPtr pFN) +xfont2_free_font_names(FontNamesPtr pFN) { int i; @@ -53,7 +54,7 @@ FreeFontNames(FontNamesPtr pFN) } FontNamesPtr -MakeFontNamesRecord(unsigned int size) +xfont2_make_font_names_record(unsigned size) { FontNamesPtr pFN; @@ -82,7 +83,9 @@ MakeFontNamesRecord(unsigned int size) } int -AddFontNamesName(FontNamesPtr names, char *name, int length) +xfont2_add_font_names_name(FontNamesPtr names, + char *name, + int length) { int index = names->nnames; char *nelt; diff --git a/src/util/fontutil.c b/src/util/fontutil.c index 2c5ea6f..d1b845b 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> @@ -44,25 +45,14 @@ from The Open Group. static int defaultGlyphCachingMode = DEFAULT_GLYPH_CACHING_MODE; int glyphCachingMode = DEFAULT_GLYPH_CACHING_MODE; -void -GetGlyphs(FontPtr font, - unsigned long count, - unsigned char *chars, - FontEncoding fontEncoding, - unsigned long *glyphcount, /* RETURN */ - CharInfoPtr *glyphs) /* RETURN */ -{ - (*font->get_glyphs) (font, count, chars, fontEncoding, glyphcount, glyphs); -} - #define MIN(a,b) ((a)<(b)?(a):(b)) #define MAX(a,b) ((a)>(b)?(a):(b)) void -QueryGlyphExtents(FontPtr pFont, - CharInfoPtr *charinfo, - unsigned long count, - ExtentInfoRec *info) +xfont2_query_glyph_extents(FontPtr pFont, + CharInfoPtr *charinfo, + unsigned long count, + ExtentInfoRec *info) { register unsigned long i; xCharInfo *pCI; @@ -131,10 +121,10 @@ QueryGlyphExtents(FontPtr pFont, } Bool -QueryTextExtents(FontPtr pFont, - unsigned long count, - unsigned char *chars, - ExtentInfoRec *info) +xfont2_query_text_extents(FontPtr pFont, + unsigned long count, + unsigned char *chars, + ExtentInfoRec *info) { xCharInfo **charinfo; unsigned long n; @@ -182,15 +172,15 @@ QueryTextExtents(FontPtr pFont, } cm = pFont->info.constantMetrics; pFont->info.constantMetrics = FALSE; - QueryGlyphExtents(pFont, (CharInfoPtr*) charinfo + firstReal, - n - firstReal, info); + xfont2_query_glyph_extents(pFont, (CharInfoPtr*) charinfo + firstReal, + n - firstReal, info); pFont->info.constantMetrics = cm; free(charinfo); return TRUE; } Bool -ParseGlyphCachingMode(char *str) +xfont2_parse_glyph_caching_mode(char *str) { if (!strcmp(str, "none")) defaultGlyphCachingMode = CACHING_OFF; else if (!strcmp(str, "all")) defaultGlyphCachingMode = CACHE_ALL_GLYPHS; @@ -200,7 +190,7 @@ ParseGlyphCachingMode(char *str) } void -InitGlyphCaching(void) +xfont2_init_glyph_caching(void) { /* Set glyphCachingMode to the mode the server hopes to support. DDX drivers that do not support the requested level @@ -215,7 +205,7 @@ InitGlyphCaching(void) * caching they can support. */ void -SetGlyphCachingMode(int newmode) +xfont2_set_glyph_caching_mode(int newmode) { if ( (glyphCachingMode > newmode) && (newmode >= 0) ) glyphCachingMode = newmode; diff --git a/src/util/fontxlfd.c b/src/util/fontxlfd.c index 99a3679..0bd1140 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..e76f1f4 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> @@ -55,15 +56,15 @@ typedef struct _FontPatternCacheEntry { FontPtr pFont; /* associated font */ } FontPatternCacheEntryRec, *FontPatternCacheEntryPtr; -typedef struct _FontPatternCache { +typedef struct _xfont2_pattern_cache { FontPatternCacheEntryPtr buckets[NBUCKETS]; FontPatternCacheEntryRec entries[NENTRIES]; FontPatternCacheEntryPtr free; -} FontPatternCacheRec; +} xfont2_pattern_cache_rec; /* Empty cache (for rehash) */ void -EmptyFontPatternCache (FontPatternCachePtr cache) +xfont2_empty_font_pattern_cache(xfont2_pattern_cache_ptr cache) { int i; @@ -83,10 +84,10 @@ EmptyFontPatternCache (FontPatternCachePtr cache) } /* Create and initialize cache */ -FontPatternCachePtr -MakeFontPatternCache (void) +xfont2_pattern_cache_ptr +xfont2_make_font_pattern_cache(void) { - FontPatternCachePtr cache; + xfont2_pattern_cache_ptr cache; int i; cache = malloc (sizeof *cache); if (!cache) @@ -96,13 +97,13 @@ MakeFontPatternCache (void) cache->entries[i].pattern = 0; cache->entries[i].pFont = 0; } - EmptyFontPatternCache (cache); + xfont2_empty_font_pattern_cache (cache); return cache; } /* toss cache */ void -FreeFontPatternCache (FontPatternCachePtr cache) +xfont2_free_font_pattern_cache(xfont2_pattern_cache_ptr cache) { int i; @@ -127,10 +128,10 @@ Hash (const char *string, int len) /* add entry */ void -CacheFontPattern (FontPatternCachePtr cache, - const char *pattern, - int patlen, - FontPtr pFont) +xfont2_cache_font_pattern(xfont2_pattern_cache_ptr cache, + const char * pattern, + int patlen, + FontPtr pFont) { FontPatternCacheEntryPtr e; char *newpat; @@ -173,9 +174,9 @@ CacheFontPattern (FontPatternCachePtr cache, /* find matching entry */ FontPtr -FindCachedFontPattern (FontPatternCachePtr cache, - const char *pattern, - int patlen) +xfont2_find_cached_font_pattern(xfont2_pattern_cache_ptr cache, + const char * pattern, + int patlen) { int hash; int i; @@ -195,8 +196,8 @@ FindCachedFontPattern (FontPatternCachePtr cache, } void -RemoveCachedFontPattern (FontPatternCachePtr cache, - FontPtr pFont) +xfont2_remove_cached_font_pattern(xfont2_pattern_cache_ptr cache, + FontPtr pFont) { FontPatternCacheEntryPtr e; int i; diff --git a/src/util/private.c b/src/util/private.c index e55e193..92075c2 100644 --- a/src/util/private.c +++ b/src/util/private.c @@ -31,13 +31,14 @@ 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> static int _FontPrivateAllocateIndex = 0; int -AllocateFontPrivateIndex (void) +xfont2_allocate_font_private_index (void) { return _FontPrivateAllocateIndex++; } @@ -77,7 +78,7 @@ ResetFontPrivateIndex (void) } Bool -_FontSetNewPrivate (FontPtr pFont, int n, pointer ptr) +xfont2_font_set_private(FontPtr pFont, int n, pointer ptr) { pointer *new; 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/xfont2.pc.in index f08dea0..ac3f53a 100644 --- a/xfont.pc.in +++ b/xfont2.pc.in @@ -3,11 +3,11 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ -Name: Xfont -Description: X font Library +Name: Xfont2 +Description: X font Library version 2 Version: @VERSION@ Requires: xproto fontsproto Requires.private: fontenc @FREETYPE_REQUIRES@ Cflags: -I${includedir} -Libs: -L${libdir} -lXfont +Libs: -L${libdir} -lXfont2 Libs.private: @Z_LIBS@ -lm |