+++ /dev/null
-// https://research.swtch.com/glob
-int irc_glob(const char *key, const char *mask)
-{
- const char *key2 = 0, *mask2 = 0;
- while (*key || *mask) {
- if (*mask) {
- switch (*mask) {
- case '\\':
- if (*key == *mask) {
- key++, mask++;
- if (!*mask)
- continue;
- if (*key == *mask) {
- key++, mask++;
- continue;
- }
- }
- break;
- default:
- if (*key == *mask) {
- key++, mask++;
- continue;
- }
- break;
- case '?':
- if (*key) {
- key++, mask++;
- continue;
- }
- break;
- case '*':
- key2 = *key ? key + 1 : 0;
- mask2 = mask++;
- continue;
- }
- }
- if (key2) {
- key = key2;
- mask = mask2;
- continue;
- }
- return 0;
- }
- return 1;
-}
void channel_join(struct client_data *client, const char *channel, const char *chankey);
void channel_part(struct client_data *client, struct channel *chan, const char *reason, struct client_data *kicker);
extern struct dynarr databuf;
-
-// glob.c
-int irc_glob(const char *key, const char *mask);
#endif
void set_time(time_t t) {
faketime = t;
}
+
+/* https://research.swtch.com/glob */
+int irc_glob(const char *key, const char *mask)
+{
+ const char *key2 = 0, *mask2 = 0;
+ while (*key || *mask) {
+ if (*mask) {
+ switch (*mask) {
+ case '\\':
+ if (*key == *mask) {
+ key++, mask++;
+ if (!*mask)
+ continue;
+ if (*key == *mask) {
+ key++, mask++;
+ continue;
+ }
+ }
+ break;
+ default:
+ if (*key == *mask) {
+ key++, mask++;
+ continue;
+ }
+ break;
+ case '?':
+ if (*key) {
+ key++, mask++;
+ continue;
+ }
+ break;
+ case '*':
+ key2 = *key ? key + 1 : 0;
+ mask2 = mask++;
+ continue;
+ }
+ }
+ if (key2) {
+ key = key2;
+ mask = mask2;
+ continue;
+ }
+ return 0;
+ }
+ return 1;
+}
char *mystrdup(const char *s);
time_t get_time();
void set_time(time_t t);
+int irc_glob(const char *key, const char *mask);
#endif