about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--chat.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/chat.h b/chat.h
index be3952c..fc5043d 100644
--- a/chat.h
+++ b/chat.h
@@ -16,6 +16,7 @@
 
 #include <err.h>
 #include <stdbool.h>
+#include <stdint.h>
 #include <string.h>
 #include <sysexits.h>
 #include <time.h>
@@ -93,6 +94,16 @@ enum Color {
 	Yellow, LightGreen, Cyan, LightCyan, LightBlue, Pink, Gray, LightGray,
 	Default = 99,
 };
+static inline enum Color hash(const char *str) {
+	if (*str == '~') str++;
+	uint32_t hash = 0;
+	for (; *str; ++str) {
+		hash = (hash << 5) | (hash >> 27);
+		hash ^= *str;
+		hash *= 0x27220A95;
+	}
+	return 2 + hash % 14;
+}
 
 void ircConfig(bool insecure, const char *cert, const char *priv);
 int ircConnect(const char *host, const char *port);
atgirl/commit/ui.c?h=1.3&id=cc80fae758c392807dc0cea6ab2e7f78804b6712&follow=1'>Set self.nick to * initiallyJune McEnroe 2020-02-11Define ColorCap instead of hardcoding 100June McEnroe 2020-02-11Move hash to top of chat.hJune McEnroe 2020-02-11Move base64 out of chat.hJune McEnroe 2020-02-11Move XDG_SUBDIR out of chat.hJune McEnroe 2020-02-11Fix whois idle unit calculationJune McEnroe 2020-02-11Cast towupper to wchar_tJune McEnroe 2020-02-11Cast set but unused variables to voidJune McEnroe 2020-02-11Declare strlcatJune McEnroe 2020-02-11Check if VDSUSP existsJune McEnroe 2020-02-11Fix completeReplace iterationJune McEnroe 2020-02-11Use pkg(8) to configure on FreeBSDJune McEnroe 2020-02-11Remove legacy codeJune McEnroe 2020-02-11Add INSTALLING section to READMEJune McEnroe