Back to index

courier  0.68.2
rfc2045decode.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 1998 - 1999 Double Precision, Inc.  See COPYING for
00003 ** distribution information.
00004 */
00005 
00006 /*
00007 */
00008 #include      "rfc2045.h"
00009 
00010 static void decode(struct rfc2045id *topid,
00011               struct rfc2045id **childidptr,
00012               struct rfc2045 *r,
00013               void (*func)(struct rfc2045 *, struct rfc2045id *, void *),
00014               void *ptr)
00015 {
00016 struct rfc2045id nextid;
00017 
00018        *childidptr=0;
00019        (*func)(r, topid, ptr);
00020        *childidptr=&nextid;
00021        nextid.idnum=1;
00022        if (r->content_type && strncmp(r->content_type, "multipart/", 10) == 0)
00023               nextid.idnum=0;
00024        for (r=r->firstpart; r; r=r->next)
00025        {
00026               if (nextid.idnum)
00027                      decode(topid, &nextid.next, r, func, ptr);
00028               ++nextid.idnum;
00029        }
00030 }
00031 
00032 void rfc2045_decode(struct rfc2045 *p,
00033        void (*func)(struct rfc2045 *, struct rfc2045id *, void *),
00034        void *ptr)
00035 {
00036 struct rfc2045id topid;
00037 
00038        topid.idnum=1;
00039        decode(&topid, &topid.next, p, func, ptr);
00040 }