| 1 | /* |
|---|
| 2 | error.h - Part of libsensors, a Linux library for reading sensor data. |
|---|
| 3 | Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
|---|
| 4 | Copyright (C) 2007-2009 Jean Delvare <khali@linux-fr.org> |
|---|
| 5 | |
|---|
| 6 | This library is free software; you can redistribute it and/or |
|---|
| 7 | modify it under the terms of the GNU Lesser General Public |
|---|
| 8 | License as published by the Free Software Foundation; either |
|---|
| 9 | version 2.1 of the License, or (at your option) any later version. |
|---|
| 10 | |
|---|
| 11 | This library is distributed in the hope that it will be useful, |
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | GNU Lesser General Public License for more details. |
|---|
| 15 | |
|---|
| 16 | You should have received a copy of the GNU General Public License |
|---|
| 17 | along with this program; if not, write to the Free Software |
|---|
| 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|---|
| 19 | MA 02110-1301 USA. |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | #ifndef LIB_SENSORS_ERROR_H |
|---|
| 23 | #define LIB_SENSORS_ERROR_H |
|---|
| 24 | |
|---|
| 25 | #define SENSORS_ERR_WILDCARDS 1 /* Wildcard found in chip name */ |
|---|
| 26 | #define SENSORS_ERR_NO_ENTRY 2 /* No such subfeature known */ |
|---|
| 27 | #define SENSORS_ERR_ACCESS_R 3 /* Can't read */ |
|---|
| 28 | #define SENSORS_ERR_KERNEL 4 /* Kernel interface error */ |
|---|
| 29 | #define SENSORS_ERR_DIV_ZERO 5 /* Divide by zero */ |
|---|
| 30 | #define SENSORS_ERR_CHIP_NAME 6 /* Can't parse chip name */ |
|---|
| 31 | #define SENSORS_ERR_BUS_NAME 7 /* Can't parse bus name */ |
|---|
| 32 | #define SENSORS_ERR_PARSE 8 /* General parse error */ |
|---|
| 33 | #define SENSORS_ERR_ACCESS_W 9 /* Can't write */ |
|---|
| 34 | #define SENSORS_ERR_IO 10 /* I/O error */ |
|---|
| 35 | #define SENSORS_ERR_RECURSION 11 /* Evaluation recurses too deep */ |
|---|
| 36 | |
|---|
| 37 | #ifdef __cplusplus |
|---|
| 38 | extern "C" { |
|---|
| 39 | #endif /* __cplusplus */ |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | /* This function returns a pointer to a string which describes the error. |
|---|
| 43 | errnum may be negative (the corresponding positive error is returned). |
|---|
| 44 | You may not modify the result! */ |
|---|
| 45 | const char *sensors_strerror(int errnum); |
|---|
| 46 | |
|---|
| 47 | /* These functions are called when a parse error is detected. Give them new |
|---|
| 48 | values, and your own functions are called instead of the default (which |
|---|
| 49 | print to stderr). These functions may terminate the program, but they |
|---|
| 50 | usually output an error and return. The first function is the original |
|---|
| 51 | one, the second one was added later when support for multiple |
|---|
| 52 | configuration files was added. |
|---|
| 53 | The library code now only calls the second function. However, for |
|---|
| 54 | backwards compatibility, if an application provides a custom handling |
|---|
| 55 | function for the first function but not the second, then all parse |
|---|
| 56 | errors will be reported using the first function (that is, the filename |
|---|
| 57 | is never reported.) |
|---|
| 58 | Note that filename can be NULL (if filename isn't known) and lineno |
|---|
| 59 | can be 0 (if the error occurs before the actual parsing starts.) */ |
|---|
| 60 | extern void (*sensors_parse_error) (const char *err, int lineno); |
|---|
| 61 | extern void (*sensors_parse_error_wfn) (const char *err, |
|---|
| 62 | const char *filename, int lineno); |
|---|
| 63 | |
|---|
| 64 | /* This function is called when an immediately fatal error (like no |
|---|
| 65 | memory left) is detected. Give it a new value, and your own function |
|---|
| 66 | is called instead of the default (which prints to stderr and ends |
|---|
| 67 | the program). Never let it return! */ |
|---|
| 68 | extern void (*sensors_fatal_error) (const char *proc, const char *err); |
|---|
| 69 | |
|---|
| 70 | #ifdef __cplusplus |
|---|
| 71 | } |
|---|
| 72 | #endif /* __cplusplus */ |
|---|
| 73 | |
|---|
| 74 | #endif /* def LIB_SENSORS_ERROR_H */ |
|---|