shorten name of error enumerations
diff --git a/README b/README
index adada85..62a1893 100644
--- a/README
+++ b/README
@@ -76,11 +76,13 @@
instance of libtelnet_cb_t. A single instance of the structure
can be shared between any number of libtelnet_t instances.
- The mode parameter must be one of LIBTELNET_MODE_SERVER or
- LIBTELNET_MODE_CLIENT. These slightly alter the behavior of
- libtelnet in certain instances. If you are implementing a
- TELNET server, use the SERVER mode. If you are implementing a
- client, use the CLIENT mode.
+ The mode parameter must be one of LIBTELNET_MODE_SERVER,
+ LIBTELNET_MODE_CLIENT, or LIBTELNET_MODE_PROXY. These slightly
+ alter the behavior of libtelnet in certain instances. If you are
+ implementing a TELNET server, use the SERVER mode. If you are
+ implementing a client, use the CLIENT mode. The PROXY mode
+ enables special behavior for telnet-proxy (or similar
+ applications).
boid libtelnet_free(struct libtelnet_t *telnet);
Releases any internal memory allocated by libtelnet. This must
diff --git a/libtelnet.c b/libtelnet.c
index 0b9462a..0c3496b 100644
--- a/libtelnet.c
+++ b/libtelnet.c
@@ -29,10 +29,10 @@
#define ERROR(telnet, code, user_data, msg) \
_error(telnet, __FILE__, __LINE__, code, user_data, "%s", msg)
#define ERROR_NOMEM(telnet, user_data, msg) \
- _error(telnet, __FILE__, __LINE__, LIBTELNET_ERROR_NOMEM, user_data, \
+ _error(telnet, __FILE__, __LINE__, LIBTELNET_ENOMEM, user_data, \
"%s: %s", msg, strerror(errno))
#define ERROR_ZLIB(telnet, user_data, rs, msg) \
- _error(telnet, __FILE__, __LINE__, LIBTELNET_ERROR_UNKNOWN, \
+ _error(telnet, __FILE__, __LINE__, LIBTELNET_EUNKNOWN, \
user_data, "%s: %s", msg, zError(rs))
/* buffer sizes */
@@ -151,10 +151,10 @@
/* overflow -- can't grow any more */
if (i >= _buffer_sizes_count - 1) {
- _error(telnet, __FILE__, __LINE__, LIBTELNET_ERROR_OVERFLOW,
+ _error(telnet, __FILE__, __LINE__, LIBTELNET_EOVERFLOW,
user_data, "subnegotiation buffer size limit reached");
libtelnet_free(telnet);
- return LIBTELNET_ERROR_OVERFLOW;
+ return LIBTELNET_EOVERFLOW;
}
/* (re)allocate buffer */
@@ -163,7 +163,7 @@
if (new_buffer == 0) {
ERROR_NOMEM(telnet, user_data, "realloc() failed");
libtelnet_free(telnet);
- return LIBTELNET_ERROR_NOMEM;
+ return LIBTELNET_ENOMEM;
}
telnet->buffer = new_buffer;
@@ -172,7 +172,7 @@
/* push the byte, all set */
telnet->buffer[telnet->length++] = byte;
- return LIBTELNET_ERROR_OK;
+ return LIBTELNET_EOK;
}
static void _process(struct libtelnet_t *telnet, unsigned char *buffer,
@@ -257,7 +257,7 @@
telnet->state = LIBTELNET_STATE_SB_IAC;
/* buffer the byte, or bail if we can't */
} else if (_buffer_byte(telnet, byte, user_data) !=
- LIBTELNET_ERROR_OK) {
+ LIBTELNET_EOK) {
start = i + 1;
telnet->state = LIBTELNET_STATE_DATA;
}
@@ -274,7 +274,7 @@
/* zero-size buffer is a protocol error */
if (telnet->length == 0) {
- ERROR(telnet, LIBTELNET_ERROR_PROTOCOL, user_data,
+ ERROR(telnet, LIBTELNET_EPROTOCOL, user_data,
"subnegotiation has zero data");
break;
}
@@ -318,7 +318,7 @@
case LIBTELNET_IAC:
/* push IAC into buffer */
if (_buffer_byte(telnet, LIBTELNET_IAC, user_data) !=
- LIBTELNET_ERROR_OK) {
+ LIBTELNET_EOK) {
start = i + 1;
telnet->state = LIBTELNET_STATE_DATA;
} else {
@@ -327,7 +327,7 @@
break;
/* something else -- protocol error */
default:
- _error(telnet, __FILE__, __LINE__, LIBTELNET_ERROR_PROTOCOL,
+ _error(telnet, __FILE__, __LINE__, LIBTELNET_EPROTOCOL,
user_data, "unexpected byte after IAC inside SB: %d",
byte);
start = i + 1;
diff --git a/libtelnet.h b/libtelnet.h
index b6058a0..4efc87b 100644
--- a/libtelnet.h
+++ b/libtelnet.h
@@ -106,11 +106,11 @@
/* error codes */
enum libtelnet_error_t {
- LIBTELNET_ERROR_OK = 0,
- LIBTELNET_ERROR_NOMEM, /* memory allocation failure */
- LIBTELNET_ERROR_OVERFLOW, /* data exceeds buffer size */
- LIBTELNET_ERROR_PROTOCOL, /* invalid sequence of special bytes */
- LIBTELNET_ERROR_UNKNOWN /* some crazy unexplainable unknown error */
+ LIBTELNET_EOK = 0,
+ LIBTELNET_ENOMEM, /* memory allocation failure */
+ LIBTELNET_EOVERFLOW, /* data exceeds buffer size */
+ LIBTELNET_EPROTOCOL, /* invalid sequence of special bytes */
+ LIBTELNET_EUNKNOWN /* some crazy unexplainable unknown error */
};
/* libtelnet callback declarations */