X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fhdd.c;h=24e9e8de1444cf87f07d3b22e5f7fdd40c55129b;hb=82b743a766ce466826d01e639222c98883d03c28;hp=dc61c9a1e179def1761d4353b9505dfe737e435f;hpb=cde76fd1723bbdad164adac96d105111b831bf50;p=psensor.git diff --git a/src/lib/hdd.c b/src/lib/hdd.c index dc61c9a..24e9e8d 100644 --- a/src/lib/hdd.c +++ b/src/lib/hdd.c @@ -1,22 +1,21 @@ /* - Copyright (C) 2010-2011 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 published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program 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, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA -*/ - + * Copyright (C) 2010-2011 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 + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ #include #include #define _(str) gettext(str) @@ -45,7 +44,7 @@ struct hdd_info { int temp; }; -char *hdd_fetch() +static char *fetch() { int sockfd; ssize_t n = 1; @@ -56,7 +55,7 @@ char *hdd_fetch() sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd == -1) { - fprintf(stderr, _("ERROR: hdd_fetch, failed to open socket\n")); + fprintf(stderr, _("ERROR: hdd fetch, failed to open socket\n")); return NULL; } @@ -70,7 +69,7 @@ char *hdd_fetch() (struct sockaddr *)&address, (socklen_t) sizeof(address)) == -1) { fprintf(stderr, - _("ERROR: hdd_fetch, failed to open connection\n")); + _("ERROR: hdd fetch, failed to open connection\n")); } else { buffer = malloc(HDDTEMP_OUTPUT_BUFFER_LENGTH); @@ -92,7 +91,7 @@ char *hdd_fetch() return buffer; } -int str_index(char *str, char d) +static int str_index(char *str, char d) { char *c; int i; @@ -113,13 +112,14 @@ int str_index(char *str, char d) return -1; } -struct psensor *hdd_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, values_max_length); } -char *next_hdd_info(char *string, struct hdd_info *info) +static char *next_hdd_info(char *string, struct hdd_info *info) { char *c; int idx_name_n, i, temp; @@ -169,7 +169,7 @@ char *next_hdd_info(char *string, struct hdd_info *info) struct psensor **hdd_psensor_list_add(struct psensor **sensors, int values_max_length) { - char *hddtemp_output = hdd_fetch(); + char *hddtemp_output = fetch(); char *c; struct hdd_info info; struct psensor **result; @@ -198,7 +198,7 @@ struct psensor **hdd_psensor_list_add(struct psensor **sensors, strcpy(id, "hdd "); strcat(id, info.name); - sensor = hdd_create_sensor(id, info.name, values_max_length); + sensor = create_sensor(id, info.name, values_max_length); tmp_sensors = psensor_list_add(result, sensor); @@ -213,7 +213,7 @@ struct psensor **hdd_psensor_list_add(struct psensor **sensors, return result; } -void hdd_psensor_update(struct psensor **sensors, struct hdd_info *info) +static void update(struct psensor **sensors, struct hdd_info *info) { struct psensor **sensor_cur = sensors; @@ -229,7 +229,7 @@ void hdd_psensor_update(struct psensor **sensors, struct hdd_info *info) void hdd_psensor_list_update(struct psensor **sensors) { - char *hddtemp_output = hdd_fetch(); + char *hddtemp_output = fetch(); if (!hddtemp_output) return; @@ -243,7 +243,7 @@ void hdd_psensor_list_update(struct psensor **sensors) while (c && (c = next_hdd_info(c, &info))) { - hdd_psensor_update(sensors, &info); + update(sensors, &info); free(info.name); }