diff options
author | June McEnroe <june@causal.agency> | 2018-12-02 23:08:49 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-12-02 23:08:49 -0500 |
commit | 0e1297e068258baba6e26265d81b93bda71be8b2 (patch) | |
tree | d0e953245129e195fe59f14fe6d12f9a92365efc /chat.c | |
parent | Send automated messages to TagStatus with UICold (diff) | |
download | catgirl-0e1297e068258baba6e26265d81b93bda71be8b2.tar.gz catgirl-0e1297e068258baba6e26265d81b93bda71be8b2.zip |
Add -r option for realname
Diffstat (limited to '')
-rw-r--r-- | chat.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/chat.c b/chat.c index 152bf84..1de145d 100644 --- a/chat.c +++ b/chat.c @@ -25,20 +25,17 @@ #include "chat.h" +static void freedup(char **field, const char *str) { + free(*field); + *field = strdup(str); + if (!*field) err(EX_OSERR, "strdup"); +} + void selfNick(const char *nick) { - free(self.nick); - self.nick = strdup(nick); - if (!self.nick) err(EX_OSERR, "strdup"); + freedup(&self.nick, nick); } void selfUser(const char *user) { - free(self.user); - self.user = strdup(user); - if (!self.user) err(EX_OSERR, "strdup"); -} -void selfJoin(const char *join) { - free(self.join); - self.join = strdup(join); - if (!self.join) err(EX_OSERR, "strdup"); + freedup(&self.user, user); } static char *prompt(const char *prompt) { @@ -65,15 +62,16 @@ int main(int argc, char *argv[]) { char *webirc = NULL; int opt; - while (0 < (opt = getopt(argc, argv, "NW:h:j:l:n:p:u:vw:"))) { + while (0 < (opt = getopt(argc, argv, "NW:h:j:l:n:p:r:u:vw:"))) { switch (opt) { break; case 'N': self.notify = true; break; case 'W': webirc = strdup(optarg); break; case 'h': host = strdup(optarg); - break; case 'j': selfJoin(optarg); + break; case 'j': freedup(&self.join, optarg); break; case 'l': logOpen(optarg); break; case 'n': selfNick(optarg); break; case 'p': port = strdup(optarg); + break; case 'r': freedup(&self.real, optarg); break; case 'u': selfUser(optarg); break; case 'v': self.verbose = true; break; case 'w': pass = strdup(optarg); @@ -85,6 +83,7 @@ int main(int argc, char *argv[]) { if (!host) host = prompt("Host: "); if (!self.nick) self.nick = prompt("Name: "); if (!self.user) selfUser(self.nick); + if (!self.real) freedup(&self.real, self.nick); inputTab(); uiInit(); |