Back to index

courier  0.68.2
rfc2045searchcontenttype.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 2000 Double Precision, Inc.  See COPYING for
00003 ** distribution information.
00004 */
00005 
00006 #include "rfc2045_config.h"
00007 #include      "rfc2045.h"
00008 
00009 
00010 /*
00011 ** This function is generally called to find the "primary" text/plain
00012 ** section in a MIME message which, presumably, contains the main message
00013 ** text.
00014 **
00015 ** Still the content type is set as a parameter in the event, I guess, we'll
00016 ** ever be able to grok text/html.
00017 **
00018 ** We'll return a NULL pointer if we can't find it.
00019 */
00020 
00021 struct rfc2045 *rfc2045_searchcontenttype(struct rfc2045 *rfc, const char *ct)
00022 {
00023        const  char *content_type, *dummy;
00024        struct rfc2045 *p;
00025 
00026         rfc2045_mimeinfo(rfc, &content_type, &dummy, &dummy);
00027        if (strcmp(content_type, ct) == 0)
00028               return (rfc);
00029 
00030        for (p=rfc->firstpart; p; p=p->next)
00031        {
00032               if (p->isdummy)      continue;
00033               rfc2045_mimeinfo(p, &content_type, &dummy, &dummy);
00034               if (strcmp(content_type, ct) == 0)
00035                      break;
00036               if (strncmp(content_type, "multipart/", 10) == 0)
00037                      return(rfc2045_searchcontenttype(p, ct));
00038        }
00039 
00040        return (p);
00041 }