root/lm-sensors/branches/lm-sensors-3.0.0/prog/sensord/lib.c @ 5163

Revision 5163, 2.5 KB (checked in by khali, 6 years ago)

Patch from Aurelien Jarno:

I have just noticed that the FSF address is the old one in all files
except COPYING. Please find a patch below to fix that.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2 * sensord
3 *
4 * A daemon that periodically logs sensor information to syslog.
5 *
6 * Copyright (c) 1999-2002 Merlin Hughes <merlin@merlin.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301 USA.
22 */
23
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27#include <syslog.h>
28#include <time.h>
29#include <unistd.h>
30#include <sys/stat.h>
31
32#include "sensord.h"
33#include "lib/error.h"
34
35static int
36loadConfig
37(const char *cfgPath, int reload) {
38  struct stat stats;
39  FILE *cfg = NULL;
40  int ret = 0;
41
42  if (cfgPath && !strcmp (cfgPath, "-")) {
43    if (!reload) {
44      if ((ret = sensors_init (stdin))) {
45        sensorLog (LOG_ERR, "Error loading sensors configuration file <stdin>: %s",
46                   sensors_strerror (ret));
47        ret = 12;
48      }
49    }
50  } else if (cfgPath && stat (cfgPath, &stats) < 0) {
51    sensorLog (LOG_ERR, "Error stating sensors configuration file: %s", cfgPath);
52    ret = 10;
53  } else {
54    if (reload) {
55      sensorLog (LOG_INFO, "configuration reloading");
56      sensors_cleanup ();
57    }
58    if (cfgPath && !(cfg = fopen (cfgPath, "r"))) {
59      sensorLog (LOG_ERR, "Error opening sensors configuration file: %s", cfgPath);
60      ret = 11;
61    } else if ((ret = sensors_init (cfg))) {
62      sensorLog (LOG_ERR, "Error loading sensors configuration file %s: %s",
63                 cfgPath ? cfgPath : "(default)", sensors_strerror (ret));
64      ret = 11;
65    }
66    if (cfg)
67      fclose (cfg);
68  }
69
70  return ret;
71}
72
73int
74loadLib
75(const char *cfgPath) {
76  int ret;
77  ret = loadConfig (cfgPath, 0);
78  if (!ret)
79    ret = initKnownChips ();
80  return ret;
81}
82
83int
84reloadLib
85(const char *cfgPath) {
86  int ret;
87  freeKnownChips ();
88  ret = loadConfig (cfgPath, 1);
89  if (!ret)
90    ret = initKnownChips ();
91  return ret;
92}
93
94int
95unloadLib
96(void) {
97  freeKnownChips ();
98  sensors_cleanup ();
99  return 0; 
100}
Note: See TracBrowser for help on using the browser.