5 static inline char *token(char **foo
, char sep
)
7 char *line
= *foo
, *ret
;
11 while (*line
&& *line
!= sep
)
17 *foo
= *line
? line
: NULL
;
23 static inline unsigned getrand(void)
26 int fd
= open("/dev/urandom", O_RDONLY
);
28 read(fd
, &rand
, sizeof(rand
));
38 void (*cmd
)(struct bio
*b
, const char *nick
, const char *host
, const char *target
, char *args
);
40 char failed_command
[];
41 } __attribute__((aligned(256)));
43 static unsigned strhash(const char *h
)
45 TDB_DATA in
= { .dptr
= (char*)h
, .dsize
= strlen(h
) };
46 return tdb_jenkins_hash(&in
);
49 static void __attribute__ ((__format__(__printf__
, 3, 4))) privmsg(struct bio
*b
, const char *who
, const char *fmt
, ...)
55 vasprintf(&buffer
, fmt
, va
);
59 b
->writeline(b
, "PRIVMSG %s :\00301,01%s", who
, buffer
);
61 b
->writeline(b
, "PRIVMSG %s :%s", who
, buffer
);
65 static void __attribute__ ((__format__(__printf__
, 3, 4))) action(struct bio
*b
, const char *who
, const char *fmt
, ...)
71 vasprintf(&buffer
, fmt
, va
);
75 b
->writeline(b
, "PRIVMSG %s :\001ACTION \00301,01%s\001", who
, buffer
);
77 b
->writeline(b
, "PRIVMSG %s :\001ACTION %s\001", who
, buffer
);