* Brought over a utility function I'll need later
authorArt Cancro <ajc@citadel.org>
Thu, 23 May 2002 03:40:05 +0000 (03:40 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 23 May 2002 03:40:05 +0000 (03:40 +0000)
webcit/ChangeLog
webcit/tools.c
webcit/webcit.h

index 0a2eb9c714751f835d09430f6e9cd577eb2924a4..5a6d027af3f9035d7b5cb4e64791b03df72ed9f8 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 323.38  2002/05/23 03:40:05  ajc
+* Brought over a utility function I'll need later
+
 Revision 323.37  2002/05/22 02:34:56  ajc
 * Finished room/folder view selector.  Pretty cool.
 
@@ -828,3 +831,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 3d0080630bda47adf7dd35502f4b0fe9ae2557b2..a5b943b27843521b1b022e7e2de954d7f68bd8aa 100644 (file)
@@ -291,5 +291,40 @@ void striplt(char *buf)
 }
 
 
+/*
+ * Determine whether the specified message number is contained within the
+ * specified set.
+ */
+int is_msg_in_mset(char *mset, long msgnum) {
+       int num_sets;
+       int s;
+       char setstr[SIZ], lostr[SIZ], histr[SIZ];       /* was 1024 */
+       long lo, hi;
+
+       /*
+        * Now set it for all specified messages.
+        */
+       num_sets = num_tokens(mset, ',');
+       for (s=0; s<num_sets; ++s) {
+               extract_token(setstr, mset, s, ',');
+
+               extract_token(lostr, setstr, 0, ':');
+               if (num_tokens(setstr, ':') >= 2) {
+                       extract_token(histr, setstr, 1, ':');
+                       if (!strcmp(histr, "*")) {
+                               snprintf(histr, sizeof histr, "%ld", LONG_MAX);
+                       }
+               } 
+               else {
+                       strcpy(histr, lostr);
+               }
+               lo = atol(lostr);
+               hi = atol(histr);
+
+               if ((msgnum >= lo) && (msgnum <= hi)) return(1);
+       }
+
+       return(0);
+}
 
 
index 26d57e158d1cc54e9fd189b9ef2b430d73bc506a..f8cb1e5edd4c19245eb8b78f73ca291c7be2b202 100644 (file)
@@ -307,3 +307,4 @@ void save_preferences(void);
 void get_preference(char *key, char *value);
 void set_preference(char *key, char *value);
 void knrooms(void);
+int is_msg_in_mset(char *mset, long msgnum);