File: maildirparsequota.c

package info (click to toggle)
maildrop 0.75-2.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,760 kB
  • ctags: 1,588
  • sloc: cpp: 9,269; ansic: 6,018; perl: 786; sh: 467; makefile: 398
file content (48 lines) | stat: -rw-r--r-- 1,349 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* DSTART                                                                    */
/*                                                                           */
/*           maildrop - mail delivery agent with filtering abilities         */
/*                                                                           */
/*  Copyright 1998-1999, Double Precision Inc.                               */
/*                                                                           */
/*  This program is distributed under the terms of the GNU General Public    */
/*  License. See COPYING for additional information.                         */
/* DEND                                                                      */
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include	"maildirquota.h"
#include	<stdlib.h>
#include	<string.h>

static const char rcsid[]="$Id: maildirparsequota.c,v 1.1 1999/08/19 02:05:20 mrsam Exp $";

int maildir_parsequota(const char *n, unsigned long *s)
{
const char *o;
int	yes;

	if ((o=strrchr(n, '/')) == 0)	o=n;

	for (; *o; o++)
		if (*o == ':')	break;
	yes=0;
	for ( ; o >= n; --o)
	{
		if (*o == '/')	break;

		if (*o == ',' && o[1] == 'S' && o[2] == '=')
		{
			yes=1;
			o += 3;
			break;
		}
	}
	if (yes)
	{
		*s=0;
		while (*o >= '0' && *o <= '9')
			*s= *s*10 + (*o++ - '0');
		return (0);
	}
	return (-1);
}