diff options
Diffstat (limited to 'overmaildirquota.c')
| -rw-r--r-- | overmaildirquota.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/overmaildirquota.c b/overmaildirquota.c new file mode 100644 index 0000000..5e1877c --- /dev/null +++ b/overmaildirquota.c | |||
| @@ -0,0 +1,43 @@ | |||
| 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 | #include <errno.h> | ||
| 13 | #include <sys/stat.h> | ||
| 14 | |||
| 15 | static const char rcsid[]="$Id: overquota.c,v 1.0 2002/06/09 16:21:05 mr \ | ||
| 16 | sam Exp $"; | ||
| 17 | |||
| 18 | |||
| 19 | int user_over_maildirquota( const char *dir, const char *q) | ||
| 20 | { | ||
| 21 | struct stat stat_buf; | ||
| 22 | int quotafd; | ||
| 23 | int ret_value; | ||
| 24 | |||
| 25 | if (fstat(0, &stat_buf) == 0 && S_ISREG(stat_buf.st_mode) && | ||
| 26 | stat_buf.st_size > 0 && *q) | ||
| 27 | { | ||
| 28 | if (maildir_checkquota(dir, "afd, q, stat_buf.st_size, 1) | ||
| 29 | && errno != EAGAIN) | ||
| 30 | { | ||
| 31 | if (quotafd >= 0) close(quotafd); | ||
| 32 | ret_value = 1; | ||
| 33 | } else { | ||
| 34 | maildir_addquota(dir, quotafd, q, stat_buf.st_size, 1); | ||
| 35 | if (quotafd >= 0) close(quotafd); | ||
| 36 | ret_value = 0; | ||
| 37 | } | ||
| 38 | } else { | ||
| 39 | ret_value = 0; | ||
| 40 | } | ||
| 41 | |||
| 42 | return(ret_value); | ||
| 43 | } | ||
