diff options
author | June McEnroe <june@causal.agency> | 2020-02-10 05:50:28 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-02-10 05:50:28 -0500 |
commit | 0d93e66a68ded28440e20cd7012b4e8b0c705fc6 (patch) | |
tree | 110b83877027e09361e2d361e94a57ead6524fca | |
parent | Hash to colors in the range 2-75 (diff) | |
download | test-0d93e66a68ded28440e20cd7012b4e8b0c705fc6.tar.gz test-0d93e66a68ded28440e20cd7012b4e8b0c705fc6.zip |
Add -H
-rw-r--r-- | catgirl.1 | 7 | ||||
-rw-r--r-- | chat.c | 7 | ||||
-rw-r--r-- | chat.h | 3 |
3 files changed, 14 insertions, 3 deletions
diff --git a/catgirl.1 b/catgirl.1 index 5e333a8..15b387b 100644 --- a/catgirl.1 +++ b/catgirl.1 @@ -1,4 +1,4 @@ -.Dd February 9, 2020 +.Dd February 10, 2020 .Dt CATGIRL 1 .Os . @@ -10,6 +10,7 @@ .Nm .Op Fl ev .Op Fl C Ar copy +.Op Fl H Ar hash .Op Fl O Ar open .Op Fl a Ar auth .Op Fl c Ar cert @@ -57,6 +58,10 @@ The default is the first available of .Xr xclip 1 , .Xr xsel 1 . . +.It Fl H Ar hash , Cm hash = Ar hash +Set the initial value of +the nick color hash function. +. .It Fl O Ar util , Cm open = Ar util Set the utility used by .Ic /open . diff --git a/chat.c b/chat.c index ff74485..c58fdc5 100644 --- a/chat.c +++ b/chat.c @@ -21,6 +21,7 @@ #include <poll.h> #include <signal.h> #include <stdbool.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -46,6 +47,8 @@ size_t idNext = Network + 1; struct Self self = { .color = Default }; +uint32_t hashInit; + int procPipe[2] = { -1, -1 }; static void pipeRead(void) { @@ -81,10 +84,11 @@ int main(int argc, char *argv[]) { const char *user = NULL; const char *real = NULL; - const char *Opts = "!C:O:a:c:eh:j:k:n:p:r:u:vw:"; + const char *Opts = "!C:H:O:a:c:eh:j:k:n:p:r:u:vw:"; const struct option LongOpts[] = { { "insecure", no_argument, NULL, '!' }, { "copy", required_argument, NULL, 'C' }, + { "hash", required_argument, NULL, 'H' }, { "open", required_argument, NULL, 'O' }, { "sasl-plain", required_argument, NULL, 'a' }, { "cert", required_argument, NULL, 'c' }, @@ -106,6 +110,7 @@ int main(int argc, char *argv[]) { switch (opt) { break; case '!': insecure = true; break; case 'C': urlCopyUtil = optarg; + break; case 'H': hashInit = strtoul(optarg, NULL, 0); break; case 'O': urlOpenUtil = optarg; break; case 'a': sasl = true; self.plain = optarg; break; case 'c': cert = optarg; diff --git a/chat.h b/chat.h index e7bb9cc..16cc683 100644 --- a/chat.h +++ b/chat.h @@ -190,9 +190,10 @@ int getopt_config( const char *optstring, const struct option *longopts, int *longindex ); +extern uint32_t hashInit; static inline enum Color hash(const char *str) { if (*str == '~') str++; - uint32_t hash = 0; + uint32_t hash = hashInit; for (; *str; ++str) { hash = (hash << 5) | (hash >> 27); hash ^= *str; |