Tue, 26 Aug 2008 19:14:23 +0100
made error codes negative
tweaked lpfk_read to return an error constant instead of a magic number
include/liblpfk.h | file | annotate | diff | revisions | |
src/liblpfk.c | file | annotate | diff | revisions |
1.1 diff -r 93f5d26366ad -r 81d49d42ad6a include/liblpfk.h 1.2 --- a/include/liblpfk.h Tue Aug 26 18:45:45 2008 +0100 1.3 +++ b/include/liblpfk.h Tue Aug 26 19:14:23 2008 +0100 1.4 @@ -66,11 +66,12 @@ 1.5 */ 1.6 enum { 1.7 LPFK_E_OK = 0, ///< No error, success. 1.8 - LPFK_E_PORT_OPEN, ///< Could not open comm port. 1.9 - LPFK_E_NOT_PRESENT, ///< LPFK not present on specified port. 1.10 - LPFK_E_COMMS, ///< Communication error. 1.11 - LPFK_E_PARAM, ///< Invalid function parameter. 1.12 -LPFK_E_NOT_ENABLED ///< Attempt to read key when LPFK disabled 1.13 + LPFK_E_NO_KEYS = -1, ///< No keys in input buffer 1.14 + LPFK_E_PORT_OPEN = -2, ///< Could not open comm port. 1.15 + LPFK_E_NOT_PRESENT = -3, ///< LPFK not present on specified port. 1.16 + LPFK_E_COMMS = -4, ///< Communication error. 1.17 + LPFK_E_PARAM = -5, ///< Invalid function parameter. 1.18 + LPFK_E_NOT_ENABLED = -6 ///< Attempt to read key when LPFK disabled 1.19 }; 1.20 1.21 /** 1.22 @@ -159,7 +160,7 @@ 1.23 /** 1.24 * @brief Read a key from the LPFK 1.25 * @param ctx Pointer to an LPFK_CTX struct initialised by lpfk_open(). 1.26 - * @return -1 if no keys in buffer, 0-31 for key 1-32 down. 1.27 + * @return LPFK_E_NO_KEYS if no keys in buffer, 0-31 for key 1-32 down. 1.28 */ 1.29 int lpfk_read(LPFK_CTX *ctx); 1.30
2.1 diff -r 93f5d26366ad -r 81d49d42ad6a src/liblpfk.c 2.2 --- a/src/liblpfk.c Tue Aug 26 18:45:45 2008 +0100 2.3 +++ b/src/liblpfk.c Tue Aug 26 19:14:23 2008 +0100 2.4 @@ -361,7 +361,7 @@ 2.5 2.6 if ((nbytes < 1) || (key > 31)) { 2.7 // no keys buffered, or keycode invalid. 2.8 - return -1; 2.9 + return LPFK_E_NO_KEYS; 2.10 } else { 2.11 // key buffered, pass it along. 2.12 return key;