home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume18 / fnet / part05 < prev    next >
Encoding:
Internet Message Format  |  1989-03-05  |  28.9 KB

  1. Subject:  v18i006:  Fido/Usenet gateway, Part05/05
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Heikki Suonsivu <hsu@santra.hut.fi>
  7. Posting-number: Volume 18, Issue 6
  8. Archive-name: fnet/part05
  9.  
  10. #!/bin/sh
  11. # this is part 5 of a multipart archive
  12. # do not concatenate these parts, unpack them in order with /bin/sh
  13. # file crc.c continued
  14. #
  15. CurArch=5
  16. if test ! -r s2_seq_.tmp
  17. then echo "Please unpack part 1 first!"
  18.      exit 1; fi
  19. ( read Scheck
  20.   if test "$Scheck" != $CurArch
  21.   then echo "Please unpack part $Scheck next!"
  22.        exit 1;
  23.   else exit 0; fi
  24. ) < s2_seq_.tmp || exit 1
  25. echo "x - Continuing file crc.c"
  26. sed 's/^X//' << 'SHAR_EOF' >> crc.c
  27. X0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
  28.  0x316e8eef, 0x4669be79,
  29. X0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703,
  30.  0x220216b9, 0x5505262f,
  31. X0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
  32.  0x2cd99e8b, 0x5bdeae1d,
  33. X0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
  34.  0x72076785, 0x05005713,
  35. X0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d,
  36.  0x7cdcefb7, 0x0bdbdf21,
  37. X0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b,
  38.  0x6fb077e1, 0x18b74777,
  39. X0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
  40.  0x616bffd3, 0x166ccf45,
  41. X0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
  42.  0x4969474d, 0x3e6e77db,
  43. X0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5,
  44.  0x47b2cf7f, 0x30b5ffe9,
  45. X0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
  46.  0x54de5729, 0x23d967bf,
  47. X0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1,
  48.  0x5a05df1b, 0x2d02ef8d
  49. X};
  50. X#endif
  51. X
  52. X#ifdef NFGM
  53. Xlong
  54. XUPDC32(b, c)
  55. Xlong c;
  56. X{
  57. X    return (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF));
  58. X}
  59. X
  60. X#else
  61. X
  62. X#define UPDC32(b, c) (cr3tab[((int)c ^ b) & 0xff] ^ ((c >> 8) & 0x00FFFFFF))
  63. X#endif
  64. X
  65. X
  66. SHAR_EOF
  67. echo "File crc.c is complete"
  68. chmod 0644 crc.c || echo "restore of crc.c fails"
  69. echo "x - extracting lintlib.c (Text)"
  70. sed 's/^X//' << 'SHAR_EOF' > lintlib.c &&
  71. X/* This is for functions not defined anywhere */
  72. X
  73. X#include <stdio.h>
  74. X#include <sys/types.h>
  75. X#include "hsu.h"
  76. X#include "config.h"
  77. X
  78. X#ifdef lint
  79. X/*ARGSUSED*/
  80. Xlockf(fd, mode, position) int fd, mode; long position; { return 0; }
  81. X/*ARGSUSED*/
  82. Xchar *strnchr(p, c, maxlen) unsigned char *p; int c, maxlen;
  83. X{ return (char *) p; }
  84. X/*ARGSUSED*/
  85. Xchar *strsave(s) char *s; { return s; }
  86. X/*ARGSUSED*/
  87. X/*VARARGS1*/
  88. Xchar *regex(re) char *re; {}
  89. X/*ARGSUSED*/
  90. Xtime_t getdate(p, now) char *p; struct timeb *now; { return 0L; }
  91. X#endif
  92. X
  93. X
  94. SHAR_EOF
  95. chmod 0644 lintlib.c || echo "restore of lintlib.c fails"
  96. echo "x - extracting sprintfs.c (Text)"
  97. sed 's/^X//' << 'SHAR_EOF' > sprintfs.c &&
  98. X#include <stdio.h>
  99. X#include <varargs.h>
  100. X#include "hsu.h"
  101. X
  102. X#define MAX_CONVERT_BUFFERS 10
  103. X#define MAX_CONVERT_BUFLEN 80
  104. Xstatic char bufs[MAX_CONVERT_BUFFERS][MAX_CONVERT_BUFLEN], *tcharp;
  105. Xstatic bflag;
  106. X
  107. X#define SHUFFLEBUFFERS \
  108. Xloop_increment(bflag, MAX_CONVERT_BUFFERS); tcharp = bufs[bflag]
  109. X
  110. X/* Strcat creating its own buffer */
  111. X
  112. Xchar *sstrcat(d, s)
  113. X     char *d, *s;
  114. X{
  115. X  SHUFFLEBUFFERS;
  116. X
  117. X  (void) strncpy(tcharp, d, MAX_CONVERT_BUFLEN);
  118. X  tcharp[MAX_CONVERT_BUFLEN - 1] = '\0';
  119. X  (void) strncat(tcharp, s, MAX_CONVERT_BUFLEN);
  120. X  return tcharp;
  121. X}
  122. X
  123. X/* Sprintf with own buffer */
  124. X
  125. X/*VARARGS1*/
  126. Xchar *sprintfs(fmt, va_alist)
  127. X     char *fmt;
  128. X     va_dcl
  129. X{
  130. X  va_list pvar;
  131. X
  132. X  va_start(pvar);
  133. X
  134. X  SHUFFLEBUFFERS;
  135. X
  136. X  vsprintf(tcharp, fmt, pvar);
  137. X
  138. X  va_end(pvar);
  139. X
  140. X  return tcharp;
  141. X}
  142. X
  143. SHAR_EOF
  144. chmod 0644 sprintfs.c || echo "restore of sprintfs.c fails"
  145. echo "x - extracting strempty.c (Text)"
  146. sed 's/^X//' << 'SHAR_EOF' > strempty.c &&
  147. X#include <string.h>
  148. X#include <ctype.h>
  149. X#include "hsu.h"
  150. X
  151. X/* Check if string just consists of space (or is null). Return TRUE if so */
  152. X
  153. Xstrempty(s)
  154. X     char *s;
  155. X{
  156. X  while (*s) if (!isspace(*s)) return FALSE; else s++;
  157. X  return TRUE;
  158. X}
  159. X
  160. X/* Clean up space from start and end */
  161. X
  162. Xchar *strclean(s)
  163. X     char *s;
  164. X{
  165. X  char *d = s, *p = s;
  166. X
  167. X  /* Find first non-space char */
  168. X  for (; *p; p++) if (!isspace(*p)) break;
  169. X
  170. X  /* Copy until end */
  171. X  if (d != p) while (*d++ = *p++);
  172. X
  173. X  /* Strip space from end */
  174. X  while (strlen(s) && isspace(s[strlen(s) - 1])) s[strlen(s) - 1] = 0;
  175. X
  176. X  return s;
  177. X}
  178. X
  179. X/* Clean up whitespace from start */
  180. Xchar *strsclean(s)
  181. X     char *s;
  182. X{
  183. X  char *d = s, *p = s;
  184. X
  185. X  /* Find first non-space char */
  186. X  for (; *p; p++) if (!isspace(*p)) break;
  187. X
  188. X  /* Copy until end */
  189. X  if (d != p) while (*d++ = *p++);
  190. X
  191. X  return s;
  192. X}
  193. X
  194. SHAR_EOF
  195. chmod 0644 strempty.c || echo "restore of strempty.c fails"
  196. echo "x - extracting listscan.c (Text)"
  197. sed 's/^X//' << 'SHAR_EOF' > listscan.c &&
  198. X#include <stdio.h>
  199. X#include <string.h>
  200. X#include "hsu.h"
  201. X
  202. X/* Searches char * table for string */
  203. X
  204. Xint listscan(list,search)
  205. Xchar **list;
  206. Xchar *search;
  207. X{
  208. X  register int i;
  209. X  static char *p1, *p2;
  210. X
  211. X  i = 0;
  212. X  p1 = *list++;
  213. X  while (*p1 != '\0') {
  214. X    p2 = search;
  215. X    while (*p1 == *p2) {
  216. X      if (*p1++ == '\0')
  217. X    return(i);
  218. X      p2++;
  219. X    }
  220. X    if (*p2 == ' ') return i;
  221. X    i++;
  222. X    p1 = *list++;
  223. X  }
  224. X  return -1;
  225. X}
  226. X
  227. SHAR_EOF
  228. chmod 0664 listscan.c || echo "restore of listscan.c fails"
  229. echo "x - extracting ftime.c (Text)"
  230. sed 's/^X//' << 'SHAR_EOF' > ftime.c &&
  231. X#ifdef SCCSID
  232. Xstatic char    *SccsId = "@(#)ftime.c    2.5    4/26/85";
  233. X#endif /* SCSCID */
  234. X
  235. X#include <sys/types.h>
  236. X#include "hsu.h"
  237. X
  238. Xstruct timeb
  239. X{
  240. X    time_t    time;
  241. X    unsigned short millitm;
  242. X    short    timezone;
  243. X    short    dstflag;
  244. X};
  245. X
  246. Xextern long timezone;
  247. Xextern int  daylight;
  248. X
  249. Xftime(tp)
  250. Xstruct timeb *tp;
  251. X{
  252. X    long t;
  253. X
  254. X    (void) time(&t);
  255. X    tp->time = t;
  256. X    tp->millitm = 0;
  257. X    tp->timezone = timezone/60;
  258. X    tp->dstflag = daylight;
  259. X}
  260. SHAR_EOF
  261. chmod 0644 ftime.c || echo "restore of ftime.c fails"
  262. echo "x - extracting fnet.h (Text)"
  263. sed 's/^X//' << 'SHAR_EOF' > fnet.h &&
  264. X/* @(#)%M%  %I%  Teemu Torma %H%
  265. X
  266. X   General definitions for fidonet software
  267. X
  268. X   @(#)Copyright (c) 1987 by Teemu Torma
  269. X
  270. X   Permission is given to distribute this program and alter this code as
  271. X   needed to adapt it to forign systems provided that this header is
  272. X   included and that the original author's name is preserved. */
  273. X
  274. X#define PROGRAMNAME "rfmail 0.3.3"
  275. X
  276. X/* General defines to make program more readable and easier to write... */
  277. X
  278. X#define True (1)
  279. X#define False (0)
  280. X#define bool int
  281. X#ifdef lint
  282. Xextern char *strsave();
  283. X#else
  284. X#define strsave(s) (strcpy(malloc((unsigned) (strlen(s) + 1)), (s)))
  285. X#endif
  286. X#define BUFLEN 256
  287. X#define OK (0)
  288. X#define ERROR (-1)
  289. X
  290. X/* Global variables. */
  291. X
  292. Xextern bool verbose;
  293. Xextern int line;
  294. Xextern int receiving_data;
  295. X
  296. X/* Function declarations. */
  297. X
  298. Xextern int fine_convert();
  299. Xextern char *ascnode();
  300. Xextern char *internode();
  301. Xextern char *ascnodei();
  302. Xextern char *ascii_convert();
  303. Xextern int stricmp();
  304. Xextern int strnicmp();
  305. Xextern char *sprintfs();
  306. Xextern time_t getdate();
  307. Xextern char *alloca();
  308. Xextern void flush();
  309. Xextern void sendline();
  310. Xextern char *getcl();
  311. Xextern void section();
  312. Xextern void log();
  313. Xextern void debug();
  314. Xextern int lock();
  315. Xextern int unlock();
  316. Xextern char *spoolfile();
  317. Xextern int quit();
  318. Xextern char *basename();
  319. Xextern FILE *pfopen();
  320. Xextern char *date();
  321. Xextern long job_number();
  322. Xextern char *parse_address();
  323. Xextern long sequencer();
  324. Xextern char *mheader();
  325. SHAR_EOF
  326. chmod 0644 fnet.h || echo "restore of fnet.h fails"
  327. echo "x - extracting config.h (Text)"
  328. sed 's/^X//' << 'SHAR_EOF' > config.h &&
  329. X/* @(#)%M%  %I%  Teemu Torma %H%
  330. X
  331. X   Configure file for FidoNet mailing system.
  332. X
  333. X   @(#)Copyright (c) 1987 by Teemu Torma
  334. X
  335. X   Permission is given to distribute this program and alter this code as
  336. X   needed to adapt it to forign systems provided that this header is
  337. X   included and that the original author's name is preserved. */
  338. X
  339. X/* Change these defines for your system. */
  340. X
  341. X#ifndef INIT_VERBOSE
  342. X#ifdef DEBUG
  343. X#define INIT_VERBOSE 20
  344. X#else
  345. X#define INIT_VERBOSE 0
  346. X#endif
  347. X#endif
  348. X
  349. X/* Machine information */
  350. X#define USG
  351. X
  352. X#ifdef USG
  353. Xstruct timeb
  354. X{
  355. X  time_t    time;
  356. X  unsigned short    millitm;
  357. X  short        timezone;
  358. X  short        dstflag;
  359. X};
  360. X#else
  361. X#include <sys/timeb.h>
  362. X#endif
  363. X#include <ctype.h>
  364. X
  365. X/* This is our net and node number */
  366. X#define MY_ZONE 2
  367. X#define MY_REGION 22
  368. X#define MY_NET 504
  369. X#define MY_NODE 7
  370. X#define MY_POINT 0
  371. X
  372. X/* Define your echo feed here. Currently only one echo feed
  373. X   is supported but I work on it... */
  374. X
  375. X#define ECHOFEED_NET 504
  376. X#define ECHOFEED_NODE 26
  377. X
  378. X/* How many seconds wait before starting up fidonet handshake */
  379. X
  380. X#define PREWAIT 5
  381. X
  382. X/* How many seconds to wait for line to clear */
  383. X
  384. X#define WAITCLEAR 2
  385. X
  386. X/* How many tries to give for xmodem startup in send. This should be low
  387. X   value, it just gives possibility to retry xmodem startup if modems
  388. X   handshaked too fast (really a acu configuration problems, dial should
  389. X   return after it has a working line available!) */
  390. X
  391. X#define MAX_SEND_RETRIES 1
  392. X
  393. X/* Maximum baud rate to use when calling out */
  394. X
  395. X#define MAXBAUD 1200
  396. X
  397. X/* Define minimum baud rate to use when calling out */
  398. X
  399. X#define MINBAUD 300
  400. X
  401. X/* Width of formatted messages. Lines will be wrapped to be less
  402. X   than this. If word is longer than 2/3s of MAX_LINELEN, it will be
  403. X   cut instead of correct wrapping. */
  404. X
  405. X#define MAX_LINELEN 78
  406. X
  407. X/* Path to be added messages received. This is mostly to prevent
  408. X   news messages to be resent back. Not really a nice way of doing
  409. X   this but I feel sleepy now. */
  410. X#define RECEIVE_PATH "emma"
  411. X
  412. X/* My domain suffix. If you don't have one, it will just be .UUCP */
  413. X#define DOMAIN ".UUCP"
  414. X
  415. X/* Spool directory for packets and sended mail */
  416. X#define SPOOL "/usr/spool/fnet"
  417. X
  418. X/* Spool directory for saving unpacked packets (should be cleared
  419. X   from time to time.
  420. X   NOTE! This directory must be on same file system as SPOOL. */
  421. X#define UNPACKED_DIR "/usr/spool/fnet/unpacked"
  422. X
  423. X/* Spool directory for saving sent packets (should be cleared
  424. X   from time to time.
  425. X   NOTE! This directory must be on same file system as SPOOL. */
  426. X#define SENTBUNDLE_DIR "/usr/spool/fnet/sentbundles"
  427. X
  428. X/* Library to hold all configure files and special programs */
  429. X#define LIBDIR "/u2/lib/fnet"
  430. X
  431. X/* Program cabable of receiving a news-article (usually rnews) */
  432. X#define RNEWS "/usr/bin/rnews"
  433. X
  434. X/* Name of log file */
  435. X#define LOGFILE "/u2/lib/fnet/log"
  436. X
  437. X/* Name of orphans file (to put private echo messages to */
  438. X#define ORPHANS "/u2/lib/fnet/orphans"
  439. X
  440. X/* Directory for bad messages, rmail or rnews returned nonzero exit */
  441. X#define BADARTICLES "/usr/spool/fnet/bad"
  442. X
  443. X/* Name of Message-id sequence file */
  444. X#define IDSEQUENCE "/u2/lib/fnet/idseq"
  445. X
  446. X/* Name of Input packet name sequence file */
  447. X#define IPACKETSEQUENCE "/u2/lib/fnet/ipacketseq"
  448. X
  449. X/* Name of Output packet name sequence file (in sent packet directory) */
  450. X#define OPACKETSEQUENCE "/u2/lib/fnet/opacketseq"
  451. X
  452. X/* Name of bad message sequence file */
  453. X#define BADSEQ "/u2/lib/fnet/badseq"
  454. X
  455. X/* Lowist user's uid. */
  456. X#define USERUID 50
  457. X
  458. X/* Name of alias file */
  459. X#define ALIAS "/u2/lib/fnet/Alias"
  460. X
  461. X/* Mail sender */
  462. X#define RMAIL "/bin/rmail"
  463. X
  464. X/* Define this if you have <sysexits.h> */
  465. X/* #define HAVE_SYSEXITS /**/
  466. X
  467. X/* Type to hold 16 bit integer */
  468. X#define INT16 short
  469. X
  470. X/* Define this if bytes need to be swapped to msdos */
  471. X/* #define SWAB_BYTES /**/
  472. X
  473. X/* Define this if you want rfmail to return underlivered mail. You do
  474. X   not need this if you are running sendmail or similiar which returns
  475. X   undelivered mail. */
  476. X#define RETURN_FAILED_MAIL /**/
  477. X
  478. X/* Shortnames, yak */
  479. X
  480. X#define packet_net zz0001zz
  481. X#define packet_node zz0002zz
  482. X
  483. X/* Dial translation table. first string stripped out, second one replaced */
  484. X
  485. X#define DIALTABLE "358-0-", "",  "358-", "9",  "", "990"
  486. X
  487. X  /* End of configure section */
  488. X
  489. X#ifdef HAVE_SYSEXITS
  490. X# include <sysexits.h>
  491. X#else /* not HAVE_SYSEXITS */
  492. X# define EX_OK 0 /* successful termination */
  493. X# define EX_USAGE 64 /* command line usage error */
  494. X# define EX_DATAERR 65 /* data format error */
  495. X# define EX_NOINPUT 66 /* cannot open input */
  496. X# define EX_NOHOST 68 /* host name unknown */
  497. X# define EX_UNAVAILABLE 69 /* service unavailable */
  498. X# define EX_SOFTWARE 70 /* internal software error */
  499. X# define EX_OSERR 71 /* system error (e.g., can't fork) */
  500. X# define EX_OSFILE 72 /* critical OS file missing */
  501. X# define EX_CANTCREAT 73 /* can't create (user) output file */
  502. X# define EX_IOERR 74 /* input/output error */
  503. X#endif /* not HAVE_SYSEXITS */
  504. X
  505. SHAR_EOF
  506. chmod 0644 config.h || echo "restore of config.h fails"
  507. echo "x - extracting fpack.h (Text)"
  508. sed 's/^X//' << 'SHAR_EOF' > fpack.h &&
  509. X/* @(#)%M%  %I%  Teemu Torma %H%
  510. X
  511. X   Header file for FidoNet-routines.
  512. X
  513. X   @(#)Copyright (c) 1987 by Teemu Torma
  514. X
  515. X   Permission is given to distribute this program and alter this code as
  516. X   needed to adapt it to forign systems provided that this header is
  517. X   included and that the original author's name is preserved. */
  518. X
  519. X/* Structure for packet header. */
  520. X
  521. Xtypedef struct _packet {
  522. X  short orig_node; /* originating node */
  523. X  short dest_node; /* destinating mode */
  524. X  short year; /* packing year (e.g. 1986) */
  525. X  short month; /* 0-11 for Jan - Dec */
  526. X  short day; /* 1-31 */
  527. X  short hour; /* 0-23 */
  528. X  short minute; /* 0-59 */
  529. X  short second; /* 0-59 */
  530. X  short rate; /* maximum baud rate */
  531. X  short ver; /* header version */
  532. X  short orig_net; /* originating net */
  533. X  short dest_net; /* destination net */
  534. X  char product; /* product */
  535. X  char x1; /* Extra byte */
  536. X#ifdef FIDO_V11w
  537. X  short fill[16]; /* extra space */
  538. X#else
  539. X  char pwd_kludge[8];
  540. X  short orig_zone;
  541. X  short dest_zone;
  542. X  char B_fill2[16];
  543. X  long B_fill3;
  544. X#endif
  545. X} Packet;
  546. X
  547. X/* Attributes tranferred via mail. */
  548. X
  549. X#define ATTR_PRIVATE (0000001) /* private msg */
  550. X#define ATTR_CRASH (0000002) /* SEAdog only */
  551. X#define ATTR_FILE (0000020) /* files attached */
  552. X#define ATTR_UNUSED (0002000) /* unused */
  553. X#define ATTR_RRR (0010000) /* SEAdog only */
  554. X#define ATTR_IRR (0020000) /* SEAdog only */
  555. X#define ATTR_AUDREQ (0040000) /* SEAdog only */
  556. X
  557. X/* Packet and message types. */
  558. X
  559. X#define HDRVER (02)
  560. X#define MSGTYPE (02)
  561. SHAR_EOF
  562. chmod 0644 fpack.h || echo "restore of fpack.h fails"
  563. echo "x - extracting rmail.h (Text)"
  564. sed 's/^X//' << 'SHAR_EOF' > rmail.h &&
  565. X/* @(#)%M%  %I%  Teemu Torma %H%
  566. X
  567. X   Definitions for rmail
  568. X
  569. X   @(#)Copyright (c) 1987 by Teemu Torma
  570. X
  571. X   Permission is given to distribute this program and alter this code as
  572. X   needed to adapt it to forign systems provided that this header is
  573. X   included and that the original author's name is preserved. */
  574. X
  575. X/* Configurable definitions. Change them to according your configuration. */
  576. X
  577. X#define FIDOMAILER "/usr/llib/fnet/rfmail" /* fidonet mailer */
  578. X/* #define RMAIL "/usr/lib/mail/rmail" /* real rmail */
  579. X#define RMAIL "/bin/rmail" /* real rmail */
  580. X#undef GATEWAY /* "pgmf" /* route to fidonet gateway */
  581. X/* above undef??? */
  582. X
  583. X/* Don't touch the rest if you are not absolutely sure what you are
  584. X   doing... */
  585. X
  586. X#define True (1)
  587. X#define False (0)
  588. X#define bool int
  589. X#define marray(n) ((char **) malloc((unsigned) ((n) * sizeof(char *))))
  590. SHAR_EOF
  591. chmod 0644 rmail.h || echo "restore of rmail.h fails"
  592. echo "x - extracting fio.h (Text)"
  593. sed 's/^X//' << 'SHAR_EOF' > fio.h &&
  594. X/* @(#)%M%  %I%  Teemu Torma %H%
  595. X
  596. X   Definitions for io.
  597. X
  598. X   @(#)Copyright (c) 1987 by Teemu Torma
  599. X
  600. X   Permission is given to distribute this program and alter this code as
  601. X   needed to adapt it to forign systems provided that this header is
  602. X   included and that the original author's name is preserved. */
  603. X
  604. X/* Telink/xmodem special characters. */
  605. X
  606. X#define SOH (0x01) /* first character of xmodem block */
  607. X#define STX (0x02) /* send 1 k blocks */
  608. X#define ENQ (0x05) /* Bink sends this if there is no mail to pick up */
  609. X#define ACK (0x06) /* ok to send */
  610. X#define NAK (0x15) /* fail, resend */
  611. X#define SYN (0x16) /* first character of telink block */
  612. X#define EOT (0x04) /* end of stransmission */
  613. X#define SUB (0x1a) /* end of filename in MODEM7 */
  614. X#define CTRLZ (0x1a) /* char to fill partial packet */
  615. X
  616. X/* Definitions for xmodem. */
  617. X
  618. X#define BlockSize (128) /* small xmodem sector size */
  619. X#define KBlockSize (1024) /* one k-byte xmodem sector size */
  620. X
  621. X/* Misc. definitions. */
  622. X
  623. X#define TSYNCH (0xae) /* sync character for fido */
  624. X#define TIMEOUT (-2) /* timeout on readline() */
  625. SHAR_EOF
  626. chmod 0644 fio.h || echo "restore of fio.h fails"
  627. echo "x - extracting crc.h (Text)"
  628. sed 's/^X//' << 'SHAR_EOF' > crc.h &&
  629. X/* %M%  %I%  Teemu Torma %H%
  630. X
  631. X   Header file for updcrc macro.
  632. X
  633. X   @(#)Copyright (c) 1987 by Teemu Torma
  634. X
  635. X   Permission is given to distribute this program and alter this code as
  636. X   needed to adapt it to forign systems provided that this header is
  637. X   included and that the original author's name is preserved. */
  638. X
  639. Xextern unsigned short crctab[];
  640. X
  641. X/* #define updcrc(c, crc) (crctab[((crc >> 8) & 255)] ^ (crc << 8) ^ c) */
  642. X#define updcrc(c, crc) (crctab[((crc >> 8) & 255) ^ ((c) & 255)] ^ (crc << 8))
  643. SHAR_EOF
  644. chmod 0644 crc.h || echo "restore of crc.h fails"
  645. echo "x - extracting hsu.h (Text)"
  646. sed 's/^X//' << 'SHAR_EOF' > hsu.h &&
  647. X#ifndef H_HSU
  648. X#define H_HSU 1
  649. X
  650. X/* I'm here !!! */
  651. X
  652. X#define HSU 1
  653. X
  654. X/* I fucked it up again */
  655. X
  656. X#define HSU_ERROR 100
  657. X
  658. X/* to debug or not to debug */
  659. X
  660. X#ifdef DEBUG
  661. X#define LOG(level, x) printf x; _rkey()
  662. X#define DBUG(x) LOG(D_ALL, (x))
  663. X#else
  664. X#define LOG(level, x)
  665. X#define DBUG(x)
  666. X#endif
  667. X#define D_LOG 1
  668. X#define D_ALL 2
  669. X#define D_TEMP 4
  670. X
  671. X/* Specifies machine I run on */
  672. X
  673. X/* & needed to take address of setjmp variable? */
  674. X#ifdef unix
  675. X#define ADDRESS_OF_SETJMP_VARIABLE (char *) &
  676. X#endif
  677. X#ifdef MSDOS
  678. X#define ADDRESS_OF_SETJMP_VARIABLE (char *) &
  679. X#endif
  680. X#ifndef ADDRESS_OF_SETJMP_VARIABLE
  681. Xpang, pang, youre dead !!
  682. X#endif
  683. X
  684. X/* General stuff I like */
  685. X
  686. X#ifndef TRUE
  687. X#define TRUE 1
  688. X#endif
  689. X#ifndef FALSE
  690. X#define FALSE 0
  691. X#endif
  692. X
  693. X#define LINEBUF 256
  694. X#define ERRBUF 512
  695. X
  696. X#define FLOATCHARS "0123456789.-eE+"
  697. X#define INTCHARS "0123456789-"
  698. X#define UNSIGNEDCHARS "0123456789"
  699. X#define SEPARATORS " ,;\015\012\011"
  700. X#define WHITESPACE " \015\012\011"
  701. X
  702. X/* If ALIGN_ODD defined, align long, int, double to n lower bits */
  703. X
  704. X#define ALIGN_ODD 1
  705. X
  706. X/* New alignment system, use this now and ignore ALIGN_ODD */
  707. X
  708. X#ifdef MSDOS
  709. X#define SIZEOFINT 2
  710. X#define INT_ALIGN 2
  711. X#define CHAR_ARRAY_ALIGN 1
  712. X#define LONG_ALIGN 2
  713. X#define DOUBLE_ALIGN 2
  714. X#define CHAR_ALIGN 1
  715. X#endif
  716. X#ifdef i286
  717. X#define SIZEOFINT 2
  718. X#define INT_ALIGN 2
  719. X#define CHAR_ARRAY_ALIGN 1
  720. X#define LONG_ALIGN 2
  721. X#define DOUBLE_ALIGN 2
  722. X#define CHAR_ALIGN 1
  723. X#endif
  724. X#ifdef i386
  725. X#define SIZEOFINT 4
  726. X#define INT_ALIGN 4
  727. X#define CHAR_ARRAY_ALIGN 1
  728. X#define LONG_ALIGN 4
  729. X#define DOUBLE_ALIGN 4
  730. X#define CHAR_ALIGN 1
  731. X#endif
  732. X#if defined(mc68k) || defined(m68k) || defined(m68000) || defined(m68k32)
  733. X#define SIZEOFINT 4
  734. X#define INT_ALIGN 4
  735. X#define CHAR_ARRAY_ALIGN 1
  736. X#define LONG_ALIGN 4
  737. X#define DOUBLE_ALIGN 4
  738. X#define CHAR_ALIGN 1
  739. X#endif
  740. X
  741. X#ifndef SIZEOFINT
  742. Xpang, pang, youre dead!!
  743. X#endif
  744. X
  745. X/* Pointer type is int/long etc with size same as pointers */
  746. X
  747. X#define POINTER_TYPE long
  748. X
  749. X/* keys */
  750. X
  751. X#define ESC 27
  752. X
  753. X/* Can't live without this macro */
  754. X
  755. X#ifdef lint
  756. Xextern char *strsave(), *strasave();
  757. X#else
  758. X#define strsave(s) (strcpy(malloc((unsigned) (strlen(s) + 1)), (s)))
  759. X#define strasave(s) (strcpy(alloca((unsigned) (strlen(s) + 1)), (s)))
  760. X#endif
  761. X#define strequ(x,y) (strcmp(x,y) == 0)
  762. X#define strnequ(x,y) (strcmp(x,y) != 0)
  763. X#define strnotnull(x) (*x != '\0')
  764. X#define strnull(x) (*x == '\0');
  765. X/* Pointer to end of string */
  766. X#define strend(x) ((x) + strlen(x))
  767. X
  768. X/* Increment counter, looping back to 0 if wrap-over */
  769. X
  770. X#define loop_increment(x,y) (x = (++x >= (y)) ? 0 : x)
  771. X#define loop_decrement(x,y) (x = (--x < 0) ? (y)-1 : x)
  772. X
  773. X/* I use this always */
  774. X
  775. X#define curse(buf) waddstr(crnt_window,buf); wrefresh(crnt_window)
  776. X
  777. X#define BIT0 1
  778. X#define BIT1 2
  779. X#define BIT2 4
  780. X#define BIT3 8
  781. X#define BIT4 16
  782. X#define BIT5 32
  783. X#define BIT6 64
  784. X#define BIT7 128
  785. X#define BIT8 256
  786. X#define BIT9 512
  787. X#define BIT10 1024
  788. X#define BIT11 2048
  789. X#define BIT12 4096
  790. X
  791. X/* Some procedures */
  792. X
  793. Xextern char *alloca(), *strncpy(), *strncat(), *sprintfs(), *sstrcat();
  794. Xextern char *mktemp(), *strclean(), *strsclean();
  795. Xextern int strempty();
  796. Xextern void exit(), qsort();
  797. Xextern long time();
  798. Xextern unsigned short getuid();
  799. Xextern unsigned short geteuid();
  800. Xextern unsigned short getgid();
  801. Xextern unsigned short getegid();
  802. Xextern unsigned alarm();
  803. Xextern unsigned sleep();
  804. X
  805. X/* Some typedefs */
  806. X
  807. Xtypedef         int (*INT_FP)();
  808. X
  809. X/* Defines which are not in std libraries (why!?) */
  810. X
  811. Xextern char *optarg, *sys_errlist[], *getenv();
  812. Xextern int optind, opterr, errno, sys_nerr;
  813. Xextern long atol();
  814. X
  815. X/* I like it, and it's not always defined in math.h, (not in msc headers). */
  816. X
  817. X#ifndef _ABS
  818. X#define _ABS(x) ((x) < 0 ? -(x) : (x))
  819. X#endif
  820. X#ifndef _MIN
  821. X#define _MIN(x, y) ((x) < (y) ? (x) : (y))
  822. X#endif
  823. X
  824. X/* Macro version of getw putw. w is destination. */
  825. X
  826. X#define FGETW(w, fp) \
  827. X  if ((fp)->_cnt < sizeof(int)) w = getw(fp); \
  828. X  else { w = *(int *) (fp)->_ptr; \
  829. X       (fp)->_ptr += sizeof(int); (fp)->_cnt -= sizeof(int); }
  830. X
  831. X#define FPUTW(w, fp) \
  832. X  if ((fp)->_cnt < sizeof(int)) putw(w, fp); \
  833. X  else { *(int *) (fp)->_ptr = w; \
  834. X       (fp)->_ptr += sizeof(int); (fp)->_cnt -= sizeof(int); }
  835. X
  836. X#define FGETINT16(w, fp) \
  837. X  if ((fp)->_cnt < sizeof(short)) fread( (char *) &(w), sizeof(short), 1, fp);\
  838. X  else { w = *(short *) (fp)->_ptr; \
  839. X       (fp)->_ptr += sizeof(short); (fp)->_cnt -= sizeof(short); }
  840. X
  841. X#define FPUTINT16(w, fp) \
  842. X  if ((fp)->_cnt < sizeof(short)) \
  843. X    fwrite( (char *) &(w), sizeof(short), 1, fp); \
  844. X  else { *(short *) (fp)->_ptr = w; \
  845. X       (fp)->_ptr += sizeof(short); (fp)->_cnt -= sizeof(short); }
  846. X
  847. X#define FGETLW(w, fp) \
  848. X  if ((fp)->_cnt < sizeof(long)) fread( (char *) &w, sizeof(long), 1, fp); \
  849. X  else { w = *(long *) (fp)->_ptr; \
  850. X       (fp)->_ptr += sizeof(long); (fp)->_cnt -= sizeof(long); }
  851. X
  852. X#define FPUTLW(w, fp) \
  853. X  if ((fp)->_cnt < sizeof(long)) fwrite( (char *) &w, sizeof(long), 1, fp); \
  854. X  else { *(long *) (fp)->_ptr = w; \
  855. X       (fp)->_ptr += sizeof(long); (fp)->_cnt -= sizeof(long); }
  856. X
  857. X#ifdef SAFE
  858. X#define FREAD(p, bytes, nitems, fp) (void) fread(p, bytes, nitems, fp)
  859. X#define FWRITE(p, bytes, nitems, fp) (void) fwrite(p, bytes, nitems, fp)
  860. X#else
  861. X
  862. X/* And fread, fwrite. Don't return a value, so it has to be checked. */
  863. X/*
  864. X
  865. X  could this work? test it!
  866. X  #define FREAD(p, bytes, nitems, fp)
  867. X  (((fp)->_cnt < (nitems) * (bytes)) ? fread(p, bytes, nitems, fp) :
  868. X  nitems, memcpy( (p), (char *) (fp)->_ptr, (int) ((nitems) * (bytes))),
  869. X  (fp)->_ptr += (nitems) * (bytes), (fp)->_cnt -= (nitems) * (bytes))
  870. X
  871. X  */
  872. X#define FREAD(p, bytes, nitems, fp) \
  873. X  if ((fp)->_cnt < (nitems) * (bytes)) (void) fread(p, bytes, nitems, fp); \
  874. X  else { memcpy( (p), (char *) (fp)->_ptr, (int) ((nitems) * (bytes))); \
  875. X       (fp)->_ptr += (nitems) * (bytes); \
  876. X         (fp)->_cnt -= (nitems) * (bytes); }
  877. X
  878. X#define FWRITE(p, bytes, nitems, fp) \
  879. X  if ((fp)->_cnt < (nitems) * (bytes)) (void) fwrite(p, bytes, nitems, fp); \
  880. X  else { memcpy( (char *) (fp)->_ptr, (p), (int) ((nitems) * (bytes))); \
  881. X       (fp)->_ptr += (nitems) * (bytes); \
  882. X         (fp)->_cnt -= (nitems) * (bytes); }
  883. X#endif
  884. X
  885. X/* FGETS differ from original: \n in the end is NOT copied!! (because
  886. X   I don't like that) */
  887. X
  888. Xextern char *strnchr();
  889. X
  890. X#define FGETS(cp, maxlen, fp) \
  891. X  if (strnchr((fp)->_ptr, '\n', (fp)->_cnt)) \
  892. X{ \
  893. X  register count; \
  894. X  register char *p; \
  895. X  for (count = 1, p = cp; (*p = *(fp)->_ptr++) != '\n'; p++, count++) \
  896. X    if (count >= (maxlen)) break; \
  897. X  *p = '\0'; \
  898. X  (fp)->_cnt -= count; \
  899. X} else { \
  900. X  fgets(cp, maxlen, fp); \
  901. X  if (strchr(cp, '\n')) *(strchr(cp, '\n')) = '\0'; \
  902. X}
  903. X
  904. X/* Checks for both eof and error status, better than feof || ferror when
  905. X   compilers are stupid enough not to optimize that kind of situation. */
  906. X
  907. X#define ferr(fp) ((fp)->_flag & (_IOEOF | _IOERR))
  908. X
  909. X#endif /* H_HSU */
  910. X
  911. SHAR_EOF
  912. chmod 0664 hsu.h || echo "restore of hsu.h fails"
  913. echo "x - extracting shuffle.h (Text)"
  914. sed 's/^X//' << 'SHAR_EOF' > shuffle.h &&
  915. X#define MAX_CONVERT_BUFFERS 10
  916. X#define MAX_CONVERT_BUFLEN 80
  917. Xstatic char bufs[MAX_CONVERT_BUFFERS][MAX_CONVERT_BUFLEN], *tcharp;
  918. Xstatic int bflag;
  919. X
  920. X#define SHUFFLEBUFFERS \
  921. Xloop_increment(bflag, MAX_CONVERT_BUFFERS); tcharp = bufs[bflag]
  922. SHAR_EOF
  923. chmod 0644 shuffle.h || echo "restore of shuffle.h fails"
  924. echo "x - extracting sysexits.h (Text)"
  925. sed 's/^X//' << 'SHAR_EOF' > sysexits.h &&
  926. X/* @(#)%M%  %I%  Teemu Torma %H%
  927. X
  928. X   Exit statuses for systems that doesn't have /usr/include/sysexits.h */
  929. X
  930. X#define EX_OK 0 /* successful termination */
  931. X#define EX_USAGE 64 /* command line usage error */
  932. X#define EX_DATAERR 65 /* data format error */
  933. X#define EX_NOINPUT 66 /* cannot open input */
  934. X#define EX_NOHOST 68 /* host name unknown */
  935. X#define EX_UNAVAILABLE 69 /* service unavailable */
  936. X#define EX_SOFTWARE 70 /* internal software error */
  937. X#define EX_OSERR 71 /* system error (e.g., can't fork) */
  938. X#define EX_OSFILE 72 /* critical OS file missing */
  939. X#define EX_CANTCREAT 73 /* can't create (user) output file */
  940. X#define EX_IOERR 74 /* input/output error */
  941. SHAR_EOF
  942. chmod 0644 sysexits.h || echo "restore of sysexits.h fails"
  943. echo "x - extracting nodelist.h (Text)"
  944. sed 's/^X//' << 'SHAR_EOF' > nodelist.h &&
  945. X/* @(#)%M%  %I%  Teemu Torma %H%
  946. X
  947. X   Structures and definitions for nodelist.
  948. X
  949. X   @(#)Copyright (c) 1987 by Teemu Torma
  950. X
  951. X   Permission is given to distribute this program and alter this code as
  952. X   needed to adapt it to forign systems provided that this header is
  953. X   included and that the original author's name is preserved. */
  954. X
  955. X/* Change these if you wish. */
  956. X
  957. X/* Name of nodelist in LIBDIR */
  958. X#define NODELIST "nodelist"
  959. X
  960. X/* Name of nodelist index file in LIBDIR */
  961. X#define INODELIST "nodelist.idx"
  962. X
  963. X/* Name of sysop name index file in LIBDIR */
  964. X#define NAMELIST "name.idx"
  965. X
  966. X/* Compare two node entried to see if they are same node (ignoring
  967. X   possible other information */
  968. X#define samenode(n1, n2) ((n1).zone == (n2).zone && (n1).net == (n2).net && \
  969. X              (n1).node == (n2).node && (n1).point == (n2).point)
  970. X
  971. X/* Structure for nodelist entry. Routines to get one node from nodelist
  972. X   will return this structure. */
  973. X
  974. Xtypedef struct _node {
  975. X  int type; /* type of entry (see below) */
  976. X  int region; /* region (not necessarily used/set) */
  977. X  int net; /* net/region of node */
  978. X  int zone; /* Zone of node (not really supported yet) */
  979. X  int node; /* number of node */
  980. X  int point; /* Point of node (not really supported yet) */
  981. X  char name[20]; /* name of fido */
  982. X  char city[40]; /* city */
  983. X  char sysop[36]; /* name of sysop */
  984. X  char phone[40]; /* phone-number */
  985. X  int speed; /* speeds */
  986. X  char flags[60]; /* flags-string */
  987. X} Node;
  988. X
  989. Xtypedef struct _indexnode {
  990. X  int zone;
  991. X  int net;
  992. X  int node;
  993. X  long offset;
  994. X} NODEINDEX;
  995. X
  996. Xtypedef struct _indexname {
  997. X  char name[36]; /* Sysop name */
  998. X  long offset; /* Refers to nodelist index entry */
  999. X  int zone;
  1000. X  int net;
  1001. X} NAMEINDEX;
  1002. X
  1003. X/* Entry types. */
  1004. X
  1005. X#define REGION (1) /* region-host */
  1006. X#define HOST (2) /* net-host */
  1007. X#define HUB (3) /* local-host */
  1008. X#define PVT (4) /* private node */
  1009. X#define HOLD (5) /* no mail to this node */
  1010. X#define DOWN (6) /* node is down */
  1011. X#define KENL (7) /* should not be comminucated */
  1012. X#define NORMAL (8) /* normal node */
  1013. X#define ZONE (9) /* Zone */
  1014. X#define POINT (10) /* point (points are not in nodelist but this is used
  1015. X              elsewhere. */
  1016. X
  1017. X/* Declarations for routines. */
  1018. X
  1019. XNode *node_entry(); /* get entry from nodelist */
  1020. Xchar *update_index(); /* update index-file */
  1021. Xextern Node *parse_entry();
  1022. X
  1023. Xextern Node originnode;
  1024. Xextern NODEINDEX *nodeindex;
  1025. Xextern NAMEINDEX *nameindex;
  1026. Xextern int nodes;
  1027. SHAR_EOF
  1028. chmod 0644 nodelist.h || echo "restore of nodelist.h fails"
  1029. echo "x - extracting fnews.h (Text)"
  1030. sed 's/^X//' << 'SHAR_EOF' > fnews.h &&
  1031. X/* @(#)%M%  %I% Teemu Torma %H%
  1032. X
  1033. X   Definitions for fidonet news-system.
  1034. X
  1035. X   @(#)Copyright (c) 1987 by Teemu Torma
  1036. X
  1037. X   Permission is given to distribute this program and alter this code as
  1038. X   needed to adapt it to forign systems provided that this header is
  1039. X   included and that the original author's name is preserved. */
  1040. X
  1041. X/* Section definitions for configure file. */
  1042. X
  1043. X#define SECT_NETNODE (1) /* Net/node for receiving node */
  1044. X#define SECT_NG_AREA (2) /* Newsgroup -> area conversions */
  1045. X#define SECT_HEADERS (3) /* Header-field definitions */
  1046. X#define SECT_ENDMSG (4) /* Text to be placed at the end of msg */
  1047. X#define SECT_AREA_NG (5) /* Area -> newsgroup conversions */
  1048. X
  1049. X/* Other definitions for news-system. */
  1050. X
  1051. X/* If you have some junk area (like junk in Usenet News), define this
  1052. X   to name of that area. Otherwise messages to unknown areas will
  1053. X   be dicarded. */
  1054. X#define JUNK_AREA "FNET.JUNK" /**/
  1055. X
  1056. X/* Usenet news junk area. Unknown echos are put here */
  1057. X#define JUNK "junk" /**/
  1058. SHAR_EOF
  1059. chmod 0644 fnews.h || echo "restore of fnews.h fails"
  1060. rm -f s2_seq_.tmp
  1061. echo "You have unpacked the last part"
  1062. exit 0
  1063.  
  1064.