blob: 0eb61d9904f7ae22439c168bb7edb0091b81b33c (
plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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);
}
|