Article View: news.software.nntp
Article #1342An attempt to support NNTPD internationalization
From: Pekka Nikander
Date: Wed, 02 Oct 1991 13:11
Date: Wed, 02 Oct 1991 13:11
437 lines
12803 bytes
12803 bytes
This is my first attempt to support internationalization with NNTPD.
This patch supports on the fly character set conversions when reading
or posting news with NNTPD. The patch is based on the BIT8 routines
and patches by Keld Simonssen for sendmail. You need the BIT8
routines in order to be able to use these patches. The BIT8 patches
are available with anonymous FTP from dkuug.dk. Furthermore, they
come along with sendmail-5.65c+IDA.1.4.4. I have used the version
provided with sendmail.
To use these patches:
1. Locate your BIT8 patch routines. If you use the sendmail
distribution, they are in the directory ida/charset.
This directory will be called BIT8DIR from here on.
2. Locate your NNTP source directory. This directory is
called NNTPDIR from here on.
3. Copy strcnv.c and charset.h from BIT8DIR to NNTPDIR/common:
cp $BIT8DIR/strcnv.c $BIT8DIR/charset.h $NNTPDIR
4. Go to BIT8DIR and make install:
cd $BIT8DIR
make install
This will install the character set support files
into /usr/local/lib/mail/char. You may need to modify Makefile
or make some directories in order to get this accomplished.
5. Go to NNTPDIR and apply this patch:
cd $NNTPDIR
patch -p0 < this-article
I haven't actually tested this step so you may need to apply some
hunks by hand...
6. Check configuration parameters in $NNTPDIR/common/conf.h
Especially, you probably want to change SERVER_CHSET.
For proper character set names, see directory /usr/local/lib/mail/char.
7. Remake NNTPD
cd $NNTPDIR
make server
8. Install the new server
cp /etc/nntpd /etc/nntpd.orig
cd $NNTPDIR/server
make install
9. Configure your /usr/lib/news/nntp_access file
The character set is specified as the FIFTH field in the file.
So, if you previously had
myhost.mydom.fi read post
you should change it into
myhost.mydom.fi read post all LOCAL_CHARSET
where LOCAL_CHARSET is the character set used in the client
myhost.mydom.fi.
10. Good luck!
Pekka Nikander Internet: pnr@ngs.fi -or-
Telecom Finland Pekka.Nikander@ngs.fi
----------------------------------------------------------------
*** common/Makefile.orig Wed Oct 2 14:53:04 1991
--- common/Makefile Wed Oct 2 11:48:01 1991
***************
*** 2,9 ****
# Makefile for common directory
#
! SRCS = version.c clientlib.c
! OBJS = version.o clientlib.o
HFILES =
clean:
--- 2,9 ----
# Makefile for common directory
#
! SRCS = version.c clientlib.c strcnv.c
! OBJS = version.o clientlib.o strcnv.o
HFILES =
clean:
*** common/charset.h.orig Wed Oct 2 14:53:44 1991
--- common/charset.h Wed Oct 2 12:12:07 1991
***************
*** 24,29 ****
--- 24,32 ----
** @(#)$Header: /usr/local/src/mail/sendmail/ida/charset/RCS/charset.h,v 2.0 1991/04/05 05:33:29 paul Exp $
*/
+ #ifndef _charset_h_
+ #define _charset_h_
+
/*
* The following 3 parameters may need modifying.
*/
***************
*** 48,50 ****
--- 51,57 ----
OUT_CH *out; /* characters in 8 bit format */
INT16S esc;
};
+
+ extern CHARSET *getchset();
+
+ #endif _charset_h_
*** common/conf.h.orig Wed Oct 2 14:52:46 1991
--- common/conf.h Wed Oct 2 14:49:28 1991
***************
*** 7,12 ****
--- 7,20 ----
* Compile time options.
*/
+ #define BIT8 /* Support for 8 bit character sets and
+ automatic conversion */
+ #ifdef BIT8
+ #define MAPDIR "/usr/local/lib/mail/char"
+ #define SERVER_CHSET "FI"
+ #define NO_XHDR_BIT8 /* Mac TheNews grocks on 8 bits in XHDR reply */
+ #endif
+
#define AUTH /* Define if you want simple authentication */
#undef ALONE /* True if we're running without inetd */
*** common/strcnv.c.orig Wed Oct 2 14:54:03 1991
--- common/strcnv.c Wed Oct 2 12:24:21 1991
***************
*** 25,31 ****
--- 25,47 ----
** Illinois.
*/
+ #ifdef NNTPD
+ #include "../common/conf.h"
+ #include "../common/charset.h"
+ #include "../common/nntp.h"
+ #include <stdio.h>
+ #include <string.h>
+ #include <syslog.h>
+ #define MAXNAME NNTP_STRLEN
+ #define dfopen fopen
+ #define xalloc malloc
+ #define syserr(msg, n) fprintf(stderr, msg, n)
+ #ifndef __STDC__
+ #define const
+ #endif
+ #else
#include "sendmail.h"
+ #endif
#ifdef BIT8
# ifndef lint
***************
*** 263,269 ****
--- 279,289 ----
free(c);
return (NULL);
}
+ #ifdef NNTPD
+ c->name = strdup(s);
+ #else
c->name = newstr(s);
+ #endif
c->in = getinch(s);
c->esc = esc;
if (charsets)
*** server/Makefile.orig Wed Oct 2 11:41:37 1991
--- server/Makefile Wed Oct 2 12:11:16 1991
***************
*** 6,20 ****
ahbs.o globals.o group.o help.o ihave.o list.o misc.o netaux.o \
newgroups.o newnews.o nextlast.o ngmatch.o post.o parsit.o scandir.o \
slave.o spawn.o strcasecmp.o subnet.o time.o xhdr.o fakesyslog.o \
! batch.o auth.o timer.o ../common/version.o
SRVRSRC = main.c serve.c access.c access_inet.c access_dnet.c active.c \
ahbs.c globals.c group.c help.c ihave.c list.c misc.c netaux.c \
newgroups.c newnews.c nextlast.c ngmatch.c post.c parsit.c scandir.c \
slave.c spawn.c strcasecmp.c subnet.c time.c xhdr.c fakesyslog.c \
! batch.c auth.c timer.c ../common/version.c
! SRVRINC = common.h ../common/conf.h ../common/nntp.h timer.h
SRCS = ${SRVRSRC}
--- 6,21 ----
ahbs.o globals.o group.o help.o ihave.o list.o misc.o netaux.o \
newgroups.o newnews.o nextlast.o ngmatch.o post.o parsit.o scandir.o \
slave.o spawn.o strcasecmp.o subnet.o time.o xhdr.o fakesyslog.o \
! batch.o auth.o timer.o ../common/version.o ../common/strcnv.o
SRVRSRC = main.c serve.c access.c access_inet.c access_dnet.c active.c \
ahbs.c globals.c group.c help.c ihave.c list.c misc.c netaux.c \
newgroups.c newnews.c nextlast.c ngmatch.c post.c parsit.c scandir.c \
slave.c spawn.c strcasecmp.c subnet.c time.c xhdr.c fakesyslog.c \
! batch.c auth.c timer.c ../common/version.c ../common/strcnv.c
! SRVRINC = common.h ../common/conf.h ../common/nntp.h \
! ../common/charset.h timer.h
SRCS = ${SRVRSRC}
***************
*** 60,62 ****
--- 61,68 ----
../common/version.o:
${CC} ${CFLAGS} -c ../common/version.c
mv version.o ../common/version.o
+
+ ../common/strcnv.o:
+ ${CC} ${CFLAGS} -DNNTPD -c ../common/strcnv.c
+ mv strcnv.o ../common/strcnv.o
+
*** server/access.c.orig Wed Oct 2 11:51:10 1991
--- server/access.c Wed Oct 2 13:55:07 1991
***************
*** 46,51 ****
--- 46,57 ----
extern int Needauth;
#endif AUTH
+
+ #ifdef BIT8
+ CHARSET *client_chset = NULL;
+ CHARSET *server_chset = NULL;
+ #endif
+
host_access(canread, canpost, canxfer, gdlist)
int *canread, *canpost, *canxfer;
char *gdlist;
***************
*** 62,71 ****
--- 68,85 ----
char readperm[MAXBUFLEN];
char postperm[MAXBUFLEN];
char groups[MAXBUFLEN];
+ #ifdef BIT8
+ char charset_name[MAXBUFLEN];
+ #endif
char line[MAXBUFLEN];
register char *cp;
register FILE *acs_fp;
+ #ifdef BIT8
+ if (server_chset == NULL)
+ server_chset = getchset(SERVER_CHSET, 0);
+ #endif
+
gdlist[0] = '\0';
#ifdef DEBUG
***************
*** 162,169 ****
--- 176,191 ----
if (*line == '\0')
continue;
+ #ifdef BIT8
+ count = sscanf(line, "%s %s %s %s %s",
+ hostornet, readperm, postperm, groups,
+ charset_name);
+ if (count < 5)
+ charset_name[0] = '\0';
+ #else
count = sscanf(line, "%s %s %s %s",
hostornet, readperm, postperm, groups);
+ #endif
if (count < 4) {
if (count < 3)
***************
*** 182,187 ****
--- 204,219 ----
*canxfer = *canread = 1;
*canpost = (postperm[0] == 'p' || postperm[0] == 'P');
(void) strcpy(gdlist, groups);
+ #ifdef BIT8
+ if (charset_name[0] != '\0') {
+ #ifdef SYSLOG
+ syslog(LOG_DEBUG,
+ "Charset '%s' specified for '%s'",
+ charset_name, hostname);
+ #endif
+ client_chset = getchset(charset_name, 0);
+ }
+ #endif
break;
}
***************
*** 194,199 ****
--- 226,241 ----
*canxfer = *canread = 1;
*canpost = (postperm[0] == 'p' || postperm[0] == 'P');
(void) strcpy(gdlist, groups);
+ #ifdef BIT8
+ if (charset_name[0] != '\0') {
+ #ifdef SYSLOG
+ syslog(LOG_DEBUG,
+ "Charset '%s' specified for '%s'",
+ charset_name, hostname);
+ #endif
+ client_chset = getchset(charset_name, 0);
+ }
+ #endif
}
if (match != SNETMATCH && (!strcasecmp(hostornet, net_name) ||
***************
*** 206,211 ****
--- 248,263 ----
*canxfer = *canread = 1;
*canpost = (postperm[0] == 'p' || postperm[0] == 'P');
(void) strcpy(gdlist, groups);
+ #ifdef BIT8
+ if (charset_name[0] != '\0') {
+ #ifdef SYSLOG
+ syslog(LOG_DEBUG,
+ "Charset '%s' specified for '%s'",
+ charset_name, hostname);
+ #endif
+ client_chset = getchset(charset_name, 0);
+ }
+ #endif
}
}
/*
*** server/misc.c.orig Wed Dec 12 08:00:11 1990
--- server/misc.c Wed Oct 2 13:55:08 1991
***************
*** 357,362 ****
--- 357,365 ----
int how;
{
char line[NNTP_STRLEN];
+ #ifdef BIT8
+ char line2[NNTP_STRLEN];
+ #endif
register char *cp;
#ifdef LOG
***************
*** 371,376 ****
--- 374,386 ----
while (fgets(line, sizeof(line)-6, fp) != NULL && *line != '\n') {
if (how == BODY) /* We need to skip this anyway */
continue;
+ #ifdef BIT8
+ if (client_chset != NULL) {
+ strncnv(client_chset, server_chset,
+ line2, line, sizeof(line)-6);
+ strncpy(line, line2, sizeof(line)-6);
+ }
+ #endif
cp = index(line, '\n');
if (cp != NULL)
*cp = '\0';
***************
*** 398,403 ****
--- 408,420 ----
}
while (fgets(line, sizeof(line)-6, fp) != NULL) {
+ #ifdef BIT8
+ if (client_chset != NULL) {
+ strncnv(client_chset, server_chset,
+ line2, line, sizeof(line)-6);
+ strncpy(line, line2, sizeof(line)-6);
+ }
+ #endif
cp = index(line, '\n');
if (cp != NULL)
*cp = '\0';
*** server/spawn.c.orig Sat Jan 12 19:25:36 1991
--- server/spawn.c Wed Oct 2 13:55:08 1991
***************
*** 49,54 ****
--- 49,57 ----
char *msg_id;
{
char line[NNTP_STRLEN];
+ #ifdef BIT8
+ char line2[NNTP_STRLEN];
+ #endif
register char *cp;
int i, fd;
int fds[2];
***************
*** 113,118 ****
--- 116,129 ----
if (line[0] == '.' && line[1] == '\0')
break;
+
+ #ifdef BIT8
+ if (client_chset != NULL) {
+ strncnv(server_chset, client_chset,
+ line2, line, sizeof(line));
+ strncpy(line, line2, sizeof(line));
+ }
+ #endif
if (line[0] == '.')
fputs(line+1, fp);
*** server/xhdr.c.orig Wed Oct 2 14:50:26 1991
--- server/xhdr.c Wed Oct 2 14:54:29 1991
***************
*** 139,144 ****
--- 139,147 ----
register char *artname;
{
char line[NNTP_STRLEN];
+ #ifdef BIT8
+ char line2[NNTP_STRLEN];
+ #endif
register char *cp, *cp1;
while (fgets(line, sizeof (line), fp) != NULL) {
***************
*** 152,157 ****
--- 155,169 ----
if (!strcasecmp(header, line)) {
if (cp1 = index(cp + 2, '\n'))
*cp1 = '\0';
+ #ifdef BIT8
+ #ifndef NO_XHDR_BIT8
+ if (client_chset != NULL) {
+ strncnv(client_chset, server_chset,
+ line2, cp + 2, sizeof(line)-6);
+ printf("%s %s\r\n", artname, line2);
+ } else
+ #endif
+ #endif
printf("%s %s\r\n", artname, cp + 2);
return;
}
--
Pekka Nikander Internet: pnr@ngs.fi -or-
Helsinki Unixversity of Technology Pekka.Nikander@ngs.fi
Technical Details
Message-ID:
<PNR.91Oct2151141@ngs.fi>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp!wupost!uunet!mcsun!fuug!fuug.fi!pnrShow Full Headers
Complete Article Headers
Message-ID: <PNR.91Oct2151141@ngs.fi> Subject: An attempt to support NNTPD internationalization Date: Wed, 02 Oct 1991 13:11:41 +0000 From: pnr@ngs.fi (Pekka Nikander) Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp!wupost!uunet!mcsun!fuug!fuug.fi!pnr Newsgroups: sfnet.atk.unix,news.software.nntp,alt.sources Sender: usenet@fuug.fi (USENET News System) Organization: Nixu Oy, Helsinki, Finland Lines: 436 Nntp-Posting-Host: ngs.fi