mirror of https://gerrit.osmocom.org/libtelnet
s/input/data/, s/output/send/
This commit is contained in:
parent
b9ab0b6b9a
commit
78f400feff
14
libtelnet.c
14
libtelnet.c
|
@ -92,7 +92,7 @@ void libtelnet_push(struct libtelnet_t *telnet, unsigned char *buffer,
|
|||
* switch states */
|
||||
if (byte == LIBTELNET_IAC) {
|
||||
if (i != start)
|
||||
libtelnet_input_cb(telnet, &buffer[start], i - start,
|
||||
libtelnet_data_cb(telnet, &buffer[start], i - start,
|
||||
user_data);
|
||||
telnet->state = LIBTELNET_STATE_IAC;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void libtelnet_push(struct libtelnet_t *telnet, unsigned char *buffer,
|
|||
break;
|
||||
/* IAC escaping */
|
||||
case LIBTELNET_IAC:
|
||||
libtelnet_input_cb(telnet, &byte, 1, user_data);
|
||||
libtelnet_data_cb(telnet, &byte, 1, user_data);
|
||||
start = i + 1;
|
||||
telnet->state = LIBTELNET_STATE_TEXT;
|
||||
break;
|
||||
|
@ -214,21 +214,21 @@ void libtelnet_push(struct libtelnet_t *telnet, unsigned char *buffer,
|
|||
|
||||
/* pass through any remaining bytes */
|
||||
if (i != start)
|
||||
libtelnet_input_cb(telnet, &buffer[start], i - start, user_data);
|
||||
libtelnet_data_cb(telnet, &buffer[start], i - start, user_data);
|
||||
}
|
||||
|
||||
/* send an iac command */
|
||||
void libtelnet_send_command(struct libtelnet_t *telnet, unsigned char cmd,
|
||||
void *user_data) {
|
||||
unsigned char bytes[2] = { LIBTELNET_IAC, cmd };
|
||||
libtelnet_output_cb(telnet, bytes, 2, user_data);
|
||||
libtelnet_send_cb(telnet, bytes, 2, user_data);
|
||||
}
|
||||
|
||||
/* send negotiation */
|
||||
void libtelnet_send_negotiate(struct libtelnet_t *telnet, unsigned char cmd,
|
||||
unsigned char opt, void *user_data) {
|
||||
unsigned char bytes[3] = { LIBTELNET_IAC, cmd, opt };
|
||||
libtelnet_output_cb(telnet, bytes, 3, user_data);
|
||||
libtelnet_send_cb(telnet, bytes, 3, user_data);
|
||||
}
|
||||
|
||||
/* send non-command data (escapes IAC bytes) */
|
||||
|
@ -240,7 +240,7 @@ void libtelnet_send_data(struct libtelnet_t *telnet, unsigned char *buffer,
|
|||
if (buffer[i] == LIBTELNET_IAC) {
|
||||
/* dump prior text if any */
|
||||
if (i != l)
|
||||
libtelnet_output_cb(telnet, buffer + l, i - l, user_data);
|
||||
libtelnet_send_cb(telnet, buffer + l, i - l, user_data);
|
||||
l = i + 1;
|
||||
|
||||
/* send escape */
|
||||
|
@ -250,7 +250,7 @@ void libtelnet_send_data(struct libtelnet_t *telnet, unsigned char *buffer,
|
|||
|
||||
/* send whatever portion of buffer is left */
|
||||
if (i != l)
|
||||
libtelnet_output_cb(telnet, buffer + l, i - l, user_data);
|
||||
libtelnet_send_cb(telnet, buffer + l, i - l, user_data);
|
||||
}
|
||||
|
||||
/* send sub-request */
|
||||
|
|
|
@ -40,7 +40,7 @@ enum libtelnet_state_t {
|
|||
enum libtelnet_error_t {
|
||||
LIBTELNET_ERROR_OK = 0,
|
||||
LIBTELNET_ERROR_NOMEM, /* memory allocation failure */
|
||||
LIBTELNET_ERROR_OVERFLOW, /* input exceeds buffer size */
|
||||
LIBTELNET_ERROR_OVERFLOW, /* data exceeds buffer size */
|
||||
LIBTELNET_ERROR_PROTOCOL, /* invalid sequence of special bytes */
|
||||
LIBTELNET_ERROR_UNKNOWN, /* some crazy unexplainable unknown error */
|
||||
};
|
||||
|
@ -60,9 +60,9 @@ struct libtelnet_t {
|
|||
/* libtelnet callback declarations
|
||||
* APPLICATION MUST IMPLEMENT THESE FUNCTIONS!!
|
||||
*/
|
||||
extern void libtelnet_input_cb(struct libtelnet_t *telnet,
|
||||
extern void libtelnet_data_cb(struct libtelnet_t *telnet,
|
||||
unsigned char *buffer, unsigned int size, void *user_data);
|
||||
extern void libtelnet_output_cb(struct libtelnet_t *telnet,
|
||||
extern void libtelnet_send_cb(struct libtelnet_t *telnet,
|
||||
unsigned char *buffer, unsigned int size, void *user_data);
|
||||
extern void libtelnet_command_cb(struct libtelnet_t *telnet,
|
||||
unsigned char cmd, void *user_data);
|
||||
|
|
|
@ -50,11 +50,11 @@ static void print_buffer(unsigned char *buffer, unsigned int size) {
|
|||
}
|
||||
}
|
||||
|
||||
void libtelnet_input_cb(struct libtelnet_t *telnet, unsigned char *buffer,
|
||||
void libtelnet_data_cb(struct libtelnet_t *telnet, unsigned char *buffer,
|
||||
unsigned int size, void *user_data) {
|
||||
int sock = *(int*)user_data;
|
||||
|
||||
printf("%s INPUT: ", get_name(sock));
|
||||
printf("%s DATA: ", get_name(sock));
|
||||
print_buffer(buffer, size);
|
||||
printf("\e[0m\n");
|
||||
|
||||
|
@ -62,12 +62,12 @@ void libtelnet_input_cb(struct libtelnet_t *telnet, unsigned char *buffer,
|
|||
other_socket(sock));
|
||||
}
|
||||
|
||||
void libtelnet_output_cb(struct libtelnet_t *telnet, unsigned char *buffer,
|
||||
void libtelnet_send_cb(struct libtelnet_t *telnet, unsigned char *buffer,
|
||||
unsigned int size, void *user_data) {
|
||||
int sock = *(int*)user_data;
|
||||
|
||||
/* DONT SPAM
|
||||
printf("%s OUTPUT: ", get_name(sock));
|
||||
printf("%s SEND: ", get_name(sock));
|
||||
print_buffer(buffer, size);
|
||||
printf("\e[0m\n");
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue