root/lm-sensors/tags/V2-10-2/lib/error.c

Revision 2208, 2.4 kB (checked in by khali, 5 years ago)

Reword the "Can't access /proc file" error message so that

Linux 2.6 users don't get confused. Update the FAQ accordingly.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2     error.c - Part of libsensors, a Linux library for reading sensor data.
3     Copyright (c) 1998, 1999  Frodo Looijaard <frodol@dds.nl>
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include "error.h"
23
24 static void sensors_default_parse_error(const char *err, int lineno);
25 static void sensors_default_fatal_error(const char *proc,const char *err);
26
27 void (*sensors_parse_error) (const char *err, int lineno) =
28                                                   sensors_default_parse_error;
29 void (*sensors_fatal_error) (const char *proc, const char *err) =
30                                                   sensors_default_fatal_error;
31
32 static const char *errorlist[] =
33  { /* Unknown error         */ "sensors_strerror: Unknown error!",
34    /* SENSORS_ERR_WILDCARDS */ "Wildcard found in chip name",
35    /* SENSORS_ERR_NO_ENTRY  */ "No such feature known",
36    /* SENSORS_ERR_ACCESS    */ "Can't read or write",
37    /* SENSORS_ERR_PROC      */ "Can't access procfs/sysfs file",
38    /* SENSORS_ERR_DIV_ZERO  */ "Divide by zero",
39    /* SENSORS_ERR_CHIP_NAME */ "Can't parse chip name",
40    /* SENSORS_ERR_BUS_NAME  */ "Can't parse bus name",
41    /* SENSORS_ERR_PARSE     */ "General parse error",
42    /* SENSORS_ERR_ACCESS_W  */ "Can't write",
43    /* SENSORS_ERR_ACCESS_R  */ "Can't read"
44  };
45
46 #define ERROR_LIST_LEN (sizeof(errorlist) / sizeof(char *))
47
48 const char *sensors_strerror(int errnum)
49 {
50   if (errnum < 0)
51     errnum = -errnum;
52   if (errnum >= ERROR_LIST_LEN)
53     errnum = 0;
54   return errorlist[errnum];
55 }
56
57 void sensors_default_parse_error(const char *err, int lineno)
58 {
59   fprintf(stderr,"Error: Line %d: %s\n",lineno,err);
60 }
61
62 void sensors_default_fatal_error(const char *proc, const char *err)
63 {
64   fprintf(stderr,"Fatal error in `%s': %s\n",proc,err);
65   exit(1);
66 }
Note: See TracBrowser for help on using the browser.