Hi!

I tried to modify courier 0.37.3 code to allow globalfilters to modify the
D* file.
It seems I missed something, please check the code below if somebody has
time :-)


Dobos Sandor
IBCnet Hungary Ltd.


<snip><snip><snip><snip><snip><snip><snip><snip><snip>
--- rfc2045/rfc2045_fromfd.c.bck   Wed Dec 15 23:27:57 1999
+++ rfc2045/rfc2045_fromfd.c  Thu Apr  4 16:18:59 2002
@@ -19,7 +19,7 @@

 /* Convert a message to the RFC2045 structure */

-struct rfc2045 *rfc2045_fromfd(int fd)
+struct rfc2045 *rfc2045_fromfd_x(int fd,int ac)
 {
 struct   rfc2045   *rfc;
 char     buf[BUFSIZ];
@@ -28,7 +28,11 @@

     if ((orig_pos=lseek(fd, 0L, SEEK_CUR)) == (off_t)-1) return (NULL);
     if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1)    return (NULL);
-    if ((rfc=rfc2045_alloc()) == 0)     return (NULL);
+    if (ac) {
+         if ((rfc=rfc2045_alloc_ac()) == 0)  return (NULL);
+    } else {
+         if ((rfc=rfc2045_alloc()) == 0)     return (NULL);
+    }

     while ((n=read(fd, buf, sizeof(buf))) > 0)
          rfc2045_parse(rfc, buf, n);
--- courier/submit.h.bck Sun Aug  5 22:01:35 2001
+++ courier/submit.h     Thu Apr  4 15:23:27 2002
@@ -77,6 +77,7 @@

 class SubmitFile {
 private:
+    int chkmsg(int *,char**,char**);

 static   SubmitFile *current_submit_file;

--- courier/submit2.C.bck     Wed Feb 20 14:10:54 2002
+++ courier/submit2.C    Thu Apr  4 16:21:02 2002
@@ -771,20 +771,14 @@
 }


-/* ------------ */

-int SubmitFile::MessageEnd(unsigned rcptnum, int iswhitelisted)
+int SubmitFile::chkmsg(int * dorewriteptr, char ** mimeptr, char **
rfcerrptr)
 {
-int is8bit=0, dorewrite=0, rwmode=0;
-const    char *mime=getenv("MIME");
-unsigned n;
-struct   stat stat_buf;
-const char *rfcerr=NULL;
-const char *bofhbadmime=getenv("BOFHBADMIME");
-int bofhbadmimebounce= bofhbadmime && strcmp(bofhbadmime, "reject") == 0;
-int bofhbadmimeaccept= bofhbadmime && strcmp(bofhbadmime, "accept") == 0;
+    const char *bofhbadmime=getenv("BOFHBADMIME");
+    int bofhbadmimebounce= bofhbadmime && strcmp(bofhbadmime, "reject")
== 0;
+    int bofhbadmimeaccept= bofhbadmime && strcmp(bofhbadmime, "accept")
== 0;

-    if (sizelimit && bytecount > sizelimit)
+    if (sizelimit && bytecount > sizelimit)
     {
          cout << "523 Message length exceeds administrative limit."
               << endl << flush;
@@ -805,8 +799,8 @@

     if (rwrfcptr->rfcviolation & RFC2045_ERR8BITHEADER)
     {
-         rfcerr= SYSCONFDIR "/rfcerr2047.txt";
-         dorewrite=1;
+         *rfcerrptr= SYSCONFDIR "/rfcerr2047.txt";
+         *dorewriteptr=1;

          if (bofhbadmimebounce)
          {
@@ -819,14 +813,14 @@

          if (bofhbadmimeaccept)
          {
-              dorewrite=0;
-              mime="none";
+              *dorewriteptr=0;
+              *mimeptr="none";
          }
         }
     else if (rwrfcptr->rfcviolation & RFC2045_ERR8BITCONTENT)
     {
-         rfcerr= SYSCONFDIR "/rfcerr2045.txt";
-         dorewrite=1;
+         *rfcerrptr= SYSCONFDIR "/rfcerr2045.txt";
+         *dorewriteptr=1;

          if (bofhbadmimebounce)
          {
@@ -840,14 +834,14 @@

          if (bofhbadmimeaccept)
          {
-              dorewrite=0;
-              mime="none";
+              *dorewriteptr=0;
+              *mimeptr="none";
          }
         }
     else if (rwrfcptr->rfcviolation & RFC2045_ERRBADBOUNDARY)
     {
-         rfcerr= SYSCONFDIR "/rfcerr2046.txt";
-         dorewrite=1;
+         *rfcerrptr= SYSCONFDIR "/rfcerr2046.txt";
+         *dorewriteptr=1;

          if (bofhbadmimebounce)
          {
@@ -860,8 +854,8 @@

          if (bofhbadmimeaccept)
          {
-              dorewrite=0;
-              mime="none";
+              *dorewriteptr=0;
+              *mimeptr="none";
          }
         }
     else
@@ -871,6 +865,27 @@
                    "550 Message MIME complexity exceeds the policy
maximum.\n";
          return (1);
     }
+
+    return(0);
+}
+
+
+
+/* ------------ */
+
+int SubmitFile::MessageEnd(unsigned rcptnum, int iswhitelisted)
+{
+const char *rfcerr=NULL;
+int is8bit=0, dorewrite=0, rwmode=0;
+const    char *mime=getenv("MIME");
+unsigned n;
+struct   stat stat_buf;
+
+
+
+    if (chkmsg(&dorewrite,(char**)&mime,(char**)&rfcerr)) {
+        return (1);
+    }

     datfile << flush;
     if (datfile.fail()) clog_msg_errno();
@@ -884,9 +899,39 @@

 SubmitFile *voidp=this;

+
+    {
+         datfile.close();
+         if (datfile.fail()) clog_msg_errno();
+         rfc2045_free(rwrfcptr);
+    }
+
+
     if (run_filter(dfile, num_control_files_created, iswhitelisted,
          &SubmitFile::get_msgid_for_filtering, &voidp))
          return (1);
+
+
+
+    {
+         int nfd=open((const char*)dfile, O_RDWR | O_CREAT | O_TRUNC,
PERMISSION);
+         if (nfd < 0) clog_msg_errno();
+
+        datfile.fd(nfd);
+         if (datfile.fail()) clog_msg_errno();
+
+         rwrfcptr=rfc2045_fromfd_ac(nfd);
+         if (rwrfcptr == NULL)
+         clog_msg_errno();
+    }
+
+
+
+    if (chkmsg(&dorewrite,(char**)&mime,(char**)&rfcerr)) {
+        return (1);
+    }
+
+

     if (rwrfcptr->has8bitchars)
          is8bit=1;
--- rfc2045/rfc2045.h.bck     Sun Apr  8 01:38:50 2001
+++ rfc2045/rfc2045.h    Thu Apr  4 15:03:17 2002
@@ -147,7 +147,9 @@

 const char *rfc2045_getdefaultcharset();
 void rfc2045_setdefaultcharset(const char *);
-struct rfc2045 *rfc2045_fromfd(int);
+struct rfc2045 *rfc2045_fromfd_x(int,int);
+#define  rfc2045_fromfd(f)   (rfc2045_fromfd_x((f),0))
+#define  rfc2045_fromfd_ac(f)     (rfc2045_fromfd_x((f),1))
 #define  rfc2045_fromfp(f)   (rfc2045_fromfd(fileno((f))))

 extern void rfc2045_error(const char *);

<snip><snip><snip><snip><snip><snip><snip><snip><snip>







_______________________________________________
courier-users mailing list
[EMAIL PROTECTED]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to