10145ab54Ssnj#include "stubs.h"
20145ab54Ssnj
30145ab54Ssnj#if defined(NO_WEAK_SYMBOLS) && defined(PIC)
40145ab54Ssnj
50145ab54Ssnj#ifdef WIN32
60145ab54Ssnj#include <X11/Xwindows.h>
70145ab54Ssnj#define DLOPEN_SELF() GetModuleHandle(NULL)
80145ab54Ssnj#define DLSYM(h,f) GetProcAddress(h,f)
90145ab54Ssnj#else
100145ab54Ssnj#include <dlfcn.h>
110145ab54Ssnj#define DLOPEN_SELF() dlopen(NULL, RTLD_LOCAL)
120145ab54Ssnj#define DLSYM(h,f) dlsym(h, f)
130145ab54Ssnj#endif
140145ab54Ssnj
150145ab54Ssnjint (*__client_auth_generation)(ClientPtr) = NULL;
160145ab54SsnjBool (*__ClientSignal)(ClientPtr) = NULL;
170145ab54Ssnjvoid (*__DeleteFontClientID)(Font) = NULL;
180145ab54Ssnjvoid (*__VErrorF)(const char *, va_list) = NULL;
190145ab54SsnjFontPtr (*__find_old_font)(FSID) = NULL;
200145ab54SsnjFontResolutionPtr (*__GetClientResolutions)(int *) = NULL;
210145ab54Ssnjint (*__GetDefaultPointSize)(void) = NULL;
220145ab54SsnjFont (*__GetNewFontClientID)(void) = NULL;
230145ab54Ssnjunsigned long (*__GetTimeInMillis)(void) = NULL;
240145ab54Ssnjint (*__init_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr) = NULL;
250145ab54Ssnjint (*__RegisterFPEFunctions)(NameCheckFunc, InitFpeFunc, FreeFpeFunc,
260145ab54Ssnj     ResetFpeFunc, OpenFontFunc, CloseFontFunc, ListFontsFunc,
270145ab54Ssnj     StartLfwiFunc, NextLfwiFunc, WakeupFpeFunc, ClientDiedFunc,
280145ab54Ssnj     LoadGlyphsFunc, StartLaFunc, NextLaFunc, SetPathFunc) = NULL;
290145ab54Ssnjvoid (*__remove_fs_handlers)(FontPathElementPtr, BlockHandlerProcPtr, Bool) = NULL;
300145ab54Ssnjvoid **__ptr_serverClient = NULL;
310145ab54Ssnjint (*__set_font_authorizations)(char **, int *, ClientPtr) = NULL;
320145ab54Ssnjint (*__StoreFontClientFont)(FontPtr, Font) = NULL;
330145ab54SsnjAtom (*__MakeAtom)(const char *, unsigned, int) = NULL;
340145ab54Ssnjint (*__ValidAtom)(Atom) = NULL;
350145ab54Ssnjchar *(*__NameForAtom)(Atom) = NULL;
360145ab54Ssnjunsigned long *__ptr_serverGeneration = NULL;
370145ab54Ssnjvoid (*__register_fpe_functions)(void) = NULL;
380145ab54Ssnj
390145ab54Ssnj#define INIT_SYMBOL(sym) \
400145ab54Ssnj  if (!__##sym) \
410145ab54Ssnj   __##sym = (typeof(__##sym)) DLSYM(handle, #sym)
420145ab54Ssnj#define INIT_DATA(sym) \
430145ab54Ssnj  if (!__ptr_##sym) \
440145ab54Ssnj   __ptr_##sym = (typeof(__ptr_##sym)) DLSYM(handle, #sym)
450145ab54Ssnj
460145ab54Ssnjint
470145ab54Ssnj_font_init_stubs (void)
480145ab54Ssnj{
490145ab54Ssnj  static int inited = FALSE;
500145ab54Ssnj  static void *handle = NULL;
510145ab54Ssnj
520145ab54Ssnj  if (inited)
530145ab54Ssnj    return inited;
540145ab54Ssnj  if (!handle)
550145ab54Ssnj    handle = DLOPEN_SELF();
560145ab54Ssnj
570145ab54Ssnj  INIT_SYMBOL(client_auth_generation);
580145ab54Ssnj  INIT_SYMBOL(ClientSignal);
590145ab54Ssnj  INIT_SYMBOL(DeleteFontClientID);
600145ab54Ssnj  INIT_SYMBOL(VErrorF);
610145ab54Ssnj  INIT_SYMBOL(find_old_font);
620145ab54Ssnj  INIT_SYMBOL(GetClientResolutions);
630145ab54Ssnj  INIT_SYMBOL(GetDefaultPointSize);
640145ab54Ssnj  INIT_SYMBOL(GetNewFontClientID);
650145ab54Ssnj  INIT_SYMBOL(GetTimeInMillis);
660145ab54Ssnj  INIT_SYMBOL(init_fs_handlers);
670145ab54Ssnj  INIT_SYMBOL(RegisterFPEFunctions);
680145ab54Ssnj  INIT_SYMBOL(remove_fs_handlers);
690145ab54Ssnj  INIT_SYMBOL(set_font_authorizations);
700145ab54Ssnj  INIT_SYMBOL(StoreFontClientFont);
710145ab54Ssnj  INIT_SYMBOL(MakeAtom);
720145ab54Ssnj  INIT_SYMBOL(ValidAtom);
730145ab54Ssnj  INIT_SYMBOL(NameForAtom);
740145ab54Ssnj  INIT_SYMBOL(register_fpe_functions);
750145ab54Ssnj  INIT_DATA(serverClient);
760145ab54Ssnj  INIT_DATA(serverGeneration);
770145ab54Ssnj
780145ab54Ssnj  inited = TRUE;
790145ab54Ssnj  return inited;
800145ab54Ssnj}
810145ab54Ssnj
820145ab54Ssnj#endif /* NO_WEAK_SYMBOLS && PIC */
83