#include <arpa/inet.h>
#include <unistd.h>
-#include "hdd.h"
-#include "psensor.h"
+#include <hdd.h>
+#include <psensor.h>
-#define HDDTEMP_SERVER_IP_ADDRESS "127.0.0.1"
-#define HDDTEMP_PORT_NUMBER 7634
-#define HDDTEMP_OUTPUT_BUFFER_LENGTH 4048
+static const char *PROVIDER_NAME = "hddtemp";
+
+static const char *HDDTEMP_SERVER_IP_ADDRESS = "127.0.0.1";
+static const int HDDTEMP_PORT_NUMBER = 7634;
+static const int HDDTEMP_OUTPUT_BUFFER_LENGTH = 4048;
struct hdd_info {
char *name;
struct psensor **hddtemp_psensor_list_add(struct psensor **sensors,
int values_max_length)
{
- char *hddtemp_output = fetch();
- char *c;
+ char *hddtemp_output, *c;
struct hdd_info info;
struct psensor **result;
+ hddtemp_output = fetch();
+
if (!hddtemp_output)
return sensors;
while (c && (c = next_hdd_info(c, &info))) {
struct psensor *sensor;
struct psensor **tmp_sensors;
+ char *id;
- char *id = malloc(strlen("hddtemp ") + strlen(info.name) + 1);
- strcpy(id, "hddtemp ");
- strcat(id, info.name);
+ id = malloc(strlen(PROVIDER_NAME) + 1 + strlen(info.name) + 1);
+ sprintf(id, "%s %s", PROVIDER_NAME, info.name);
sensor = create_sensor(id, info.name, values_max_length);
void hddtemp_psensor_list_update(struct psensor **sensors)
{
- char *hddtemp_output = fetch();
+ char *hddtemp_output;
+
+ hddtemp_output = fetch();
if (!hddtemp_output)
return;
if (hddtemp_output[0] == '|') {
-
char *c = hddtemp_output;
struct hdd_info info;
+
info.name = NULL;
info.temp = 0;