From 3678b302dbf2b202afe9e53b46153da69ecbb28e Mon Sep 17 00:00:00 2001 From: charmlesscoin Date: Fri, 2 Aug 2013 21:22:02 -0400 Subject: cleaned up print_friendlist(), it now prints a message if you have _no_ friends --- testing/nTox.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/testing/nTox.c b/testing/nTox.c index 24d40ead..4989f88a 100644 --- a/testing/nTox.c +++ b/testing/nTox.c @@ -82,18 +82,22 @@ void new_lines(char *line) void print_friendlist() { char name[MAX_NAME_LENGTH]; + int i = 0; new_lines("[i] Friend List:"); - uint32_t i; - for (i = 0; i <= num_requests; i++) { - char fstring[128]; - getname(i, (uint8_t*)name); + while(getname(i++, (uint8_t *)name) != -1) { + /* account for the longest name and the longest "base" string */ + char fstring[MAX_NAME_LENGTH + strlen("[i] Friend: NULL\n\tid: ")]; + if (strlen(name) <= 0) { - sprintf(fstring, "[i] Friend: NULL\n\tid: %i", i); + sprintf(fstring, "[i] Friend: No Friend!\n\tid: %i", i); } else { sprintf(fstring, "[i] Friend: %s\n\tid: %i", (uint8_t*)name, i); } new_lines(fstring); } + + if(i == 1) + new_lines("\tno friends! D:"); } char *format_message(char *message, int friendnum) -- cgit v1.2.3