1
0
Fork 0
forked from murx/irc9

Add optional server names to the channel tree

This commit is contained in:
Johannes Findeisen 2026-11-27 21:34:07 +01:00
commit ab170467a5
3 changed files with 21 additions and 1 deletions

17
irc9.c
View file

@ -89,6 +89,7 @@ typedef struct AutojoinChannel {
typedef struct Server {
char host[HOSTLEN];
char *name;
int port;
char nick[NICKLEN];
char user[NICKLEN];
@ -569,6 +570,19 @@ static void load_config(const char *path)
char *save = NULL;
key = strtok_r(p, " \t", &save);
if (!key) continue;
if (strcasecmp(key, "name") == 0) {
save += strspn(save, " \t");
size_t len = strlen(save);
while (len && (save[len - 1] == ' ' || save[len - 1] == '\t'))
save[--len] = 0;
if (last && *save) {
free(last->name);
last->name = dupstr(save);
} else {
fprintf(stderr, "irc9: name requires a server and a display name\n");
}
continue;
}
if (strcasecmp(key, "autocommand") == 0) {
save += strspn(save, " \t");
if (last && *save && strlen(save) <= MAXLINE - 2 &&
@ -2176,7 +2190,7 @@ static void draw_tree(void)
terminal_move(y, 1);
fputs(selected ? (terminal_color ? "\033[1;4m" : "\033[7m") : "\033[1m", stdout);
printf("%c ", s->connected ? '*' : ' ');
terminal_text(s->host, treew - 4);
terminal_text(s->name ? s->name : s->host, treew - 4);
fputs("\033[0m", stdout);
}
y++;
@ -2637,6 +2651,7 @@ int main(int argc, char **argv)
free(channel);
}
#endif
free(s->name);
free(s->autocommand);
free(s);
s = sn;