diff options
author | charmlesscoin <charmlesscoin@gmail.com> | 2013-08-02 21:22:02 -0400 |
---|---|---|
committer | charmlesscoin <charmlesscoin@gmail.com> | 2013-08-02 21:22:02 -0400 |
commit | 3678b302dbf2b202afe9e53b46153da69ecbb28e (patch) | |
tree | ef6c0e6e252224b9d8d8f3501d133f832dc3992a | |
parent | e029b65eceef49f3cf5a29d612dde0c184f74287 (diff) |
cleaned up print_friendlist(), it now prints a message if you have _no_ friends
-rw-r--r-- | testing/nTox.c | 14 |
1 files 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) | |||
82 | void print_friendlist() | 82 | void print_friendlist() |
83 | { | 83 | { |
84 | char name[MAX_NAME_LENGTH]; | 84 | char name[MAX_NAME_LENGTH]; |
85 | int i = 0; | ||
85 | new_lines("[i] Friend List:"); | 86 | new_lines("[i] Friend List:"); |
86 | uint32_t i; | 87 | while(getname(i++, (uint8_t *)name) != -1) { |
87 | for (i = 0; i <= num_requests; i++) { | 88 | /* account for the longest name and the longest "base" string */ |
88 | char fstring[128]; | 89 | char fstring[MAX_NAME_LENGTH + strlen("[i] Friend: NULL\n\tid: ")]; |
89 | getname(i, (uint8_t*)name); | 90 | |
90 | if (strlen(name) <= 0) { | 91 | if (strlen(name) <= 0) { |
91 | sprintf(fstring, "[i] Friend: NULL\n\tid: %i", i); | 92 | sprintf(fstring, "[i] Friend: No Friend!\n\tid: %i", i); |
92 | } else { | 93 | } else { |
93 | sprintf(fstring, "[i] Friend: %s\n\tid: %i", (uint8_t*)name, i); | 94 | sprintf(fstring, "[i] Friend: %s\n\tid: %i", (uint8_t*)name, i); |
94 | } | 95 | } |
95 | new_lines(fstring); | 96 | new_lines(fstring); |
96 | } | 97 | } |
98 | |||
99 | if(i == 1) | ||
100 | new_lines("\tno friends! D:"); | ||
97 | } | 101 | } |
98 | 102 | ||
99 | char *format_message(char *message, int friendnum) | 103 | char *format_message(char *message, int friendnum) |