]> PatchyGit - patchyircd.git/commitdiff
move irc_glob to util.c
authorEgor <egor@patchysicp.xyz>
Thu, 19 Oct 2023 11:10:20 +0000 (14:10 +0300)
committerEgor <egor@patchysicp.xyz>
Thu, 19 Oct 2023 11:10:20 +0000 (14:10 +0300)
glob.c [deleted file]
irc.h
util.c
util.h

diff --git a/glob.c b/glob.c
deleted file mode 100644 (file)
index 22973c7..0000000
--- a/glob.c
+++ /dev/null
@@ -1,45 +0,0 @@
-// 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;
-}
diff --git a/irc.h b/irc.h
index 2ac5e2d..0a3ada2 100644 (file)
--- a/irc.h
+++ b/irc.h
@@ -18,7 +18,4 @@ void channel_sendnames(struct client_data *client, struct channel *chan);
 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
diff --git a/util.c b/util.c
index 2f9de8b..35b4bee 100644 (file)
--- a/util.c
+++ b/util.c
@@ -90,3 +90,49 @@ time_t get_time() {
 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;
+}
diff --git a/util.h b/util.h
index 15f98d1..e9ebc11 100644 (file)
--- a/util.h
+++ b/util.h
@@ -26,4 +26,5 @@ void stringlower(char *s);
 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