about summary refs log tree commit diff
path: root/chat.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-01-09 17:58:29 -0500
committerJune McEnroe <june@causal.agency>2021-01-09 17:58:29 -0500
commita324795b8610b7c3e5626ac72d202ce6207066d7 (patch)
tree4f340e00b8d3e6e637444f645f8b5856b77665df /chat.c
parentCount width of 2 for invalid multibyte with high bit (diff)
downloadcatgirl-a324795b8610b7c3e5626ac72d202ce6207066d7.tar.gz
catgirl-a324795b8610b7c3e5626ac72d202ce6207066d7.zip
Allow configuring the upper bound of the hash function
This allows limiting the nick colors used to the 16-color terminal set
without modifying the TERM environment variable. Produces different
results from just using the default configuration in a 16-color
terminal, but what can you do?
Diffstat (limited to '')
-rw-r--r--chat.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/chat.c b/chat.c
index 016d604..fd2b89a 100644
--- a/chat.c
+++ b/chat.c
@@ -87,8 +87,6 @@ static void exitSave(void) {
 	}
 }
 
-uint32_t hashInit;
-
 uint execID;
 int execPipe[2] = { -1, -1 };
 int utilPipe[2] = { -1, -1 };
@@ -117,6 +115,14 @@ static void utilRead(void) {
 	}
 }
 
+uint32_t hashInit;
+uint32_t hashBound = 75;
+
+static void parseHash(char *str) {
+	hashInit = strtoul(str, &str, 0);
+	if (*str) hashBound = strtoul(&str[1], NULL, 0);
+}
+
 static volatile sig_atomic_t signals[NSIG];
 static void signalHandler(int signal) {
 	signals[signal] = 1;
@@ -179,7 +185,7 @@ int main(int argc, char *argv[]) {
 		switch (opt) {
 			break; case '!': insecure = true;
 			break; case 'C': utilPush(&urlCopyUtil, optarg);
-			break; case 'H': hashInit = strtoul(optarg, NULL, 0);
+			break; case 'H': parseHash(optarg);
 			break; case 'N': utilPush(&uiNotifyUtil, optarg);
 			break; case 'O': utilPush(&urlOpenUtil, optarg);
 			break; case 'R': self.restricted = true;