-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtelnet-client.h
77 lines (67 loc) · 1.67 KB
/
telnet-client.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Sean Middleditch
*
* The author or authors of this code dedicate any and all copyright interest
* in this code to the public domain. We make this dedication for the benefit
* of the public at large and to the detriment of our heirs and successors. We
* intend this dedication to be an overt act of relinquishment in perpetuity of
* all present and future rights to this code under copyright law.
*/
#if !defined(_POSIX_SOURCE)
# define _POSIX_SOURCE
#endif
#if !defined(_BSD_SOURCE)
# define _BSD_SOURCE
#endif
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <poll.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <termios.h>
#include <unistd.h>
#include <unistd.h>
#include <time.h>
#ifdef HAVE_ZLIB
#include "zlib.h"
#endif
#include "libtelnet.h"
/**
* @brief Structure needed for telnet initialization
*/
typedef struct telnet_config {
char buffer[512];
int rs;
int sock;
struct sockaddr_in addr;
struct pollfd pfd[2];
struct addrinfo *ai;
struct addrinfo hints;
struct termios tios;
} telnet_config_t;
static struct termios orig_tios;
static telnet_t *telnet;
static int do_echo;
/**
* @brief initialize telnet client
*
* @param [in] telnet_config_t *config - structure filled with necessary data
* @param [out]
* @return
*/
int telnet_construct(telnet_config_t *config);
/**
* @brief deinitialize telnet client
*
* @param [in] telnet_config_t *config - structure filled with necessary data
* @param [out]
* @return
*/
int telnet_deconstruct (telnet_config_t * config);