From 9c45d9ad13fdf439d44d7443ae75da15ea0223ed Mon Sep 17 00:00:00 2001 From: Sam Varshavchik Date: Mon, 19 Aug 2013 16:39:41 -0400 Subject: Initial checkin Imported from subversion report, converted to git. Updated all paths in scripts and makefiles, reflecting the new directory hierarchy. --- gpglib/mimegpgstack.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 gpglib/mimegpgstack.c (limited to 'gpglib/mimegpgstack.c') 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 +#include +#include +#include +#include +#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); +} + + -- cgit v1.2.3