summaryrefslogtreecommitdiff
path: root/testing/nTox.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/nTox.c')
-rw-r--r--testing/nTox.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/testing/nTox.c b/testing/nTox.c
index 097c73af..caa7d45c 100644
--- a/testing/nTox.c
+++ b/testing/nTox.c
@@ -1,3 +1,26 @@
1/* nTox.c
2 *
3 * Textual frontend for Tox.
4 *
5 * Copyright (C) 2013 Tox project All Rights Reserved.
6 *
7 * This file is part of Tox.
8 *
9 * Tox is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * Tox is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23
1#include "nTox.h" 24#include "nTox.h"
2#include <stdio.h> 25#include <stdio.h>
3#include <time.h> 26#include <time.h>
@@ -28,8 +51,7 @@ unsigned char * hex_string_to_bin(char hex_string[])
28 unsigned char * val = malloc(strlen(hex_string)); 51 unsigned char * val = malloc(strlen(hex_string));
29 char * pos = hex_string; 52 char * pos = hex_string;
30 int i=0; 53 int i=0;
31 while(i < strlen(hex_string)) 54 while(i < strlen(hex_string)) {
32 {
33 sscanf(pos,"%2hhx",&val[i]); 55 sscanf(pos,"%2hhx",&val[i]);
34 pos+=2; 56 pos+=2;
35 i++; 57 i++;
@@ -167,6 +189,7 @@ void do_refresh()
167 clrtoeol(); 189 clrtoeol();
168 refresh(); 190 refresh();
169} 191}
192
170void print_request(uint8_t * public_key, uint8_t * data, uint16_t length) 193void print_request(uint8_t * public_key, uint8_t * data, uint16_t length)
171{ 194{
172 new_lines("[i] received friend request"); 195 new_lines("[i] received friend request");
@@ -182,6 +205,7 @@ void print_request(uint8_t * public_key, uint8_t * data, uint16_t length)
182 new_lines(numchar); 205 new_lines(numchar);
183 } 206 }
184} 207}
208
185void print_message(int friendnumber, uint8_t * string, uint16_t length) 209void print_message(int friendnumber, uint8_t * string, uint16_t length)
186{ 210{
187 char name[MAX_NAME_LENGTH]; 211 char name[MAX_NAME_LENGTH];
@@ -197,6 +221,7 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length)
197 sprintf(msg, "[%d] %s <%s> %s", friendnumber, temp, name, string); // someone please fix this 221 sprintf(msg, "[%d] %s <%s> %s", friendnumber, temp, name, string); // someone please fix this
198 new_lines(msg); 222 new_lines(msg);
199} 223}
224
200void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) { 225void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) {
201 char name[MAX_NAME_LENGTH]; 226 char name[MAX_NAME_LENGTH];
202 getname(friendnumber, (uint8_t*)name); 227 getname(friendnumber, (uint8_t*)name);
@@ -204,6 +229,7 @@ void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) {
204 sprintf(msg, "[i] [%d] %s is now known as %s.", friendnumber, name, string); 229 sprintf(msg, "[i] [%d] %s is now known as %s.", friendnumber, name, string);
205 new_lines(msg); 230 new_lines(msg);
206} 231}
232
207void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) { 233void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) {
208 char name[MAX_NAME_LENGTH]; 234 char name[MAX_NAME_LENGTH];
209 getname(friendnumber, (uint8_t*)name); 235 getname(friendnumber, (uint8_t*)name);
@@ -211,6 +237,7 @@ void print_statuschange(int friendnumber, uint8_t *string, uint16_t length) {
211 sprintf(msg, "[i] [%d] %s's status changed to %s.", friendnumber, name, string); 237 sprintf(msg, "[i] [%d] %s's status changed to %s.", friendnumber, name, string);
212 new_lines(msg); 238 new_lines(msg);
213} 239}
240
214void load_key(){ 241void load_key(){
215 FILE *data_file = NULL; 242 FILE *data_file = NULL;
216 if ((data_file = fopen("data","r"))) { 243 if ((data_file = fopen("data","r"))) {
@@ -237,6 +264,7 @@ void load_key(){
237 } 264 }
238 fclose(data_file); 265 fclose(data_file);
239} 266}
267
240int main(int argc, char *argv[]) 268int main(int argc, char *argv[])
241{ 269{
242 if (argc < 4) { 270 if (argc < 4) {
@@ -294,9 +322,7 @@ int main(int argc, char *argv[])
294 DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3])); 322 DHT_bootstrap(bootstrap_ip_port, hex_string_to_bin(argv[3]));
295 nodelay(stdscr, TRUE); 323 nodelay(stdscr, TRUE);
296 while(true) { 324 while(true) {
297 325 if (on == 0 && DHT_isconnected()) {
298 if (on == 0 && DHT_isconnected())
299 {
300 new_lines("[i] connected to DHT\n[i] define username with /n"); 326 new_lines("[i] connected to DHT\n[i] define username with /n");
301 on = 1; 327 on = 1;
302 } 328 }