[comp.sources.unix] v18i006: Fido/Usenet gateway, Part05/05

rsalz@uunet.uu.net (Rich Salz) (03/07/89)

Submitted-by: Heikki Suonsivu <hsu@santra.hut.fi>
Posting-number: Volume 18, Issue 6
Archive-name: fnet/part05

#!/bin/sh
# this is part 5 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file crc.c continued
#
CurArch=5
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file crc.c"
sed 's/^X//' << 'SHAR_EOF' >> crc.c
X0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
 0x316e8eef, 0x4669be79,
X0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703,
 0x220216b9, 0x5505262f,
X0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
 0x2cd99e8b, 0x5bdeae1d,
X0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
 0x72076785, 0x05005713,
X0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d,
 0x7cdcefb7, 0x0bdbdf21,
X0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b,
 0x6fb077e1, 0x18b74777,
X0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
 0x616bffd3, 0x166ccf45,
X0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
 0x4969474d, 0x3e6e77db,
X0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5,
 0x47b2cf7f, 0x30b5ffe9,
X0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
 0x54de5729, 0x23d967bf,
X0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1,
 0x5a05df1b, 0x2d02ef8d
X};
X#endif
X
X#ifdef NFGM
Xlong
XUPDC32(b, c)
Xlong c;
X{
X    return (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF));
X}
X
X#else
X
X#define UPDC32(b, c) (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF))
X#endif
X
X
SHAR_EOF
echo "File crc.c is complete"
chmod 0644 crc.c || echo "restore of crc.c fails"
echo "x - extracting lintlib.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > lintlib.c &&
X/* This is for functions not defined anywhere */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include "hsu.h"
X#include "config.h"
X
X#ifdef lint
X/*ARGSUSED*/
Xlockf(fd, mode, position) int fd, mode; long position; { return 0; }
X/*ARGSUSED*/
Xchar *strnchr(p, c, maxlen) unsigned char *p; int c, maxlen;
X{ return (char *) p; }
X/*ARGSUSED*/
Xchar *strsave(s) char *s; { return s; }
X/*ARGSUSED*/
X/*VARARGS1*/
Xchar *regex(re) char *re; {}
X/*ARGSUSED*/
Xtime_t getdate(p, now) char *p; struct timeb *now; { return 0L; }
X#endif
X
X
SHAR_EOF
chmod 0644 lintlib.c || echo "restore of lintlib.c fails"
echo "x - extracting sprintfs.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > sprintfs.c &&
X#include <stdio.h>
X#include <varargs.h>
X#include "hsu.h"
X
X#define MAX_CONVERT_BUFFERS 10
X#define MAX_CONVERT_BUFLEN 80
Xstatic char bufs[MAX_CONVERT_BUFFERS][MAX_CONVERT_BUFLEN], *tcharp;
Xstatic bflag;
X
X#define SHUFFLEBUFFERS \
Xloop_increment(bflag, MAX_CONVERT_BUFFERS); tcharp = bufs[bflag]
X
X/* Strcat creating its own buffer */
X
Xchar *sstrcat(d, s)
X     char *d, *s;
X{
X  SHUFFLEBUFFERS;
X
X  (void) strncpy(tcharp, d, MAX_CONVERT_BUFLEN);
X  tcharp[MAX_CONVERT_BUFLEN - 1] = '\0';
X  (void) strncat(tcharp, s, MAX_CONVERT_BUFLEN);
X  return tcharp;
X}
X
X/* Sprintf with own buffer */
X
X/*VARARGS1*/
Xchar *sprintfs(fmt, va_alist)
X     char *fmt;
X     va_dcl
X{
X  va_list pvar;
X
X  va_start(pvar);
X
X  SHUFFLEBUFFERS;
X
X  vsprintf(tcharp, fmt, pvar);
X
X  va_end(pvar);
X
X  return tcharp;
X}
X
SHAR_EOF
chmod 0644 sprintfs.c || echo "restore of sprintfs.c fails"
echo "x - extracting strempty.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > strempty.c &&
X#include <string.h>
X#include <ctype.h>
X#include "hsu.h"
X
X/* Check if string just consists of space (or is null). Return TRUE if so */
X
Xstrempty(s)
X     char *s;
X{
X  while (*s) if (!isspace(*s)) return FALSE; else s++;
X  return TRUE;
X}
X
X/* Clean up space from start and end */
X
Xchar *strclean(s)
X     char *s;
X{
X  char *d = s, *p = s;
X
X  /* Find first non-space char */
X  for (; *p; p++) if (!isspace(*p)) break;
X
X  /* Copy until end */
X  if (d != p) while (*d++ = *p++);
X
X  /* Strip space from end */
X  while (strlen(s) && isspace(s[strlen(s) - 1])) s[strlen(s) - 1] = 0;
X
X  return s;
X}
X
X/* Clean up whitespace from start */
Xchar *strsclean(s)
X     char *s;
X{
X  char *d = s, *p = s;
X
X  /* Find first non-space char */
X  for (; *p; p++) if (!isspace(*p)) break;
X
X  /* Copy until end */
X  if (d != p) while (*d++ = *p++);
X
X  return s;
X}
X
SHAR_EOF
chmod 0644 strempty.c || echo "restore of strempty.c fails"
echo "x - extracting listscan.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > listscan.c &&
X#include <stdio.h>
X#include <string.h>
X#include "hsu.h"
X
X/* Searches char * table for string */
X
Xint listscan(list,search)
Xchar **list;
Xchar *search;
X{
X  register int i;
X  static char *p1, *p2;
X
X  i = 0;
X  p1 = *list++;
X  while (*p1 != '\0') {
X    p2 = search;
X    while (*p1 == *p2) {
X      if (*p1++ == '\0')
X    return(i);
X      p2++;
X    }
X    if (*p2 == ' ') return i;
X    i++;
X    p1 = *list++;
X  }
X  return -1;
X}
X
SHAR_EOF
chmod 0664 listscan.c || echo "restore of listscan.c fails"
echo "x - extracting ftime.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ftime.c &&
X#ifdef SCCSID
Xstatic char    *SccsId = "@(#)ftime.c    2.5    4/26/85";
X#endif /* SCSCID */
X
X#include <sys/types.h>
X#include "hsu.h"
X
Xstruct timeb
X{
X    time_t    time;
X    unsigned short millitm;
X    short    timezone;
X    short    dstflag;
X};
X
Xextern long timezone;
Xextern int  daylight;
X
Xftime(tp)
Xstruct timeb *tp;
X{
X    long t;
X
X    (void) time(&t);
X    tp->time = t;
X    tp->millitm = 0;
X    tp->timezone = timezone/60;
X    tp->dstflag = daylight;
X}
SHAR_EOF
chmod 0644 ftime.c || echo "restore of ftime.c fails"
echo "x - extracting fnet.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > fnet.h &&
X/* @(#)%M%  %I%  Teemu Torma %H%
X
X   General definitions for fidonet software
X
X   @(#)Copyright (c) 1987 by Teemu Torma
X
X   Permission is given to distribute this program and alter this code as
X   needed to adapt it to forign systems provided that this header is
X   included and that the original author's name is preserved. */
X
X#define PROGRAMNAME "rfmail 0.3.3"
X
X/* General defines to make program more readable and easier to write... */
X
X#define True (1)
X#define False (0)
X#define bool int
X#ifdef lint
Xextern char *strsave();
X#else
X#define strsave(s) (strcpy(malloc((unsigned) (strlen(s) + 1)), (s)))
X#endif
X#define BUFLEN 256
X#define OK (0)
X#define ERROR (-1)
X
X/* Global variables. */
X
Xextern bool verbose;
Xextern int line;
Xextern int receiving_data;
X
X/* Function declarations. */
X
Xextern int fine_convert();
Xextern char *ascnode();
Xextern char *internode();
Xextern char *ascnodei();
Xextern char *ascii_convert();
Xextern int stricmp();
Xextern int strnicmp();
Xextern char *sprintfs();
Xextern time_t getdate();
Xextern char *alloca();
Xextern void flush();
Xextern void sendline();
Xextern char *getcl();
Xextern void section();
Xextern void log();
Xextern void debug();
Xextern int lock();
Xextern int unlock();
Xextern char *spoolfile();
Xextern int quit();
Xextern char *basename();
Xextern FILE *pfopen();
Xextern char *date();
Xextern long job_number();
Xextern char *parse_address();
Xextern long sequencer();
Xextern char *mheader();
SHAR_EOF
chmod 0644 fnet.h || echo "restore of fnet.h fails"
echo "x - extracting config.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > config.h &&
X/* @(#)%M%  %I%  Teemu Torma %H%
X
X   Configure file for FidoNet mailing system.
X
X   @(#)Copyright (c) 1987 by Teemu Torma
X
X   Permission is given to distribute this program and alter this code as
X   needed to adapt it to forign systems provided that this header is
X   included and that the original author's name is preserved. */
X
X/* Change these defines for your system. */
X
X#ifndef INIT_VERBOSE
X#ifdef DEBUG
X#define INIT_VERBOSE 20
X#else
X#define INIT_VERBOSE 0
X#endif
X#endif
X
X/* Machine information */
X#define USG
X
X#ifdef USG
Xstruct timeb
X{
X  time_t    time;
X  unsigned short    millitm;
X  short        timezone;
X  short        dstflag;
X};
X#else
X#include <sys/timeb.h>
X#endif
X#include <ctype.h>
X
X/* This is our net and node number */
X#define MY_ZONE 2
X#define MY_REGION 22
X#define MY_NET 504
X#define MY_NODE 7
X#define MY_POINT 0
X
X/* Define your echo feed here. Currently only one echo feed
X   is supported but I work on it... */
X
X#define ECHOFEED_NET 504
X#define ECHOFEED_NODE 26
X
X/* How many seconds wait before starting up fidonet handshake */
X
X#define PREWAIT 5
X
X/* How many seconds to wait for line to clear */
X
X#define WAITCLEAR 2
X
X/* How many tries to give for xmodem startup in send. This should be low
X   value, it just gives possibility to retry xmodem startup if modems
X   handshaked too fast (really a acu configuration problems, dial should
X   return after it has a working line available!) */
X
X#define MAX_SEND_RETRIES 1
X
X/* Maximum baud rate to use when calling out */
X
X#define MAXBAUD 1200
X
X/* Define minimum baud rate to use when calling out */
X
X#define MINBAUD 300
X
X/* Width of formatted messages. Lines will be wrapped to be less
X   than this. If word is longer than 2/3s of MAX_LINELEN, it will be
X   cut instead of correct wrapping. */
X
X#define MAX_LINELEN 78
X
X/* Path to be added messages received. This is mostly to prevent
X   news messages to be resent back. Not really a nice way of doing
X   this but I feel sleepy now. */
X#define RECEIVE_PATH "emma"
X
X/* My domain suffix. If you don't have one, it will just be .UUCP */
X#define DOMAIN ".UUCP"
X
X/* Spool directory for packets and sended mail */
X#define SPOOL "/usr/spool/fnet"
X
X/* Spool directory for saving unpacked packets (should be cleared
X   from time to time.
X   NOTE! This directory must be on same file system as SPOOL. */
X#define UNPACKED_DIR "/usr/spool/fnet/unpacked"
X
X/* Spool directory for saving sent packets (should be cleared
X   from time to time.
X   NOTE! This directory must be on same file system as SPOOL. */
X#define SENTBUNDLE_DIR "/usr/spool/fnet/sentbundles"
X
X/* Library to hold all configure files and special programs */
X#define LIBDIR "/u2/lib/fnet"
X
X/* Program cabable of receiving a news-article (usually rnews) */
X#define RNEWS "/usr/bin/rnews"
X
X/* Name of log file */
X#define LOGFILE "/u2/lib/fnet/log"
X
X/* Name of orphans file (to put private echo messages to */
X#define ORPHANS "/u2/lib/fnet/orphans"
X
X/* Directory for bad messages, rmail or rnews returned nonzero exit */
X#define BADARTICLES "/usr/spool/fnet/bad"
X
X/* Name of Message-id sequence file */
X#define IDSEQUENCE "/u2/lib/fnet/idseq"
X
X/* Name of Input packet name sequence file */
X#define IPACKETSEQUENCE "/u2/lib/fnet/ipacketseq"
X
X/* Name of Output packet name sequence file (in sent packet directory) */
X#define OPACKETSEQUENCE "/u2/lib/fnet/opacketseq"
X
X/* Name of bad message sequence file */
X#define BADSEQ "/u2/lib/fnet/badseq"
X
X/* Lowist user's uid. */
X#define USERUID 50
X
X/* Name of alias file */
X#define ALIAS "/u2/lib/fnet/Alias"
X
X/* Mail sender */
X#define RMAIL "/bin/rmail"
X
X/* Define this if you have <sysexits.h> */
X/* #define HAVE_SYSEXITS /**/
X
X/* Type to hold 16 bit integer */
X#define INT16 short
X
X/* Define this if bytes need to be swapped to msdos */
X/* #define SWAB_BYTES /**/
X
X/* Define this if you want rfmail to return underlivered mail. You do
X   not need this if you are running sendmail or similiar which returns
X   undelivered mail. */
X#define RETURN_FAILED_MAIL /**/
X
X/* Shortnames, yak */
X
X#define packet_net zz0001zz
X#define packet_node zz0002zz
X
X/* Dial translation table. first string stripped out, second one replaced */
X
X#define DIALTABLE "358-0-", "",  "358-", "9",  "", "990"
X
X  /* End of configure section */
X
X#ifdef HAVE_SYSEXITS
X# include <sysexits.h>
X#else /* not HAVE_SYSEXITS */
X# define EX_OK 0 /* successful termination */
X# define EX_USAGE 64 /* command line usage error */
X# define EX_DATAERR 65 /* data format error */
X# define EX_NOINPUT 66 /* cannot open input */
X# define EX_NOHOST 68 /* host name unknown */
X# define EX_UNAVAILABLE 69 /* service unavailable */
X# define EX_SOFTWARE 70 /* internal software error */
X# define EX_OSERR 71 /* system error (e.g., can't fork) */
X# define EX_OSFILE 72 /* critical OS file missing */
X# define EX_CANTCREAT 73 /* can't create (user) output file */
X# define EX_IOERR 74 /* input/output error */
X#endif /* not HAVE_SYSEXITS */
X
SHAR_EOF
chmod 0644 config.h || echo "restore of config.h fails"
echo "x - extracting fpack.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > fpack.h &&
X/* @(#)%M%  %I%  Teemu Torma %H%
X
X   Header file for FidoNet-routines.
X
X   @(#)Copyright (c) 1987 by Teemu Torma
X
X   Permission is given to distribute this program and alter this code as
X   needed to adapt it to forign systems provided that this header is
X   included and that the original author's name is preserved. */
X
X/* Structure for packet header. */
X
Xtypedef struct _packet {
X  short orig_node; /* originating node */
X  short dest_node; /* destinating mode */
X  short year; /* packing year (e.g. 1986) */
X  short month; /* 0-11 for Jan - Dec */
X  short day; /* 1-31 */
X  short hour; /* 0-23 */
X  short minute; /* 0-59 */
X  short second; /* 0-59 */
X  short rate; /* maximum baud rate */
X  short ver; /* header version */
X  short orig_net; /* originating net */
X  short dest_net; /* destination net */
X  char product; /* product */
X  char x1; /* Extra byte */
X#ifdef FIDO_V11w
X  short fill[16]; /* extra space */
X#else
X  char pwd_kludge[8];
X  short orig_zone;
X  short dest_zone;
X  char B_fill2[16];
X  long B_fill3;
X#endif
X} Packet;
X
X/* Attributes tranferred via mail. */
X
X#define ATTR_PRIVATE (0000001) /* private msg */
X#define ATTR_CRASH (0000002) /* SEAdog only */
X#define ATTR_FILE (0000020) /* files attached */
X#define ATTR_UNUSED (0002000) /* unused */
X#define ATTR_RRR (0010000) /* SEAdog only */
X#define ATTR_IRR (0020000) /* SEAdog only */
X#define ATTR_AUDREQ (0040000) /* SEAdog only */
X
X/* Packet and message types. */
X
X#define HDRVER (02)
X#define MSGTYPE (02)
SHAR_EOF
chmod 0644 fpack.h || echo "restore of fpack.h fails"
echo "x - extracting rmail.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > rmail.h &&
X/* @(#)%M%  %I%  Teemu Torma %H%
X
X   Definitions for rmail
X
X   @(#)Copyright (c) 1987 by Teemu Torma
X
X   Permission is given to distribute this program and alter this code as
X   needed to adapt it to forign systems provided that this header is
X   included and that the original author's name is preserved. */
X
X/* Configurable definitions. Change them to according your configuration. */
X
X#define FIDOMAILER "/usr/llib/fnet/rfmail" /* fidonet mailer */
X/* #define RMAIL "/usr/lib/mail/rmail" /* real rmail */
X#define RMAIL "/bin/rmail" /* real rmail */
X#undef GATEWAY /* "pgmf" /* route to fidonet gateway */
X/* above undef??? */
X
X/* Don't touch the rest if you are not absolutely sure what you are
X   doing... */
X
X#define True (1)
X#define False (0)
X#define bool int
X#define marray(n) ((char **) malloc((unsigned) ((n) * sizeof(char *))))
SHAR_EOF
chmod 0644 rmail.h || echo "restore of rmail.h fails"
echo "x - extracting fio.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > fio.h &&
X/* @(#)%M%  %I%  Teemu Torma %H%
X
X   Definitions for io.
X
X   @(#)Copyright (c) 1987 by Teemu Torma
X
X   Permission is given to distribute this program and alter this code as
X   needed to adapt it to forign systems provided that this header is
X   included and that the original author's name is preserved. */
X
X/* Telink/xmodem special characters. */
X
X#define SOH (0x01) /* first character of xmodem block */
X#define STX (0x02) /* send 1 k blocks */
X#define ENQ (0x05) /* Bink sends this if there is no mail to pick up */
X#define ACK (0x06) /* ok to send */
X#define NAK (0x15) /* fail, resend */
X#define SYN (0x16) /* first character of telink block */
X#define EOT (0x04) /* end of stransmission */
X#define SUB (0x1a) /* end of filename in MODEM7 */
X#define CTRLZ (0x1a) /* char to fill partial packet */
X
X/* Definitions for xmodem. */
X
X#define BlockSize (128) /* small xmodem sector size */
X#define KBlockSize (1024) /* one k-byte xmodem sector size */
X
X/* Misc. definitions. */
X
X#define TSYNCH (0xae) /* sync character for fido */
X#define TIMEOUT (-2) /* timeout on readline() */
SHAR_EOF
chmod 0644 fio.h || echo "restore of fio.h fails"
echo "x - extracting crc.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > crc.h &&
X/* %M%  %I%  Teemu Torma %H%
X
X   Header file for updcrc macro.
X
X   @(#)Copyright (c) 1987 by Teemu Torma
X
X   Permission is given to distribute this program and alter this code as
X   needed to adapt it to forign systems provided that this header is
X   included and that the original author's name is preserved. */
X
Xextern unsigned short crctab[];
X
X/* #define updcrc(c, crc) (crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ c) */
X#define updcrc(c, crc) (crctab[((crc >> 8) & 255) ^ ((c) & 255)] ^ (crc << 8))
SHAR_EOF
chmod 0644 crc.h || echo "restore of crc.h fails"
echo "x - extracting hsu.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > hsu.h &&
X#ifndef H_HSU
X#define H_HSU 1
X
X/* I'm here !!! */
X
X#define HSU 1
X
X/* I fucked it up again */
X
X#define HSU_ERROR 100
X
X/* to debug or not to debug */
X
X#ifdef DEBUG
X#define LOG(level, x) printf x; _rkey()
X#define DBUG(x) LOG(D_ALL, (x))
X#else
X#define LOG(level, x)
X#define DBUG(x)
X#endif
X#define D_LOG 1
X#define D_ALL 2
X#define D_TEMP 4
X
X/* Specifies machine I run on */
X
X/* & needed to take address of setjmp variable? */
X#ifdef unix
X#define ADDRESS_OF_SETJMP_VARIABLE (char *) &
X#endif
X#ifdef MSDOS
X#define ADDRESS_OF_SETJMP_VARIABLE (char *) &
X#endif
X#ifndef ADDRESS_OF_SETJMP_VARIABLE
Xpang, pang, youre dead !!
X#endif
X
X/* General stuff I like */
X
X#ifndef TRUE
X#define TRUE 1
X#endif
X#ifndef FALSE
X#define FALSE 0
X#endif
X
X#define LINEBUF 256
X#define ERRBUF 512
X
X#define FLOATCHARS "0123456789.-eE+"
X#define INTCHARS "0123456789-"
X#define UNSIGNEDCHARS "0123456789"
X#define SEPARATORS " ,;\015\012\011"
X#define WHITESPACE " \015\012\011"
X
X/* If ALIGN_ODD defined, align long, int, double to n lower bits */
X
X#define ALIGN_ODD 1
X
X/* New alignment system, use this now and ignore ALIGN_ODD */
X
X#ifdef MSDOS
X#define SIZEOFINT 2
X#define INT_ALIGN 2
X#define CHAR_ARRAY_ALIGN 1
X#define LONG_ALIGN 2
X#define DOUBLE_ALIGN 2
X#define CHAR_ALIGN 1
X#endif
X#ifdef i286
X#define SIZEOFINT 2
X#define INT_ALIGN 2
X#define CHAR_ARRAY_ALIGN 1
X#define LONG_ALIGN 2
X#define DOUBLE_ALIGN 2
X#define CHAR_ALIGN 1
X#endif
X#ifdef i386
X#define SIZEOFINT 4
X#define INT_ALIGN 4
X#define CHAR_ARRAY_ALIGN 1
X#define LONG_ALIGN 4
X#define DOUBLE_ALIGN 4
X#define CHAR_ALIGN 1
X#endif
X#if defined(mc68k) || defined(m68k) || defined(m68000) || defined(m68k32)
X#define SIZEOFINT 4
X#define INT_ALIGN 4
X#define CHAR_ARRAY_ALIGN 1
X#define LONG_ALIGN 4
X#define DOUBLE_ALIGN 4
X#define CHAR_ALIGN 1
X#endif
X
X#ifndef SIZEOFINT
Xpang, pang, youre dead!!
X#endif
X
X/* Pointer type is int/long etc with size same as pointers */
X
X#define POINTER_TYPE long
X
X/* keys */
X
X#define ESC 27
X
X/* Can't live without this macro */
X
X#ifdef lint
Xextern char *strsave(), *strasave();
X#else
X#define strsave(s) (strcpy(malloc((unsigned) (strlen(s) + 1)), (s)))
X#define strasave(s) (strcpy(alloca((unsigned) (strlen(s) + 1)), (s)))
X#endif
X#define strequ(x,y) (strcmp(x,y) == 0)
X#define strnequ(x,y) (strcmp(x,y) != 0)
X#define strnotnull(x) (*x != '\0')
X#define strnull(x) (*x == '\0');
X/* Pointer to end of string */
X#define strend(x) ((x) + strlen(x))
X
X/* Increment counter, looping back to 0 if wrap-over */
X
X#define loop_increment(x,y) (x = (++x >= (y)) ? 0 : x)
X#define loop_decrement(x,y) (x = (--x < 0) ? (y)-1 : x)
X
X/* I use this always */
X
X#define curse(buf) waddstr(crnt_window,buf); wrefresh(crnt_window)
X
X#define BIT0 1
X#define BIT1 2
X#define BIT2 4
X#define BIT3 8
X#define BIT4 16
X#define BIT5 32
X#define BIT6 64
X#define BIT7 128
X#define BIT8 256
X#define BIT9 512
X#define BIT10 1024
X#define BIT11 2048
X#define BIT12 4096
X
X/* Some procedures */
X
Xextern char *alloca(), *strncpy(), *strncat(), *sprintfs(), *sstrcat();
Xextern char *mktemp(), *strclean(), *strsclean();
Xextern int strempty();
Xextern void exit(), qsort();
Xextern long time();
Xextern unsigned short getuid();
Xextern unsigned short geteuid();
Xextern unsigned short getgid();
Xextern unsigned short getegid();
Xextern unsigned alarm();
Xextern unsigned sleep();
X
X/* Some typedefs */
X
Xtypedef         int (*INT_FP)();
X
X/* Defines which are not in std libraries (why!?) */
X
Xextern char *optarg, *sys_errlist[], *getenv();
Xextern int optind, opterr, errno, sys_nerr;
Xextern long atol();
X
X/* I like it, and it's not always defined in math.h, (not in msc headers). */
X
X#ifndef _ABS
X#define _ABS(x) ((x) < 0 ? -(x) : (x))
X#endif
X#ifndef _MIN
X#define _MIN(x, y) ((x) < (y) ? (x) : (y))
X#endif
X
X/* Macro version of getw putw. w is destination. */
X
X#define FGETW(w, fp) \
X  if ((fp)->_cnt < sizeof(int)) w = getw(fp); \
X  else { w = *(int *) (fp)->_ptr; \
X       (fp)->_ptr += sizeof(int); (fp)->_cnt -= sizeof(int); }
X
X#define FPUTW(w, fp) \
X  if ((fp)->_cnt < sizeof(int)) putw(w, fp); \
X  else { *(int *) (fp)->_ptr = w; \
X       (fp)->_ptr += sizeof(int); (fp)->_cnt -= sizeof(int); }
X
X#define FGETINT16(w, fp) \
X  if ((fp)->_cnt < sizeof(short)) fread( (char *) &(w), sizeof(short), 1, fp);\
X  else { w = *(short *) (fp)->_ptr; \
X       (fp)->_ptr += sizeof(short); (fp)->_cnt -= sizeof(short); }
X
X#define FPUTINT16(w, fp) \
X  if ((fp)->_cnt < sizeof(short)) \
X    fwrite( (char *) &(w), sizeof(short), 1, fp); \
X  else { *(short *) (fp)->_ptr = w; \
X       (fp)->_ptr += sizeof(short); (fp)->_cnt -= sizeof(short); }
X
X#define FGETLW(w, fp) \
X  if ((fp)->_cnt < sizeof(long)) fread( (char *) &w, sizeof(long), 1, fp); \
X  else { w = *(long *) (fp)->_ptr; \
X       (fp)->_ptr += sizeof(long); (fp)->_cnt -= sizeof(long); }
X
X#define FPUTLW(w, fp) \
X  if ((fp)->_cnt < sizeof(long)) fwrite( (char *) &w, sizeof(long), 1, fp); \
X  else { *(long *) (fp)->_ptr = w; \
X       (fp)->_ptr += sizeof(long); (fp)->_cnt -= sizeof(long); }
X
X#ifdef SAFE
X#define FREAD(p, bytes, nitems, fp) (void) fread(p, bytes, nitems, fp)
X#define FWRITE(p, bytes, nitems, fp) (void) fwrite(p, bytes, nitems, fp)
X#else
X
X/* And fread, fwrite. Don't return a value, so it has to be checked. */
X/*
X
X  could this work? test it!
X  #define FREAD(p, bytes, nitems, fp)
X  (((fp)->_cnt < (nitems) * (bytes)) ? fread(p, bytes, nitems, fp) :
X  nitems, memcpy( (p), (char *) (fp)->_ptr, (int) ((nitems) * (bytes))),
X  (fp)->_ptr += (nitems) * (bytes), (fp)->_cnt -= (nitems) * (bytes))
X
X  */
X#define FREAD(p, bytes, nitems, fp) \
X  if ((fp)->_cnt < (nitems) * (bytes)) (void) fread(p, bytes, nitems, fp); \
X  else { memcpy( (p), (char *) (fp)->_ptr, (int) ((nitems) * (bytes))); \
X       (fp)->_ptr += (nitems) * (bytes); \
X         (fp)->_cnt -= (nitems) * (bytes); }
X
X#define FWRITE(p, bytes, nitems, fp) \
X  if ((fp)->_cnt < (nitems) * (bytes)) (void) fwrite(p, bytes, nitems, fp); \
X  else { memcpy( (char *) (fp)->_ptr, (p), (int) ((nitems) * (bytes))); \
X       (fp)->_ptr += (nitems) * (bytes); \
X         (fp)->_cnt -= (nitems) * (bytes); }
X#endif
X
X/* FGETS differ from original: \n in the end is NOT copied!! (because
X   I don't like that) */
X
Xextern char *strnchr();
X
X#define FGETS(cp, maxlen, fp) \
X  if (strnchr((fp)->_ptr, '\n', (fp)->_cnt)) \
X{ \
X  register count; \
X  register char *p; \
X  for (count = 1, p = cp; (*p = *(fp)->_ptr++) != '\n'; p++, count++) \
X    if (count >= (maxlen)) break; \
X  *p = '\0'; \
X  (fp)->_cnt -= count; \
X} else { \
X  fgets(cp, maxlen, fp); \
X  if (strchr(cp, '\n')) *(strchr(cp, '\n')) = '\0'; \
X}
X
X/* Checks for both eof and error status, better than feof || ferror when
X   compilers are stupid enough not to optimize that kind of situation. */
X
X#define ferr(fp) ((fp)->_flag & (_IOEOF | _IOERR))
X
X#endif /* H_HSU */
X
SHAR_EOF
chmod 0664 hsu.h || echo "restore of hsu.h fails"
echo "x - extracting shuffle.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > shuffle.h &&
X#define MAX_CONVERT_BUFFERS 10
X#define MAX_CONVERT_BUFLEN 80
Xstatic char bufs[MAX_CONVERT_BUFFERS][MAX_CONVERT_BUFLEN], *tcharp;
Xstatic int bflag;
X
X#define SHUFFLEBUFFERS \
Xloop_increment(bflag, MAX_CONVERT_BUFFERS); tcharp = bufs[bflag]
SHAR_EOF
chmod 0644 shuffle.h || echo "restore of shuffle.h fails"
echo "x - extracting sysexits.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > sysexits.h &&
X/* @(#)%M%  %I%  Teemu Torma %H%
X
X   Exit statuses for systems that doesn't have /usr/include/sysexits.h */
X
X#define EX_OK 0 /* successful termination */
X#define EX_USAGE 64 /* command line usage error */
X#define EX_DATAERR 65 /* data format error */
X#define EX_NOINPUT 66 /* cannot open input */
X#define EX_NOHOST 68 /* host name unknown */
X#define EX_UNAVAILABLE 69 /* service unavailable */
X#define EX_SOFTWARE 70 /* internal software error */
X#define EX_OSERR 71 /* system error (e.g., can't fork) */
X#define EX_OSFILE 72 /* critical OS file missing */
X#define EX_CANTCREAT 73 /* can't create (user) output file */
X#define EX_IOERR 74 /* input/output error */
SHAR_EOF
chmod 0644 sysexits.h || echo "restore of sysexits.h fails"
echo "x - extracting nodelist.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > nodelist.h &&
X/* @(#)%M%  %I%  Teemu Torma %H%
X
X   Structures and definitions for nodelist.
X
X   @(#)Copyright (c) 1987 by Teemu Torma
X
X   Permission is given to distribute this program and alter this code as
X   needed to adapt it to forign systems provided that this header is
X   included and that the original author's name is preserved. */
X
X/* Change these if you wish. */
X
X/* Name of nodelist in LIBDIR */
X#define NODELIST "nodelist"
X
X/* Name of nodelist index file in LIBDIR */
X#define INODELIST "nodelist.idx"
X
X/* Name of sysop name index file in LIBDIR */
X#define NAMELIST "name.idx"
X
X/* Compare two node entried to see if they are same node (ignoring
X   possible other information */
X#define samenode(n1, n2) ((n1).zone == (n2).zone && (n1).net == (n2).net && \
X              (n1).node == (n2).node && (n1).point == (n2).point)
X
X/* Structure for nodelist entry. Routines to get one node from nodelist
X   will return this structure. */
X
Xtypedef struct _node {
X  int type; /* type of entry (see below) */
X  int region; /* region (not necessarily used/set) */
X  int net; /* net/region of node */
X  int zone; /* Zone of node (not really supported yet) */
X  int node; /* number of node */
X  int point; /* Point of node (not really supported yet) */
X  char name[20]; /* name of fido */
X  char city[40]; /* city */
X  char sysop[36]; /* name of sysop */
X  char phone[40]; /* phone-number */
X  int speed; /* speeds */
X  char flags[60]; /* flags-string */
X} Node;
X
Xtypedef struct _indexnode {
X  int zone;
X  int net;
X  int node;
X  long offset;
X} NODEINDEX;
X
Xtypedef struct _indexname {
X  char name[36]; /* Sysop name */
X  long offset; /* Refers to nodelist index entry */
X  int zone;
X  int net;
X} NAMEINDEX;
X
X/* Entry types. */
X
X#define REGION (1) /* region-host */
X#define HOST (2) /* net-host */
X#define HUB (3) /* local-host */
X#define PVT (4) /* private node */
X#define HOLD (5) /* no mail to this node */
X#define DOWN (6) /* node is down */
X#define KENL (7) /* should not be comminucated */
X#define NORMAL (8) /* normal node */
X#define ZONE (9) /* Zone */
X#define POINT (10) /* point (points are not in nodelist but this is used
X              elsewhere. */
X
X/* Declarations for routines. */
X
XNode *node_entry(); /* get entry from nodelist */
Xchar *update_index(); /* update index-file */
Xextern Node *parse_entry();
X
Xextern Node originnode;
Xextern NODEINDEX *nodeindex;
Xextern NAMEINDEX *nameindex;
Xextern int nodes;
SHAR_EOF
chmod 0644 nodelist.h || echo "restore of nodelist.h fails"
echo "x - extracting fnews.h (Text)"
sed 's/^X//' << 'SHAR_EOF' > fnews.h &&
X/* @(#)%M%  %I% Teemu Torma %H%
X
X   Definitions for fidonet news-system.
X
X   @(#)Copyright (c) 1987 by Teemu Torma
X
X   Permission is given to distribute this program and alter this code as
X   needed to adapt it to forign systems provided that this header is
X   included and that the original author's name is preserved. */
X
X/* Section definitions for configure file. */
X
X#define SECT_NETNODE (1) /* Net/node for receiving node */
X#define SECT_NG_AREA (2) /* Newsgroup -> area conversions */
X#define SECT_HEADERS (3) /* Header-field definitions */
X#define SECT_ENDMSG (4) /* Text to be placed at the end of msg */
X#define SECT_AREA_NG (5) /* Area -> newsgroup conversions */
X
X/* Other definitions for news-system. */
X
X/* If you have some junk area (like junk in Usenet News), define this
X   to name of that area. Otherwise messages to unknown areas will
X   be dicarded. */
X#define JUNK_AREA "FNET.JUNK" /**/
X
X/* Usenet news junk area. Unknown echos are put here */
X#define JUNK "junk" /**/
SHAR_EOF
chmod 0644 fnews.h || echo "restore of fnews.h fails"
rm -f s2_seq_.tmp
echo "You have unpacked the last part"
exit 0

-- 
Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.