This is an automated email from the git hooks/post-receive script. timystery pushed a commit to branch master in repository panel-plugins/xfce4-sensors-plugin.
commit cedc3035f8c17ac44d7693d10d55b0eb3965244b Author: Fabian <[email protected]> Date: Wed Feb 8 20:00:06 2017 +0100 Code cleanup and refactoring in files acpi and configuration, with minor API change --- include/acpi.h | 12 +- include/configuration.h | 40 +-- include/hddtemp.h | 2 +- lib/acpi.c | 654 +++++++++++++++++++++--------------------- lib/configuration.c | 192 +++++++------ panel-plugin/sensors-plugin.c | 2 +- 6 files changed, 447 insertions(+), 455 deletions(-) diff --git a/include/acpi.h b/include/acpi.h index 1948d4d..2756fd6 100644 --- a/include/acpi.h +++ b/include/acpi.h @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright 2004-2010 Fabian Nowak ([email protected]) +/* Copyright 2004-2017 Fabian Nowak ([email protected]) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -63,7 +63,7 @@ void refresh_acpi (gpointer ptr_chipfeature, gpointer ptr_unused); * @Param str_filename: file to read information from, e.g. info. * @Return: value from first line of file after keyword and colon. */ -gdouble get_acpi_zone_value (char *str_zone, char *str_filename); +gdouble get_acpi_zone_value (gchar *str_zone, char *str_filename); /** @@ -72,14 +72,14 @@ gdouble get_acpi_zone_value (char *str_zone, char *str_filename); * @Param str_zonename: file to read information from, e.g. state. * @Return: valued from any line starting with "status:", converted to 1 or 0 */ -double get_fan_zone_value (char *str_zonename); +double get_fan_zone_value (gchar *str_zonename); /** * Read a double value from special battery subzone denoted by str_filename. * @Param str_filename: name in the /pro/acpi/battery directory. * @Param ptr_chipfeature: pointer to chipfeature to get a max value. */ -void get_battery_max_value (char *str_filename, t_chipfeature *ptr_chipfeature); +void get_battery_max_value (gchar *str_filename, t_chipfeature *ptr_chipfeature); /** * Read information from the thermal zone. @@ -118,7 +118,7 @@ char * get_acpi_info (); * @Param str_filename: Complete path to file to be inspected. * @Return: String of value found, "<Unknown>" otherwise. */ -char * get_acpi_value (char *str_filename); +char * get_acpi_value (gchar *str_filename); /** @@ -126,7 +126,7 @@ char * get_acpi_value (char *str_filename); * @Param str_zone: Complete zone path including both e.g. "battery" and "BAT0" * @Return double value of current battery power */ -gdouble get_battery_zone_value (char *str_zone); +gdouble get_battery_zone_value (gchar *str_zone); /** diff --git a/include/configuration.h b/include/configuration.h index 239b704..8eeadc0 100644 --- a/include/configuration.h +++ b/include/configuration.h @@ -1,7 +1,7 @@ /* $Id$ */ /* File configuration.h * - * Copyright 2004-2010 Fabian Nowak ([email protected]) + * Copyright 2004-2017 Fabian Nowak ([email protected]) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,38 +32,38 @@ /** * Gets the internally used chipfeature index for the given parameters. * @Param chipnumber: number of the chip to search for - * @Param addr: address of the chipfeature - * @Param sensors: pointer to sensors structure + * @Param addr_chipfeature: address of the chipfeature + * @Param ptr_sensors: pointer to sensors structure * @Return: -1 on error; else chipfeature index for the parameters */ -gint get_Id_from_address (gint chipnumber, gint addr, t_sensors *sensors); +gint get_Id_from_address (gint chipnumber, gint addr_chipfeature, t_sensors *ptr_sensors); /** - * . - * @Param : - * @Param : + * Write the configuration, e.g., when exiting the plugin. + * @Param ptr_sensors: pointer to sensors structure */ -void sensors_write_config (XfcePanelPlugin *plugin, t_sensors *sensors); +void sensors_write_config (t_sensors *ptr_sensors); /** - * . - * @Param : - * @Param : + * Read the general settings stuff. + * @Param ptr_xfcerc: pointer to xfce settings resource + * @Param ptr_sensors: pointer to sensors structure */ -void sensors_read_general_config (XfceRc *rc, t_sensors *sensors); +void sensors_read_general_config (XfceRc *ptr_xfcerc, t_sensors *ptr_sensors); /** - * . - * @Param : - * @Param : + * Read the configuration file at init: + * Open the resource file and read down to the per-feature settings. + * @Param ptr_panelplugin: pointer to panel plugin structure + * @Param ptr_sensors: pointer to sensors structure */ -void sensors_read_config (XfcePanelPlugin *plugin, t_sensors *sensors); +void sensors_read_config (XfcePanelPlugin *ptr_panelplugin, t_sensors *ptr_sensors); /** - * . - * @Param : - * @Param : + * Read the preliminary config, i.e, "suppress hdd tooltips". + * @Param ptr_panelplugin: pointer to panel plugin structure + * @Param ptr_sensors: pointer to sensors structure */ -void sensors_read_preliminary_config (XfcePanelPlugin *plugin, t_sensors *sensors); +void sensors_read_preliminary_config (XfcePanelPlugin *ptr_panelplugin, t_sensors *ptr_sensors); #endif /* define XFCE4_SENSORS_CONFIGURATION_H */ diff --git a/include/hddtemp.h b/include/hddtemp.h index ed5817d..ab1b4b4 100644 --- a/include/hddtemp.h +++ b/include/hddtemp.h @@ -40,7 +40,7 @@ int initialize_hddtemp (GPtrArray *chips, gboolean *suppressmessage); /** * Refreshs a hddtemp chip's feature in sense of raw and formatted value - + * * @Param chip_feature: Pointer to feature * @Param data: Pointer to t_sensors or NULL */ diff --git a/lib/acpi.c b/lib/acpi.c index cc7d7f7..24227c3 100644 --- a/lib/acpi.c +++ b/lib/acpi.c @@ -1,5 +1,5 @@ /* $Id$ */ -/* Copyright 2004-2010 Fabian Nowak ([email protected]) +/* Copyright 2004-2017 Fabian Nowak ([email protected]) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,45 +37,44 @@ #include <unistd.h> -static char * -strip_key_colon_spaces (char *buf) +static gchar * +strip_key_colon_spaces (gchar *ptr_string) { - char *p; - p = buf; + gchar *ptr_position = ptr_string; /* Skip everything before the ':' */ - if (strchr(buf, ':')) + if (strchr(ptr_string, ':')) { - while (*(p++)) { - if (*p == ':') { + while (*(ptr_position++)) { + if (*ptr_position == ':') { break; } } - p++; + ptr_position++; } /* Skip all the spaces */ - while (*p) { - if (*p != ' ') { + while (*ptr_position) { + if (*ptr_position != ' ') { break; } - p++; + ptr_position++; } - return p; + return ptr_position; } #ifdef HAVE_SYSFS_ACPI static void -cut_newline (char *buf) +cut_newline (gchar *ptr_string) { - int i; + gint index; - for (i=0; buf[i]!='\0'; i++) + for (index=0; ptr_string[index]!='\0'; index++) { - if (buf[i]=='\n') + if (ptr_string[index]=='\n') { - buf[i] = '\0'; + ptr_string[index] = '\0'; break; } } @@ -86,15 +85,16 @@ cut_newline (char *buf) gint read_thermal_zone (t_chip *ptr_chip) { - DIR *d; - FILE *file; - char *filename; - struct dirent *de; - t_chipfeature *chipfeature; + gint res_value = -2; + DIR *ptr_directory; + FILE *ptr_file; + gchar *str_filename; + struct dirent *ptr_dirent; + t_chipfeature *ptr_chipfeature; #ifdef HAVE_SYSFS_ACPI - char buf[1024]; + gchar buffer[1024]; #else - char *zone; + gchar *str_zone; #endif TRACE ("enters read_thermal_zone"); @@ -105,187 +105,185 @@ read_thermal_zone (t_chip *ptr_chip) if ((chdir (ACPI_PATH) == 0) && (chdir (ACPI_DIR_THERMAL) == 0)) #endif { - d = opendir ("."); - if (!d) { - closedir (d); - return -1; + ptr_directory = opendir ("."); + if (!ptr_directory) { + closedir (ptr_directory); + res_value = -1; } - - while ((de = readdir (d))) + else { - if (strncmp(de->d_name, ".", 1)==0) - continue; - -#ifdef HAVE_SYSFS_ACPI - filename = g_strdup_printf ("/sys/class/thermal/%s/temp", de->d_name); -#else - filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, - ACPI_DIR_THERMAL, de->d_name, - ACPI_FILE_THERMAL); -#endif - file = fopen (filename, "r"); - if (file) + while ((ptr_dirent = readdir (ptr_directory))) { - DBG("parsing temperature file \"%s\"...\n", filename); - /* if (acpi_ignore_directory_entry (de)) - continue; */ - - chipfeature = g_new0 (t_chipfeature, 1); - - chipfeature->color = g_strdup("#0000B0"); - chipfeature->address = ptr_chip->chip_features->len; - chipfeature->devicename = g_strdup (de->d_name); - chipfeature->name = g_strdup (chipfeature->devicename); - chipfeature->formatted_value = NULL; /* Gonna refresh it in - sensors_get_wrapper or some - other functions */ - -#ifdef HAVE_SYSFS_ACPI - if (fgets (buf, 1024, file)!=NULL) + if (strncmp(ptr_dirent->d_name, ".", 1)==0) + continue; + + #ifdef HAVE_SYSFS_ACPI + str_filename = g_strdup_printf ("/sys/class/thermal/%s/temp", ptr_dirent->d_name); + #else + str_filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, + ACPI_DIR_THERMAL, ptr_dirent->d_name, + ACPI_FILE_THERMAL); + #endif + ptr_file = fopen (str_filename, "r"); + if (ptr_file) { - cut_newline (buf); - chipfeature->raw_value = strtod (buf, NULL) / 1000.0; - DBG ("Raw-Value=%f\n", chipfeature->raw_value); - } -#else - zone = g_strdup_printf ("%s/%s", ACPI_DIR_THERMAL, de->d_name); - chipfeature->raw_value = get_acpi_zone_value (zone, ACPI_FILE_THERMAL); - g_free (zone); -#endif + DBG("parsing temperature file \"%s\"...\n", str_filename); + /* if (acpi_ignore_directory_entry (ptr_dirent)) + continue; */ + + ptr_chipfeature = g_new0 (t_chipfeature, 1); + + ptr_chipfeature->color = g_strdup("#0000B0"); + ptr_chipfeature->address = ptr_chip->chip_features->len; + ptr_chipfeature->devicename = g_strdup (ptr_dirent->d_name); + ptr_chipfeature->name = g_strdup (ptr_chipfeature->devicename); + ptr_chipfeature->formatted_value = NULL; /* Gonna refresh it in + sensors_get_wrapper or some + other functions */ + + #ifdef HAVE_SYSFS_ACPI + if (fgets (buffer, 1024, ptr_file)!=NULL) + { + cut_newline (buffer); + ptr_chipfeature->raw_value = strtod (buffer, NULL) / 1000.0; + DBG ("Raw-Value=%f\n", ptr_chipfeature->raw_value); + } + #else + str_zone = g_strdup_printf ("%s/%s", ACPI_DIR_THERMAL, ptr_dirent->d_name); + ptr_chipfeature->raw_value = get_acpi_zone_value (str_zone, ACPI_FILE_THERMAL); + g_free (str_zone); + #endif - chipfeature->valid = TRUE; - chipfeature->min_value = 20.0; - chipfeature->max_value = 60.0; - chipfeature->class = TEMPERATURE; + ptr_chipfeature->valid = TRUE; + ptr_chipfeature->min_value = 20.0; + ptr_chipfeature->max_value = 60.0; + ptr_chipfeature->class = TEMPERATURE; - g_ptr_array_add (ptr_chip->chip_features, chipfeature); + g_ptr_array_add (ptr_chip->chip_features, ptr_chipfeature); - ptr_chip->num_features++; /* FIXME: actually I am just the same as - chip->chip_features->len */ + ptr_chip->num_features++; /* FIXME: actually I am just the same as + chip->chip_features->len */ - fclose(file); - } - //else - //printf ("not parsing temperature file...\n"); + fclose(ptr_file); + } - g_free (filename); - } + g_free (str_filename); + } /* while */ - closedir (d); - TRACE ("leaves read_thermal_zone"); + closedir (ptr_directory); + TRACE ("leaves read_thermal_zone"); - return 0; + res_value = 0; + } /* if */ } else { TRACE ("leaves read_thermal_zone"); - return -2; } + + return res_value; } gdouble -get_fan_zone_value (char *str_zonename) +get_fan_zone_value (gchar *str_zonename) { - gdouble value; + gdouble res_value = 0.0; - FILE *file; - char buf [1024], *filename, *tmp; + FILE *ptr_file; + gchar buffer [1024], *str_filename, *ptr_strippedbuffer; TRACE ("enters get_fan_zone_value for %s", str_zonename); - value = 0.0; - - filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, ACPI_DIR_FAN, + str_filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, ACPI_DIR_FAN, str_zonename, ACPI_FILE_FAN); - DBG("filename=%s", filename); - file = fopen (filename, "r"); - if (file) { - while (fgets (buf, 1024, file)!=NULL) + DBG("filename=%s", str_filename); + ptr_file = fopen (str_filename, "r"); + if (ptr_file) { + while (fgets (buffer, 1024, ptr_file)!=NULL) { - if (strncmp (buf, "status:", 7)==0) + if (strncmp (buffer, "status:", 7)==0) { - tmp = strip_key_colon_spaces(buf); - DBG ("tmp=%s", tmp); - if (strncmp (tmp, "on", 2)==0) - value = 1.0; + ptr_strippedbuffer = strip_key_colon_spaces(buffer); + DBG ("tmp=%s", ptr_strippedbuffer); + if (strncmp (ptr_strippedbuffer, "on", 2)==0) + res_value = 1.0; else - value = 0.0; + res_value = 0.0; break; } } - fclose (file); + fclose (ptr_file); } - g_free (filename); + g_free (str_filename); - return value; + return res_value; } gdouble -get_battery_zone_value (char *str_zone) +get_battery_zone_value (gchar *str_zone) { - double value; + gdouble res_value = 0.0; - FILE *file; - char buf [1024], *filename; + FILE *ptr_file; + gchar buffer [1024], *str_filename; #ifndef HAVE_SYSFS_ACPI - char *tmp; + gchar *ptr_strippedbuffer; #endif TRACE ("enters get_battery_zone_value for %s", str_zone); - value = 0.0; - #ifdef HAVE_SYSFS_ACPI - filename = g_strdup_printf ("/sys/class/power_supply/%s/energy_now", str_zone); + str_filename = g_strdup_printf ("/sys/class/power_supply/%s/energy_now", str_zone); #else - filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, ACPI_DIR_BATTERY, + str_filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, ACPI_DIR_BATTERY, str_zone, ACPI_FILE_BATTERY_STATE); #endif - DBG("filename=%s\n", filename); - file = fopen (filename, "r"); - if (file) { + DBG("str_filename=%s\n", str_filename); + ptr_file = fopen (str_filename, "r"); + if (ptr_file) { #ifdef HAVE_SYSFS_ACPI - if (fgets (buf, 1024, file)!=NULL) + if (fgets (buffer, 1024, ptr_file)!=NULL) { - cut_newline (buf); - value = strtod (buf, NULL) / 1000.0; + cut_newline (buffer); + res_value = strtod (buffer, NULL) / 1000.0; } #else - while (fgets (buf, 1024, file)!=NULL) + while (fgets (buffer, 1024, ptr_file)!=NULL) { - if (strncmp (buf, "remaining capacity:", 19)==0) + if (strncmp (buffer, "remaining capacity:", 19)==0) { - tmp = strip_key_colon_spaces(buf); - value = strtod (tmp, NULL); + ptr_strippedbuffer = strip_key_colon_spaces(buffer); + res_value = strtod (ptr_strippedbuffer, NULL); break; } } #endif - fclose (file); + fclose (ptr_file); } - g_free (filename); + g_free (str_filename); - return value; + return res_value; } gint read_battery_zone (t_chip *ptr_chip) { - DIR *d; - FILE *file; - char *filename; + gint res_value = -1; + DIR *ptr_dir; + FILE *ptr_file; + gchar *str_filename; #ifndef HAVE_SYSFS_ACPI - char *tmp; + gchar *ptr_strippedbuffer; #endif - char buf[1024]; - struct dirent *de; - t_chipfeature *chipfeature = NULL; + gchar buffer[1024]; + struct dirent *ptr_dirent; + t_chipfeature *ptr_chipfeature = NULL; TRACE ("enters read_battery_zone"); @@ -294,169 +292,167 @@ read_battery_zone (t_chip *ptr_chip) #else if ((chdir (ACPI_PATH) == 0) && (chdir (ACPI_DIR_BATTERY) == 0)) { #endif - d = opendir ("."); - if (!d) { - closedir (d); - return -1; - } + ptr_dir = opendir ("."); - while ((de = readdir (d))) + while (ptr_dir && (ptr_dirent = readdir (ptr_dir))) { - if (strncmp(de->d_name, "BAT", 3)==0) + if (strncmp(ptr_dirent->d_name, "BAT", 3)==0) { /* have a battery subdirectory */ #ifdef HAVE_SYSFS_ACPI - filename = g_strdup_printf ("/sys/class/power_supply/%s/model_name", de->d_name); + str_filename = g_strdup_printf ("/sys/class/power_supply/%s/model_name", ptr_dirent->d_name); #else - filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, - ACPI_DIR_BATTERY, de->d_name, + str_filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, + ACPI_DIR_BATTERY, ptr_dirent->d_name, ACPI_FILE_BATTERY_STATE); #endif - DBG ("filename=%s\n", filename); - file = fopen (filename, "r"); - chipfeature = g_new0 (t_chipfeature, 1); - if (file) { - chipfeature->address = ptr_chip->chip_features->len; - chipfeature->devicename = g_strdup (de->d_name); + DBG ("str_filename=%s\n", str_filename); + ptr_file = fopen (str_filename, "r"); + ptr_chipfeature = g_new0 (t_chipfeature, 1); + if (ptr_file) { + ptr_chipfeature->address = ptr_chip->chip_features->len; + ptr_chipfeature->devicename = g_strdup (ptr_dirent->d_name); #ifdef HAVE_SYSFS_ACPI - if (fgets (buf, 1024, file)!=NULL) + if (fgets (buffer, 1024, ptr_file)!=NULL) { - cut_newline (buf); - chipfeature->name = g_strdup (buf); - DBG ("Name=%s\n", buf); + cut_newline (buffer); + ptr_chipfeature->name = g_strdup (buffer); + DBG ("Name=%s\n", buffer); } #else - chipfeature->name = g_strdup (chipfeature->devicename); + ptr_chipfeature->name = g_strdup (ptr_chipfeature->devicename); #endif - chipfeature->valid = TRUE; - chipfeature->min_value = 0.0; - chipfeature->raw_value = 0.0; - chipfeature->class = ENERGY; - chipfeature->formatted_value = NULL; - chipfeature->color = g_strdup("#0000B0"); + ptr_chipfeature->valid = TRUE; + ptr_chipfeature->min_value = 0.0; + ptr_chipfeature->raw_value = 0.0; + ptr_chipfeature->class = ENERGY; + ptr_chipfeature->formatted_value = NULL; + ptr_chipfeature->color = g_strdup("#0000B0"); #ifdef HAVE_SYSFS_ACPI - fclose (file); + fclose (ptr_file); } - g_free (filename); - filename = g_strdup_printf ("/sys/class/power_supply/%s/energy_now", de->d_name); - file = fopen (filename, "r"); - if (file) { + g_free (str_filename); + str_filename = g_strdup_printf ("/sys/class/power_supply/%s/energy_now", ptr_dirent->d_name); + ptr_file = fopen (str_filename, "r"); + if (ptr_file) { - if (fgets (buf, 1024, file)!=NULL) + if (fgets (buffer, 1024, ptr_file)!=NULL) { - cut_newline (buf); - chipfeature->raw_value = strtod (buf, NULL); - DBG ("Raw-Value=%f\n", chipfeature->raw_value); + cut_newline (buffer); + ptr_chipfeature->raw_value = strtod (buffer, NULL); + DBG ("Raw-Value=%f\n", ptr_chipfeature->raw_value); } - fclose (file); + fclose (ptr_file); } - g_free (filename); - filename = g_strdup_printf ("/sys/class/power_supply/%s/alarm", de->d_name); - file = fopen (filename, "r"); - if (file) { - if (fgets (buf, 1024, file)!=NULL) + g_free (str_filename); + str_filename = g_strdup_printf ("/sys/class/power_supply/%s/alarm", ptr_dirent->d_name); + ptr_file = fopen (str_filename, "r"); + if (ptr_file) { + if (fgets (buffer, 1024, ptr_file)!=NULL) { - cut_newline (buf); - chipfeature->min_value = strtod (buf, NULL) / 1000.0; - DBG ("Min-Value=%f\n", chipfeature->min_value); + cut_newline (buffer); + ptr_chipfeature->min_value = strtod (buffer, NULL) / 1000.0; + DBG ("Min-Value=%f\n", ptr_chipfeature->min_value); } #else - while (fgets (buf, 1024, file)!=NULL) + while (fgets (buffer, 1024, ptr_file)!=NULL) { - if (strncmp (buf, "design capacity low:", 20)==0) + if (strncmp (buffer, "design capacity low:", 20)==0) { - tmp = strip_key_colon_spaces(buf); - chipfeature->min_value = strtod (tmp, NULL); + ptr_strippedbuffer = strip_key_colon_spaces(buffer); + ptr_chipfeature->min_value = strtod (ptr_strippedbuffer, NULL); } - else if (strncmp (buf, "remaining capacity:", 19)==0) + else if (strncmp (buffer, "remaining capacity:", 19)==0) { - tmp = strip_key_colon_spaces(buf); - chipfeature->raw_value = strtod (tmp, NULL); + ptr_strippedbuffer = strip_key_colon_spaces(buffer); + ptr_chipfeature->raw_value = strtod (ptr_strippedbuffer, NULL); } } #endif - fclose (file); + fclose (ptr_file); - g_ptr_array_add (ptr_chip->chip_features, chipfeature); + g_ptr_array_add (ptr_chip->chip_features, ptr_chipfeature); ptr_chip->num_features++; /* FIXME: actually I am just the same as chip->chip_features->len */ } else { - g_free (filename); + g_free (str_filename); continue; /* what would we want to do with only a maxval and no real value inside? */ } - g_free (filename); + g_free (str_filename); - get_battery_max_value (de->d_name, chipfeature); + get_battery_max_value (ptr_dirent->d_name, ptr_chipfeature); } + res_value = 0; } - closedir (d); - TRACE ("leaves read_battery_zone"); - - return 0; + if (ptr_dir) + closedir (ptr_dir); + TRACE ("leaves read_battery_zone"); } else { TRACE ("leaves read_battery_zone"); - return -2; + res_value = -2; } + + return res_value; } void -get_battery_max_value (char *str_filename, t_chipfeature *ptr_chipfeature) +get_battery_max_value (gchar *str_filename, t_chipfeature *ptr_chipfeature) { - FILE *file; - char *filename, buf[1024]; + FILE *ptr_file; + gchar *str_pathtofile, buffer[1024]; #ifndef HAVE_SYSFS_ACPI - char *tmp; + gchar *ptr_strippedbuffer; #endif TRACE ("enters get_battery_max_value"); #ifdef HAVE_SYSFS_ACPI - filename = g_strdup_printf ("/sys/class/power_supply/%s/energy_full", str_filename); + str_pathtofile = g_strdup_printf ("/sys/class/power_supply/%s/energy_full", str_filename); #else - filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, + str_pathtofile = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, ACPI_DIR_BATTERY, str_filename, ACPI_FILE_BATTERY_INFO); #endif - DBG ("filename=%s\n", filename); - file = fopen (filename, "r"); - if (file) + DBG ("str_pathtofile=%s\n", str_pathtofile); + ptr_file = fopen (str_pathtofile, "r"); + if (ptr_file) { #ifdef HAVE_SYSFS_ACPI - if (fgets (buf, 1024, file)!=NULL) + if (fgets (buffer, 1024, ptr_file)!=NULL) { - cut_newline (buf); - ptr_chipfeature->max_value = strtod (buf, NULL) / 1000.0; + cut_newline (buffer); + ptr_chipfeature->max_value = strtod (buffer, NULL) / 1000.0; DBG ("Max-Value=%f\n", ptr_chipfeature->max_value); } #else - while (fgets (buf, 1024, file)!=NULL) + while (fgets (buffer, 1024, ptr_file)!=NULL) { - if (strncmp (buf, "last full capacity:", 19)==0) + if (strncmp (buffer, "last full capacity:", 19)==0) { - tmp = strip_key_colon_spaces(buf); - ptr_chipfeature->max_value = strtod (tmp, NULL); + ptr_strippedbuffer = strip_key_colon_spaces(buffer); + ptr_chipfeature->max_value = strtod (ptr_strippedbuffer, NULL); break; } } #endif - fclose (file); + fclose (ptr_file); } - g_free (filename); + g_free (str_pathtofile); TRACE ("leaves get_battery_max_value"); } @@ -465,109 +461,106 @@ get_battery_max_value (char *str_filename, t_chipfeature *ptr_chipfeature) gint read_fan_zone (t_chip *ptr_chip) { - DIR *d; - FILE *file; - char *filename; - struct dirent *de; - t_chipfeature *chipfeature; + gint res_value = -1; + DIR *ptr_dir; + FILE *ptr_file; + gchar *str_filename; + struct dirent *ptr_dirent; + t_chipfeature *ptr_chipfeature; TRACE ("enters read_fan_zone"); if ((chdir (ACPI_PATH) == 0) && (chdir (ACPI_DIR_FAN) == 0)) { - d = opendir ("."); - if (!d) { - closedir (d); - return -1; - } + ptr_dir = opendir ("."); - while ((de = readdir (d))) + while (ptr_dir && (ptr_dirent = readdir (ptr_dir))) { - if (strncmp(de->d_name, ".", 1)==0) + if (strncmp(ptr_dirent->d_name, ".", 1)==0) continue; - filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, - ACPI_DIR_FAN, de->d_name, + str_filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, + ACPI_DIR_FAN, ptr_dirent->d_name, ACPI_FILE_FAN); - file = fopen (filename, "r"); - if (file) + ptr_file = fopen (str_filename, "r"); + if (ptr_file) { /* if (acpi_ignore_directory_entry (de)) continue; */ - chipfeature = g_new0 (t_chipfeature, 1); + ptr_chipfeature = g_new0 (t_chipfeature, 1); - chipfeature->color = g_strdup("#0000B0"); - chipfeature->address = ptr_chip->chip_features->len; - chipfeature->devicename = g_strdup (de->d_name); - chipfeature->name = g_strdup (chipfeature->devicename); - chipfeature->formatted_value = NULL; /* Gonna refresh it in + ptr_chipfeature->color = g_strdup("#0000B0"); + ptr_chipfeature->address = ptr_chip->chip_features->len; + ptr_chipfeature->devicename = g_strdup (ptr_dirent->d_name); + ptr_chipfeature->name = g_strdup (ptr_chipfeature->devicename); + ptr_chipfeature->formatted_value = NULL; /* Gonna refresh it in sensors_get_wrapper or some other functions */ - chipfeature->raw_value = get_fan_zone_value (de->d_name); + ptr_chipfeature->raw_value = get_fan_zone_value (ptr_dirent->d_name); - chipfeature->valid = TRUE; - chipfeature->min_value = 0.0; - chipfeature->max_value = 2.0; - chipfeature->class = STATE; + ptr_chipfeature->valid = TRUE; + ptr_chipfeature->min_value = 0.0; + ptr_chipfeature->max_value = 2.0; + ptr_chipfeature->class = STATE; - g_ptr_array_add (ptr_chip->chip_features, chipfeature); + g_ptr_array_add (ptr_chip->chip_features, ptr_chipfeature); ptr_chip->num_features++; /* FIXME: actually I am just the same as chip->chip_features->len */ - fclose(file); + fclose(ptr_file); } - g_free (filename); + g_free (str_filename); + res_value = 0; } - closedir (d); - TRACE ("leaves read_fan_zone"); + if (ptr_dir) + closedir (ptr_dir); - return 0; + TRACE ("leaves read_fan_zone"); } else { TRACE ("leaves read_fan_zone"); - return -2; + res_value = -2; } - return -7; + return res_value; } gint initialize_ACPI (GPtrArray *arr_ptr_chips) { - t_chip *chip; + t_chip *ptr_chip; sensors_chip_name *ptr_chipname_tmp; - gchar *ptr_str_acpi_info; + gchar *str_acpi_info; TRACE ("enters initialize_ACPI"); - chip = g_new0 (t_chip, 1); - chip->name = g_strdup(_("ACPI")); /* to be displayed */ - /* chip->description = g_strdup(_("Advanced Configuration and Power Interface")); */ - ptr_str_acpi_info = get_acpi_info(); - chip->description = g_strdup_printf (_("ACPI v%s zones"), ptr_str_acpi_info); - g_free(ptr_str_acpi_info); - chip->sensorId = g_strdup ("ACPI"); /* used internally */ + ptr_chip = g_new0 (t_chip, 1); + ptr_chip->name = g_strdup(_("ACPI")); /* to be displayed */ + str_acpi_info = get_acpi_info(); + ptr_chip->description = g_strdup_printf (_("ACPI v%s zones"), str_acpi_info); + g_free(str_acpi_info); + ptr_chip->sensorId = g_strdup ("ACPI"); /* used internally */ - chip->type = ACPI; + ptr_chip->type = ACPI; ptr_chipname_tmp = g_new0 (sensors_chip_name, 1); ptr_chipname_tmp->prefix = g_strdup(_("ACPI")); ptr_chipname_tmp->path = g_strdup(_("ACPI")); - chip->chip_name = (sensors_chip_name *) ptr_chipname_tmp; + ptr_chip->chip_name = (sensors_chip_name *) ptr_chipname_tmp; - chip->chip_features = g_ptr_array_new (); + ptr_chip->chip_features = g_ptr_array_new (); - chip->num_features = 0; + ptr_chip->num_features = 0; - read_battery_zone (chip); - read_thermal_zone (chip); - read_fan_zone (chip); + read_battery_zone (ptr_chip); + read_thermal_zone (ptr_chip); + read_fan_zone (ptr_chip); - g_ptr_array_add (arr_ptr_chips, chip); + g_ptr_array_add (arr_ptr_chips, ptr_chip); TRACE ("leaves initialize_ACPI"); @@ -578,12 +571,12 @@ initialize_ACPI (GPtrArray *arr_ptr_chips) void refresh_acpi (gpointer ptr_chipfeature, gpointer ptr_unused) { - char *file, *zone, *state; + gchar *str_filename, *str_zone, *str_state; t_chipfeature *cf; #ifdef HAVE_SYSFS_ACPI - FILE *f = NULL; - char buf[1024]; + FILE *ptr_file = NULL; + gchar buffer[1024]; #endif TRACE ("enters refresh_acpi"); @@ -595,22 +588,22 @@ refresh_acpi (gpointer ptr_chipfeature, gpointer ptr_unused) switch (cf->class) { case TEMPERATURE: #ifdef HAVE_SYSFS_ACPI - zone = g_strdup_printf ("/sys/class/thermal_zone/%s/temp", cf->devicename); - f = fopen(zone, "r"); - if (f != NULL) + str_zone = g_strdup_printf ("/sys/class/thermal_zone/%s/temp", cf->devicename); + ptr_file = fopen(str_zone, "r"); + if (ptr_file) { - if (fgets (buf, 1024, f)) + if (fgets (buffer, 1024, ptr_file)) { - cut_newline(buf); - cf->raw_value = strtod(buf, NULL) / 1000.0; + cut_newline(buffer); + cf->raw_value = strtod(buffer, NULL) / 1000.0; } - fclose (f); + fclose (ptr_file); } #else - zone = g_strdup_printf ("%s/%s", ACPI_DIR_THERMAL, cf->devicename); - cf->raw_value = get_acpi_zone_value (zone, ACPI_FILE_THERMAL); + str_zone = g_strdup_printf ("%s/%s", ACPI_DIR_THERMAL, cf->devicename); + cf->raw_value = get_acpi_zone_value (str_zone, ACPI_FILE_THERMAL); #endif - g_free (zone); + g_free (str_zone); /* g_free (cf->formatted_value); cf->formatted_value = g_strdup_printf (_("%+5.1f °C"), cf->raw_value); */ break; @@ -624,20 +617,20 @@ refresh_acpi (gpointer ptr_chipfeature, gpointer ptr_unused) break; case STATE: - file = g_strdup_printf ("%s/%s/%s/state", ACPI_PATH, ACPI_DIR_FAN, cf->devicename); + str_filename = g_strdup_printf ("%s/%s/%s/state", ACPI_PATH, ACPI_DIR_FAN, cf->devicename); - state = get_acpi_value(file); // return value is strdup'ped - if (state==NULL) + str_state = get_acpi_value(str_filename); // return value is strdup'ped + if (!str_state) { DBG("Could not determine fan state."); cf->raw_value = 0.0; } else { - cf->raw_value = strncmp(state, "on", 2)==0 ? 1.0 : 0.0; - g_free (state); + cf->raw_value = strncmp(str_state, "on", 2)==0 ? 1.0 : 0.0; + g_free (str_state); } - g_free (file); + g_free (str_filename); /* g_free (cf->formatted_value); cf->formatted_value = g_strdup_printf (_("%.0f"), cf->raw_value); */ @@ -665,46 +658,36 @@ acpi_ignore_directory_entry (struct dirent *ptr_dirent) * Obtains ACPI version information. * Might forget some space or tab bytes due to g_strchomp **/ -char * +gchar * get_acpi_info (void) { - char *filename, *version; + gchar *str_filename, *str_version; TRACE ("enters get_acpi_info"); - filename = g_strdup_printf ("%s/%s", ACPI_PATH, ACPI_INFO); - version = get_acpi_value (filename); - g_free (filename); + str_filename = g_strdup_printf ("%s/%s", ACPI_PATH, ACPI_INFO); + str_version = get_acpi_value (str_filename); + g_free (str_filename); - if (version!=NULL) - { - version = g_strchomp (version); - } - else // if (version==NULL) + if (!str_version) { - filename = g_strdup_printf ("%s/%s_", ACPI_PATH, ACPI_INFO); - version = get_acpi_value (filename); - g_free (filename); + str_filename = g_strdup_printf ("%s/%s_", ACPI_PATH, ACPI_INFO); + str_version = get_acpi_value (str_filename); + g_free (str_filename); - if (version!=NULL) - version = g_strchomp (version); - - else //if (version==NULL) - - { - version = get_acpi_value ("/sys/module/acpi/parameters/acpica_version"); - if (version!=NULL) - version = g_strchomp (version); - } + if (!str_version) + str_version = get_acpi_value ("/sys/module/acpi/parameters/acpica_str_version"); } - /* who knows, if we obtain non-NULL version at all... */ - if (version==NULL) - version = g_strdup(_("<Unknown>")); + /* who knows, if we obtain non-NULL str_version at all... */ + if (str_version) + str_version = g_strchomp (str_version); + else + str_version = g_strdup(_("<Unknown>")); TRACE ("leaves get_acpi_info"); - return version; + return str_version; } @@ -712,24 +695,27 @@ get_acpi_info (void) * thermal_zone and THRM. */ gdouble -get_acpi_zone_value (char *str_zone, char *str_filename) +get_acpi_zone_value (gchar *str_zone, gchar *str_filename) { - char *filename, *value; - double retval; + gchar *str_localfilename, *str_value; + gdouble res_value = 0.0; TRACE ("enters get_acpi_zone_value for %s/%s", str_zone, str_filename); - filename = g_strdup_printf ("%s/%s/%s", ACPI_PATH, str_zone, str_filename); - value = get_acpi_value (filename); - g_free(filename); + str_localfilename = g_strdup_printf ("%s/%s/%s", ACPI_PATH, str_zone, str_filename); + str_value = get_acpi_value (str_localfilename); + g_free(str_localfilename); TRACE ("leaves get_acpi_zone_value with correctly converted value"); /* Return it as a double */ - retval = strtod (value, NULL); - g_free (value); + if (str_value) + { + res_value = strtod (str_value, NULL); + g_free (str_value); + } - return retval; + return res_value; } @@ -738,27 +724,29 @@ get_acpi_zone_value (char *str_zone, char *str_filename) * @param str_filename An absolute filename, most likely starting with /proc/acpi... * @return value found inside as a character */ -char * -get_acpi_value (char *str_filename) +gchar * +get_acpi_value (gchar *str_filename) { - FILE *file; - char buf [1024], *p; + FILE *ptr_file; + gchar buffer [1024], *ptr_valueinstring, *str_result = NULL; TRACE ("enters get_acpi_value for %s", str_filename); - file = fopen (str_filename, "r"); - if (!file) - return NULL; + ptr_file = fopen (str_filename, "r"); + if (ptr_file) + { + fgets (buffer, 1024, ptr_file); + fclose (ptr_file); - fgets (buf, 1024, file); - fclose (file); + ptr_valueinstring = strip_key_colon_spaces (buffer); - p = strip_key_colon_spaces (buf); + TRACE ("leaves get_acpi_value with %s", ptr_valueinstring); - TRACE ("leaves get_acpi_value with %s", p); + str_result = g_strdup (ptr_valueinstring); + } /* Have read the data */ - return g_strdup (p); + return str_result; } diff --git a/lib/configuration.c b/lib/configuration.c index e5e76d2..93c9ed6 100644 --- a/lib/configuration.c +++ b/lib/configuration.c @@ -1,7 +1,7 @@ /* $Id$ */ /* File configuration.c * - * Copyright 2004-2010 Fabian Nowak ([email protected]) + * Copyright 2004-2017 Fabian Nowak ([email protected]) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,159 +40,164 @@ gint -get_Id_from_address (gint chipnumber, gint addr, t_sensors *sensors) +get_Id_from_address (gint chipnumber, gint addr_chipfeature, t_sensors *ptr_sensors) { - gint feature; - t_chip *chip; - t_chipfeature *chipfeature; + gint idx_feature = -1; + t_chip *ptr_chip = NULL; + t_chipfeature *ptr_chipfeature = NULL; TRACE ("enters get_Id_from_address"); - chip = (t_chip *) g_ptr_array_index (sensors->chips, chipnumber); - - for (feature=0; feature<chip->num_features; feature++) { - chipfeature = g_ptr_array_index(chip->chip_features, feature); - if (addr == chipfeature->address) { - TRACE ("leaves get_Id_from_address with %d", feature); - return feature; + ptr_chip = (t_chip *) g_ptr_array_index (ptr_sensors->chips, chipnumber); + + if (ptr_chip) + { + for (idx_feature=0; idx_feature<ptr_chip->num_features; idx_feature++) { + ptr_chipfeature = g_ptr_array_index(ptr_chip->chip_features, idx_feature); + if (ptr_chipfeature) + { + if (addr_chipfeature == ptr_chipfeature->address) { + break; + } + } } } - TRACE ("leaves get_Id_from_address with -1"); - - return (gint) -1; + TRACE ("leaves get_Id_from_address with %d", idx_feature); + return idx_feature; } -/* Write the configuration at exit */ void -sensors_write_config (XfcePanelPlugin *plugin, t_sensors *sensors) +sensors_write_config (t_sensors *ptr_sensors) { - XfceRc *rc; - char *file, *tmp, rc_chip[8], feature[20]; - int i, j; + XfceRc *ptr_xfcerc; + gchar *str_file, *str_tmp, rc_chip[8], feature[20]; + gint i, j; t_chip *chip; t_chipfeature *chipfeature; TRACE ("enters sensors_write_config"); - if ( ! (file = sensors->plugin_config_file) ) { + if ( ! (str_file = ptr_sensors->plugin_config_file) ) { TRACE ("leaves sensors_write_config: No file location specified."); - return; } + else + { + unlink (str_file); - unlink (file); - - rc = xfce_rc_simple_open (file, FALSE); + ptr_xfcerc = xfce_rc_simple_open (str_file, FALSE); - if (!rc) { - TRACE ("leaves sensors_write_config: No rc file opened"); - return; - } - - xfce_rc_set_group (rc, "General"); + if (!ptr_xfcerc) { + TRACE ("leaves sensors_write_config: No rc file opened"); + } + else + { + xfce_rc_set_group (ptr_xfcerc, "General"); - xfce_rc_write_bool_entry (rc, "Show_Title", sensors->show_title); + xfce_rc_write_bool_entry (ptr_xfcerc, "Show_Title", ptr_sensors->show_title); - xfce_rc_write_bool_entry (rc, "Show_Labels", sensors->show_labels); + xfce_rc_write_bool_entry (ptr_xfcerc, "Show_Labels", ptr_sensors->show_labels); - xfce_rc_write_int_entry (rc, "Use_Bar_UI", sensors->display_values_type); + xfce_rc_write_int_entry (ptr_xfcerc, "Use_Bar_UI", ptr_sensors->display_values_type); - xfce_rc_write_bool_entry (rc, "Show_Colored_Bars", sensors->show_colored_bars); + xfce_rc_write_bool_entry (ptr_xfcerc, "Show_Colored_Bars", ptr_sensors->show_colored_bars); - xfce_rc_write_int_entry (rc, "Scale", sensors->scale); + xfce_rc_write_int_entry (ptr_xfcerc, "Scale", ptr_sensors->scale); - xfce_rc_write_entry (rc, "str_fontsize", sensors->str_fontsize); + xfce_rc_write_entry (ptr_xfcerc, "str_fontsize", ptr_sensors->str_fontsize); - xfce_rc_write_int_entry (rc, "val_fontsize", - sensors->val_fontsize); + xfce_rc_write_int_entry (ptr_xfcerc, "val_fontsize", + ptr_sensors->val_fontsize); - if (font!=NULL) - xfce_rc_write_entry (rc, "Font", font); // the font for the tachometers exported from tacho.h + if (font) + xfce_rc_write_entry (ptr_xfcerc, "Font", font); // the font for the tachometers exported from tacho.h - xfce_rc_write_int_entry (rc, "Lines_Size", sensors->lines_size); + xfce_rc_write_int_entry (ptr_xfcerc, "Lines_Size", ptr_sensors->lines_size); - xfce_rc_write_int_entry (rc, "Update_Interval", sensors->sensors_refresh_time); + xfce_rc_write_int_entry (ptr_xfcerc, "Update_Interval", ptr_sensors->sensors_refresh_time); - xfce_rc_write_bool_entry (rc, "Exec_Command", sensors->exec_command); + xfce_rc_write_bool_entry (ptr_xfcerc, "Exec_Command", ptr_sensors->exec_command); - xfce_rc_write_bool_entry (rc, "Show_Units", sensors->show_units); + xfce_rc_write_bool_entry (ptr_xfcerc, "Show_Units", ptr_sensors->show_units); - xfce_rc_write_bool_entry(rc, "Small_Spacings", sensors->show_smallspacings); + xfce_rc_write_bool_entry(ptr_xfcerc, "Small_Spacings", ptr_sensors->show_smallspacings); - xfce_rc_write_entry (rc, "Command_Name", sensors->command_name); + xfce_rc_write_entry (ptr_xfcerc, "Command_Name", ptr_sensors->command_name); - xfce_rc_write_int_entry (rc, "Number_Chips", sensors->num_sensorchips); + xfce_rc_write_int_entry (ptr_xfcerc, "Number_Chips", ptr_sensors->num_sensorchips); - xfce_rc_write_bool_entry (rc, "Suppress_Hddtemp_Message", sensors->suppressmessage); + xfce_rc_write_bool_entry (ptr_xfcerc, "Suppress_Hddtemp_Message", ptr_sensors->suppressmessage); - xfce_rc_write_bool_entry (rc, "Suppress_Tooltip", sensors->suppresstooltip); + xfce_rc_write_bool_entry (ptr_xfcerc, "Suppress_Tooltip", ptr_sensors->suppresstooltip); - xfce_rc_write_int_entry (rc, "Preferred_Width", sensors->preferred_width); - xfce_rc_write_int_entry (rc, "Preferred_Height", sensors->preferred_height); + xfce_rc_write_int_entry (ptr_xfcerc, "Preferred_Width", ptr_sensors->preferred_width); + xfce_rc_write_int_entry (ptr_xfcerc, "Preferred_Height", ptr_sensors->preferred_height); - for (i=0; i<sensors->num_sensorchips; i++) { + for (i=0; i<ptr_sensors->num_sensorchips; i++) { - chip = (t_chip *) g_ptr_array_index(sensors->chips, i); - g_assert (chip!=NULL); + chip = (t_chip *) g_ptr_array_index(ptr_sensors->chips, i); + g_assert (chip!=NULL); - g_snprintf (rc_chip, 8, "Chip%d", i); + g_snprintf (rc_chip, 8, "Chip%d", i); - xfce_rc_set_group (rc, rc_chip); + xfce_rc_set_group (ptr_xfcerc, rc_chip); - xfce_rc_write_entry (rc, "Name", chip->sensorId); + xfce_rc_write_entry (ptr_xfcerc, "Name", chip->sensorId); - /* number of sensors is still limited */ - xfce_rc_write_int_entry (rc, "Number", i); + /* number of sensors is still limited */ + xfce_rc_write_int_entry (ptr_xfcerc, "Number", i); - for (j=0; j<chip->num_features; j++) { - chipfeature = g_ptr_array_index(chip->chip_features, j); - g_assert (chipfeature!=NULL); + for (j=0; j<chip->num_features; j++) { + chipfeature = g_ptr_array_index(chip->chip_features, j); + g_assert (chipfeature!=NULL); - if (chipfeature->show == TRUE) { + if (chipfeature->show) { - g_snprintf (feature, 20, "%s_Feature%d", rc_chip, j); + g_snprintf (feature, 20, "%s_Feature%d", rc_chip, j); - xfce_rc_set_group (rc, feature); + xfce_rc_set_group (ptr_xfcerc, feature); - xfce_rc_write_int_entry (rc, "Id", get_Id_from_address(i, j, sensors)); + xfce_rc_write_int_entry (ptr_xfcerc, "Id", get_Id_from_address(i, j, ptr_sensors)); - /* only use this if no hddtemp sensor */ - /* or do only use this , if it is an lmsensors device. whatever. */ - if ( strcmp(chip->sensorId, _("Hard disks")) != 0 ) /* chip->name? */ - xfce_rc_write_int_entry (rc, "Address", j); - else - xfce_rc_write_entry (rc, "DeviceName", chipfeature->devicename); + /* only use this if no hddtemp sensor */ + /* or do only use this , if it is an lmsensors device. whatever. */ + if ( strcmp(chip->sensorId, _("Hard disks")) != 0 ) /* chip->name? */ + xfce_rc_write_int_entry (ptr_xfcerc, "Address", j); + else + xfce_rc_write_entry (ptr_xfcerc, "DeviceName", chipfeature->devicename); - xfce_rc_write_entry (rc, "Name", chipfeature->name); + xfce_rc_write_entry (ptr_xfcerc, "Name", chipfeature->name); - xfce_rc_write_entry (rc, "Color", chipfeature->color); + xfce_rc_write_entry (ptr_xfcerc, "Color", chipfeature->color); - xfce_rc_write_bool_entry (rc, "Show", chipfeature->show); + xfce_rc_write_bool_entry (ptr_xfcerc, "Show", chipfeature->show); - tmp = g_strdup_printf("%.2f", chipfeature->min_value); - xfce_rc_write_entry (rc, "Min", tmp); - g_free (tmp); + str_tmp = g_strdup_printf("%.2f", chipfeature->min_value); + xfce_rc_write_entry (ptr_xfcerc, "Min", str_tmp); + g_free (str_tmp); - tmp = g_strdup_printf("%.2f", chipfeature->max_value); - xfce_rc_write_entry (rc, "Max", tmp); - g_free (tmp); - } /* end if */ + str_tmp = g_strdup_printf("%.2f", chipfeature->max_value); + xfce_rc_write_entry (ptr_xfcerc, "Max", str_tmp); + g_free (str_tmp); + } /* end if */ - } /* end for j */ + } /* end for j */ - } /* end for i */ + } /* end for i */ - xfce_rc_close (rc); + xfce_rc_close (ptr_xfcerc); - TRACE ("leaves sensors_write_config"); + TRACE ("leaves sensors_write_config"); + } + } } void sensors_read_general_config (XfceRc *rc, t_sensors *sensors) { - const char *value; + const gchar *value; TRACE ("enters sensors_read_general_config"); @@ -259,7 +264,7 @@ sensors_read_general_config (XfceRc *rc, t_sensors *sensors) void sensors_read_preliminary_config (XfcePanelPlugin *plugin, t_sensors *sensors) { - char *file; + gchar *file; XfceRc *rc; TRACE ("enters sensors_read_preliminary_config"); @@ -285,18 +290,17 @@ sensors_read_preliminary_config (XfcePanelPlugin *plugin, t_sensors *sensors) } -/* Read the configuration file at init */ // TODO: modify to store chipname as indicator and access features by acpitz-1_Feature0 etc. // this will require differently storing the stuff as well. // targeted for 1.1 or 1.2 release void sensors_read_config (XfcePanelPlugin *plugin, t_sensors *sensors) { - const char *value; - char *file; + const gchar *value; + gchar *file; XfceRc *rc; - int i, j, k; - char rc_chip[8], feature[20]; + gint i, j, k; + gchar rc_chip[8], feature[20]; gchar* sensorName=NULL; gint num_sensorchip, id, address; t_chip *chip; diff --git a/panel-plugin/sensors-plugin.c b/panel-plugin/sensors-plugin.c index 553e69f..1be69cf 100644 --- a/panel-plugin/sensors-plugin.c +++ b/panel-plugin/sensors-plugin.c @@ -2301,7 +2301,7 @@ on_optionsDialog_response (GtkWidget *dlg, int response, t_sensors_dialog *sd) sd->sensors->plugin_config_file = xfce_panel_plugin_save_location (sd->sensors->plugin, TRUE); if (sd->sensors->plugin_config_file) - sensors_write_config (sd->sensors->plugin, sd->sensors); + sensors_write_config (sd->sensors); } gtk_window_get_size ( GTK_WINDOW(dlg), &(sd->sensors->preferred_width), &(sd->sensors->preferred_height)); gtk_widget_destroy (sd->dialog); -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list [email protected] https://mail.xfce.org/mailman/listinfo/xfce4-commits
