diff --git a/src/irda.c b/src/irda.c index 1dfed42..476fa7e 100644 --- a/src/irda.c +++ b/src/irda.c @@ -62,45 +62,6 @@ struct irda_t { }; -int irda_errcode (void) -{ -#ifdef _WIN32 - return WSAGetLastError (); -#else - return errno; -#endif -} - - -const char* irda_errmsg (void) -{ -#ifdef _WIN32 - static char buffer[256] = {0}; - unsigned int size = sizeof (buffer) / sizeof (char); - - DWORD errcode = WSAGetLastError (); - DWORD rc = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, errcode, 0, buffer, size, NULL); - // Remove certain characters ('\r', '\n' and '.') - // at the end of the error message. - while (rc > 0 && ( - buffer[rc-1] == '\n' || - buffer[rc-1] == '\r' || - buffer[rc-1] == '.')) { - buffer[rc-1] = '\0'; - rc--; - } - if (rc) { - return buffer; - } else { - return NULL; - } -#else - return strerror (errno); -#endif -} - - int irda_socket_open (irda_t **out, dc_context_t *context) { diff --git a/src/irda.h b/src/irda.h index f3faa12..ff284f8 100644 --- a/src/irda.h +++ b/src/irda.h @@ -32,10 +32,6 @@ typedef struct irda_t irda_t; typedef void (*irda_callback_t) (unsigned int address, const char *name, unsigned int charset, unsigned int hints, void *userdata); -int irda_errcode (void); - -const char* irda_errmsg (void); - int irda_socket_open (irda_t **device, dc_context_t *context); int irda_socket_close (irda_t *device); diff --git a/src/serial.h b/src/serial.h index 33cd80e..1f84dcc 100644 --- a/src/serial.h +++ b/src/serial.h @@ -55,9 +55,6 @@ typedef enum serial_line_t { SERIAL_LINE_RNG, // Ring indicator } serial_line_t; -int serial_errcode (void); -const char* serial_errmsg (void); - int serial_open (serial_t **device, dc_context_t *context, const char* name); int serial_close (serial_t *device); diff --git a/src/serial_posix.c b/src/serial_posix.c index b6af4ae..3f20186 100644 --- a/src/serial_posix.c +++ b/src/serial_posix.c @@ -66,21 +66,6 @@ struct serial_t { unsigned int nbits; }; -// -// Error reporting. -// - -int serial_errcode (void) -{ - return errno; -} - - -const char* serial_errmsg (void) -{ - return strerror (errno); -} - // // Open the serial port. // diff --git a/src/serial_win32.c b/src/serial_win32.c index 4acca1a..ad6e23e 100644 --- a/src/serial_win32.c +++ b/src/serial_win32.c @@ -45,40 +45,6 @@ struct serial_t { unsigned int nbits; }; -// -// Error reporting. -// - -int serial_errcode (void) -{ - return GetLastError (); -} - - -const char* serial_errmsg (void) -{ - static char buffer[256] = {0}; - unsigned int size = sizeof (buffer) / sizeof (char); - - DWORD errcode = GetLastError (); - DWORD rc = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, errcode, 0, buffer, size, NULL); - // Remove certain characters ('\r', '\n' and '.') - // at the end of the error message. - while (rc > 0 && ( - buffer[rc-1] == '\n' || - buffer[rc-1] == '\r' || - buffer[rc-1] == '.')) { - buffer[rc-1] = '\0'; - rc--; - } - if (rc) { - return buffer; - } else { - return NULL; - } -} - // // Open the serial port. //