diff options
| author | Sam Varshavchik | 2013-08-19 16:39:41 -0400 | 
|---|---|---|
| committer | Sam Varshavchik | 2013-08-25 14:43:51 -0400 | 
| commit | 9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch) | |
| tree | 7a81a04cb51efb078ee350859a64be2ebc6b8813 /gpglib/mimegpgstack.c | |
| parent | a9520698b770168d1f33d6301463bb70a19655ec (diff) | |
| download | courier-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 'gpglib/mimegpgstack.c')
| -rw-r--r-- | gpglib/mimegpgstack.c | 72 | 
1 files changed, 72 insertions, 0 deletions
| diff --git a/gpglib/mimegpgstack.c b/gpglib/mimegpgstack.c new file mode 100644 index 0000000..0eb61d9 --- /dev/null +++ b/gpglib/mimegpgstack.c @@ -0,0 +1,72 @@ +/* +** Copyright 2001 Double Precision, Inc.  See COPYING for +** distribution information. +*/ + + +#include "config.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <ctype.h> +#include "mimegpgstack.h" + +int libmail_mimestack_push(struct mimestack **s, const char *b) +{ +	struct mimestack *ss=(struct mimestack *) +		malloc(sizeof(**s)); + +	if (!ss) +		return -1; + +	if ((ss->boundary=strdup(b)) == NULL) +	{ +		free(ss); +		return -1; +	} + +	ss->next= *s; +	*s=ss; +	return 0; +} + +void libmail_mimestack_pop(struct mimestack **p) +{ +	struct mimestack *pp= *p; + +	if (pp) +	{ +		*p=pp->next; +		free(pp->boundary); +		free(pp); +	} +} + +void libmail_mimestack_pop_to(struct mimestack **p, struct mimestack *s) +{ +	while (*p) +	{ +		int last=strcmp( (*p)->boundary, s->boundary) == 0; +		libmail_mimestack_pop(p); +		if (last) +			break; +	} +} + +struct mimestack *libmail_mimestack_search(struct mimestack *p, const char *c) +{ +	int l=strlen(c); + +	while (p) +	{ +		int ll=strlen(p->boundary); + +		if (l >= ll && strncasecmp(p->boundary, c, ll) == 0) +			break; +		p=p->next; +	} +	return (p); +} + + | 
