diff options
Diffstat (limited to 'testing/Messenger_test.c')
-rw-r--r-- | testing/Messenger_test.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c index f9215b44..19ab4cc3 100644 --- a/testing/Messenger_test.c +++ b/testing/Messenger_test.c | |||
@@ -17,7 +17,24 @@ | |||
17 | * Or the argument can be the path to the save file. | 17 | * Or the argument can be the path to the save file. |
18 | * | 18 | * |
19 | * EX: ./test Save.bak | 19 | * EX: ./test Save.bak |
20 | * | 20 | * |
21 | * Copyright (C) 2013 Tox project All Rights Reserved. | ||
22 | * | ||
23 | * This file is part of Tox. | ||
24 | * | ||
25 | * Tox is free software: you can redistribute it and/or modify | ||
26 | * it under the terms of the GNU General Public License as published by | ||
27 | * the Free Software Foundation, either version 3 of the License, or | ||
28 | * (at your option) any later version. | ||
29 | * | ||
30 | * Tox is distributed in the hope that it will be useful, | ||
31 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
32 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
33 | * GNU General Public License for more details. | ||
34 | * | ||
35 | * You should have received a copy of the GNU General Public License | ||
36 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
37 | * | ||
21 | */ | 38 | */ |
22 | 39 | ||
23 | #include "../core/Messenger.h" | 40 | #include "../core/Messenger.h" |
@@ -87,15 +104,12 @@ int main(int argc, char *argv[]) | |||
87 | exit(0); | 104 | exit(0); |
88 | } | 105 | } |
89 | initMessenger(); | 106 | initMessenger(); |
90 | if(argc > 3) | 107 | if(argc > 3) { |
91 | { | ||
92 | IP_Port bootstrap_ip_port; | 108 | IP_Port bootstrap_ip_port; |
93 | bootstrap_ip_port.port = htons(atoi(argv[2])); | 109 | bootstrap_ip_port.port = htons(atoi(argv[2])); |
94 | bootstrap_ip_port.ip.i = inet_addr(argv[1]); | 110 | bootstrap_ip_port.ip.i = inet_addr(argv[1]); |
95 | DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); | 111 | DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); |
96 | } | 112 | } else { |
97 | else | ||
98 | { | ||
99 | FILE *file = fopen(argv[1], "rb"); | 113 | FILE *file = fopen(argv[1], "rb"); |
100 | if ( file==NULL ){return 1;} | 114 | if ( file==NULL ){return 1;} |
101 | int read; | 115 | int read; |
@@ -110,8 +124,7 @@ int main(int argc, char *argv[]) | |||
110 | 124 | ||
111 | printf("OUR ID: "); | 125 | printf("OUR ID: "); |
112 | uint32_t i; | 126 | uint32_t i; |
113 | for(i = 0; i < 32; i++) | 127 | for(i = 0; i < 32; i++) { |
114 | { | ||
115 | if(self_public_key[i] < 16) | 128 | if(self_public_key[i] < 16) |
116 | printf("0"); | 129 | printf("0"); |
117 | printf("%hhX",self_public_key[i]); | 130 | printf("%hhX",self_public_key[i]); |
@@ -121,16 +134,14 @@ int main(int argc, char *argv[]) | |||
121 | 134 | ||
122 | char temp_id[128]; | 135 | char temp_id[128]; |
123 | printf("\nEnter the client_id of the friend you wish to add (32 bytes HEX format):\n"); | 136 | printf("\nEnter the client_id of the friend you wish to add (32 bytes HEX format):\n"); |
124 | if(scanf("%s", temp_id) != 1) | 137 | if(scanf("%s", temp_id) != 1) { |
125 | { | ||
126 | return 1; | 138 | return 1; |
127 | } | 139 | } |
128 | int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); | 140 | int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); |
129 | 141 | ||
130 | perror("Initialization"); | 142 | perror("Initialization"); |
131 | 143 | ||
132 | while(1) | 144 | while(1) { |
133 | { | ||
134 | uint8_t name[128]; | 145 | uint8_t name[128]; |
135 | getname(num, name); | 146 | getname(num, name); |
136 | printf("%s\n", name); | 147 | printf("%s\n", name); |
@@ -145,6 +156,5 @@ int main(int argc, char *argv[]) | |||
145 | fwrite(buffer, 1, Messenger_size(), file); | 156 | fwrite(buffer, 1, Messenger_size(), file); |
146 | free(buffer); | 157 | free(buffer); |
147 | fclose(file); | 158 | fclose(file); |
148 | } | 159 | } |
149 | |||
150 | } | 160 | } |