projects
/
psensor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
made sensor type translatable
[psensor.git]
/
src
/
lib
/
hdd_hddtemp.c
diff --git
a/src/lib/hdd_hddtemp.c
b/src/lib/hdd_hddtemp.c
index
5883fa5
..
3e692f0
100644
(file)
--- a/
src/lib/hdd_hddtemp.c
+++ b/
src/lib/hdd_hddtemp.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 2010-201
2
jeanfi@gmail.com
+ * Copyright (C) 2010-201
4
jeanfi@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@
-21,9
+21,9
@@
#define _(str) gettext(str)
/*
#define _(str) gettext(str)
/*
- Following code is based on GNOME sensors applet code hddtemp-plugin.c
- see http://sensors-applet.sourceforge.net/
-*/
+ * Following code is based on GNOME sensors applet code
+
* hddtemp-plugin.c
see http://sensors-applet.sourceforge.net/
+
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@
-56,7
+56,7
@@
static char *fetch()
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1) {
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1) {
-
fprintf(stderr, _("ERROR: hdd fetch, failed to open socket\n
"));
+
log_err(_("hddtemp: failed to open socket.
"));
return NULL;
}
return NULL;
}
@@
-69,8
+69,7
@@
static char *fetch()
if (connect(sockfd,
(struct sockaddr *)&address,
(socklen_t) sizeof(address)) == -1) {
if (connect(sockfd,
(struct sockaddr *)&address,
(socklen_t) sizeof(address)) == -1) {
- fprintf(stderr,
- _("ERROR: hdd fetch, failed to open connection\n"));
+ log_err(_("hddtemp: failed to open connection."));
} else {
buffer = malloc(HDDTEMP_OUTPUT_BUFFER_LENGTH);
} else {
buffer = malloc(HDDTEMP_OUTPUT_BUFFER_LENGTH);
@@
-116,7
+115,12
@@
static int str_index(char *str, char d)
static struct psensor *
create_sensor(char *id, char *name, int values_max_length)
{
static struct psensor *
create_sensor(char *id, char *name, int values_max_length)
{
- return psensor_create(id, name, SENSOR_TYPE_HDD_TEMP_HDDTEMP,
+ int t;
+
+ t = SENSOR_TYPE_HDD | SENSOR_TYPE_HDDTEMP | SENSOR_TYPE_TEMP;
+
+ return psensor_create(id, name, strdup(_("Disk")),
+ t,
values_max_length);
}
values_max_length);
}
@@
-167,8
+171,8
@@
static char *next_hdd_info(char *string, struct hdd_info *info)
return c;
}
return c;
}
-struct psensor **hdd_psensor_list_add(struct psensor **sensors,
- int values_max_length)
+struct psensor **hdd
temp
_psensor_list_add(struct psensor **sensors,
+
int values_max_length)
{
char *hddtemp_output = fetch();
char *c;
{
char *hddtemp_output = fetch();
char *c;
@@
-179,8
+183,7
@@
struct psensor **hdd_psensor_list_add(struct psensor **sensors,
return sensors;
if (hddtemp_output[0] != '|') {
return sensors;
if (hddtemp_output[0] != '|') {
- fprintf(stderr,
- _("ERROR: wrong hdd string: %s"), hddtemp_output);
+ log_err(_("hddtemp: wrong string: %s."), hddtemp_output);
free(hddtemp_output);
free(hddtemp_output);
@@
-219,7
+222,8
@@
static void update(struct psensor **sensors, struct hdd_info *info)
struct psensor **sensor_cur = sensors;
while (*sensor_cur) {
struct psensor **sensor_cur = sensors;
while (*sensor_cur) {
- if ((*sensor_cur)->type == SENSOR_TYPE_HDD_TEMP_HDDTEMP
+ if (!((*sensor_cur)->type & SENSOR_TYPE_REMOTE)
+ && (*sensor_cur)->type & SENSOR_TYPE_HDDTEMP
&& !strcmp((*sensor_cur)->id + 4, info->name))
psensor_set_current_value(*sensor_cur,
(float)info->temp);
&& !strcmp((*sensor_cur)->id + 4, info->name))
psensor_set_current_value(*sensor_cur,
(float)info->temp);
@@
-228,7
+232,7
@@
static void update(struct psensor **sensors, struct hdd_info *info)
}
}
}
}
-void hdd_psensor_list_update(struct psensor **sensors)
+void hdd
temp
_psensor_list_update(struct psensor **sensors)
{
char *hddtemp_output = fetch();
{
char *hddtemp_output = fetch();
@@
-249,8
+253,7
@@
void hdd_psensor_list_update(struct psensor **sensors)
free(info.name);
}
} else {
free(info.name);
}
} else {
- fprintf(stderr,
- _("ERROR: wrong hdd string: %s\n"), hddtemp_output);
+ log_err(_("hddtemp: wrong string: %s."), hddtemp_output);
}
free(hddtemp_output);
}
free(hddtemp_output);