partially fixed friend add bug (key length test still broken)

This commit is contained in:
Jfreegman 2013-07-31 17:30:16 -04:00
parent 3eafbc900e
commit 8f6e1d8fbf

View File

@ -98,16 +98,33 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
if (line[0] == '/') {
char inpt_command = line[1];
char prompt[STRING_LENGTH+2] = "> ";
int prompt_offset = 3;
strcat(prompt, line);
new_lines(prompt);
if (inpt_command == 'f') { // add friend command: /f ID
int i;
char temp_id[128];
for (i = 0; i < 128; i++)
temp_id[i] = line[i+3];
temp_id[i] = line[i+prompt_offset];
int num = m_addfriend(hex_string_to_bin(temp_id), (uint8_t*)"Install Gentoo", sizeof("Install Gentoo"));
char numstring[100];
sprintf(numstring, "[i] added friend %d", num);
switch (num) {
case -1:
sprintf(numstring, "[i] Incorrect key length");
break;
case -2:
sprintf(numstring, "[i] That appears to be your own key");
break;
case -3:
sprintf(numstring, "[i] Friend request already sent");
break;
case -4:
sprintf(numstring, "[i] Could not add friend");
break;
default:
sprintf(numstring, "[i] Added friend %d", num);
break;
}
new_lines(numstring);
do_refresh();
}
@ -171,7 +188,7 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
uint8_t numf = atoi(line + 3);
char numchar[100];
int num = m_addfriend_norequest(pending_requests[numf]);
if (num != -1) {
if (num >= 0) {
sprintf(numchar, "[i] friend request %u accepted", numf);
new_lines(numchar);
sprintf(numchar, "[i] added friendnumber %d", num);