]> code.citadel.org Git - citadel.git/blobdiff - webcit/tools.c
* Display PARTSTAT for attendees
[citadel.git] / webcit / tools.c
index 647c2fefc0b9cc4198c894ddf1842684791b7187..6912515cae5e1e73393c7ad88cbeb2a8de6d4977 100644 (file)
@@ -376,3 +376,35 @@ void read_server_binary(char *buffer, size_t total_len) {
                }
        }
 }
+
+
+
+/*
+ * Strip a boundarized substring out of a string (for example, remove
+ * parentheses and anything inside them).
+ *
+ * This improved version can strip out *multiple* boundarized substrings.
+ */
+void stripout(char *str, char leftboundary, char rightboundary) {
+       int a;
+        int lb = (-1);
+        int rb = (-1);
+
+       do {
+               lb = (-1);
+               rb = (-1);
+       
+               for (a = 0; a < strlen(str); ++a) {
+                       if (str[a] == leftboundary) lb = a;
+                       if (str[a] == rightboundary) rb = a;
+               }
+
+               if ( (lb > 0) && (rb > lb) ) {
+                       strcpy(&str[lb - 1], &str[rb + 1]);
+               }
+
+       } while ( (lb > 0) && (rb > lb) );
+
+}
+
+