Remove the obsolete error functions.
This commit is contained in:
parent
38c7b022cd
commit
30feb3b3ed
39
src/irda.c
39
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)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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.
|
||||
//
|
||||
|
||||
@ -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.
|
||||
//
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user