--- smtpserver/smtpserver.c.orig Wed Dec 25 04:59:50 1996 +++ smtpserver/smtpserver.c Wed Dec 25 20:34:59 1996 @@ -84,6 +84,9 @@ #include "syslog.h" /* we use local -- we should anyway */ #include "identuser.h" +#ifdef USE_TRANSLATION +# include "libtrans.h" +#endif /* USE_TRANSLATION */ #ifndef SIGCHLD #define SIGCHLD SIGCLD @@ -202,6 +205,11 @@ int pid, routerpid; FILE *logfp = NULL; int D_alloc = 0; +#ifdef USE_TRANSLATION +int X_translation=0; +int X_8bit=0; +int X_settrrc=9; +#endif /* USE_TRANSLATION */ char *helplines[20] = { NULL, }; @@ -384,7 +392,11 @@ exit(1); } /* optarg = NULL; */ +#ifdef USE_TRANSLATION + while ((c = getopt(argc, argv, "aBd:ighl:np:L:M:P:R:s:VvX8")) != EOF) { +#else /* USE_TRANSLATION */ while ((c = getopt(argc, argv, "aBd:ighl:np:L:M:P:R:s:Vv")) != EOF) { +#endif /* USE_TRANSLATION */ switch (c) { case 'a': ident_flag = 1; @@ -442,6 +454,14 @@ prversion("smtpserver"); exit(0); break; /* paranoia */ +#ifdef USE_TRANSLATION + case 'X': + X_translation=1; + break; + case '8': + X_8bit=1; + break; +#endif /* USE_TRANSLATION */ default: fprintf(stderr, "%s: Unknown option, c=%d ('%c')\n",progname,c,c); @@ -462,6 +482,17 @@ } #endif /* CHECK42INETD */ if (errflg || optind != argc) { +#ifdef USE_TRANSLATION +#ifdef USE_INET + fprintf(stderr, + "Usage: %s [-aBivgnVX8] [-s xx] [-L maxLoadAvg] [-M SMTPmaxsize] [-R rtrprog] [-p port#] [-P postoffice] [-l logfile]\n", + progname); +#else /* !USE_INET */ + fprintf(stderr, + "Usage: %s [-aBivgnVX8] [-s xx] [-L maxLoadAvg] [-M SMTPmaxsize] [-R rtrprog] [-P postoffice] [-l logfile]\n", + progname); +#endif /* USE_INET */ +#else /* USE_TRANSLATION */ #ifdef USE_INET fprintf(stderr, "Usage: %s [-aBivgnV] [-s xx] [-L maxLoadAvg] [-M SMTPmaxsize] [-R rtrprog] [-p port#] [-P postoffice] [-l logfile]\n", @@ -471,6 +502,7 @@ "Usage: %s [-aBivgnV] [-s xx] [-L maxLoadAvg] [-M SMTPmaxsize] [-R rtrprog] [-P postoffice] [-l logfile]\n", progname); #endif /* USE_INET */ +#endif /* USE_TRANSLATION */ exit(1); } @@ -1919,6 +1951,11 @@ int localsocksize; int VerboseCommand = 0; +#ifdef USE_TRANSLATION + char lang[4]; + + lang[0]='\0'; +#endif pid = getpid(); if (!logfp) @@ -1945,8 +1982,19 @@ /* Success with it :) */ struct hostent *hostent = gethostbyaddr((void*)&localsock.sin_addr,4, localsock.sin_family); - if (hostent) + if (hostent) { strcpy(myhostname,hostent->h_name); +#ifdef USE_TRANSLATION + strncpy(lang,hostent->h_name,3); + lang[3]='\0'; + X_settrrc=settrtab_byname(lang); + } + if (!(*lang) || (X_settrrc < 0)) { + /* we don't know our codetable, hush client away */ + type(451, "Server could not setup translation.", NULL); + return; +#endif /* USE_TRANSLATION */ + } } if (rejectnets != NULL) @@ -1976,8 +2024,14 @@ myhostname); type(553, NULL, "Ask HELP for our contact information."); } else +#ifdef USE_TRANSLATION + type(220, NULL, "%s ZMailer Server %s ESMTP%s (%s) ready at %s", + myhostname, VersionNumb, ident_flag ? "+IDENT":"", + *lang?lang:"nulltrans", cp); +#else /* USE_TRANSLATION */ type(220, NULL, "%s ZMailer Server %s ESMTP%s ready at %s", myhostname, VersionNumb, ident_flag ? "+IDENT":"", cp); +#endif /* USE_TRANSLATION */ fflush(stdout); state = Hello; @@ -2903,6 +2957,16 @@ /* XXX: HEADERS -> MIME-2 */ } +#ifdef USE_TRANSLATION +static void header_from_mime(buf, lenptr, maxlen) + char *buf; + int *lenptr; + int maxlen; +{ + /* XXX: HEADERS -> MIME-2 */ +} +#endif /* USE_TRANSLATION */ + /* Implement SMTP DATA filter */ /* @@ -2995,6 +3059,31 @@ int from__err = 0; int linecnt = 0; int was8bit = 0; +#ifdef USE_TRANSLATION + int wi; + char hdr_cte[4000],hdr_ct[4000]; + int delay_cte = 0, delay_ct = 0; + int ct_is_text = 1; +#define CTE_8BIT 0 +#define CTE_BASE64 1 +#define CTE_QP 2 + int cte = CTE_8BIT; + int do_decode=0,do_translate=0; + int qp_chars=0,qp_hex=0; + int b64decoding=1,b64eod=0,b64i=0; + char b64c[4]; + static char index_64[128] = { + -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, + -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, + -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63, + 52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1, + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14, + 15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1, + -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40, + 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1 + }; +#define char64(c) (((c) < 0 || (c) > 127) ? -1 : index_64[(c)]) +#endif /* USE_TRANSLATION */ fflush(stdout); @@ -3030,9 +3119,18 @@ if (state & O_) { if (state == endstate) { if (col > 0) { +#ifdef USE_TRANSLATION + if (has8bit && !X_8bit) + header_to_mime(linebuf,&col,sizeof(linebuf)); + else + header_from_mime(linebuf,&col,sizeof(linebuf)); + for (wi=0;wi