cleanup some
[fillybot.git] / mod.h
blob861d8d3e57cf508d53677cc132ac862c55a11f21
1 #include "shared.h"
3 static inline char *token(char **foo, char sep)
5 char *line = *foo, *ret;
6 ret = line;
7 while (*line && *line != sep)
8 line++;
9 if (*line) {
10 *(line++) = 0;
11 while (*line == sep)
12 line++;
13 *foo = *line ? line : NULL;
14 } else
15 *foo = NULL;
16 return ret;
19 static inline unsigned getrand(void)
21 unsigned rand = 0;
22 int fd = open("/dev/urandom", O_RDONLY);
23 if (fd >= 0) {
24 read(fd, &rand, sizeof(rand));
25 close(fd);
26 return rand;
28 return random();
31 static unsigned admin(const char *host)
33 return host && (!strcmp(host, "equestria") || !strcmp(host, "is.best.ship"));
36 #define privmsg(b, who, contents, args...) b->writeline(b, "PRIVMSG %s :" contents, who, args)
37 #define privmsgs(b, who, contents) b->writeline(b, "PRIVMSG %s :" contents, who)
38 #define action(b, who, contents, args...) b->writeline(b, "PRIVMSG %s :\001ACTION " contents "\001", who, args)
39 #define actions(b, who, contents) b->writeline(b, "PRIVMSG %s :\001ACTION " contents "\001", who)