[patch] rest of charset adjustments

IKEDA Soji <[email protected]>
Newsgroups gmane.mail.sqwebmail
Message-ID <[email protected]>
Hi

This is my last patch for charset adjustments.

sqwebmail/auth.c:
  login_fromhdr(): Convert fullname from charset of auth module to 
  content charset.

  1. If $sysconfdir/authcharset exists and contains supported
     charset name, source charset is read from it.
  2. If sqwebmail_system_charset is set (accoding to system locale
     name), it is assumed as charset of auth module(s).
  3. Otherwise, no conversion.

                                 *

Ichikawa's suggestion is that Japanese-writing users have been
look forward to.  Though Brend's option (b) is interesting.

Thanks.


  --- nezumi
sqwebmail-cvs20040215-auth_charset-1.0.patch (application/octet-stream, 2.7 KB)
Index: sqwebmail-cvs20040215/sqwebmail/auth.c
===================================================================
RCS file: /cvsroot/courier/courier/webmail/auth.c,v
retrieving revision 1.33
diff -u -r1.33 auth.c
--- sqwebmail-cvs20040215/sqwebmail/auth.c	19 Jan 2004 21:49:32 -0000	1.33
+++ sqwebmail-cvs20040215/sqwebmail/auth.c	15 Feb 2004 07:48:29 -0000
@@ -46,6 +46,11 @@
 
 extern int check_sqwebpass(const char *);
 
+#if	HAVE_SQWEBMAIL_UNICODE
+extern char *sqwebmail_content_charset, *sqwebmail_system_charset;
+#include	"unicode/unicode.h"
+#endif
+
 const char *myhostname()
 {
 char    buf[512];
@@ -389,9 +394,42 @@
 
 static char *hdrbuf=0;
 
+#if	HAVE_SQWEBMAIL_UNICODE
+FILE *fp;
+char authcharset[128];
+const struct unicode_info *uiptr=NULL, *uoptr=NULL;
+char *ufullname=0;
+static char *uhdrbuf=0;
+#endif
+
 	if (!fullname || !*fullname)
 		return (address);	/* That was easy */
 
+#if	HAVE_SQWEBMAIL_UNICODE
+	authcharset[0] = 0;
+	if ((fp=fopen(AUTHCHARSET, "r")))
+	{
+		char *p;
+		fgets(authcharset, sizeof(authcharset), fp);
+		fclose(fp);
+
+		if ((p=strchr(authcharset, '\n')))
+			*p = '\0';
+	}
+
+	if (authcharset[0] == 0
+	    && sqwebmail_system_charset && *sqwebmail_system_charset
+	    && strcasecmp(sqwebmail_system_charset, "ASCII"))
+		strncpy(authcharset, sqwebmail_system_charset,
+			sizeof(authcharset)-1);
+
+	if (authcharset[0] && (uiptr=unicode_find(authcharset))
+	    && sqwebmail_content_charset && *sqwebmail_content_charset
+	    && (uoptr=unicode_find(sqwebmail_content_charset))
+	    && (ufullname=unicode_ctoutf8(uiptr, fullname, NULL)))
+		fullname = ufullname;
+#endif
+
 	l=sizeof("\"\" <>")+strlen(address)+strlen(fullname);
 
 	for (p=fullname; *p; p++)
@@ -425,6 +463,12 @@
 	*q++='>';
 	*q=0;
 
+#if	HAVE_SQWEBMAIL_UNICODE
+	if (ufullname)	free(ufullname);
+	if (uhdrbuf)	free(uhdrbuf);
+	if (uoptr && (uhdrbuf=unicode_cfromutf8(uoptr, hdrbuf, NULL)))
+		return (uhdrbuf);
+#endif
 	return (hdrbuf);
 }
 
Index: sqwebmail-cvs20040215/sqwebmail/Makefile.am
===================================================================
RCS file: /cvsroot/courier/courier/webmail/Makefile.am,v
retrieving revision 1.84
diff -u -r1.84 Makefile.am
--- sqwebmail-cvs20040215/sqwebmail/Makefile.am	8 Feb 2004 04:37:08 -0000	1.84
+++ sqwebmail-cvs20040215/sqwebmail/Makefile.am	15 Feb 2004 07:48:29 -0000
@@ -129,6 +129,7 @@
 	echo '#define LDAPSEARCH "$(scriptdir)/ldapsearch"' >>htmllibdir.h
 	echo '#define MODULEFILE "$(sysconfdir)/authmodulelist"' >>htmllibdir.h
 	echo '#define NOIMAGES "$(sysconfdir)/noimages"' >>htmllibdir.h
+	echo '#define AUTHCHARSET "$(sysconfdir)/authcharset"' >>htmllibdir.h
 
 ldapsearch: ../ldapaddressbook/ldapsearch
 	cp ../ldapaddressbook/ldapsearch .
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.