diff options
Diffstat (limited to 'testing/nTox.h')
-rw-r--r-- | testing/nTox.h | 49 |
1 files changed, 2 insertions, 47 deletions
diff --git a/testing/nTox.h b/testing/nTox.h index df9d404a..a72ce0c2 100644 --- a/testing/nTox.h +++ b/testing/nTox.h | |||
@@ -27,61 +27,16 @@ | |||
27 | #include <stdio.h> | 27 | #include <stdio.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <string.h> | 29 | #include <string.h> |
30 | #include <ncurses.h> | ||
31 | #include <curses.h> | 30 | #include <curses.h> |
32 | #include <ctype.h> | 31 | #include <ctype.h> |
33 | #include <sys/socket.h> | 32 | |
34 | #include <netinet/in.h> | ||
35 | #include <arpa/inet.h> | ||
36 | #include <sys/types.h> | ||
37 | #include <netdb.h> | ||
38 | #include "../toxcore/tox.h" | 33 | #include "../toxcore/tox.h" |
39 | 34 | ||
40 | #define STRING_LENGTH 256 | 35 | #define STRING_LENGTH 256 |
41 | #define HISTORY 50 | 36 | #define HISTORY 50 |
42 | #define PUB_KEY_BYTES 32 | 37 | #define PUB_KEY_BYTES 32 |
43 | 38 | ||
44 | /* | 39 | uint32_t resolve_addr(const char *address); |
45 | resolve_addr(): | ||
46 | address should represent IPv4 or a hostname with A record | ||
47 | |||
48 | returns a data in network byte order that can be used to set IP.i or IP_Port.ip.i | ||
49 | returns 0 on failure | ||
50 | |||
51 | TODO: Fix ipv6 support | ||
52 | */ | ||
53 | |||
54 | uint32_t resolve_addr(const char *address) | ||
55 | { | ||
56 | struct addrinfo *server = NULL; | ||
57 | struct addrinfo hints; | ||
58 | int rc; | ||
59 | uint32_t addr; | ||
60 | |||
61 | memset(&hints, 0, sizeof(hints)); | ||
62 | hints.ai_family = AF_INET; // IPv4 only right now. | ||
63 | hints.ai_socktype = SOCK_DGRAM; // type of socket Tox uses. | ||
64 | |||
65 | rc = getaddrinfo(address, "echo", &hints, &server); | ||
66 | |||
67 | // Lookup failed. | ||
68 | if (rc != 0) { | ||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | // IPv4 records only.. | ||
73 | if (server->ai_family != AF_INET) { | ||
74 | freeaddrinfo(server); | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | |||
79 | addr = ((struct sockaddr_in *)server->ai_addr)->sin_addr.s_addr; | ||
80 | |||
81 | freeaddrinfo(server); | ||
82 | return addr; | ||
83 | } | ||
84 | |||
85 | void new_lines(char *line); | 40 | void new_lines(char *line); |
86 | void line_eval(Tox *m, char *line); | 41 | void line_eval(Tox *m, char *line); |
87 | void wrap(char output[STRING_LENGTH], char input[STRING_LENGTH], int line_width) ; | 42 | void wrap(char output[STRING_LENGTH], char input[STRING_LENGTH], int line_width) ; |