FIDOGATE 3.7 - Patch 1 Priority: * Medium Bugs fixed: * Empty tear lines "---\n" causing illegal empty X-FTN-Tearline headers Other changes: * pktdebug now writes to stdout Applying this patch: * Change to the directory containing the top level fidogate/ subdirectory * Enter patch -p0 FIDO NetMail/EchoMail * - * $Id: fakelog.c,v 3.7 1994/05/02 05:36:42 mj Exp mj $ + * $Id: fakelog.c,v 3.7.1.1 1994/05/07 08:20:41 mj Exp mj $ * * Alternate log() without writing to file * @@ -30,6 +30,6 @@ * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. *****************************************************************************/ -#define FAKELOG +#define LOG_NOFILE #include "log.c" diff -uN /home/mj/tmp/fidogate-3.7/src/ffx.c fidogate/src/ffx.c --- /home/mj/tmp/fidogate-3.7/src/ffx.c Mon May 2 08:35:58 1994 +++ fidogate/src/ffx.c Sat May 7 10:21:17 1994 @@ -2,7 +2,7 @@ /***************************************************************************** * FIDOGATE --- Gateway UNIX Mail/News <-> FIDO NetMail/EchoMail * - * $Id: ffx.c,v 3.7 1994/05/02 05:36:42 mj Exp mj $ + * $Id: ffx.c,v 3.7.1.1 1994/05/07 08:20:41 mj Exp mj $ * * ffx FIDO-FIDO execution * @@ -38,7 +38,7 @@ #define PROGRAM "ffx" -#define VERSION "$Revision: 3.7 $" +#define VERSION "$Revision: 3.7.1.1 $" /* diff -uN /home/mj/tmp/fidogate-3.7/src/fido2rfc.c fidogate/src/fido2rfc.c --- /home/mj/tmp/fidogate-3.7/src/fido2rfc.c Mon May 2 07:37:19 1994 +++ fidogate/src/fido2rfc.c Tue May 10 23:59:39 1994 @@ -2,7 +2,7 @@ /***************************************************************************** * FIDOGATE --- Gateway UNIX Mail/News <-> FIDO NetMail/EchoMail * - * $Id: fido2rfc.c,v 3.7 1994/05/02 05:36:42 mj Exp mj $ + * $Id: fido2rfc.c,v 3.7.1.2 1994/05/10 21:59:17 mj Exp mj $ * * Unpack FIDO mail packets in INBOUND directory and convert to RFC mails * and news batches (directories INBOUND_MAIL / INBOUND_NEWS) @@ -42,7 +42,7 @@ #define PROGRAM "fido2rfc" -#define VERSION "$Revision: 3.7 $" +#define VERSION "$Revision: 3.7.1.2 $" @@ -642,7 +642,8 @@ save_tear_line = NULL; } - if(!strncmp("---", buffer, 3)) /* Possible tear line */ + if(!strncmp("--- ", buffer, 4) || + !strcmp("---\n", buffer) ) /* Possible tear line */ { save_tear_line = strsave(buffer); continue; @@ -659,7 +660,15 @@ */ if(save_tear_line) tear_line = save_tear_line; - + /* + * Don't keep an empty tear line + */ + if(tear_line && !strcmp(tear_line, "---\n")) + { + free(tear_line); + tear_line = NULL; + } + /* * Check for mail or news. @@ -977,7 +986,7 @@ #endif #ifdef X_FTN_TEARLINE if(tear_line) - Textlist_appendf(&theader, "X-FTN-Tearline:%s", tear_line+3 ); + Textlist_appendf(&theader, "X-FTN-Tearline: %s", tear_line+4 ); #endif #ifdef X_FTN_VIA Textlist_add(&theader, &tvia); @@ -1026,7 +1035,7 @@ #endif #ifdef X_FTN_TEARLINE if(tear_line) - Textlist_appendf(&theader, "X-FTN-Tearline:%s", tear_line+3 ); + Textlist_appendf(&theader, "X-FTN-Tearline: %s", tear_line+4 ); #endif #ifdef X_FTN_PATH Textlist_add(&theader, &tpath); diff -uN /home/mj/tmp/fidogate-3.7/src/fidogate.h fidogate/src/fidogate.h --- /home/mj/tmp/fidogate-3.7/src/fidogate.h Mon May 2 07:37:22 1994 +++ fidogate/src/fidogate.h Sat May 7 10:21:28 1994 @@ -2,7 +2,7 @@ /***************************************************************************** * FIDOGATE --- Gateway software UNIX <-> FIDO * - * $Id: fidogate.h,v 3.7 1994/05/02 05:36:42 mj Exp mj $ + * $Id: fidogate.h,v 3.7.1.1 1994/05/07 08:20:41 mj Exp mj $ * * Common header file * @@ -324,7 +324,7 @@ void msg_body_init P((MsgBody *)); void msg_body_clear P((MsgBody *)); int msg_body_parse P((Textlist *, MsgBody *)); -void msg_body_debug P((MsgBody *)); +void msg_body_debug P((FILE *, MsgBody *)); /* misc.c */ void stripbad P((char *)); @@ -353,6 +353,7 @@ int pkt_get_string P((FILE *, char *, int)); time_t pkt_get_date P((FILE *)); int pkt_get_msg_hdr P((FILE *, Message *)); +void pkt_debug_msg_hdr P((FILE *, Message *)); int pkt_put_string P((FILE *, char *)); int pkt_put_line P((FILE *, char *)); int pkt_put_int16 P((FILE *, int)); @@ -361,6 +362,7 @@ long pkt_get_int16 P((FILE *)); int pkt_get_nbytes P((FILE *, char *, int)); int pkt_get_hdr P((FILE *, Packet *)); +void pkt_debug_hdr P((FILE *, Packet *)); int pkt_put_string_padded P((FILE *, char *, int)); int pkt_put_hdr P((FILE *, Packet *)); diff -uN /home/mj/tmp/fidogate-3.7/src/log.c fidogate/src/log.c --- /home/mj/tmp/fidogate-3.7/src/log.c Mon May 2 07:37:32 1994 +++ fidogate/src/log.c Sat May 7 10:21:44 1994 @@ -2,7 +2,7 @@ /***************************************************************************** * FIDOGATE --- Gateway UNIX Mail/News <-> FIDO NetMail/EchoMail * - * $Id: log.c,v 3.7 1994/05/02 05:36:42 mj Exp mj $ + * $Id: log.c,v 3.7.1.1 1994/05/07 08:20:41 mj Exp mj $ * * Log and debug functions * @@ -33,6 +33,10 @@ #include "fidogate.h" +#ifndef LOG_OUTPUT +#define LOG_OUTPUT stderr +#endif + int verbose = 0; /* -v --verbose option */ @@ -64,7 +68,7 @@ void log(const char *fmt, ...) { va_list args; -#ifndef FAKELOG +#ifndef LOG_NOFILE FILE *logfp; char buf[MAXPATH]; #endif @@ -76,7 +80,7 @@ { va_list args; char *fmt; -#ifndef FAKELOG +#ifndef LOG_NOFILE FILE *logfp; char buf[MAXPATH]; #endif @@ -85,7 +89,7 @@ fmt = va_arg(args, char *); #endif /**__STDC__*/ -#ifndef FAKELOG +#ifndef LOG_NOFILE strncpy0(buf, cf_libdir(), sizeof(buf)); strncat0(buf, "/", sizeof(buf)); strncat0(buf, LOG, sizeof(buf)); @@ -105,19 +109,20 @@ fclose(logfp); /* - * if verbose is set, print also to stderr (without date) + * if verbose is set, print also to LOG_OUTPUT (without date) */ if (verbose) -#else /**FAKELOG**/ +#else /**LOG_NOFILE**/ if(TRUE) -#endif /**FAKELOG**/ +#endif /**LOG_NOFILE**/ { - vfprintf(stderr, *fmt == '$' ? fmt + 1 : fmt, args); + vfprintf(LOG_OUTPUT, *fmt == '$' ? fmt + 1 : fmt, args); if (*fmt == '$') - fprintf(stderr, "\n\t\terrno=%d (%s)\n", errno, strerror(errno)); + fprintf(LOG_OUTPUT, "\n\t\terrno=%d (%s)\n", + errno, strerror(errno)); else - fprintf(stderr, "\n"); - fflush(stderr); + fprintf(LOG_OUTPUT, "\n"); + fflush(LOG_OUTPUT); } } @@ -146,7 +151,8 @@ #endif /**__STDC__*/ if (debug_level <= verbose) { - vfprintf(stderr, fmt, args); - fprintf(stderr, "\n"); + vfprintf(LOG_OUTPUT, fmt, args); + fprintf(LOG_OUTPUT, "\n"); + fflush(LOG_OUTPUT); } } diff -uN /home/mj/tmp/fidogate-3.7/src/message.c fidogate/src/message.c --- /home/mj/tmp/fidogate-3.7/src/message.c Mon May 2 07:37:37 1994 +++ fidogate/src/message.c Sat May 7 10:21:51 1994 @@ -2,7 +2,7 @@ /***************************************************************************** * FIDOGATE --- Gateway UNIX Mail/News <-> FIDO NetMail/EchoMail * - * $Id: message.c,v 3.7 1994/05/02 05:36:42 mj Exp mj $ + * $Id: message.c,v 3.7.1.1 1994/05/07 08:20:41 mj Exp mj $ * * Reading and processing FTN text body * @@ -35,6 +35,25 @@ /* + * Debug output of line + */ +static void debug_line(out, line) + FILE *out; + char *line; +{ + int c; + + while( (c = *line++) ) + if( !(c & 0x60) ) + fprintf(out, "^%c", '@' + c); + else + putc(c, out); + putc('\n', out); +} + + + +/* * Read one "line" from FTN text body. A line comprises arbitrary * characters terminated with a CR '\r'. None, one, or many LFs '\n' * may follow: @@ -115,8 +134,8 @@ return ERROR; if(c1 == 0) /* Looks like it is ... */ { - log("pkt_get_line(): grunged packet"); *p = 0; + log("pkt_get_line(): grunged packet"); return MSG_TYPE; } *p++ = c; @@ -461,59 +480,43 @@ /* - * Debug output of line - */ -static void debug_line(line) - char *line; -{ - int c; - - while( (c = *line++) ) - if( !(c & 0x60) ) - fprintf(stderr, "^%c", '@' + c); - else - putc(c, stderr); - putc('\n', stderr); -} - - -/* * Debug output of message body */ -void msg_body_debug(body) +void msg_body_debug(out, body) + FILE *out; MsgBody *body; { Textline *p; - fprintf(stderr, "----------------------------------------" - "--------------------------------------\n"); + fprintf(out, "----------------------------------------" + "--------------------------------------\n"); if(body->area) - debug_line(body->area); + debug_line(out, body->area); for(p=body->kludge.first; p; p=p->next) - debug_line(p->line); - fprintf(stderr, "----------------------------------------" + debug_line(out, p->line); + fprintf(out, "----------------------------------------" "--------------------------------------\n"); if(body->rfc.first) { for(p=body->rfc.first; p; p=p->next) - debug_line(p->line); - fprintf(stderr, "----------------------------------------" - "--------------------------------------\n"); + debug_line(out, p->line); + fprintf(out, "----------------------------------------" + "--------------------------------------\n"); } for(p=body->body.first; p; p=p->next) - debug_line(p->line); - fprintf(stderr, "----------------------------------------" - "--------------------------------------\n"); + debug_line(out, p->line); + fprintf(out, "----------------------------------------" + "--------------------------------------\n"); if(body->tear) - debug_line(body->tear); + debug_line(out, body->tear); if(body->origin) - debug_line(body->origin); + debug_line(out, body->origin); for(p=body->seenby.first; p; p=p->next) - debug_line(p->line); + debug_line(out, p->line); for(p=body->path.first; p; p=p->next) - debug_line(p->line); + debug_line(out, p->line); for(p=body->via.first; p; p=p->next) - debug_line(p->line); - fprintf(stderr, "========================================" - "======================================\n"); + debug_line(out, p->line); + fprintf(out, "========================================" + "======================================\n"); } diff -uN /home/mj/tmp/fidogate-3.7/src/out-attach.c fidogate/src/out-attach.c --- /home/mj/tmp/fidogate-3.7/src/out-attach.c Mon May 2 08:35:58 1994 +++ fidogate/src/out-attach.c Sat May 7 10:21:57 1994 @@ -2,7 +2,7 @@ /***************************************************************************** * FIDOGATE --- Gateway UNIX Mail/News <-> FIDO NetMail/EchoMail * - * $Id: out-attach.c,v 3.7 1994/05/02 05:36:42 mj Exp mj $ + * $Id: out-attach.c,v 3.7.1.1 1994/05/07 08:20:41 mj Exp mj $ * * Attach file to FLO entry in outbound * @@ -39,7 +39,7 @@ #define PROGRAM "out-attach" -#define VERSION "$Revision: 3.7 $" +#define VERSION "$Revision: 3.7.1.1 $" diff -uN /home/mj/tmp/fidogate-3.7/src/packet.c fidogate/src/packet.c --- /home/mj/tmp/fidogate-3.7/src/packet.c Mon May 2 07:37:49 1994 +++ fidogate/src/packet.c Sat May 7 10:21:59 1994 @@ -2,7 +2,7 @@ /***************************************************************************** * FIDOGATE --- Gateway UNIX Mail/News <-> FIDO NetMail/EchoMail * - * $Id: packet.c,v 3.7 1994/05/02 05:36:42 mj Exp mj $ + * $Id: packet.c,v 3.7.1.1 1994/05/07 08:20:41 mj Exp mj $ * * Functions to read/write packets and messages * @@ -102,15 +102,8 @@ pkt_get_string( fp, msg->name_from, sizeof(msg->name_from) ); pkt_get_string( fp, msg->subject , sizeof(msg->subject ) ); - debug(2, "FTN message header:"); - debug(2, " From: %-36s @ %s", - msg->name_from, node_to_asc(&msg->node_from, TRUE)); - debug(2, " To : %-36s @ %s", - msg->name_to , node_to_asc(&msg->node_to , TRUE)); - debug(2, " Subj: %s", msg->subject); - debug(2, " Date: %s", - msg->date!=-1 ? date(NULL, &msg->date) : "LOCAL" ); - debug(3, " Attr: %04x", msg->attr); + if(verbose >= 2) + pkt_debug_msg_hdr(stderr, msg); return ferror(fp); } @@ -118,6 +111,26 @@ /* + * Debug output of message header + */ +void pkt_debug_msg_hdr(out, msg) + FILE *out; + Message *msg; +{ + fprintf(out, "FTN message header:\n"); + fprintf(out, " From: %-36s @ %s\n", + msg->name_from, node_to_asc(&msg->node_from, TRUE)); + fprintf(out, " To : %-36s @ %s\n", + msg->name_to , node_to_asc(&msg->node_to , TRUE)); + fprintf(out, " Subj: %s\n", msg->subject); + fprintf(out, " Date: %s\n", + msg->date!=-1 ? date(NULL, &msg->date) : "LOCAL" ); + fprintf(out, " Attr: %04x\n", msg->attr); +} + + + +/* * Write string to packet in null-terminated format. */ int pkt_put_string(fp, s) @@ -206,15 +219,8 @@ Message *msg; int kludge_flag; /* TRUE: write AREA/^AINTL,^AFMPT,^ATOPT */ { - debug(2, "FTN message header:"); - debug(2, " From: %-36s @ %s", - msg->name_from, node_to_asc(&msg->node_from, TRUE)); - debug(2, " To : %-36s @ %s", - msg->name_to , node_to_asc(&msg->node_to , TRUE)); - debug(2, " Subj: %s", msg->subject); - debug(2, " Date: %s", - msg->date!=-1 ? date(NULL, &msg->date) : "LOCAL" ); - debug(3, " Attr: %04x", msg->attr); + if(verbose >= 2) + pkt_debug_msg_hdr(stderr, msg); /* * Write message header @@ -318,8 +324,8 @@ * Read packet header from file */ int pkt_get_hdr(fp, pkt) -FILE *fp; -Packet *pkt; + FILE *fp; + Packet *pkt; { long val; struct tm t; @@ -437,15 +443,8 @@ /* Prod specific data */ if(pkt_get_nbytes(fp, xpkt, 4) == ERROR) return ERROR; - debug(2, "Reading FTN packet header:"); - debug(2, " From: %s", node_to_asc(&pkt->from, TRUE)); - debug(2, " To : %s", node_to_asc(&pkt->to , TRUE)); - debug(2, " Date: %s", date(NULL, &pkt->time)); - debug(3, " Baud: %d", pkt->baud); - debug(2, " Prod: %02x %02x", pkt->product_h, pkt->product_l); - debug(2, " Rev : %d.%d", pkt->rev_maj, pkt->rev_min); - debug(2, " Pass: \"%s\"", pkt->passwd); - debug(3, " Capw: %04x", pkt->capword & 0xffff); + if(verbose >= 2) + pkt_debug_hdr(stderr, pkt); return ferror(fp); } @@ -453,6 +452,26 @@ /* + * Debug output of packet header + */ +void pkt_debug_hdr(out, pkt) + FILE *out; + Packet *pkt; +{ + fprintf(out, "FTN packet header:\n"); + fprintf(out, " From: %s\n", node_to_asc(&pkt->from, TRUE)); + fprintf(out, " To : %s\n", node_to_asc(&pkt->to , TRUE)); + fprintf(out, " Date: %s\n", date(NULL, &pkt->time)); + fprintf(out, " Baud: %d\n", pkt->baud); + fprintf(out, " Prod: %02x %02x\n", pkt->product_h, pkt->product_l); + fprintf(out, " Rev : %d.%d\n", pkt->rev_maj, pkt->rev_min); + fprintf(out, " Pass: \"%s\"\n", pkt->passwd); + fprintf(out, " Capw: %04x\n", pkt->capword & 0xffff); +} + + + +/* * Write string to packet, padded with 0 bytes to length n */ int pkt_put_string_padded(fp, s, n) @@ -476,8 +495,8 @@ * (FSC-0039) header. */ int pkt_put_hdr(fp, pkt) -FILE *fp; -Packet *pkt; + FILE *fp; + Packet *pkt; { struct tm *tm; int swap; @@ -495,16 +514,8 @@ swap = 0x0100; /* Byte swapped capability word */ tm = localtime(&pkt->time); - - debug(2, "Writing FTN 2+ packet header:"); - debug(2, " From: %s", node_to_asc(&pkt->from, TRUE)); - debug(2, " To : %s", node_to_asc(&pkt->to , TRUE)); - debug(2, " Date: %s", date(NULL, &pkt->time)); - debug(3, " Baud: %d", pkt->baud); - debug(2, " Prod: %02x %02x", pkt->product_h, pkt->product_l); - debug(2, " Rev : %d.%d", pkt->rev_maj, pkt->rev_min); - debug(2, " Pass: \"%s\"", pkt->passwd); - debug(3, " Capw: %04x", pkt->capword & 0xffff); + if(verbose >= 2) + pkt_debug_hdr(stderr, pkt); /* * Write the actual header diff -uN /home/mj/tmp/fidogate-3.7/src/patchlevel.h fidogate/src/patchlevel.h --- /home/mj/tmp/fidogate-3.7/src/patchlevel.h Mon May 2 07:37:55 1994 +++ fidogate/src/patchlevel.h Wed May 11 00:00:11 1994 @@ -2,9 +2,9 @@ /***************************************************************************** * FIDOGATE --- Gateway software UNIX Mail/News <-> FIDO NetMail/EchoMail * - * $Id: patchlevel.h,v 3.7 1994/05/02 05:36:42 mj Exp mj $ + * $Id: patchlevel.h,v 3.7.1.2 1994/05/10 21:59:17 mj Exp mj $ * * Global patch level *****************************************************************************/ -#define PATCHLEVEL 0 +#define PATCHLEVEL 1 diff -uN /home/mj/tmp/fidogate-3.7/src/pktdebug.c fidogate/src/pktdebug.c --- /home/mj/tmp/fidogate-3.7/src/pktdebug.c Thu Apr 28 00:30:04 1994 +++ fidogate/src/pktdebug.c Sat May 7 11:06:24 1994 @@ -2,7 +2,7 @@ /***************************************************************************** * FIDOGATE --- Gateway UNIX Mail/News <-> FIDO NetMail/EchoMail * - * $Id$ + * $Id: pktdebug.c,v 3.7 1994/05/07 09:06:22 mj Exp mj $ * * Debug contents of FTN packet * @@ -37,7 +37,7 @@ #define PROGRAM "pktdebug" -#define VERSION "$Revision: 0.0 $" +#define VERSION "$Revision: 3.7 $" @@ -62,6 +62,7 @@ options: -m --msg-header print message header\n\ -t --msg-text print message text\n\ \n\ + -v --verbose more verbose\n\ -h --help this help\n"); exit(0); @@ -72,8 +73,8 @@ /***** main() ****************************************************************/ int main(argc, argv) -int argc; -char *argv[]; + int argc; + char *argv[]; { FILE *fp; Packet pkt; @@ -90,6 +91,7 @@ { { "msg-header", 0, 0, 'm'}, { "msg-text", 0, 0, 't'}, + { "verbose", 0, 0, 'v'}, /* More verbose */ { "help", 0, 0, 'h'}, /* Help */ { 0, 0, 0, 0 } }; @@ -97,7 +99,7 @@ Textlist_init(&tl); msg_body_init(&body); - while ((c = getopt_long(argc, argv, "mth", + while ((c = getopt_long(argc, argv, "mtvh", long_options, &option_index )) != EOF) switch (c) { case 'm': @@ -108,6 +110,9 @@ break; /***** Common options *****/ + case 'v': + verbose++; + break; case 'h': usage(); break; @@ -129,28 +134,31 @@ fp = xfopen(name, R_MODE); - verbose = 5; - pkt_get_hdr(fp, &pkt); - verbose = 0; + if(t_flag) + fprintf(stdout, "========================================" + "======================================\n"); + pkt_get_hdr(fp, &pkt); + pkt_debug_hdr(stdout, &pkt); + if(t_flag) - fprintf(stderr, "========================================" + fprintf(stdout, "========================================" "======================================\n"); type = pkt_get_int16(fp); while(type == MSG_TYPE) { - if(m_flag) - verbose = 5; msg.node_from = pkt.from; msg.node_to = pkt.to; pkt_get_msg_hdr(fp, &msg); - verbose = 0; + if(m_flag) + pkt_debug_msg_hdr(stdout, &msg); + type = pkt_get_body(fp, &tl); if( (err = msg_body_parse(&tl, &body)) != OK) - fprintf(stderr, "ERROR PARSING MESSAGE BODY (%d) !!!\n", err); + fprintf(stdout, "ERROR PARSING MESSAGE BODY (%d) !!!\n", err); if(t_flag) - msg_body_debug(&body); + msg_body_debug(stdout, &body); } } diff -uN /home/mj/tmp/fidogate-3.7/src/stdoutlog.c fidogate/src/stdoutlog.c --- /home/mj/tmp/fidogate-3.7/src/stdoutlog.c Thu Jan 1 01:00:00 1970 +++ fidogate/src/stdoutlog.c Sat May 7 10:06:56 1994 @@ -0,0 +1,36 @@ +/*:ts=8*/ +/***************************************************************************** + * FIDOGATE --- Gateway UNIX Mail/News <-> FIDO NetMail/EchoMail + * + * $Id: stdoutlog.c,v 3.7 1994/05/07 08:06:54 mj Exp mj $ + * + * Alternate log() without writing to file, but writing to stdout + * + ***************************************************************************** + * Copyright (C) 1990, 1993 + * _____ _____ + * | |___ | Martin Junius FIDO: 2:242/6.1 + * | | | | | | Republikplatz 3 Internet: mj@sungate.fido.de + * |_|_|_|@home| D-52072 Aachen, Germany Phone: ++49-241-86931 (voice) + * + * This file is part of FIDOGATE. + * + * FIDOGATE is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * FIDOGATE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FIDOGATE; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + *****************************************************************************/ + +#define LOG_NOFILE +#define LOG_OUTPUT stdout + +#include "log.c"