From 4ff218d726c401ecc3d6728f1dae798bfee76c50 Mon Sep 17 00:00:00 2001 From: Stefan Gehn Date: Sat, 12 Jul 2014 22:45:33 +0200 Subject: [PATCH] Drop GLib 1.x compatibility for gkrellmd GLib version 1 is very outdated by now and not available in any recent Linux distribution. Keeping this code around without actually being able to test it makes little sense so let's get rid of that. --- Changelog | 1 + server/Makefile | 18 +---- server/gkrellmd.h | 26 ------- server/glib.c | 153 ------------------------------------------ server/mail.c | 8 --- server/monitor.c | 12 ---- src/gkrellm-sysdeps.h | 4 -- src/sysdeps/linux.c | 16 ----- 8 files changed, 2 insertions(+), 236 deletions(-) delete mode 100644 server/glib.c diff --git a/Changelog b/Changelog index 29663c6..4a3e506 100644 --- a/Changelog +++ b/Changelog @@ -27,6 +27,7 @@ GKrellM Changelog * Add support for GPU-Z sensor information on Windows * Increase minimum required GLib version to 2.32, some parts of gkrellm use newer GLib API + * Drop remaining GLib 1.x compatibility from gkrellmd 2.3.5 - Thu Oct 7, 2010 ------------------------ diff --git a/server/Makefile b/server/Makefile index 44767fd..290fd20 100644 --- a/server/Makefile +++ b/server/Makefile @@ -55,26 +55,11 @@ GKRELLMD_INCLUDES = gkrellmd.h $(SHARED_PATH)/log.h PKG_INCLUDE = `$(PKG_CONFIG) --cflags glib-2.0 gmodule-2.0 gthread-2.0` PKG_LIB = `$(PKG_CONFIG) --libs glib-2.0 gmodule-2.0 gthread-2.0` -GLIB12_INCLUDE = `glib-config --cflags` -GLIB12_LIB = `glib-config --libs glib gmodule` - FLAGS = -O2 $(PKG_INCLUDE) -ifeq ($(glib12),1) - FLAGS = -O2 $(GLIB12_INCLUDE) -endif -ifeq ($(glib12),yes) - FLAGS = -O2 $(GLIB12_INCLUDE) -endif FLAGS += $(GTOP_INCLUDE) $(PTHREAD_INC) -I.. -I$(SHARED_PATH) -DGKRELLM_SERVER LIBS = $(PKG_LIB) -ifeq ($(glib12),1) - LIBS = $(GLIB12_LIB) -endif -ifeq ($(glib12),yes) - LIBS = $(GLIB12_LIB) -endif LIBS += $(GTOP_LIBS_D) $(SYS_LIBS) $(SENSORS_LIBS) ifeq ($(debug),1) @@ -109,7 +94,7 @@ endif OS_NAME=$(shell uname -s) OS_RELEASE=$(shell uname -r) -OBJS = main.o monitor.o mail.o plugins.o glib.o utils.o sysdeps-unix.o log.o +OBJS = main.o monitor.o mail.o plugins.o utils.o sysdeps-unix.o log.o all: gkrellmd$(BINEXT) @@ -240,7 +225,6 @@ main.o: main.c $(GKRELLMD_H) monitor.o: monitor.c $(GKRELLMD_H) mail.o: mail.c $(GKRELLMD_H) plugins.o: plugins.c $(GKRELLMD_H) -glib.o: glib.c $(GKRELLMD_H) utils.o: utils.c $(GKRELLMD_H) sysdeps-unix.o: sysdeps-unix.c ../src/gkrellm-sysdeps.h $(SYSDEPS) $(GKRELLMD_H) log.o: $(SHARED_PATH)/log.c $(SHARED_PATH)/log.h $(GKRELLMD_H) diff --git a/server/gkrellmd.h b/server/gkrellmd.h index 01b9112..d14d27b 100644 --- a/server/gkrellmd.h +++ b/server/gkrellmd.h @@ -246,30 +246,4 @@ void gkrellmd_add_mailbox(gchar *); GkrellmdTicks *gkrellmd_ticks(void); gint gkrellmd_get_timer_ticks(void); - -#if !GLIB_CHECK_VERSION(2,0,0) - -/* glib2 compatibility functions -*/ -#define G_FILE_TEST_EXISTS 1 -#define G_FILE_TEST_IS_DIR 2 -#define G_FILE_TEST_IS_REGULAR 4 - -#include - -typedef struct - { - DIR *dir; - } - GDir; - -GDir *g_dir_open(gchar *path, guint flags, gpointer error); -gchar *g_dir_read_name(GDir *dir); -void g_dir_close(GDir *dir); -gboolean g_file_test(gchar *filename, gint test); -gchar *g_build_filename(gchar *first, ...); -gchar *g_path_get_basename(gchar *file_name); - -#endif - #endif // GKRELLMD_H diff --git a/server/glib.c b/server/glib.c deleted file mode 100644 index 73df268..0000000 --- a/server/glib.c +++ /dev/null @@ -1,153 +0,0 @@ -/* GKrellM -| Copyright (C) 1999-2010 Bill Wilson -| -| Author: Bill Wilson billw@gkrellm.net -| Latest versions might be found at: http://gkrellm.net -| -| -| GKrellM is free software: you can redistribute it and/or 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. -| -| GKrellM 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. -| -| You should have received a copy of the GNU General Public License -| along with this program. If not, see http://www.gnu.org/licenses/ -| -| -| Additional permission under GNU GPL version 3 section 7 -| -| If you modify this program, or any covered work, by linking or -| combining it with the OpenSSL project's OpenSSL library (or a -| modified version of that library), containing parts covered by -| the terms of the OpenSSL or SSLeay licenses, you are granted -| additional permission to convey the resulting work. -| Corresponding Source for a non-source form of such a combination -| shall include the source code for the parts of OpenSSL used as well -| as that of the covered work. -*/ - -#include "gkrellmd.h" -#include "gkrellmd-private.h" - -#if !GLIB_CHECK_VERSION(2,0,0) -/* glib2 compatibility functions for compiling gkrellmd under glib1.2 -*/ - -GDir * -g_dir_open(gchar *path, guint flags, gpointer error) - { - GDir *gdir; - DIR *dir; - - dir = opendir(path); - if (!dir) - return NULL; - gdir = g_new0(GDir, 1); - gdir->dir = dir; - return gdir; - } - -gchar* -g_dir_read_name(GDir *dir) - { - struct dirent *entry; - - while ((entry = readdir(dir->dir)) != NULL) - { - if ( !strcmp(entry->d_name, ".") - || !strcmp(entry->d_name, "..") - ) - continue; - return entry->d_name; - } - return NULL; - } - -void -g_dir_close(GDir *dir) - { - closedir(dir->dir); - g_free(dir); - } - -gboolean -g_file_test(gchar *filename, gint test) - { - struct stat s; - - if ((test & G_FILE_TEST_EXISTS) && (access(filename, F_OK) == 0)) - return TRUE; - if ( (test & G_FILE_TEST_IS_DIR) - && stat(filename, &s) == 0 - && S_ISDIR(s.st_mode) - ) - return TRUE; - if ( (test & G_FILE_TEST_IS_REGULAR) - && stat(filename, &s) == 0 - && S_ISREG(s.st_mode) - ) - return TRUE; - - return FALSE; - } - - -gchar * -g_build_filename(gchar *first, ...) - { - gchar *str; - va_list args; - gchar *s, *element, *next_element; - gboolean is_first = TRUE; - - va_start(args, first); - next_element = first; - str = g_strdup(""); - - while (1) - { - if (next_element) - { - element = next_element; - next_element = va_arg(args, gchar *); - } - else - break; - if (is_first) - { - is_first = FALSE; - g_free(str); - str = g_strdup(element); - } - else - { - s = str; - str = g_strconcat(str, G_DIR_SEPARATOR_S, element, NULL); - g_free(s); - } - } - va_end (args); - - return str; - } - -gchar * -g_path_get_basename(gchar *fname) - { - gchar *s; - - if (!*fname) - return g_strdup("."); - - s = strrchr(fname, G_DIR_SEPARATOR); - if (!s) - return g_strdup(fname); - return g_strdup(s + 1); /* don't handle paths ending in slash */ - } - -#endif diff --git a/server/mail.c b/server/mail.c index 40d0dcb..6f078df 100644 --- a/server/mail.c +++ b/server/mail.c @@ -577,11 +577,7 @@ get_local_mboxtype(Mailbox *mbox) } if (g_file_test(mbox->path, G_FILE_TEST_IS_DIR)) { -#if GLIB_CHECK_VERSION(2,0,0) path = g_build_path(G_DIR_SEPARATOR_S, mbox->path, "new", NULL); -#else - path = g_strconcat(mbox->path, G_DIR_SEPARATOR_S, "new", NULL); -#endif if (g_file_test(path, G_FILE_TEST_IS_DIR)) mbox->mboxtype = MBOX_MAILDIR; else @@ -696,11 +692,7 @@ gkrellm_mail_local_unsupported(void) /* WIN32 only calls this and it is taken care of by above #if */ } -#if GLIB_CHECK_VERSION(2,0,0) GThread * -#else -gpointer -#endif gkrellm_mail_get_active_thread(void) { return NULL; diff --git a/server/monitor.c b/server/monitor.c index 750ab9f..8364d95 100644 --- a/server/monitor.c +++ b/server/monitor.c @@ -378,7 +378,6 @@ static DiskData * add_subdisk(gchar *subdisk_name, gchar *disk_name, gint subdisk) { DiskData *sdisk = NULL; -#if GLIB_CHECK_VERSION(2,0,0) DiskData *disk; GList *list = NULL; @@ -404,7 +403,6 @@ add_subdisk(gchar *subdisk_name, gchar *disk_name, gint subdisk) } disk_list = g_list_insert_before(disk_list, list, sdisk); ++n_disks; -#endif return sdisk; } @@ -1470,7 +1468,6 @@ refresh_fstab_list(void) fstab_list_modified = TRUE; } -#if GLIB_CHECK_VERSION(2,0,0) static gpointer get_fsusage_thread(void *data) { @@ -1488,7 +1485,6 @@ get_fsusage_thread(void *data) } return NULL; } -#endif static void update_fs(GkrellmdMonitor *mon, gboolean first_update) @@ -1520,12 +1516,8 @@ update_fs(GkrellmdMonitor *mon, gboolean first_update) gkrellm_sys_fs_get_fsusage(m, m->directory); else if (nfs_check && m->is_nfs && !m->busy) { -#if GLIB_CHECK_VERSION(2,0,0) m->busy = TRUE; g_thread_new("get_fsusage", get_fsusage_thread, m); -#else - gkrellm_sys_fs_get_fsusage(m, m->directory); -#endif } } if (first_update || gkrellm_sys_fs_fstab_modified()) @@ -1859,14 +1851,10 @@ read_sensors(void *data) static void run_sensors_thread(void) { -#if GLIB_CHECK_VERSION(2,0,0) if (thread_busy) return; thread_busy = TRUE; g_thread_new("read_sensors", read_sensors, NULL); -#else - read_sensors(NULL); -#endif } diff --git a/src/gkrellm-sysdeps.h b/src/gkrellm-sysdeps.h index 222d393..02bf69d 100644 --- a/src/gkrellm-sysdeps.h +++ b/src/gkrellm-sysdeps.h @@ -83,11 +83,7 @@ gint gkrellm_get_timer_ticks(void); */ void gkrellm_mail_local_unsupported(void); -#if GLIB_CHECK_VERSION(2,0,0) GThread *gkrellm_mail_get_active_thread(void); -#else -gpointer gkrellm_mail_get_active_thread(void); -#endif /* ===================================================================== */ /* CPU monitor interface diff --git a/src/sysdeps/linux.c b/src/sysdeps/linux.c index 427fe6e..9c9bf96 100644 --- a/src/sysdeps/linux.c +++ b/src/sysdeps/linux.c @@ -2976,7 +2976,6 @@ GList *nvidia_smi_list; static NvidiaSmi * nvidia_smi_lookup(gchar *id) { -#if GLIB_CHECK_VERSION(2,0,0) GList *list; NvidiaSmi *smi; @@ -2986,7 +2985,6 @@ nvidia_smi_lookup(gchar *id) if (!strcmp(smi->id, id)) return smi; } -#endif return NULL; } @@ -3011,7 +3009,6 @@ static gboolean sensors_nvidia_smi_read(gboolean setup) { gint n = 0; -#if GLIB_CHECK_VERSION(2,0,0) gchar *args[] = { "nvidia-smi", "-q", "-a", NULL }; gchar *str, *stmp, id[64]; gchar *output = NULL; @@ -3100,7 +3097,6 @@ sensors_nvidia_smi_read(gboolean setup) g_free(errout); if (error) g_error_free(error); -#endif if (setup && (_GK.debug_level & DEBUG_SENSORS)) g_debug("nvidia-smi gpus = %d\n", n); @@ -3218,7 +3214,6 @@ gkrellm_sys_sensors_get_temperature(gchar *sensor_path, gint id, if (interface == NVIDIA_SETTINGS_INTERFACE) { -#if GLIB_CHECK_VERSION(2,0,0) gchar *args[] = { "nvidia-settings", "-q", sensor_path, NULL }; gchar *output = NULL; GError *error = NULL; @@ -3249,14 +3244,10 @@ gkrellm_sys_sensors_get_temperature(gchar *sensor_path, gint id, if (output) g_free(output); return result; -#else - return FALSE; -#endif } if (interface == NVCLOCK_INTERFACE) { -#if GLIB_CHECK_VERSION(2,0,0) gchar *args[] = { "nvclock", "-T", "-c", sensor_path, NULL }; gchar *output = NULL; gchar *s = NULL; @@ -3280,9 +3271,6 @@ gkrellm_sys_sensors_get_temperature(gchar *sensor_path, gint id, g_free(output); return result; -#else - return FALSE; -#endif } if (interface == UNINORTH_INTERFACE || interface == WINDFARM_INTERFACE) @@ -3696,7 +3684,6 @@ static gint sensors_nvidia_settings_ngpus(void) { gint n = 0; -#if GLIB_CHECK_VERSION(2,0,0) gchar *args[] = { "nvidia-settings", "-q", "gpus", NULL }; gchar *output = NULL; gchar *errout = NULL; @@ -3726,7 +3713,6 @@ sensors_nvidia_settings_ngpus(void) if (error) g_error_free(error); -#endif if (_GK.debug_level & DEBUG_SENSORS) g_debug("nvidia-settings gpus = %d\n", n); return n; @@ -3736,7 +3722,6 @@ static gint sensors_nvclock_ngpus(void) { gint n = 0; -#if GLIB_CHECK_VERSION(2,0,0) gchar *args[] = { "nvclock", "-s", NULL }; gchar *output = NULL, *s; gboolean result; @@ -3752,7 +3737,6 @@ sensors_nvclock_ngpus(void) sscanf(s, "Card number: %d", &n); } g_free(output); -#endif if (_GK.debug_level & DEBUG_SENSORS) g_debug("nvclock gpus = %d\n", n); return n;