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

View file

@ -55,6 +55,9 @@ server irc.example.org 6667
server <host> [port] [ssl|tls]
```
An optional `name <display name>` line below `server` sets its label in the
channel tree. The label defaults to the hostname.
The port defaults to `6667`. The optional third token `ssl` or `tls` enables
TLS; use port `6697` for Libera and OFTC. A `sasl <user> <pass>` line applies to
the most recent `server` line and enables SASL PLAIN for that server only. The

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;

View file

@ -11,10 +11,12 @@ real Armin
# user is your account name. An optional autocommand sends one raw IRC command
# after registration on the server above it, before startup channel joins.
server irc.libera.chat 6697 ssl
# name Libera Chat
# sasl armin my-sasl-password
# autocommand PRIVMSG NickServ :STATUS armin
server irc.oftc.net 6697 ssl
# name OFTC
# sasl armin my-sasl-password
# autocommand PRIVMSG NickServ :STATUS armin