File 01_encoding.patch of Package cvs-syncmail

#! /bin/sh /usr/share/dpatch/dpatch-run
## 01_encoding.dpatch by <csacca@thecsl.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Old patch to support character encodings

@DPATCH@

Index: syncmail-2.3/syncmail
===================================================================
--- syncmail-2.3.orig/syncmail
+++ syncmail-2.3/syncmail
@@ -65,6 +65,9 @@ Where options are:
     --reply-to=ADDR
       Add a "Reply-To: ADDR" header to the email message.
 
+    --charset=charset
+      Add a encoding header to message.
+
     --quiet / -q
         Don't print as much status to stdout.
 
@@ -212,7 +215,7 @@ def quotename(name):
 
 
 
-def blast_mail(subject, people, entries, contextlines, fromhost, replyto):
+def blast_mail(subject, people, entries, contextlines, fromhost, replyto, charset):
     # cannot wait for child process or that will cause parent to retain cvs
     # lock for too long.  Urg!
     if not os.fork():
@@ -241,6 +244,9 @@ From: %(author)s
 To: %(people)s''' % vars
         if replyto:
             print >> s, 'Reply-To: %s' % replyto
+        if charset:
+            print >> s, 'MIME-Version: 1.0\nContent-Type: text/plain; charset=%s\nContent-Transfer-Encoding: 8bit' % charset
+
         print >>s, '''\
 Subject: %(subject)s
 Date: %(date)s
@@ -365,7 +371,7 @@ def main():
             sys.argv[1:], 'hC:cuS:R:qf:m:',
             ['fromhost=', 'context=', 'cvsroot=', 'mailhost=',
              'subject-prefix=', 'reply-to=',
-             'help', 'quiet'])
+             'help', 'quiet', 'charset='])
     except getopt.error, msg:
         usage(1, msg)
 
@@ -374,6 +380,7 @@ def main():
     verbose = 1
     subject_prefix = ""
     replyto = None
+    charset = None
     fromhost = None
     for opt, arg in opts:
         if opt in ('-h', '--help'):
@@ -391,6 +398,8 @@ def main():
             subject_prefix = arg
         elif opt in ('-R', '--reply-to'):
             replyto = arg
+        elif opt == '--charset':
+            charset = arg
         elif opt in ('-q', '--quiet'):
             verbose = 0
         elif opt in ('-f', '--fromhost'):
@@ -427,7 +436,7 @@ def main():
         print 'Mailing %s...' % COMMASPACE.join(people)
         print 'Generating notification message...'
     blast_mail(subject, people, changes.values(),
-               contextlines, fromhost, replyto)
+               contextlines, fromhost, replyto, charset)
     if verbose:
         print 'Generating notification message... done.'
 
openSUSE Build Service is sponsored by