+
+/*
+ * Given the on-disk representation of our Sieve config, load
+ * it into an in-memory data structure.
+ */
+void parse_sieve_config(char *conf, struct sdm_userdata *u) {
+ char *ptr;
+ char *c;
+
+ c = conf;
+ while (ptr = bmstrcasestr(conf, CTDLSIEVECONFIGSEPARATOR), ptr != NULL) {
+ *ptr = 0;
+ ptr += strlen(CTDLSIEVECONFIGSEPARATOR);
+
+ lprintf(CTDL_DEBUG, "CONFIG: <%s>\n", c);
+
+ /* FIXME finish this */
+
+ }
+}
+
+/*
+ * We found the Sieve configuration for this user.
+ * Now do something with it.
+ */
+void get_sieve_config_backend(long msgnum, void *userdata) {
+ struct sdm_userdata *u = (struct sdm_userdata *) userdata;
+ struct CtdlMessage *msg;
+ char *conf;
+
+ u->config_msgnum = msgnum;
+ msg = CtdlFetchMessage(u->config_msgnum, 1);
+ if (msg == NULL) {
+ u->config_msgnum = (-1) ;
+ return;
+ }
+
+ conf = msg->cm_fields['M'];
+ msg->cm_fields['M'] = NULL;
+ CtdlFreeMessage(msg);
+
+ if (conf != NULL) {
+ parse_sieve_config(conf, u);
+ free(conf);
+ }
+}
+
+
+/*
+ * Write our citadel sieve config back to disk
+ */
+void rewrite_ctdl_sieve_config(struct sdm_userdata *u) {
+ char *text;
+
+ text =
+ "Content-type: application/x-citadel-sieve-config\n"
+ "\n"
+ ;
+
+ /* Save the config */
+ quickie_message("Citadel", NULL, u->config_roomname,
+ text,
+ 4,
+ "Sieve configuration"
+ );
+
+ /* And delete the old one */
+ CtdlDeleteMessages(u->config_roomname, &u->config_msgnum, 1, "", 0);
+
+}
+
+
+