summaryrefslogtreecommitdiffstats
path: root/maildir/maildirrequota.c
diff options
context:
space:
mode:
authorSam Varshavchik2013-08-19 16:39:41 -0400
committerSam Varshavchik2013-08-25 14:43:51 -0400
commit9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch)
tree7a81a04cb51efb078ee350859a64be2ebc6b8813 /maildir/maildirrequota.c
parenta9520698b770168d1f33d6301463bb70a19655ec (diff)
downloadcourier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2
Initial checkin
Imported from subversion report, converted to git. Updated all paths in scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'maildir/maildirrequota.c')
-rw-r--r--maildir/maildirrequota.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/maildir/maildirrequota.c b/maildir/maildirrequota.c
new file mode 100644
index 0000000..f4dd284
--- /dev/null
+++ b/maildir/maildirrequota.c
@@ -0,0 +1,42 @@
+/*
+** Copyright 1998 - 2002 Double Precision, Inc.
+** See COPYING for distribution information.
+*/
+
+#include "config.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "maildirrequota.h"
+
+
+char *maildir_requota(const char *oldname, unsigned long s)
+{
+char buf[40];
+char *p;
+const char *q;
+
+ sprintf(buf, ",S=%lu", s);
+
+ if ((p=malloc(strlen(oldname)+strlen(buf)+1)) == 0) return (0);
+
+ if ((q=strrchr(oldname, '/')) == 0) q=oldname;
+ while (*q)
+ {
+ if ((*q == ',' && q[1] == 'S' && q[2] == '=') || *q == MDIRSEP[0])
+ {
+ memcpy(p, oldname, q-oldname);
+ strcpy(p + (q-oldname), buf);
+
+ if (*q == ',') q += 3;
+
+ for ( ; isdigit((int)(unsigned char)*q); q++)
+ ;
+ strcat(p, q);
+ return (p);
+ }
+ ++q;
+ }
+ return (strcat(strcpy(p, oldname), buf));
+}