summaryrefslogtreecommitdiff
path: root/testing/nTox.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-07-30 14:30:33 -0400
committerirungentoo <irungentoo@gmail.com>2013-07-30 14:30:33 -0400
commit87388b302e8c9cb6a5eb78d59f792a60fe6c675f (patch)
tree5b04cac6eaf80508a5efa77ebeb4836a33fd970a /testing/nTox.c
parent2d3113699452194d9d5bc1ad7145a4e007a11fc6 (diff)
parentdc57b779d2e3d1df836698cd119a3890ffecf86d (diff)
Merge branch 'master' of https://github.com/blackwolf12333/ProjectTox-Core into blackwolf12333-master
Also fixed his pull request.
Diffstat (limited to 'testing/nTox.c')
-rw-r--r--testing/nTox.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/testing/nTox.c b/testing/nTox.c
index 97a39a12..9876f4ba 100644
--- a/testing/nTox.c
+++ b/testing/nTox.c
@@ -50,6 +50,7 @@ void new_lines(char *line)
50 do_refresh(); 50 do_refresh();
51} 51}
52 52
53
53void print_friendlist() 54void print_friendlist()
54{ 55{
55 char name[MAX_NAME_LENGTH]; 56 char name[MAX_NAME_LENGTH];
@@ -69,6 +70,26 @@ void print_friendlist()
69 } 70 }
70} 71}
71 72
73char *format_message(char *message, int friendnum)
74{
75 char name[MAX_NAME_LENGTH];
76 if(friendnum != -1) {
77 getname(friendnum, (uint8_t*)name);
78 } else {
79 getself_name((uint8_t*)name);
80 }
81 char *msg = malloc(100+strlen(message)+strlen(name)+1);
82 time_t rawtime;
83 struct tm * timeinfo;
84 time ( &rawtime );
85 timeinfo = localtime ( &rawtime );
86 char* time = asctime(timeinfo);
87 size_t len = strlen(time);
88 time[len-1]='\0';
89 sprintf(msg, "[%d] %s <%s> %s", friendnum, time, name, message); // timestamp
90 return msg;
91}
92
72void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) 93void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
73{ 94{
74 if (line[0] == '/') { 95 if (line[0] == '/') {
@@ -107,6 +128,8 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
107 int num = atoi(numstring); 128 int num = atoi(numstring);
108 if(m_sendmessage(num, (uint8_t*) message, sizeof(message)) != 1) { 129 if(m_sendmessage(num, (uint8_t*) message, sizeof(message)) != 1) {
109 new_lines("[i] could not send message"); 130 new_lines("[i] could not send message");
131 } else {
132 new_lines(format_message(message, -1));
110 } 133 }
111 } 134 }
112 else if (line[1] == 'n') { 135 else if (line[1] == 'n') {
@@ -255,7 +278,7 @@ void print_message(int friendnumber, uint8_t * string, uint16_t length)
255 size_t len = strlen(temp); 278 size_t len = strlen(temp);
256 temp[len-1]='\0'; 279 temp[len-1]='\0';
257 sprintf(msg, "[%d] %s <%s> %s", friendnumber, temp, name, string); // timestamp 280 sprintf(msg, "[%d] %s <%s> %s", friendnumber, temp, name, string); // timestamp
258 new_lines(msg); 281 new_lines(format_message((char*)string, friendnumber));
259} 282}
260 283
261void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) { 284void print_nickchange(int friendnumber, uint8_t *string, uint16_t length) {