diff options
Diffstat (limited to 'maildirparsequota.c')
| -rw-r--r-- | maildirparsequota.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/maildirparsequota.c b/maildirparsequota.c new file mode 100644 index 0000000..35e7d99 --- /dev/null +++ b/maildirparsequota.c | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | /* | ||
| 2 | ** Copyright 1998 - 1999 Double Precision, Inc. | ||
| 3 | ** See COPYING for distribution information. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #if HAVE_CONFIG_H | ||
| 7 | #include "config.h" | ||
| 8 | #endif | ||
| 9 | #include "maildirquota.h" | ||
| 10 | #include <stdlib.h> | ||
| 11 | #include <string.h> | ||
| 12 | |||
| 13 | static const char rcsid[]="$Id: maildirparsequota.c,v 1.2 1999/12/06 13:21:05 mrsam Exp $"; | ||
| 14 | |||
| 15 | int maildir_parsequota(const char *n, unsigned long *s) | ||
| 16 | { | ||
| 17 | const char *o; | ||
| 18 | int yes; | ||
| 19 | |||
| 20 | if ((o=strrchr(n, '/')) == 0) o=n; | ||
| 21 | |||
| 22 | for (; *o; o++) | ||
| 23 | if (*o == ':') break; | ||
| 24 | yes=0; | ||
| 25 | for ( ; o >= n; --o) | ||
| 26 | { | ||
| 27 | if (*o == '/') break; | ||
| 28 | |||
| 29 | if (*o == ',' && o[1] == 'S' && o[2] == '=') | ||
| 30 | { | ||
| 31 | yes=1; | ||
| 32 | o += 3; | ||
| 33 | break; | ||
| 34 | } | ||
| 35 | } | ||
| 36 | if (yes) | ||
| 37 | { | ||
| 38 | *s=0; | ||
| 39 | while (*o >= '0' && *o <= '9') | ||
| 40 | *s= *s*10 + (*o++ - '0'); | ||
| 41 | return (0); | ||
| 42 | } | ||
| 43 | return (-1); | ||
| 44 | } | ||
