Back to index

courier  0.68.2
comrwmsg7bit.c
Go to the documentation of this file.
00001 #if    HAVE_CONFIG_H
00002 #include      "courier_lib_config.h"
00003 #endif
00004 #include      "courier.h"
00005 #include      "rw.h"
00006 #include      "rwint.h"
00007 #include      "rfc2045/rfc2045.h"
00008 #if    HAVE_UNISTD_H
00009 #include      <unistd.h>
00010 #endif
00011 
00012 static int call_rw_rewrite_msgheaders(const char *p, int l,
00013        void *msginfo)
00014 {
00015        if (rw_rewrite_msgheaders(p, l, (struct rwmsginfo *)msginfo))
00016               return (0);
00017        return (l);
00018 }
00019 
00020 int rw_rewrite_msg_7bit(int fp,
00021        struct rfc2045 *rfcp,
00022        int (*writefunc)(const char *p, unsigned l, void *),
00023        void (*rewritefunc)(struct rw_info *,
00024               void (*)(struct rw_info *), void *),
00025        void *arg
00026        )
00027 {
00028        struct rwmsginfo rwinfo;
00029        int    i, j;
00030        struct rfc2045src *src;
00031 
00032        rw_rewrite_msg_init(&rwinfo, writefunc, rewritefunc, arg);
00033 
00034        src=rfc2045src_init_fd(fp);
00035 
00036        if (src)
00037        {
00038               j=rfc2045_rewrite_func(rfcp, src,
00039                                    &call_rw_rewrite_msgheaders, &rwinfo,
00040                                    "courier " COURIER_VERSION);
00041               rfc2045src_deinit(src);
00042        }
00043        else
00044               j= -1;
00045 
00046        if ((i=rw_rewrite_msg_finish(&rwinfo)) != 0)
00047               j=i;
00048        return (j);
00049 }