diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-31 15:06:40 -0700 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-31 15:06:40 -0700 |
commit | b81dc5508c7f5250a8c7fb8a934a86f9ef6217e5 (patch) | |
tree | 43b93f959924737d053b307b8561c65a9d604729 | |
parent | c558cb63f6db35bd51f2f2331e21df03105ee82a (diff) | |
parent | 52ddf5ec4372298fe794eeaff039ab365e1530ae (diff) |
Merge pull request #219 from JFreegman/master
Partially fixed friend add bug
-rw-r--r-- | testing/nTox.c | 23 | ||||
-rw-r--r-- | testing/nTox_win32.c | 24 |
2 files changed, 42 insertions, 5 deletions
diff --git a/testing/nTox.c b/testing/nTox.c index 7c84871f..17f4b0e7 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 | } |
diff --git a/testing/nTox_win32.c b/testing/nTox_win32.c index b7b6a70d..50f551de 100644 --- a/testing/nTox_win32.c +++ b/testing/nTox_win32.c | |||
@@ -126,8 +126,28 @@ void line_eval(char* line) | |||
126 | temp_id[i] = line[i+3]; | 126 | temp_id[i] = line[i+3]; |
127 | int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); | 127 | int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo")); |
128 | char numstring[100]; | 128 | char numstring[100]; |
129 | sprintf(numstring, "\n[i] added friend %d\n\n", num); | 129 | switch (num) { |
130 | printf(numstring); | 130 | case -1: |
131 | sprintf(numstring, "[i] Incorrect key length"); | ||
132 | printf(numstring); | ||
133 | break; | ||
134 | case -2: | ||
135 | sprintf(numstring, "[i] That appears to be your own key"); | ||
136 | printf(numstring); | ||
137 | break; | ||
138 | case -3: | ||
139 | sprintf(numstring, "[i] Friend request already sent"); | ||
140 | printf(numstring); | ||
141 | break; | ||
142 | case -4: | ||
143 | sprintf(numstring, "[i] Could not add friend"); | ||
144 | printf(numstring); | ||
145 | break; | ||
146 | default: | ||
147 | sprintf(numstring, "\n[i] added friend %d\n\n", num); | ||
148 | printf(numstring); | ||
149 | break; | ||
150 | } | ||
131 | } | 151 | } |
132 | 152 | ||
133 | else if (inpt_command == 'r') { | 153 | else if (inpt_command == 'r') { |