Changeset 5654

Show
Ignore:
Timestamp:
02/15/09 21:47:33 (4 years ago)
Author:
khali
Message:

Document error-related functions.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/lib/libsensors.3

    r5653 r5654  
    7171.BI "                      double " value ");" 
    7272.BI "int sensors_do_chip_sets(const sensors_chip_name *" name ");" 
     73 
     74.B #include <sensors/error.h> 
     75 
     76/* Error decoding */ 
     77.BI "const char *sensors_strerror(int " errnum ");" 
     78 
     79/* Error handlers */ 
     80.BI "void (*sensors_parse_error) (const char *" err ", int " lineno ");" 
     81.BI "void (*sensors_parse_error_wfn) (const char *" err "," 
     82.BI "                                 const char *" filename ", int " lineno ");" 
     83.BI "void (*sensors_fatal_error) (const char *" proc ", const char *" err ");" 
    7384.fi 
    7485 
     
    148159executes all set statements for this particular chip. The chip may contain 
    149160wildcards!  This function will return 0 on success, and <0 on failure. 
     161 
     162.B sensors_strerror() 
     163returns a pointer to a string which describes the error. 
     164errnum may be negative (the corresponding positive error is returned). 
     165You may not modify the result! 
     166 
     167.B sensors_parse_error() 
     168and 
     169.B sensors_parse_error_wfn() 
     170are functions which are called when a parse error is detected. Give them 
     171new values, and your own functions are called instead of the default (which 
     172print to stderr). These functions may terminate the program, but they 
     173usually output an error and return. The first function is the original 
     174one, the second one was added later when support for multiple 
     175configuration files was added. 
     176The library code now only calls the second function. However, for 
     177backwards compatibility, if an application provides a custom handling 
     178function for the first function but not the second, then all parse 
     179errors will be reported using the first function (that is, the filename 
     180is never reported.) 
     181Note that filename can be NULL (if filename isn't known) and lineno 
     182can be 0 (if the error occurs before the actual parsing starts.) 
     183 
     184.B sensors_fatal_error() 
     185Is a function which is called when an immediately fatal error (like no 
     186memory left) is detected. Give it a new value, and your own function 
     187is called instead of the default (which prints to stderr and ends 
     188the program). Never let it return! 
    150189 
    151190.SH DATA STRUCTURES