From fcbe7af1e2ac2abb71251a51f5384d22cad9a87a Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 11 Sep 2022 17:34:41 -0400 Subject: Generate /ops from cache --- chat.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'chat.h') diff --git a/chat.h b/chat.h index c7053c7..198b84e 100644 --- a/chat.h +++ b/chat.h @@ -168,6 +168,19 @@ extern struct Network { char invex; } network; +static inline uint prefixBit(char p) { + char *s = strchr(network.prefixes, p); + if (!s) return 0; + return 1 << (s - network.prefixes); +} + +static inline char bitPrefix(uint p) { + for (uint i = 0; network.prefixes[i]; ++i) { + if (p & (1 << i)) return network.prefixes[i]; + } + return '\0'; +} + #define ENUM_CAP \ X("causal.agency/consumer", CapConsumer) \ X("chghost", CapChghost) \ -- cgit 1.4.1-2-gfad0