Global: remove --lib-xxx support

This commit is contained in:
李通洲
2024-09-04 15:28:35 +08:00
parent d43c6ffe27
commit c9d539090d
44 changed files with 144 additions and 420 deletions
-1
View File
@@ -398,7 +398,6 @@ set(LIBFASTFETCH_SRC
src/options/modules.c
src/options/logo.c
src/options/general.c
src/options/library.c
src/util/edidHelper.c
src/util/base64.c
src/util/FFlist.c
+1 -1
View File
@@ -7,7 +7,7 @@
static bool loadLibSymbols(FFDBusLibrary* lib)
{
FF_LIBRARY_LOAD(dbus, &instance.config.library.libDBus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_LOAD(dbus, false, "libdbus-1" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_bus_get, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_new_method_call, false)
FF_LIBRARY_LOAD_SYMBOL_PTR(dbus, lib, dbus_message_append_args, false)
-2
View File
@@ -43,7 +43,6 @@ static void defaultConfig(void)
ffOptionsInitGeneral(&instance.config.general);
ffOptionsInitModules(&instance.config.modules);
ffOptionsInitDisplay(&instance.config.display);
ffOptionsInitLibrary(&instance.config.library);
}
void ffInitInstance(void)
@@ -148,7 +147,6 @@ static void destroyConfig(void)
ffOptionsDestroyGeneral(&instance.config.general);
ffOptionsDestroyModules(&instance.config.modules);
ffOptionsDestroyDisplay(&instance.config.display);
ffOptionsDestroyLibrary(&instance.config.library);
}
static void destroyState(void)
+16 -16
View File
@@ -55,28 +55,28 @@ static void* libraryLoad(const char* path, int maxVersion)
return result;
}
void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...)
void* ffLibraryLoad(const char* path, int maxVersion, ...)
{
if(userProvidedName != NULL && userProvidedName->length > 0)
return dlopen(userProvidedName->chars, FF_DLOPEN_FLAGS);
void* result = libraryLoad(path, maxVersion);
va_list defaultNames;
va_start(defaultNames, userProvidedName);
void* result = NULL;
while(result == NULL)
if (!result)
{
const char* path = va_arg(defaultNames, const char*);
if(path == NULL)
break;
va_list defaultNames;
va_start(defaultNames, maxVersion);
int maxVersion = va_arg(defaultNames, int);
result = libraryLoad(path, maxVersion);
do
{
const char* pathRest = va_arg(defaultNames, const char*);
if(pathRest == NULL)
break;
int maxVersionRest = va_arg(defaultNames, int);
result = libraryLoad(pathRest, maxVersionRest);
} while (!result);
va_end(defaultNames);
}
va_end(defaultNames);
return result;
}
+4 -4
View File
@@ -33,8 +33,8 @@ static inline void ffLibraryUnload(void** handle)
#define FF_LIBRARY_SYMBOL(symbolName) \
__typeof__(&symbolName) ff ## symbolName;
#define FF_LIBRARY_LOAD(libraryObjectName, userLibraryName, returnValue, ...) \
void* __attribute__((__cleanup__(ffLibraryUnload))) libraryObjectName = ffLibraryLoad(userLibraryName, __VA_ARGS__, NULL);\
#define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
void* __attribute__((__cleanup__(ffLibraryUnload))) libraryObjectName = ffLibraryLoad(__VA_ARGS__, NULL);\
if(libraryObjectName == NULL) \
return returnValue;
@@ -72,7 +72,7 @@ static inline void ffLibraryUnload(void** handle)
#define FF_LIBRARY_LOAD_SYMBOL_PTR(library, varName, symbolName, returnValue) \
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, (varName)->ff ## symbolName, symbolName, returnValue);
void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...);
void* ffLibraryLoad(const char* path, int maxVersion, ...);
#else
@@ -81,7 +81,7 @@ void* ffLibraryLoad(const FFstrbuf* userProvidedName, ...);
#define FF_LIBRARY_SYMBOL(symbolName) \
__typeof__(&symbolName) ff ## symbolName;
#define FF_LIBRARY_LOAD(libraryObjectName, userLibraryName, returnValue, ...) \
#define FF_LIBRARY_LOAD(libraryObjectName, returnValue, ...) \
FF_MAYBE_UNUSED void* libraryObjectName = NULL; // Placeholder
#define FF_LIBRARY_LOAD_SYMBOL_ADDRESS(library, symbolMapping, symbolName, returnValue) \
+4 -4
View File
@@ -60,7 +60,7 @@ static const GSettingsData* getGSettingsData(void)
if (!data.inited)
{
data.inited = true;
FF_LIBRARY_LOAD(libgsettings, &instance.config.library.libGIO, NULL, "libgio-2.0" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD(libgsettings, NULL, "libgio-2.0" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_source_lookup, NULL)
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_schema_has_key, NULL)
FF_LIBRARY_LOAD_SYMBOL_VAR(libgsettings, data, g_settings_new_full, NULL)
@@ -141,7 +141,7 @@ static const DConfData* getDConfData(void)
{
data.inited = true;
FF_LIBRARY_LOAD(libdconf, &instance.config.library.libDConf, NULL, "libdconf" FF_LIBRARY_EXTENSION, 2);
FF_LIBRARY_LOAD(libdconf, NULL, "libdconf" FF_LIBRARY_EXTENSION, 2);
FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data, dconf_client_read_full, NULL)
FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data, dconf_client_new, NULL)
FF_LIBRARY_LOAD_SYMBOL_VAR(libdconf, data.variantGetters, g_variant_dup_string, NULL)
@@ -218,7 +218,7 @@ static const XFConfData* getXFConfData(void)
if (!data.inited)
{
data.inited = true;
FF_LIBRARY_LOAD(libxfconf, &instance.config.library.libXFConf, NULL, "libxfconf-0" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_LOAD(libxfconf, NULL, "libxfconf-0" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_LOAD_SYMBOL_VAR(libxfconf, data, xfconf_channel_get, NULL)
FF_LIBRARY_LOAD_SYMBOL_VAR(libxfconf, data, xfconf_channel_has_property, NULL)
@@ -292,7 +292,7 @@ static const SQLiteData* getSQLiteData(void)
if (!data.inited)
{
data.inited = true;
FF_LIBRARY_LOAD(libsqlite, &instance.config.library.libSQLite3, NULL, "libsqlite3" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD(libsqlite, NULL, "libsqlite3" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_open_v2, NULL)
FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_prepare_v2, NULL)
FF_LIBRARY_LOAD_SYMBOL_VAR(libsqlite, data, sqlite3_step, NULL)
+1 -1
View File
@@ -10,7 +10,7 @@
const char* ffDetectBluetooth(FFlist* devices /* FFBluetoothResult */)
{
// Actually bluetoothapis.dll, but it's missing on Windows 7
FF_LIBRARY_LOAD(bluetoothapis, NULL, "dlopen bthprops.cpl failed", "bthprops.cpl", 1)
FF_LIBRARY_LOAD(bluetoothapis, "dlopen bthprops.cpl failed", "bthprops.cpl", 1)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindFirstDevice)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindNextDevice)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindDeviceClose)
@@ -54,7 +54,7 @@ static_assert(sizeof(BTH_LOCAL_RADIO_INFO) == 292, "BTH_LOCAL_RADIO_INFO should
const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */)
{
// Actually bluetoothapis.dll, but it's missing on Windows 7
FF_LIBRARY_LOAD(bluetoothapis, NULL, "dlopen bthprops.cpl failed", "bthprops.cpl", 1)
FF_LIBRARY_LOAD(bluetoothapis, "dlopen bthprops.cpl failed", "bthprops.cpl", 1)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindFirstRadio)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindNextRadio)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(bluetoothapis, BluetoothFindRadioClose)
+1 -1
View File
@@ -101,7 +101,7 @@ DDCA_Status ddca_init(const char *libopts, int syslog_level, int opts);
static const char* detectWithDdcci(FFBrightnessOptions* options, FFlist* result)
{
FF_LIBRARY_LOAD(libddcutil, &instance.config.library.libDdcutil, "dlopen ddcutil failed", "libddcutil" FF_LIBRARY_EXTENSION, 5);
FF_LIBRARY_LOAD(libddcutil, "dlopen ddcutil failed", "libddcutil" FF_LIBRARY_EXTENSION, 5);
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_get_display_info_list2)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_open_display2)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libddcutil, ddca_get_any_vcp_value_using_explicit_type)
@@ -39,7 +39,7 @@ static const char* detectWithWmi(FFlist* result)
static const char* detectWithDdcci(const FFDisplayServerResult* displayServer, FFlist* result)
{
FF_LIBRARY_LOAD(dxva2, NULL, "dlopen dxva2" FF_LIBRARY_EXTENSION " failed", "dxva2" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD(dxva2, "dlopen dxva2" FF_LIBRARY_EXTENSION " failed", "dxva2" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(dxva2, GetPhysicalMonitorsFromHMONITOR)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(dxva2, GetMonitorBrightness)
+2 -2
View File
@@ -21,9 +21,9 @@ private:
extern "C"
const char* ffDetectCamera(FF_MAYBE_UNUSED FFlist* result)
{
FF_LIBRARY_LOAD(mfplat, NULL, "dlopen mfplat" FF_LIBRARY_EXTENSION " failed", "mfplat" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD(mfplat, "dlopen mfplat" FF_LIBRARY_EXTENSION " failed", "mfplat" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(mfplat, MFCreateAttributes)
FF_LIBRARY_LOAD(mf, NULL, "dlopen mf" FF_LIBRARY_EXTENSION " failed", "mf" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD(mf, "dlopen mf" FF_LIBRARY_EXTENSION " failed", "mf" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(mf, MFEnumDeviceSources)
const char* error = ffInitCom();
+1 -1
View File
@@ -121,7 +121,7 @@ static const char* getXfce4ByLib(FFstrbuf* result)
{
#ifndef FF_DISABLE_DLOPEN
const char* xfce_version_string(void); // from `xfce4/libxfce4util/xfce-misutils.h
FF_LIBRARY_LOAD(xfce4util, NULL, "dlopen libxfce4util" FF_LIBRARY_EXTENSION "failed", "libxfce4util" FF_LIBRARY_EXTENSION, 7);
FF_LIBRARY_LOAD(xfce4util, "dlopen libxfce4util" FF_LIBRARY_EXTENSION "failed", "libxfce4util" FF_LIBRARY_EXTENSION, 7);
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xfce4util, xfce_version_string);
ffStrbufSetS(result, ffxfce_version_string());
return NULL;
@@ -9,13 +9,13 @@ bool ffdsMatchDrmConnector(const char* connName, FFstrbuf* edidName);
const char* ffdsConnectWayland(FFDisplayServerResult* result);
void ffdsConnectXcbRandr(FFDisplayServerResult* result);
void ffdsConnectXcb(FFDisplayServerResult* result);
const char* ffdsConnectXcbRandr(FFDisplayServerResult* result);
const char* ffdsConnectXcb(FFDisplayServerResult* result);
void ffdsConnectXrandr(FFDisplayServerResult* result);
void ffdsConnectXlib(FFDisplayServerResult* result);
const char* ffdsConnectXrandr(FFDisplayServerResult* result);
const char* ffdsConnectXlib(FFDisplayServerResult* result);
void ffdsConnectDrm(FFDisplayServerResult* result);
const char* ffdsConnectDrm(FFDisplayServerResult* result);
void ffdsDetectWMDE(FFDisplayServerResult* result);
+6 -4
View File
@@ -199,7 +199,7 @@ static const char* drmGetNameByConnId(uint32_t connId, FFstrbuf* name)
static const char* drmConnectLibdrm(FFDisplayServerResult* result)
{
FF_LIBRARY_LOAD(libdrm, &instance.config.library.libdrm, "dlopen libdrm" FF_LIBRARY_EXTENSION " failed", "libdrm" FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD(libdrm, "dlopen libdrm" FF_LIBRARY_EXTENSION " failed", "libdrm" FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmGetDevices)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetResources)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libdrm, drmModeGetConnectorCurrent)
@@ -376,17 +376,19 @@ static const char* drmConnectLibdrm(FFDisplayServerResult* result)
#endif
void ffdsConnectDrm(FFDisplayServerResult* result)
const char* ffdsConnectDrm(FFDisplayServerResult* result)
{
#ifdef FF_HAVE_DRM
if (instance.config.general.dsForceDrm != FF_DS_FORCE_DRM_TYPE_SYSFS_ONLY)
{
if (drmConnectLibdrm(result) == NULL)
return;
return NULL;
}
#endif
#ifdef __linux__
drmParseSysfs(result);
return drmParseSysfs(result);
#endif
return "fastfetch was compiled without drm support";
}
@@ -150,7 +150,7 @@ const char* ffdsConnectWayland(FFDisplayServerResult* result)
if (getenv("XDG_RUNTIME_DIR") == NULL)
return "Wayland requires $XDG_RUNTIME_DIR being set";
FF_LIBRARY_LOAD(wayland, &instance.config.library.libWayland, false, "libwayland-client" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD(wayland, false, "libwayland-client" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wayland, wl_display_connect)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wayland, wl_display_get_fd)
+45 -39
View File
@@ -82,21 +82,21 @@ static void xcbDetectWMfromEWMH(XcbPropertyData* data, xcb_connection_t* connect
ffStrbufSetS(&result->wmProcessName, wmName);
}
void ffdsConnectXcb(FFDisplayServerResult* result)
const char* ffdsConnectXcb(FFDisplayServerResult* result)
{
FF_LIBRARY_LOAD(xcb, &instance.config.library.libXcb, , "libxcb" FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_connect,)
FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_get_setup,)
FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_setup_roots_iterator,)
FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_screen_next,)
FF_LIBRARY_LOAD_SYMBOL(xcb, xcb_disconnect,)
FF_LIBRARY_LOAD(xcb, "dlopen lbxcb failed", "libxcb" FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_connect)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_get_setup)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_setup_roots_iterator)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_screen_next)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcb, xcb_disconnect)
XcbPropertyData propertyData;
bool propertyDataInitialized = xcbInitPropertyData(xcb, &propertyData);
xcb_connection_t* connection = ffxcb_connect(NULL, NULL);
if(connection == NULL)
return;
return "xcb_connect failed";
xcb_screen_iterator_t iterator = ffxcb_setup_roots_iterator(ffxcb_get_setup(connection));
@@ -128,14 +128,17 @@ void ffdsConnectXcb(FFDisplayServerResult* result)
//If wayland hasn't set this, connection failed for it. So we are running only a X Server, not XWayland.
if(result->wmProtocolName.length == 0)
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11);
return NULL;
}
#else
void ffdsConnectXcb(FFDisplayServerResult* result)
const char* ffdsConnectXcb(FFDisplayServerResult* result)
{
//Do nothing. There are other implementations coming
FF_UNUSED(result)
return "Fastfetch was compiled without XCB support";
}
#endif
@@ -388,45 +391,45 @@ static void xcbRandrHandleScreen(XcbRandrData* data, xcb_screen_t* screen)
);
}
void ffdsConnectXcbRandr(FFDisplayServerResult* result)
const char* ffdsConnectXcbRandr(FFDisplayServerResult* result)
{
FF_LIBRARY_LOAD(xcbRandr, &instance.config.library.libXcbRandr, , "libxcb-randr" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_connect,)
FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_get_setup,)
FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_setup_roots_iterator,)
FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_screen_next,)
FF_LIBRARY_LOAD_SYMBOL(xcbRandr, xcb_disconnect,)
FF_LIBRARY_LOAD(xcbRandr, "dlopen lbxcb-randr failed", "libxcb-randr" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_connect)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_get_setup)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_setup_roots_iterator)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_screen_next)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xcbRandr, xcb_disconnect)
XcbRandrData data;
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_intern_atom,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_intern_atom_reply,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_screen_resources_current,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_screen_resources_current_reply,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_screen_resources_current_modes_iterator,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_mode_info_next,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_monitors,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_monitors_reply,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_monitors_monitors_iterator,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_monitor_info_next,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_monitor_info_outputs_length,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_monitor_info_outputs,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_output_next,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_info,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_info_reply,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_property,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_property_reply,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_property_data,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_output_property_data_length,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_crtc_info,)
FF_LIBRARY_LOAD_SYMBOL_VAR(xcbRandr, data, xcb_randr_get_crtc_info_reply,)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_intern_atom)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_intern_atom_reply)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_screen_resources_current)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_screen_resources_current_reply)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_screen_resources_current_modes_iterator)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_mode_info_next)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_monitors)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_monitors_reply)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_monitors_monitors_iterator)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_monitor_info_next)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_monitor_info_outputs_length)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_monitor_info_outputs)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_output_next)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_output_info)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_output_info_reply)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_output_property)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_output_property_reply)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_output_property_data)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_output_property_data_length)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_crtc_info)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xcbRandr, data, xcb_randr_get_crtc_info_reply)
bool propertyDataInitialized = xcbInitPropertyData(xcbRandr, &data.propData);
data.connection = ffxcb_connect(NULL, NULL);
if(data.connection == NULL)
return;
return "xcb_connect failed";
data.result = result;
@@ -450,14 +453,17 @@ void ffdsConnectXcbRandr(FFDisplayServerResult* result)
//If wayland hasn't set this, connection failed for it. So we are running only a X Server, not XWayland.
if(result->wmProtocolName.length == 0)
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11);
return NULL;
}
#else
void ffdsConnectXcbRandr(FFDisplayServerResult* result)
const char* ffdsConnectXcbRandr(FFDisplayServerResult* result)
{
//Do nothing. There are other implementations coming
FF_UNUSED(result)
return "Fastfetch was compiled without libxcb-randr support";
}
#endif
+30 -24
View File
@@ -58,18 +58,18 @@ static void x11DetectWMFromEWMH(X11PropertyData* data, Display* display, FFDispl
data->ffXFree(wmWindow);
}
void ffdsConnectXlib(FFDisplayServerResult* result)
const char* ffdsConnectXlib(FFDisplayServerResult* result)
{
FF_LIBRARY_LOAD(x11, &instance.config.library.libX11, , "libX11" FF_LIBRARY_EXTENSION, 7, "libX11-xcb" FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD_SYMBOL(x11, XOpenDisplay,)
FF_LIBRARY_LOAD_SYMBOL(x11, XCloseDisplay,)
FF_LIBRARY_LOAD(x11, "dlopen libX11 failed", "libX11" FF_LIBRARY_EXTENSION, 7, "libX11-xcb" FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(x11, XOpenDisplay)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(x11, XCloseDisplay)
X11PropertyData propertyData;
bool propertyDataInitialized = x11InitPropertyData(x11, &propertyData);
Display* display = ffXOpenDisplay(x11);
if(display == NULL)
return;
return "XOpenDisplay failed";
if(propertyDataInitialized && ScreenCount(display) > 0)
x11DetectWMFromEWMH(&propertyData, display, result);
@@ -98,14 +98,17 @@ void ffdsConnectXlib(FFDisplayServerResult* result)
//If wayland hasn't set this, connection failed for it. So we are running only a X Server, not XWayland.
if(result->wmProtocolName.length == 0)
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11);
return NULL;
}
#else
void ffdsConnectXlib(FFDisplayServerResult* result)
const char* ffdsConnectXlib(FFDisplayServerResult* result)
{
//Do nothing. WM / DE detection will use environment vars to detect as much as possible.
FF_UNUSED(result);
return "Fastfetch was compiled without libX11 support";
}
#endif //FF_HAVE_X11
@@ -308,34 +311,34 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen)
);
}
void ffdsConnectXrandr(FFDisplayServerResult* result)
const char* ffdsConnectXrandr(FFDisplayServerResult* result)
{
FF_LIBRARY_LOAD(xrandr, &instance.config.library.libXrandr, , "libXrandr" FF_LIBRARY_EXTENSION, 3)
FF_LIBRARY_LOAD(xrandr, "dlopen libXrandr failed", "libXrandr" FF_LIBRARY_EXTENSION, 3)
FF_LIBRARY_LOAD_SYMBOL(xrandr, XOpenDisplay,)
FF_LIBRARY_LOAD_SYMBOL(xrandr, XCloseDisplay,)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xrandr, XOpenDisplay)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xrandr, XCloseDisplay)
XrandrData data;
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XInternAtom,);
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XGetAtomName,);
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XFree,);
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetMonitors,);
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetScreenResourcesCurrent,);
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetOutputInfo,);
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetOutputProperty,);
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRGetCrtcInfo,);
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRFreeCrtcInfo,);
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRFreeOutputInfo,);
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRFreeScreenResources,);
FF_LIBRARY_LOAD_SYMBOL_VAR(xrandr, data, XRRFreeMonitors,);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XInternAtom);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XGetAtomName);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XFree);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRGetMonitors);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRGetScreenResourcesCurrent);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRGetOutputInfo);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRGetOutputProperty);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRGetCrtcInfo);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRFreeCrtcInfo);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRFreeOutputInfo);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRFreeScreenResources);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(xrandr, data, XRRFreeMonitors);
X11PropertyData propertyData;
bool propertyDataInitialized = x11InitPropertyData(xrandr, &propertyData);
data.display = ffXOpenDisplay(NULL);
if(data.display == NULL)
return;
return "XOpenDisplay() failed";
if(propertyDataInitialized && ScreenCount(data.display) > 0)
x11DetectWMFromEWMH(&propertyData, data.display, result);
@@ -350,14 +353,17 @@ void ffdsConnectXrandr(FFDisplayServerResult* result)
//If wayland hasn't set this, connection failed for it. So we are running only a X Server, not XWayland.
if(result->wmProtocolName.length == 0)
ffStrbufSetS(&result->wmProtocolName, FF_WM_PROTOCOL_X11);
return NULL;
}
#else
void ffdsConnectXrandr(FFDisplayServerResult* result)
const char* ffdsConnectXrandr(FFDisplayServerResult* result)
{
//Do nothing here. There are more x11 implementations to come.
FF_UNUSED(result);
return "Fastfetch was compiled without libXrandr support";
}
#endif // FF_HAVE_XRANDR
+1 -1
View File
@@ -17,7 +17,7 @@ const char* ffDetectAmdGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverResu
if (!inited)
{
inited = true;
FF_LIBRARY_LOAD(libags, NULL, "dlopen amd_ags failed", soName , 1);
FF_LIBRARY_LOAD(libags, "dlopen amd_ags failed", soName , 1);
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libags, agsInitialize)
struct AGSContext* apiHandle;
+1 -1
View File
@@ -34,7 +34,7 @@ const char* ffDetectIntelGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverRe
if (!igclData.inited)
{
igclData.inited = true;
FF_LIBRARY_LOAD(libigcl, NULL, "dlopen igcl (ControlLib) failed", soName , 1);
FF_LIBRARY_LOAD(libigcl, "dlopen igcl (ControlLib) failed", soName , 1);
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libigcl, ctlInit)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlClose)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libigcl, igclData, ctlEnumerateDevices)
+1 -1
View File
@@ -41,7 +41,7 @@ const char *ffDetectMthreadsGpuInfo(const FFGpuDriverCondition *cond, FFGpuDrive
if (!mtmlData.inited)
{
mtmlData.inited = true;
FF_LIBRARY_LOAD(libmtml, NULL, "dlopen mtml failed", soName, 1);
FF_LIBRARY_LOAD(libmtml, "dlopen mtml failed", soName, 1);
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libmtml, mtmlLibraryInit)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlDeviceGetBrand)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libmtml, mtmlData, mtmlDeviceGetIndex)
+1 -1
View File
@@ -26,7 +26,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
if (!nvmlData.inited)
{
nvmlData.inited = true;
FF_LIBRARY_LOAD(libnvml, NULL, "dlopen nvml failed", soName , 1);
FF_LIBRARY_LOAD(libnvml, "dlopen nvml failed", soName , 1);
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libnvml, nvmlInit_v2)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libnvml, nvmlShutdown)
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetCount_v2)
+1 -1
View File
@@ -28,7 +28,7 @@ private:
extern "C"
const char* ffGPUDetectByDirectX(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist* gpus)
{
FF_LIBRARY_LOAD(libdxcore, nullptr, "dlopen libdxcore.so failed", "/usr/lib/wsl/lib/libdxcore" FF_LIBRARY_EXTENSION, 4)
FF_LIBRARY_LOAD(libdxcore, "dlopen libdxcore.so failed", "/usr/lib/wsl/lib/libdxcore" FF_LIBRARY_EXTENSION, 4)
// DXCoreCreateAdapterFactory is a reloaded function, so we can't use FF_LIBRARY_LOAD_SYMBOL_MESSAGE here
typedef HRESULT (*DXCoreCreateAdapterFactory_t)(REFIID riid, void** ppvFactory);
+1 -1
View File
@@ -54,7 +54,7 @@ static const char* getSshdVersion(FFstrbuf* version)
static const char* getSddmVersion(FFstrbuf* version)
{
FF_LIBRARY_LOAD(zlib, &instance.config.library.libZ, "dlopen libz failed", "libz" FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD(zlib, "dlopen libz failed", "libz" FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(zlib, gzopen)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(zlib, gzread)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(zlib, gzerror)
+1 -1
View File
@@ -5,7 +5,7 @@
static const char* getMedia(FFMediaResult* media)
{
FF_LIBRARY_LOAD(libffwinrt, NULL, "dlopen libffwinrt" FF_LIBRARY_EXTENSION " failed", "libffwinrt" FF_LIBRARY_EXTENSION, 0)
FF_LIBRARY_LOAD(libffwinrt, "dlopen libffwinrt" FF_LIBRARY_EXTENSION " failed", "libffwinrt" FF_LIBRARY_EXTENSION, 0)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libffwinrt, ffWinrtDetectMedia)
libffwinrt = NULL; // Don't close libffwinrt or it may crash
+1 -1
View File
@@ -135,7 +135,7 @@ static const char* xrandrHandleMonitors(XrandrData* data, Screen* screen, FFlist
static const char* detectByXrandr(FFlist* results)
{
FF_LIBRARY_LOAD(xrandr, &instance.config.library.libXrandr, "dlopen libXrandr" FF_LIBRARY_EXTENSION " failed", "libXrandr" FF_LIBRARY_EXTENSION, 3)
FF_LIBRARY_LOAD(xrandr, "dlopen libXrandr" FF_LIBRARY_EXTENSION " failed", "libXrandr" FF_LIBRARY_EXTENSION, 3)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xrandr, XOpenDisplay)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(xrandr, XCloseDisplay)
+1 -1
View File
@@ -148,7 +148,7 @@ static const char* detectOpenCL(FFOpenCLResult* result)
#ifndef __APPLE__
FF_LIBRARY_LOAD(opencl, &instance.config.library.libOpenCL, "dlopen libOpenCL" FF_LIBRARY_EXTENSION" failed",
FF_LIBRARY_LOAD(opencl, "dlopen libOpenCL" FF_LIBRARY_EXTENSION" failed",
#ifdef _WIN32
"OpenCL"FF_LIBRARY_EXTENSION, -1,
#endif
+2 -2
View File
@@ -120,7 +120,7 @@ static const char* detectByGlx(FFOpenGLResult* result)
{
GLXData data;
FF_LIBRARY_LOAD(glx, &instance.config.library.libGLX, "dlopen glx failed", "libGLX" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD(glx, "dlopen glx failed", "libGLX" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, glXGetProcAddress);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, glXQueryVersion);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(glx, data, XOpenDisplay);
@@ -189,7 +189,7 @@ static const char* detectByOsMesa(FFOpenGLResult* result)
{
OSMesaData data;
FF_LIBRARY_LOAD(osmesa, &instance.config.library.libOSMesa, "dlopen osmesa failed", "libOSMesa" FF_LIBRARY_EXTENSION, 8);
FF_LIBRARY_LOAD(osmesa, "dlopen osmesa failed", "libOSMesa" FF_LIBRARY_EXTENSION, 8);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaGetProcAddress);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaCreateContext);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(osmesa, data, OSMesaMakeCurrent);
+1 -1
View File
@@ -120,7 +120,7 @@ const char* ffOpenGLDetectByEGL(FFOpenGLResult* result)
{
EGLData eglData;
FF_LIBRARY_LOAD(egl, &instance.config.library.libEGL, "dlopen libEGL" FF_LIBRARY_EXTENSION " failed", "libEGL" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD(egl, "dlopen libEGL" FF_LIBRARY_EXTENSION " failed", "libEGL" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglGetProcAddress);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglGetDisplay);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(egl, eglData, eglQueryString);
+1 -1
View File
@@ -81,7 +81,7 @@ static LRESULT CALLBACK wglHandleWndProc(HWND hWnd, UINT message, WPARAM wParam,
static const char* wglDetectOpenGL(FFOpenGLResult* result)
{
FF_LIBRARY_LOAD(opengl32, NULL, "dlopen opengl32" FF_LIBRARY_EXTENSION " failed", "opengl32" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD(opengl32, "dlopen opengl32" FF_LIBRARY_EXTENSION " failed", "opengl32" FF_LIBRARY_EXTENSION, 1);
WGLData data = { .result = result };
+1 -1
View File
@@ -31,7 +31,7 @@ PWSTR WINAPI BrandingFormatString(PCWSTR format);
static const char* getOsNameByWinbrand(FFstrbuf* osName)
{
//https://dennisbabkin.com/blog/?t=how-to-tell-the-real-version-of-windows-your-app-is-running-on#ver_string
FF_LIBRARY_LOAD(winbrand, nullptr, "dlopen winbrand" FF_LIBRARY_EXTENSION " failed", "winbrand" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD(winbrand, "dlopen winbrand" FF_LIBRARY_EXTENSION " failed", "winbrand" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(winbrand, BrandingFormatString);
const wchar_t* rawName = ffBrandingFormatString(L"%WINDOWS_LONG%");
+1 -1
View File
@@ -322,7 +322,7 @@ static uint32_t getSnap(FFstrbuf* baseDir)
static uint32_t getRpmFromLibrpm(void)
{
FF_LIBRARY_LOAD(rpm, &instance.config.library.librpm, 0, "librpm" FF_LIBRARY_EXTENSION, 12)
FF_LIBRARY_LOAD(rpm, 0, "librpm" FF_LIBRARY_EXTENSION, 12)
FF_LIBRARY_LOAD_SYMBOL(rpm, rpmReadConfigFiles, 0)
FF_LIBRARY_LOAD_SYMBOL(rpm, rpmtsCreate, 0)
FF_LIBRARY_LOAD_SYMBOL(rpm, rpmtsInitIterator, 0)
+1 -1
View File
@@ -41,7 +41,7 @@ static void paServerInfoCallback(pa_context *c, const pa_server_info *i, void *u
static const char* detectSound(FFlist* devices)
{
FF_LIBRARY_LOAD(pulse, &instance.config.library.libPulse, "Failed to load libpulse" FF_LIBRARY_EXTENSION, "libpulse" FF_LIBRARY_EXTENSION, 0)
FF_LIBRARY_LOAD(pulse, "Failed to load libpulse" FF_LIBRARY_EXTENSION, "libpulse" FF_LIBRARY_EXTENSION, 0)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pulse, pa_mainloop_new)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pulse, pa_mainloop_get_api)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(pulse, pa_mainloop_iterate)
@@ -15,7 +15,7 @@ const char* detectTermux(FFTerminalFontResult* terminalFont)
{
#ifdef FF_HAVE_FREETYPE
FF_LIBRARY_LOAD(freetype, &instance.config.library.libfreetype, "dlopen libfreetype"FF_LIBRARY_EXTENSION " failed", "libfreetype"FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD(freetype, "dlopen libfreetype"FF_LIBRARY_EXTENSION " failed", "libfreetype"FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Init_FreeType);
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_New_Face);
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(freetype, FT_Done_Face);
+1 -1
View File
@@ -39,7 +39,7 @@ static void applyDriverName(VkPhysicalDeviceDriverPropertiesKHR* properties, FFs
static const char* detectVulkan(FFVulkanResult* result)
{
FF_LIBRARY_LOAD(vulkan, &instance.config.library.libVulkan, "dlopen libvulkan"FF_LIBRARY_EXTENSION " failed",
FF_LIBRARY_LOAD(vulkan, "dlopen libvulkan"FF_LIBRARY_EXTENSION " failed",
#ifdef __APPLE__
"libMoltenVK"FF_LIBRARY_EXTENSION, -1
#elif defined(_WIN32)
+1 -1
View File
@@ -43,7 +43,7 @@ static void convertIfStateToString(WLAN_INTERFACE_STATE state, FFstrbuf* result)
const char* ffDetectWifi(FFlist* result)
{
FF_LIBRARY_LOAD(wlanapi, NULL, "dlopen wlanapi"FF_LIBRARY_EXTENSION" failed", "wlanapi"FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD(wlanapi, "dlopen wlanapi" FF_LIBRARY_EXTENSION " failed", "wlanapi" FF_LIBRARY_EXTENSION, 1)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanOpenHandle)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanEnumInterfaces)
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanQueryInterface)
+1 -1
View File
@@ -78,7 +78,7 @@ static int enumZpoolCallback(zpool_handle_t* zpool, void* param)
const char* ffDetectZpool(FFlist* result /* list of FFZpoolResult */)
{
FF_LIBRARY_LOAD(libzfs, NULL, "dlopen libzfs" FF_LIBRARY_EXTENSION " failed", "libzfs" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_LOAD(libzfs, "dlopen libzfs" FF_LIBRARY_EXTENSION " failed", "libzfs" FF_LIBRARY_EXTENSION, 4);
FF_LIBRARY_LOAD_SYMBOL_MESSAGE(libzfs, libzfs_init);
libzfs_handle_t* handle = fflibzfs_init();
-3
View File
@@ -353,7 +353,6 @@ static bool parseJsoncFile(const char* path)
(error = ffOptionsParseLogoJsonConfig(&instance.config.logo, root)) ||
(error = ffOptionsParseGeneralJsonConfig(&instance.config.general, root)) ||
(error = ffOptionsParseDisplayJsonConfig(&instance.config.display, root)) ||
(error = ffOptionsParseLibraryJsonConfig(&instance.config.library, root)) ||
false
) {
fprintf(stderr, "JsonConfig Error: %s\n", error);
@@ -596,7 +595,6 @@ static void parseOption(FFdata* data, const char* key, const char* value)
ffOptionsParseGeneralCommandLine(&instance.config.general, key, value) ||
ffOptionsParseLogoCommandLine(&instance.config.logo, key, value) ||
ffOptionsParseDisplayCommandLine(&instance.config.display, key, value) ||
ffOptionsParseLibraryCommandLine(&instance.config.library, key, value) ||
ffParseModuleOptions(key, value)
) {}
@@ -688,7 +686,6 @@ static void writeConfigFile(FFdata* data, const FFstrbuf* filename)
ffOptionsGenerateLogoJsonConfig(&instance.config.logo, doc);
ffOptionsGenerateDisplayJsonConfig(&instance.config.display, doc);
ffOptionsGenerateGeneralJsonConfig(&instance.config.general, doc);
ffOptionsGenerateLibraryJsonConfig(&instance.config.library, doc);
ffMigrateCommandOptionToJsonc(data, doc);
if (ffStrbufEqualS(filename, "-"))
-2
View File
@@ -27,7 +27,6 @@
#include "options/logo.h"
#include "options/display.h"
#include "options/general.h"
#include "options/library.h"
typedef struct FFconfig
{
@@ -35,7 +34,6 @@ typedef struct FFconfig
FFOptionsDisplay display;
FFOptionsGeneral general;
FFOptionsModules modules;
FFOptionsLibrary library;
} FFconfig;
typedef struct FFstate
+1 -1
View File
@@ -14,7 +14,7 @@ static void* logoResize(const void* image, size_t width, size_t height, void* ex
FFLogoImageResult ffLogoPrintImageIM6(FFLogoRequestData* requestData)
{
FF_LIBRARY_LOAD(imageMagick, &instance.config.library.libImageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR, "libMagickCore-6.Q16HDRI" FF_LIBRARY_EXTENSION, 8, "libMagickCore-6.Q16" FF_LIBRARY_EXTENSION, 8)
FF_LIBRARY_LOAD(imageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR, "libMagickCore-6.Q16HDRI" FF_LIBRARY_EXTENSION, 8, "libMagickCore-6.Q16" FF_LIBRARY_EXTENSION, 8)
FF_LIBRARY_LOAD_SYMBOL_ADDRESS(imageMagick, ffResizeImage, ResizeImage, FF_LOGO_IMAGE_RESULT_INIT_ERROR);
FFLogoImageResult result = ffLogoPrintImageImpl(requestData, &(FFIMData) {
+1 -1
View File
@@ -14,7 +14,7 @@ static void* logoResize(const void* image, size_t width, size_t height, void* ex
FFLogoImageResult ffLogoPrintImageIM7(FFLogoRequestData* requestData)
{
FF_LIBRARY_LOAD(imageMagick, &instance.config.library.libImageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR,
FF_LIBRARY_LOAD(imageMagick, FF_LOGO_IMAGE_RESULT_INIT_ERROR,
"libMagickCore-7.Q16HDRI" FF_LIBRARY_EXTENSION, 11,
"libMagickCore-7.Q16" FF_LIBRARY_EXTENSION, 11,
"libMagickCore-7.Q16HDRI-10" FF_LIBRARY_EXTENSION, -1 // Required for Windows
+2 -2
View File
@@ -305,7 +305,7 @@ static inline char* realpath(const char* restrict file_name, char* restrict reso
static bool compressBlob(void** blob, size_t* length)
{
FF_LIBRARY_LOAD(zlib, &instance.config.library.libZ, false, "libz" FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD(zlib, false, "libz" FF_LIBRARY_EXTENSION, 2)
FF_LIBRARY_LOAD_SYMBOL(zlib, compressBound, false)
FF_LIBRARY_LOAD_SYMBOL(zlib, compress2, false)
@@ -490,7 +490,7 @@ static bool printImageKitty(FFLogoRequestData* requestData, const ImageData* ima
#include <chafa.h>
static bool printImageChafa(FFLogoRequestData* requestData, const ImageData* imageData)
{
FF_LIBRARY_LOAD(chafa, &instance.config.library.libChafa, false,
FF_LIBRARY_LOAD(chafa, false,
"libchafa" FF_LIBRARY_EXTENSION, 1,
"libchafa-0" FF_LIBRARY_EXTENSION, -1 // Required for Windows
)
-239
View File
@@ -1,239 +0,0 @@
#include "fastfetch.h"
#include "common/jsonconfig.h"
#include "options/general.h"
#include "util/stringUtils.h"
const char* ffOptionsParseLibraryJsonConfig(FFOptionsLibrary* options, yyjson_val* root)
{
yyjson_val* object = yyjson_obj_get(root, "library");
if (!object) return NULL;
if (!yyjson_is_obj(object)) return "Property 'library' must be an object";
yyjson_val *key_, *val;
size_t idx, max;
yyjson_obj_foreach(object, idx, max, key_, val)
{
const char* key = yyjson_get_str(key_);
if (ffStrEqualsIgnCase(key, "vulkan"))
ffStrbufSetS(&options->libVulkan, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "opencl"))
ffStrbufSetS(&options->libOpenCL, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "sqlite") || ffStrEqualsIgnCase(key, "sqlite3"))
ffStrbufSetS(&options->libSQLite3, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "imagemagick"))
ffStrbufSetS(&options->libImageMagick, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "chafa"))
ffStrbufSetS(&options->libChafa, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "z"))
ffStrbufSetS(&options->libZ, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "egl"))
ffStrbufSetS(&options->libEGL, yyjson_get_str(val));
#ifdef __ANDROID__
else if (ffStrEqualsIgnCase(key, "freetype"))
ffStrbufSetS(&options->libfreetype, yyjson_get_str(val));
#endif
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
else if (ffStrEqualsIgnCase(key, "wayland"))
ffStrbufSetS(&options->libWayland, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "xcbRandr"))
ffStrbufSetS(&options->libXcbRandr, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "xcb"))
ffStrbufSetS(&options->libXcb, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "Xrandr"))
ffStrbufSetS(&options->libXrandr, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "X11"))
ffStrbufSetS(&options->libX11, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "gio"))
ffStrbufSetS(&options->libGIO, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "DConf"))
ffStrbufSetS(&options->libDConf, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "dbus"))
ffStrbufSetS(&options->libDBus, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "XFConf"))
ffStrbufSetS(&options->libXFConf, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "rpm"))
ffStrbufSetS(&options->librpm, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "glx"))
ffStrbufSetS(&options->libGLX, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "osmesa"))
ffStrbufSetS(&options->libOSMesa, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "pulse"))
ffStrbufSetS(&options->libPulse, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "ddcutil"))
ffStrbufSetS(&options->libDdcutil, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "drm"))
ffStrbufSetS(&options->libdrm, yyjson_get_str(val));
else if (ffStrEqualsIgnCase(key, "elf"))
ffStrbufSetS(&options->libelf, yyjson_get_str(val));
#endif
else
return "Unknown library property";
}
return NULL;
}
bool ffOptionsParseLibraryCommandLine(FFOptionsLibrary* options, const char* key, const char* value)
{
if(ffStrStartsWithIgnCase(key, "--lib-"))
{
const char* subkey = key + strlen("--lib-");
if(ffStrEqualsIgnCase(subkey, "vulkan"))
ffOptionParseString(key, value, &options->libVulkan);
else if(ffStrEqualsIgnCase(subkey, "opencl"))
ffOptionParseString(key, value, &options->libOpenCL);
else if(ffStrEqualsIgnCase(subkey, "sqlite") || ffStrEqualsIgnCase(subkey, "sqlite3"))
ffOptionParseString(key, value, &options->libSQLite3);
else if(ffStrEqualsIgnCase(subkey, "imagemagick"))
ffOptionParseString(key, value, &options->libImageMagick);
else if(ffStrEqualsIgnCase(subkey, "chafa"))
ffOptionParseString(key, value, &options->libChafa);
else if(ffStrEqualsIgnCase(subkey, "z"))
ffOptionParseString(key, value, &options->libZ);
else if(ffStrEqualsIgnCase(subkey, "egl"))
ffOptionParseString(key, value, &options->libEGL);
#ifdef __ANDROID__
else if(ffStrEqualsIgnCase(subkey, "freetype"))
ffOptionParseString(key, value, &options->libfreetype);
#endif
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
else if(ffStrEqualsIgnCase(subkey, "wayland"))
ffOptionParseString(key, value, &options->libWayland);
else if(ffStrEqualsIgnCase(subkey, "xcbRandr"))
ffOptionParseString(key, value, &options->libXcbRandr);
else if(ffStrEqualsIgnCase(subkey, "xcb"))
ffOptionParseString(key, value, &options->libXcb);
else if(ffStrEqualsIgnCase(subkey, "Xrandr"))
ffOptionParseString(key, value, &options->libXrandr);
else if(ffStrEqualsIgnCase(subkey, "X11"))
ffOptionParseString(key, value, &options->libX11);
else if(ffStrEqualsIgnCase(subkey, "gio"))
ffOptionParseString(key, value, &options->libGIO);
else if(ffStrEqualsIgnCase(subkey, "DConf"))
ffOptionParseString(key, value, &options->libDConf);
else if(ffStrEqualsIgnCase(subkey, "dbus"))
ffOptionParseString(key, value, &options->libDBus);
else if(ffStrEqualsIgnCase(subkey, "XFConf"))
ffOptionParseString(key, value, &options->libXFConf);
else if(ffStrEqualsIgnCase(subkey, "rpm"))
ffOptionParseString(key, value, &options->librpm);
else if(ffStrEqualsIgnCase(subkey, "glx"))
ffOptionParseString(key, value, &options->libGLX);
else if(ffStrEqualsIgnCase(subkey, "osmesa"))
ffOptionParseString(key, value, &options->libOSMesa);
else if(ffStrEqualsIgnCase(subkey, "pulse"))
ffOptionParseString(key, value, &options->libPulse);
else if(ffStrEqualsIgnCase(subkey, "ddcutil"))
ffOptionParseString(key, value, &options->libDdcutil);
else if(ffStrEqualsIgnCase(subkey, "drm"))
ffOptionParseString(key, value, &options->libdrm);
else if(ffStrEqualsIgnCase(subkey, "elf"))
ffOptionParseString(key, value, &options->libelf);
#endif
else
return false;
}
else
return false;
return true;
}
void ffOptionsInitLibrary(FFOptionsLibrary* options)
{
static_assert(sizeof(*options) % sizeof(FFstrbuf) == 0, "FFOptionsLibrary is not aligned");
for (FFstrbuf* pBuf = (void*) options; pBuf < (FFstrbuf*) (options + 1); pBuf++)
ffStrbufInit(pBuf);
}
void ffOptionsDestroyLibrary(FFOptionsLibrary* options)
{
for (FFstrbuf* pBuf = (void*) options; pBuf < (FFstrbuf*) (options + 1); pBuf++)
ffStrbufDestroy(pBuf);
}
void ffOptionsGenerateLibraryJsonConfig(FFOptionsLibrary* options, yyjson_mut_doc* doc)
{
__attribute__((__cleanup__(ffOptionsDestroyLibrary))) FFOptionsLibrary defaultOptions;
ffOptionsInitLibrary(&defaultOptions);
yyjson_mut_val* obj = yyjson_mut_obj(doc);
if (!ffStrbufEqual(&options->libVulkan, &defaultOptions.libVulkan))
yyjson_mut_obj_add_strbuf(doc, obj, "vulkan", &options->libVulkan);
if (!ffStrbufEqual(&options->libOpenCL, &defaultOptions.libOpenCL))
yyjson_mut_obj_add_strbuf(doc, obj, "OpenCL", &options->libOpenCL);
if (!ffStrbufEqual(&options->libSQLite3, &defaultOptions.libSQLite3))
yyjson_mut_obj_add_strbuf(doc, obj, "sqlite", &options->libSQLite3);
if (!ffStrbufEqual(&options->libImageMagick, &defaultOptions.libImageMagick))
yyjson_mut_obj_add_strbuf(doc, obj, "ImageMagick", &options->libImageMagick);
if (!ffStrbufEqual(&options->libChafa, &defaultOptions.libChafa))
yyjson_mut_obj_add_strbuf(doc, obj, "chafa", &options->libChafa);
if (!ffStrbufEqual(&options->libZ, &defaultOptions.libZ))
yyjson_mut_obj_add_strbuf(doc, obj, "z", &options->libZ);
if (!ffStrbufEqual(&options->libEGL, &defaultOptions.libEGL))
yyjson_mut_obj_add_strbuf(doc, obj, "egl", &options->libEGL);
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
if (!ffStrbufEqual(&options->libWayland, &defaultOptions.libWayland))
yyjson_mut_obj_add_strbuf(doc, obj, "wayland", &options->libWayland);
if (!ffStrbufEqual(&options->libXcbRandr, &defaultOptions.libXcbRandr))
yyjson_mut_obj_add_strbuf(doc, obj, "xcbRandr", &options->libXcbRandr);
if (!ffStrbufEqual(&options->libXcb, &defaultOptions.libXcb))
yyjson_mut_obj_add_strbuf(doc, obj, "xcb", &options->libXcb);
if (!ffStrbufEqual(&options->libXrandr, &defaultOptions.libXrandr))
yyjson_mut_obj_add_strbuf(doc, obj, "Xrandr", &options->libXrandr);
if (!ffStrbufEqual(&options->libX11, &defaultOptions.libX11))
yyjson_mut_obj_add_strbuf(doc, obj, "X11", &options->libX11);
if (!ffStrbufEqual(&options->libGIO, &defaultOptions.libGIO))
yyjson_mut_obj_add_strbuf(doc, obj, "gio", &options->libGIO);
if (!ffStrbufEqual(&options->libDConf, &defaultOptions.libDConf))
yyjson_mut_obj_add_strbuf(doc, obj, "DConf", &options->libDConf);
if (!ffStrbufEqual(&options->libDBus, &defaultOptions.libDBus))
yyjson_mut_obj_add_strbuf(doc, obj, "dbus", &options->libDBus);
if (!ffStrbufEqual(&options->libXFConf, &defaultOptions.libXFConf))
yyjson_mut_obj_add_strbuf(doc, obj, "XFConf", &options->libXFConf);
if (!ffStrbufEqual(&options->librpm, &defaultOptions.librpm))
yyjson_mut_obj_add_strbuf(doc, obj, "rpm", &options->librpm);
if (!ffStrbufEqual(&options->libGLX, &defaultOptions.libGLX))
yyjson_mut_obj_add_strbuf(doc, obj, "glx", &options->libGLX);
if (!ffStrbufEqual(&options->libOSMesa, &defaultOptions.libOSMesa))
yyjson_mut_obj_add_strbuf(doc, obj, "OSMesa", &options->libOSMesa);
if (!ffStrbufEqual(&options->libPulse, &defaultOptions.libPulse))
yyjson_mut_obj_add_strbuf(doc, obj, "pulse", &options->libPulse);
if (!ffStrbufEqual(&options->libDdcutil, &defaultOptions.libDdcutil))
yyjson_mut_obj_add_strbuf(doc, obj, "ddcutil", &options->libDdcutil);
if (!ffStrbufEqual(&options->libdrm, &defaultOptions.libdrm))
yyjson_mut_obj_add_strbuf(doc, obj, "drm", &options->libdrm);
#endif
if (yyjson_mut_obj_size(obj) > 0)
yyjson_mut_obj_add_val(doc, doc->root, "library", obj);
}
-43
View File
@@ -1,43 +0,0 @@
#pragma once
#include "util/FFstrbuf.h"
typedef struct FFOptionsLibrary
{
FFstrbuf libVulkan;
FFstrbuf libOpenCL;
FFstrbuf libSQLite3;
FFstrbuf libImageMagick;
FFstrbuf libChafa;
FFstrbuf libZ;
FFstrbuf libEGL;
#ifdef __ANDROID__
FFstrbuf libfreetype;
#endif
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
FFstrbuf libWayland;
FFstrbuf libXcbRandr;
FFstrbuf libXcb;
FFstrbuf libXrandr;
FFstrbuf libX11;
FFstrbuf libGIO;
FFstrbuf libDConf;
FFstrbuf libDBus;
FFstrbuf libXFConf;
FFstrbuf librpm;
FFstrbuf libGLX;
FFstrbuf libOSMesa;
FFstrbuf libPulse;
FFstrbuf libDdcutil;
FFstrbuf libdrm;
FFstrbuf libelf;
#endif
} FFOptionsLibrary;
const char* ffOptionsParseLibraryJsonConfig(FFOptionsLibrary* options, yyjson_val* root);
bool ffOptionsParseLibraryCommandLine(FFOptionsLibrary* options, const char* key, const char* value);
void ffOptionsInitLibrary(FFOptionsLibrary* options);
void ffOptionsDestroyLibrary(FFOptionsLibrary* options);
void ffOptionsGenerateLibraryJsonConfig(FFOptionsLibrary* options, yyjson_mut_doc* doc);
+1 -1
View File
@@ -28,7 +28,7 @@ const char* ffBinaryExtractStrings(const char* elfFile, bool (*cb)(const char* s
if (!elfData.inited)
{
elfData.inited = true;
FF_LIBRARY_LOAD(libelf, &instance.config.library.libelf, "dlopen libelf" FF_LIBRARY_EXTENSION " failed", "libelf" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD(libelf, "dlopen libelf" FF_LIBRARY_EXTENSION " failed", "libelf" FF_LIBRARY_EXTENSION, 1);
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libelf, elfData, elf_version)
if (elfData.ffelf_version(EV_CURRENT) == EV_NONE) return "elf_version() failed";