mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
commit
e029b65ece
|
@ -44,13 +44,37 @@ int x, y;
|
||||||
uint8_t pending_requests[256][CLIENT_ID_SIZE];
|
uint8_t pending_requests[256][CLIENT_ID_SIZE];
|
||||||
uint8_t num_requests = 0;
|
uint8_t num_requests = 0;
|
||||||
|
|
||||||
|
void get_id(char *data)
|
||||||
|
{
|
||||||
|
char idstring0[200];
|
||||||
|
char idstring1[PUB_KEY_BYTES][5];
|
||||||
|
char idstring2[PUB_KEY_BYTES][5];
|
||||||
|
int i = 0;
|
||||||
|
for(i = 0; i < PUB_KEY_BYTES; i++)
|
||||||
|
{
|
||||||
|
if (self_public_key[i] < (PUB_KEY_BYTES / 2))
|
||||||
|
strcpy(idstring1[i],"0");
|
||||||
|
else
|
||||||
|
strcpy(idstring1[i], "");
|
||||||
|
sprintf(idstring2[i], "%hhX",self_public_key[i]);
|
||||||
|
}
|
||||||
|
strcpy(idstring0,"[i] ID: ");
|
||||||
|
int j = 0;
|
||||||
|
for (j = 0; j < PUB_KEY_BYTES; j++) {
|
||||||
|
strcat(idstring0,idstring1[j]);
|
||||||
|
strcat(idstring0,idstring2[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(data, idstring0, strlen(idstring0));
|
||||||
|
}
|
||||||
|
|
||||||
void new_lines(char *line)
|
void new_lines(char *line)
|
||||||
{
|
{
|
||||||
int i;
|
int i = 0;
|
||||||
for (i = HISTORY-1; i > 0; i--)
|
for (i = HISTORY-1; i > 0; i--)
|
||||||
strcpy(lines[i], lines[i-1]);
|
strncpy(lines[i], lines[i-1], STRING_LENGTH - 1);
|
||||||
|
|
||||||
strcpy(lines[0], line);
|
strncpy(lines[0], line, STRING_LENGTH - 1);
|
||||||
do_refresh();
|
do_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,26 +240,9 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
|
||||||
new_lines("[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)");
|
new_lines("[i] /l list (list friends), /h for help, /i for info, /n nick (to change nickname), /q (to quit)");
|
||||||
}
|
}
|
||||||
else if (inpt_command == 'i') { //info
|
else if (inpt_command == 'i') { //info
|
||||||
char idstring0[200];
|
char idstring[200];
|
||||||
char idstring1[PUB_KEY_BYTES][5];
|
get_id(idstring);
|
||||||
char idstring2[PUB_KEY_BYTES][5];
|
new_lines(idstring);
|
||||||
int i;
|
|
||||||
for (i = 0; i < PUB_KEY_BYTES; i++)
|
|
||||||
{
|
|
||||||
if (self_public_key[i] < (PUB_KEY_BYTES/2))
|
|
||||||
strcpy(idstring1[i],"0");
|
|
||||||
else
|
|
||||||
strcpy(idstring1[i], "");
|
|
||||||
sprintf(idstring2[i], "%hhX", self_public_key[i]);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
strcpy(idstring0,"[i] ID: ");
|
|
||||||
int j;
|
|
||||||
for (j = 0; j < PUB_KEY_BYTES; j++) {
|
|
||||||
strcat(idstring0,idstring1[j]);
|
|
||||||
strcat(idstring0,idstring2[j]);
|
|
||||||
}
|
|
||||||
new_lines(idstring0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (inpt_command == 'q') { //exit
|
else if (inpt_command == 'q') { //exit
|
||||||
|
@ -396,29 +403,14 @@ int main(int argc, char *argv[])
|
||||||
m_callback_friendmessage(print_message);
|
m_callback_friendmessage(print_message);
|
||||||
m_callback_namechange(print_nickchange);
|
m_callback_namechange(print_nickchange);
|
||||||
m_callback_userstatus(print_statuschange);
|
m_callback_userstatus(print_statuschange);
|
||||||
char idstring0[200];
|
|
||||||
char idstring1[PUB_KEY_BYTES][5];
|
char idstring[200];
|
||||||
char idstring2[PUB_KEY_BYTES][5];
|
get_id(idstring);
|
||||||
int i;
|
|
||||||
for(i = 0; i < PUB_KEY_BYTES; i++)
|
|
||||||
{
|
|
||||||
if (self_public_key[i] < (PUB_KEY_BYTES / 2))
|
|
||||||
strcpy(idstring1[i],"0");
|
|
||||||
else
|
|
||||||
strcpy(idstring1[i], "");
|
|
||||||
sprintf(idstring2[i], "%hhX",self_public_key[i]);
|
|
||||||
}
|
|
||||||
strcpy(idstring0,"[i] your ID: ");
|
|
||||||
int j;
|
|
||||||
for (j = 0; j < PUB_KEY_BYTES; j++) {
|
|
||||||
strcat(idstring0,idstring1[j]);
|
|
||||||
strcat(idstring0,idstring2[j]);
|
|
||||||
}
|
|
||||||
initscr();
|
initscr();
|
||||||
noecho();
|
noecho();
|
||||||
raw();
|
raw();
|
||||||
getmaxyx(stdscr, y, x);
|
getmaxyx(stdscr, y, x);
|
||||||
new_lines(idstring0);
|
new_lines(idstring);
|
||||||
new_lines(help);
|
new_lines(help);
|
||||||
strcpy(line, "");
|
strcpy(line, "");
|
||||||
IP_Port bootstrap_ip_port;
|
IP_Port bootstrap_ip_port;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user