Back to index

courier  0.68.2
comrwmsg8bit.c
Go to the documentation of this file.
00001 #include      "courier.h"
00002 #include      "rw.h"
00003 #include      "rwint.h"
00004 #if    HAVE_UNISTD_H
00005 #include      <unistd.h>
00006 #endif
00007 
00008 int rw_rewrite_msg(int fp,
00009        int (*writefunc)(const char *p, unsigned l, void *),
00010        void (*rewritefunc)(struct rw_info *,
00011               void (*)(struct rw_info *), void *),
00012        void *arg
00013        )
00014 {
00015 struct rwmsginfo rwinfo;
00016 char   buffer[BUFSIZ];
00017 int    i, j;
00018 
00019        rw_rewrite_msg_init(&rwinfo, writefunc, rewritefunc, arg);
00020 
00021        while ((j=read(fp, buffer, sizeof(buffer))) > 0)
00022        {
00023               if (rw_rewrite_msgheaders(buffer, j, &rwinfo) < 0)
00024               {
00025                      j= -1;
00026                      break;
00027               }
00028        }
00029 
00030        if ((i=rw_rewrite_msg_finish(&rwinfo)) != 0)
00031               j=i;
00032        return (j);
00033 }