diff --git a/Makefile.am b/Makefile.am index 7ec31880d533f8128db4e8d04adb8b59b1e621e2..43ccd344ffcf8c0b6640b85652b5aa2924d3e9e7 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 dddef8a258009cf7bff5cbcc4ffe699b573f2f3e..0eb4c5520d653812293e9c383a09f60e0d7f3207 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 e7a9f4a35fa02903756de523da660e09b0b95ff9..387533d6751b24c6573ec28765df3a32996adce0 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 d3926a73ec378ea054ed2f48206493cfd04a72ff..06e49f5f0d132f9fe76e1c7adacae04cf6a7d2fb 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 ed55b89e9f49c3bf16242437edc0257149d93df3..6e71aa44d550a760dba3c6f673f0e69604d5d3d0 100644 --- a/include/X11/fonts/fontutil.h +++ b/include/X11/fonts/fontutil.h @@ -3,6 +3,7 @@ #include +#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 0000000000000000000000000000000000000000..0ba7419aeb5f290328ae6602d2bdcbb7a34e2eb2 --- /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 +#include +#include +#include + +#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 0000000000000000000000000000000000000000..09772b6d504c7cdd7ff00a5f6d7024bebba2e5f3 --- /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 + +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#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 8cf31d4ab8261ac4ec951d91e1aeb9575bc7ccec..7fa86b02bec97a7c663332e49f2b8042c0f9f16d 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 9e31d75297a3bb32bcdf13cb71322c808422ddc9..dfa5cab227ee05c0da4ddab52d4511482e0a8486 100644 --- a/src/FreeType/ftenc.c +++ b/src/FreeType/ftenc.c @@ -23,6 +23,7 @@ THE SOFTWARE. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include diff --git a/src/FreeType/ftfuncs.c b/src/FreeType/ftfuncs.c index df64f5ed1d9b16bde35629ca9472ab40d82d4be7..bbd4db49780a39b97e995e059df1e28bead43481 100644 --- a/src/FreeType/ftfuncs.c +++ b/src/FreeType/ftfuncs.c @@ -29,6 +29,7 @@ THE SOFTWARE. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include diff --git a/src/FreeType/fttools.c b/src/FreeType/fttools.c index 8c5d08eca9cd6f807ee5194524ed79bcb81af859..7c0bd9b81c80da3f2c9712ca1f82e2915a04aa8a 100644 --- a/src/FreeType/fttools.c +++ b/src/FreeType/fttools.c @@ -24,6 +24,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include #include diff --git a/src/FreeType/xttcap.c b/src/FreeType/xttcap.c index e30e0f98c972367e67fcddbcb59e649ccb577d7a..f54f76c85738fd1d388a44180ed84474904713b0 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 #endif +#include "libxfontint.h" #include #include #include diff --git a/src/Makefile.am b/src/Makefile.am index 33fd135c10eb0b038861cab6cae700e653eda9f6..03c704ad7f517ddb22cb2735990010f9fae746d0 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 f343eed54ea906dfacf87071a5c53f13f03e9f55..f2b1e22388d0bc42bddb9937bc26fc319de6e6ae 100644 --- a/src/bitmap/bdfread.c +++ b/src/bitmap/bdfread.c @@ -52,6 +52,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include diff --git a/src/bitmap/bdfutils.c b/src/bitmap/bdfutils.c index 438d1970e72c5d25dfd69a0066f159438888e994..253cb9378c08fdd46aebe9d8437ba2801d7bed69 100644 --- a/src/bitmap/bdfutils.c +++ b/src/bitmap/bdfutils.c @@ -52,6 +52,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include diff --git a/src/bitmap/bitmap.c b/src/bitmap/bitmap.c index 0a379eb08728d2d88d040d323c8b0079f0106826..a780506ad3fc7de4f479821cfd8e8ad54b102330 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 #endif +#include "libxfontint.h" #include #include diff --git a/src/bitmap/bitmapfunc.c b/src/bitmap/bitmapfunc.c index 8c6b3d896797d133a4a3c904454ca7d1e28a0efe..3087e47a545c01dfff7a051859130fb5773b5541 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 #endif +#include "libxfontint.h" #include #include diff --git a/src/bitmap/bitmaputil.c b/src/bitmap/bitmaputil.c index 0a1c87e730f0b9e906677e46a1a0fe600658db66..232729ffbb1b9d6a3a5cf1ee81735d971b781ddb 100644 --- a/src/bitmap/bitmaputil.c +++ b/src/bitmap/bitmaputil.c @@ -29,6 +29,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include diff --git a/src/bitmap/bitscale.c b/src/bitmap/bitscale.c index c9af4c031a1296c0bc423c19f201a09bc25c1e7f..22747a9fd1cbec2ebc3ef92651a12aa843db6fcb 100644 --- a/src/bitmap/bitscale.c +++ b/src/bitmap/bitscale.c @@ -33,6 +33,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include @@ -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 f4898da10c68fbf6b225ec0f5ff49bf2aa18b70a..ea915e4d87d58c79475c7f0b8ba3a6a53a80bd93 100644 --- a/src/bitmap/fontink.c +++ b/src/bitmap/fontink.c @@ -33,6 +33,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include diff --git a/src/bitmap/pcfread.c b/src/bitmap/pcfread.c index 33871aec6f4b53aaf7713656311dd9730d6883ab..dab1c44fec9573f1f01a23113affd73d59e3e568 100644 --- a/src/bitmap/pcfread.c +++ b/src/bitmap/pcfread.c @@ -33,6 +33,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include diff --git a/src/bitmap/pcfwrite.c b/src/bitmap/pcfwrite.c index 0874c4bd475e6e0ffd920434b96934b35134bfd7..61ae83d0e2facfa7e1686ab599697dac148fe436 100644 --- a/src/bitmap/pcfwrite.c +++ b/src/bitmap/pcfwrite.c @@ -33,6 +33,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include @@ -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 da362c81abce3d66316fcb383b0ac9555aff2d16..452b99def9830610bac0500e979025578e082a4f 100644 --- a/src/bitmap/snfread.c +++ b/src/bitmap/snfread.c @@ -52,6 +52,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include diff --git a/src/builtins/dir.c b/src/builtins/dir.c index 0225bfc99bc009a4c7528bca8abc59713211ee3e..bda5647046aa90409eb260c307fd574c8b1784e7 100644 --- a/src/builtins/dir.c +++ b/src/builtins/dir.c @@ -24,6 +24,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include "builtin.h" static BuiltinDirPtr diff --git a/src/builtins/file.c b/src/builtins/file.c index 93527c1270692a62c9d4d734a0132fc3cabd0181..3cfcf0c993d070fcb9fbd4e79b5df943fa610310 100644 --- a/src/builtins/file.c +++ b/src/builtins/file.c @@ -24,6 +24,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include "builtin.h" diff --git a/src/builtins/fonts.c b/src/builtins/fonts.c index 38921783dd0bb7e42a956798eab8c65610f585a6..bb593d7527b5bc7ceed1966e6696430751865130 100644 --- a/src/builtins/fonts.c +++ b/src/builtins/fonts.c @@ -24,6 +24,7 @@ #ifdef HAVE_CONFIG_H #include #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 4f5d4cf7e48ad8dbeb44a4fd59c995c8bc6baecf..e1b6973034e38a752401b2ad5761804797480ce4 100644 --- a/src/builtins/fpe.c +++ b/src/builtins/fpe.c @@ -24,6 +24,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #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 2be0053b986e5164ee787397f7da9039fbc5c4be..7676c87cf65e7767d663ddac2c9a0f25099c970b 100644 --- a/src/builtins/render.c +++ b/src/builtins/render.c @@ -24,6 +24,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include #include diff --git a/src/fc/fsconvert.c b/src/fc/fsconvert.c index 18b0c0d1c167f1048497ec4fd3ae67b1df149d59..312bacb6d26c727a131f47d745f349a14ab01737 100644 --- a/src/fc/fsconvert.c +++ b/src/fc/fsconvert.c @@ -28,6 +28,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include #include diff --git a/src/fc/fserve.c b/src/fc/fserve.c index 92b0d53da7b5273f76320b515a1cf1746e688a9e..42c4028c087094d76ccf2f89d07754c74f01b398 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 #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 502e201d5d751c9fbf43274b110e5e40b7a7d0ca..27c12a70d3460cd2723d22aadc044bf7fa23bc6c 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 4deab88762f3f5e9a6797524e765b5b8602da979..a5fe5b03deda4119b868d1e9f07d1648809e0407 100644 --- a/src/fc/fsio.c +++ b/src/fc/fsio.c @@ -29,6 +29,7 @@ #ifdef HAVE_CONFIG_H #include #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 fa1e7d8f974df7d2f3a9cb26e2c7bef6699992e2..9d0255a778feaf7746ac33526619ed49c6e01f75 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 9b21864017ce45ff895af97f3bee102060bb1565..66bc978063e4450ee770fc9cf0f55230886ba882 100644 --- a/src/fc/fstrans.c +++ b/src/fc/fstrans.c @@ -23,6 +23,8 @@ #ifdef HAVE_CONFIG_H #include #endif +#define LIBXFONT_SKIP_ERRORF +#include "libxfontint.h" #define FONT_t #define TRANS_CLIENT #include diff --git a/src/fontfile/bitsource.c b/src/fontfile/bitsource.c index c73f41f9c27e9bccb323decfc2c137fd42291a48..3a6a20f145116d98d4da935457d643fba1312926 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 #endif +#include "libxfontint.h" #include BitmapSourcesRec FontFileBitmapSources; diff --git a/src/fontfile/bufio.c b/src/fontfile/bufio.c index d8d4f2964ddd51a369341aa8fb3f81c2e7ea21e7..de06e1ab8546bb478258f5b9b4074ede3e7f0145 100644 --- a/src/fontfile/bufio.c +++ b/src/fontfile/bufio.c @@ -34,6 +34,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include #include @@ -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 4078796f48efbfed6b4141dd9a38f43860c7158c..34065f8ceddb27bb9c80dbe4d4ad04b57e5721f4 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 #include diff --git a/src/fontfile/catalogue.c b/src/fontfile/catalogue.c index 81a1e13f11b7b440939cc972badd388dc52ac856..208723270eb867ff3b3627e93894aa2ae1b3de9c 100644 --- a/src/fontfile/catalogue.c +++ b/src/fontfile/catalogue.c @@ -27,6 +27,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #ifdef HAVE_READLINK #include @@ -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 20971dfb9f9037e8b359d2195ff87233ea2d2432..42e7aa030fbbac8883e4a7448e5f8493fe255853 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 #endif +#include "libxfontint.h" #include #include diff --git a/src/fontfile/defaults.c b/src/fontfile/defaults.c index 1ad7d7ce5654c09a4e321d4d2da7303958bb38a9..62b4dd5935bbb4819630f5ad64e537406a0d9f51 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 #endif +#include "libxfontint.h" #include #include diff --git a/src/fontfile/dirfile.c b/src/fontfile/dirfile.c index 38ced757384d5dbcc64f4b4bd4eb5190ca817907..04cfa40894bd574db6a812dd1a5ac92af5961178 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 #endif +#include "libxfontint.h" #include #include #include diff --git a/src/fontfile/fileio.c b/src/fontfile/fileio.c index d44cecdc465a1a900d3932048ee58bcf6379d4ee..074ebcb0233c60c4277f6f58ba389ff168d23110 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 #endif +#include "libxfontint.h" #include #include #ifndef O_BINARY diff --git a/src/fontfile/filewr.c b/src/fontfile/filewr.c index 859a0bec1be278d7adaaa77dc3b0c5c37a2294ce..2431784b98f3fcb4d2c5568dd52ea7a716a1eaa1 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 #endif +#include "libxfontint.h" #include #include #ifndef O_BINARY diff --git a/src/fontfile/fontdir.c b/src/fontfile/fontdir.c index 7271603ecfd9f4189a8c88d7ce2f5beb7c66a320..4ce24732e5184bbf34594f07beb67d654b639608 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 #endif +#include "libxfontint.h" #include #include @@ -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 4bdb495e12d454bdb99cac4655c501abf3da3d39..b5c684bfc84b5979bda3a0969a5102ea10d06f28 100644 --- a/src/fontfile/fontencc.c +++ b/src/fontfile/fontencc.c @@ -30,11 +30,10 @@ THE SOFTWARE. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include -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 05a961072f9fe017e8e5eb1427eb2dc66664c84a..b2f1a6f56b5fed64ee37f30f7d8f3735d6fe8023 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 #endif +#include "libxfontint.h" #include #include #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 a21802ff819e3d90ff8f0598af173e9952c4d96a..bbc8e106dfff4b6e474cd25374d38acdf39cdcef 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 #endif +#include "libxfontint.h" #include #include diff --git a/src/fontfile/gunzip.c b/src/fontfile/gunzip.c index 84a4eaf450cd7432ebdf99d1cd2eef78bd1905c1..36f020a69abe63dc910903cf9d13b7397091dbd5 100644 --- a/src/fontfile/gunzip.c +++ b/src/fontfile/gunzip.c @@ -5,6 +5,7 @@ #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include #include diff --git a/src/fontfile/register.c b/src/fontfile/register.c index 4faeb8f0e49f14ebbe5b8046028554888fea1529..c3c8972154d32279ea71ca5608cfb510d109af10 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 #include diff --git a/src/fontfile/renderers.c b/src/fontfile/renderers.c index bbcd466945ccbc36e7faaba0592febf08565331b..d0c406483977fdf1d543e85126292ed1563e5dd2 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 #endif +#include "libxfontint.h" #include -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 7eb16d41a4b0d3cab56cd587182238be13353619..65950cc65eb4f356c8d678535008bab131c10bef 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 0000000000000000000000000000000000000000..82c8ca3bb43da1fc9860cb6776d8c33eb797fcd8 --- /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 +#endif +#include "libxfontint.h" +#include + +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 10086e4341dcb53013f05e9815436e67793a7ccf..0000000000000000000000000000000000000000 --- a/src/stubs/cauthgen.c +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 dd88b3d3683915af907873a1e42907572505492c..0000000000000000000000000000000000000000 --- a/src/stubs/csignal.c +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 8113b9f2964401ee93486f44a9c50bad59528e50..0000000000000000000000000000000000000000 --- a/src/stubs/delfntcid.c +++ /dev/null @@ -1,14 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 d2de6c64b9d7d56adad93e0042eb072c9f287c41..0000000000000000000000000000000000000000 --- a/src/stubs/errorf.c +++ /dev/null @@ -1,14 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 c73279eb4ba68bb23680d509e2236db13ddf2eaa..0000000000000000000000000000000000000000 --- a/src/stubs/findoldfnt.c +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 27a9180801e9bc0b91564e8321c5bafee4bd322d..0000000000000000000000000000000000000000 --- a/src/stubs/getcres.c +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 50c1b182c1182a2eaff7ef42051b3cabf6a0db68..0000000000000000000000000000000000000000 --- a/src/stubs/getdefptsize.c +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 d31ccf111661624a145ada852c272ad04bfe4457..0000000000000000000000000000000000000000 --- a/src/stubs/getnewfntcid.c +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 1b20f62a420f0a7cfe9b2eebc3cdb16ea49699d0..0000000000000000000000000000000000000000 --- a/src/stubs/gettime.c +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 e1c0b2454c70b2fd0790d4ed30035221a8db7f39..0000000000000000000000000000000000000000 --- a/src/stubs/initfshdl.c +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 0000000000000000000000000000000000000000..b083dd46d9c896616beb52de167b740bb73fed3d --- /dev/null +++ b/src/stubs/libxfontstubs.c @@ -0,0 +1,198 @@ +#ifdef HAVE_CONFIG_H +#include +#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 ae12a011d26d966710fcb5f6a5b45034442befaa..0000000000000000000000000000000000000000 --- a/src/stubs/regfpefunc.c +++ /dev/null @@ -1,32 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 22a30916ccd30a5cf9563ef7c4b1d2fa086f2725..0000000000000000000000000000000000000000 --- a/src/stubs/rmfshdl.c +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 f85e08eb1815e2be9d19aac53ada9fbe5fa8c858..0000000000000000000000000000000000000000 --- a/src/stubs/servclient.c +++ /dev/null @@ -1,19 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 371807e7a8c55c3f2f74422641ef363b5bed74c7..0000000000000000000000000000000000000000 --- a/src/stubs/setfntauth.c +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 d490988c5d7d551ab514872bca80d8d215e6f7aa..0000000000000000000000000000000000000000 --- a/src/stubs/stfntcfnt.c +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include -#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 9e71806a95306be7835280713cab18ce2abe85ee..0000000000000000000000000000000000000000 --- a/src/stubs/stubs.h +++ /dev/null @@ -1,79 +0,0 @@ -#include -#include -#include - -#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 -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 fc52332b166ded06d4e780b51e48a9c00ae79789..0000000000000000000000000000000000000000 --- a/src/stubs/stubsinit.c +++ /dev/null @@ -1,82 +0,0 @@ -#include "stubs.h" - -#if defined(NO_WEAK_SYMBOLS) && defined(PIC) - -#ifdef WIN32 -#include -#define DLOPEN_SELF() GetModuleHandle(NULL) -#define DLSYM(h,f) GetProcAddress(h,f) -#else -#include -#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 32a8f3789efcdf3df66cd979244c77325eee8686..d802b596f725d7b1817d42e5c361db15f85841e2 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 5f7f1c66d4dda5046081a45eca5b3be1bf12f93a..0000000000000000000000000000000000000000 --- 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 -#endif -#include -#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 db03e73b5d5a53a9b0c172f3e0bd931b7dc6834b..c8395c45aaf900cfaa3fda977a33b9ce6efd3505 100644 --- a/src/util/fontaccel.c +++ b/src/util/fontaccel.c @@ -33,6 +33,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include #include diff --git a/src/util/fontnames.c b/src/util/fontnames.c index ceafce593f97e3c47f97cf2da12bea9a97c46bf2..b292480600d6f88c42eaa9de53db4a0d6139c9da 100644 --- a/src/util/fontnames.c +++ b/src/util/fontnames.c @@ -34,11 +34,12 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include 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 2c5ea6f3ba6dfd63788cd220b1acb9aaeb1d1416..d1b845be492b4b216840a7067bd3afb343f402d8 100644 --- a/src/util/fontutil.c +++ b/src/util/fontutil.c @@ -33,6 +33,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include #include @@ -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 99a3679e5de0ab39585d4bf136606cbc41dcb0e2..0bd1140b7ea1199dae5636a4f083943d01d8208c 100644 --- a/src/util/fontxlfd.c +++ b/src/util/fontxlfd.c @@ -33,6 +33,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include #include diff --git a/src/util/format.c b/src/util/format.c index c1f9762fa210c746eec6d9d0c652ef3dd4e9fade..0baeb3a161c574b56f9f6cb71d89e7b9848fab27 100644 --- a/src/util/format.c +++ b/src/util/format.c @@ -53,6 +53,7 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include #include diff --git a/src/util/miscutil.c b/src/util/miscutil.c index 61c9d11d1c6820653b8775f6ee14e670a5a79bc7..e01597231f6442d96ab0c7332819673120ca975e 100644 --- a/src/util/miscutil.c +++ b/src/util/miscutil.c @@ -29,38 +29,19 @@ from The Open Group. #ifdef HAVE_CONFIG_H #include #endif +#include "libxfontint.h" #include #include #include -#include "stubs.h" #define XK_LATIN1 #include - -#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 2101015844019c08c9722a7b914232287adbc200..e76f1f407250cce6d985bd976f0dc86af22c894d 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 #endif +#include "libxfontint.h" #include #include @@ -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 e55e1936813bd110853ac21536f9460bb8813e73..92075c25fcee37a5d7810aa5a14bfd9c3ee41d0d 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 #endif +#include "libxfontint.h" #include #include 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 ec726b8a470f6655fcbf68c240b373f079054608..fe1c4125718389a0c08c1610ca2a52ddd9ed7d5a 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 #endif +#include "libxfontint.h" #include /* Utility functions for reformating font bitmaps */ diff --git a/xfont.pc.in b/xfont2.pc.in similarity index 74% rename from xfont.pc.in rename to xfont2.pc.in index f08dea09c56a0a03f8f9cde8312587f9a2ae63d7..ac3f53a638cceff97e518d496e7429dc097afa41 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