1#include "stubs.h"
2
3#if defined(NO_WEAK_SYMBOLS) && defined(PIC)
4
5#ifdef WIN32
6#include <X11/Xwindows.h>
7#define DLOPEN_SELF() GetModuleHandle(NULL)
8#define DLSYM(h,f) GetProcAddress(h,f)
9#else
10#include <dlfcn.h>
11#define DLOPEN_SELF() dlopen(NULL, RTLD_LOCAL)
12#define DLSYM(h,f) dlsym(h, f)
13#endif
14
15int (*__client_auth_generation)(ClientPtr) = NULL;
16Bool (*__ClientSignal)(ClientPtr) = NULL;
17void (*__DeleteFontClientID)(Font) = NULL;
18void (*__VErrorF)(const char *, va_list) = NULL;
19FontPtr (*__find_old_font)(FSID) = NULL;
20FontResolutionPtr (*__GetClientResolutions)(int *) = NULL;
21int (*__GetDefaultPointSize)(void) = NULL;
22Font (*__GetNewFontClientID)(void) = NULL;
23unsigned long (*__GetTimeInMillis)(void) = NULL;
24int (*__init_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr) = NULL;
25int (*__RegisterFPEFunctions)(NameCheckFunc, InitFpeFunc, FreeFpeFunc,
26     ResetFpeFunc, OpenFontFunc, CloseFontFunc, ListFontsFunc,
27     StartLfwiFunc, NextLfwiFunc, WakeupFpeFunc, ClientDiedFunc,
28     LoadGlyphsFunc, StartLaFunc, NextLaFunc, SetPathFunc) = NULL;
29void (*__remove_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr, Bool) = NULL;
30void **__ptr_serverClient = NULL;
31int (*__set_font_authorizations)(char **, int *, ClientPtr) = NULL;
32int (*__StoreFontClientFont)(FontPtr, Font) = NULL;
33Atom (*__MakeAtom)(const char *, unsigned, int) = NULL;
34int (*__ValidAtom)(Atom) = NULL;
35char *(*__NameForAtom)(Atom) = NULL;
36unsigned long *__ptr_serverGeneration = NULL;
37void (*__register_fpe_functions)(void) = NULL;
38
39#define INIT_SYMBOL(sym) \
40  if (!__##sym) \
41   __##sym = (typeof(__##sym)) DLSYM(handle, #sym)
42#define INIT_DATA(sym) \
43  if (!__ptr_##sym) \
44   __ptr_##sym = (typeof(__ptr_##sym)) DLSYM(handle, #sym)
45
46int
47_font_init_stubs (void)
48{
49  static int inited = FALSE;
50  static void *handle = NULL;
51
52  if (inited)
53    return inited;
54  if (!handle)
55    handle = DLOPEN_SELF();
56
57  INIT_SYMBOL(client_auth_generation);
58  INIT_SYMBOL(ClientSignal);
59  INIT_SYMBOL(DeleteFontClientID);
60  INIT_SYMBOL(VErrorF);
61  INIT_SYMBOL(find_old_font);
62  INIT_SYMBOL(GetClientResolutions);
63  INIT_SYMBOL(GetDefaultPointSize);
64  INIT_SYMBOL(GetNewFontClientID);
65  INIT_SYMBOL(GetTimeInMillis);
66  INIT_SYMBOL(init_fs_handlers);
67  INIT_SYMBOL(RegisterFPEFunctions);
68  INIT_SYMBOL(remove_fs_handlers);
69  INIT_SYMBOL(set_font_authorizations);
70  INIT_SYMBOL(StoreFontClientFont);
71  INIT_SYMBOL(MakeAtom);
72  INIT_SYMBOL(ValidAtom);
73  INIT_SYMBOL(NameForAtom);
74  INIT_SYMBOL(register_fpe_functions);
75  INIT_DATA(serverClient);
76  INIT_DATA(serverGeneration);
77
78  inited = TRUE;
79  return inited;
80}
81
82#endif /* NO_WEAK_SYMBOLS && PIC */
83