2019-11-18 15:13:21 +01:00
|
|
|
/*
|
|
|
|
lib_static.c - static linking support
|
|
|
|
Copyright (C) 2018 Flying With Gauss
|
2019-11-17 21:31:25 +01:00
|
|
|
|
2019-11-18 15:13:21 +01:00
|
|
|
This program is free software: you can redistribute it and/sor modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2019-11-17 21:31:25 +01:00
|
|
|
|
2019-11-18 15:13:21 +01:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "platform/platform.h"
|
2020-02-08 17:39:35 +01:00
|
|
|
#include "library.h"
|
2019-11-18 15:13:21 +01:00
|
|
|
#if XASH_LIB == LIB_STATIC
|
2019-11-17 21:31:25 +01:00
|
|
|
#ifdef XASH_NO_LIBDL
|
|
|
|
|
|
|
|
void *dlsym(void *handle, const char *symbol )
|
|
|
|
{
|
2024-06-19 05:46:08 +02:00
|
|
|
Con_DPrintf( "%s( %p, \"%s\" ): stub\n", __func__, handle, symbol );
|
2019-11-17 21:31:25 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *dlopen(const char *name, int flag )
|
|
|
|
{
|
2024-06-19 05:46:08 +02:00
|
|
|
Con_DPrintf( "%s( \"%s\", %d ): stub\n", __func__, name, flag );
|
2019-11-17 21:31:25 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dlclose(void *handle)
|
|
|
|
{
|
2024-06-19 05:46:08 +02:00
|
|
|
Con_DPrintf( "%s( %p ): stub\n", __func__, handle );
|
2019-11-17 21:31:25 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *dlerror( void )
|
|
|
|
{
|
|
|
|
return "Loading ELF libraries not supported in this build!\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
int dladdr( const void *addr, void *info )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif // XASH_NO_LIBDL
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct table_s
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
void *pointer;
|
|
|
|
} table_t;
|
|
|
|
|
|
|
|
|
|
|
|
#include "generated_library_tables.h"
|
|
|
|
|
|
|
|
static void *Lib_Find(table_t *tbl, const char *name )
|
|
|
|
{
|
|
|
|
while( tbl->name )
|
|
|
|
{
|
|
|
|
if( !Q_strcmp( tbl->name, name) )
|
|
|
|
return tbl->pointer;
|
|
|
|
tbl++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *COM_LoadLibrary( const char *dllname, int build_ordinals_table, qboolean directpath )
|
|
|
|
{
|
2020-02-08 17:39:35 +01:00
|
|
|
return Lib_Find((table_t*)libs, dllname);
|
2019-11-17 21:31:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void COM_FreeLibrary( void *hInstance )
|
|
|
|
{
|
|
|
|
// impossible
|
|
|
|
}
|
|
|
|
|
|
|
|
void *COM_GetProcAddress( void *hInstance, const char *name )
|
|
|
|
{
|
|
|
|
return Lib_Find( hInstance, name );
|
|
|
|
}
|
|
|
|
|
|
|
|
void *COM_FunctionFromName( void *hInstance, const char *pName )
|
|
|
|
{
|
|
|
|
return Lib_Find( hInstance, pName );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char *COM_NameForFunction( void *hInstance, void *function )
|
|
|
|
{
|
|
|
|
#ifdef XASH_ALLOW_SAVERESTORE_OFFSETS
|
|
|
|
return COM_OffsetNameForFunction( function );
|
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|