Back to index

courier  0.68.2
mimegpgstack.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 2001 Double Precision, Inc.  See COPYING for
00003 ** distribution information.
00004 */
00005 
00006 
00007 #include "config.h"
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include <string.h>
00011 #include <errno.h>
00012 #include <ctype.h>
00013 #include "mimegpgstack.h"
00014 
00015 int libmail_mimestack_push(struct mimestack **s, const char *b)
00016 {
00017        struct mimestack *ss=(struct mimestack *)
00018               malloc(sizeof(**s));
00019 
00020        if (!ss)
00021               return -1;
00022 
00023        if ((ss->boundary=strdup(b)) == NULL)
00024        {
00025               free(ss);
00026               return -1;
00027        }
00028 
00029        ss->next= *s;
00030        *s=ss;
00031        return 0;
00032 }
00033 
00034 void libmail_mimestack_pop(struct mimestack **p)
00035 {
00036        struct mimestack *pp= *p;
00037 
00038        if (pp)
00039        {
00040               *p=pp->next;
00041               free(pp->boundary);
00042               free(pp);
00043        }
00044 }
00045 
00046 void libmail_mimestack_pop_to(struct mimestack **p, struct mimestack *s)
00047 {
00048        while (*p)
00049        {
00050               int last=strcmp( (*p)->boundary, s->boundary) == 0;
00051               libmail_mimestack_pop(p);
00052               if (last)
00053                      break;
00054        }
00055 }
00056 
00057 struct mimestack *libmail_mimestack_search(struct mimestack *p, const char *c)
00058 {
00059        int l=strlen(c);
00060 
00061        while (p)
00062        {
00063               int ll=strlen(p->boundary);
00064 
00065               if (l >= ll && strncasecmp(p->boundary, c, ll) == 0)
00066                      break;
00067               p=p->next;
00068        }
00069        return (p);
00070 }
00071 
00072