diff options
author | Jfreegman <Jfreegman@gmail.com> | 2013-07-31 17:30:16 -0400 |
---|---|---|
committer | Jfreegman <Jfreegman@gmail.com> | 2013-07-31 17:30:16 -0400 |
commit | 8f6e1d8fbf047bf491cbd93dcfcf19d6789c688e (patch) | |
tree | d0ae1b019c4d159d7bf066a9246be43204334ba3 | |
parent | 3eafbc900e0547041aae299461e59f3dfd31c8d8 (diff) |
partially fixed friend add bug (key length test still broken)
-rw-r--r-- | testing/nTox.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/testing/nTox.c b/testing/nTox.c index 7c84871f..f00ea498 100644 --- a/testing/nTox.c +++ b/testing/nTox.c | |||
@@ -97,17 +97,34 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | |||
97 | { | 97 | { |
98 | if (line[0] == '/') { | 98 | if (line[0] == '/') { |
99 | char inpt_command = line[1]; | 99 | char inpt_command = line[1]; |
100 | char prompt[STRING_LENGTH + 2] = "> "; | 100 | char prompt[STRING_LENGTH+2] = "> "; |
101 | int prompt_offset = 3; | ||
101 | strcat(prompt, line); | 102 | strcat(prompt, line); |
102 | new_lines(prompt); | 103 | new_lines(prompt); |
103 | if (inpt_command == 'f') { // add friend command: /f ID | 104 | if (inpt_command == 'f') { // add friend command: /f ID |
104 | int i; | 105 | int i; |
105 | char temp_id[128]; | 106 | char temp_id[128]; |
106 | for (i = 0; i < 128; i++) | 107 | for (i = 0; i < 128; i++) |
107 | temp_id[i] = line[i+3]; | 108 | temp_id[i] = line[i+prompt_offset]; |
108 | int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); | 109 | int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); |
109 | char numstring[100]; | 110 | char numstring[100]; |
110 | sprintf(numstring, "[i] added friend %d", num); | 111 | switch (num) { |
112 | case -1: | ||
113 | sprintf(numstring, "[i] Incorrect key length"); | ||
114 | break; | ||
115 | case -2: | ||
116 | sprintf(numstring, "[i] That appears to be your own key"); | ||
117 | break; | ||
118 | case -3: | ||
119 | sprintf(numstring, "[i] Friend request already sent"); | ||
120 | break; | ||
121 | case -4: | ||
122 | sprintf(numstring, "[i] Could not add friend"); | ||
123 | break; | ||
124 | default: | ||
125 | sprintf(numstring, "[i] Added friend %d", num); | ||
126 | break; | ||
127 | } | ||
111 | new_lines(numstring); | 128 | new_lines(numstring); |
112 | do_refresh(); | 129 | do_refresh(); |
113 | } | 130 | } |
@@ -171,7 +188,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line) | |||
171 | uint8_t numf = atoi(line + 3); | 188 | uint8_t numf = atoi(line + 3); |
172 | char numchar[100]; | 189 | char numchar[100]; |
173 | int num = m_addfriend_norequest(pending_requests[numf]); | 190 | int num = m_addfriend_norequest(pending_requests[numf]); |
174 | if (num != -1) { | 191 | if (num >= 0) { |
175 | sprintf(numchar, "[i] friend request %u accepted", numf); | 192 | sprintf(numchar, "[i] friend request %u accepted", numf); |
176 | new_lines(numchar); | 193 | new_lines(numchar); |
177 | sprintf(numchar, "[i] added friendnumber %d", num); | 194 | sprintf(numchar, "[i] added friendnumber %d", num); |