home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3412 < prev    next >
Encoding:
Internet Message Format  |  1991-05-25  |  43.0 KB

  1. From: mj@dfv.rwth-aachen.de (Martin Junius)
  2. Newsgroups: alt.sources
  3. Subject: FIDOGATE 02/06
  4. Message-ID: <mj.675078331@suntex>
  5. Date: 24 May 91 09:45:31 GMT
  6.  
  7. ---- Cut Here and feed the following to sh ----
  8. #!/bin/sh
  9. # This is part 02 of a multipart archive
  10. # ============= getdate.y ==============
  11. if test -f 'getdate.y' -a X"$1" != X"-c"; then
  12.     echo 'x - skipping getdate.y (File already exists)'
  13. else
  14. echo 'x - extracting getdate.y (Text)'
  15. sed 's/^X//' << 'SHAR_EOF' > 'getdate.y' &&
  16. %token ID MONTH DAY MERIDIAN NUMBER UNIT MUNIT SUNIT ZONE DAYZONE AGO
  17. %{
  18. X   /*  Originally from: Steven M. Bellovin (unc!smb)   */ 
  19. X   /*  Dept. of Computer Science           */
  20. X   /*  University of North Carolina at Chapel Hill */
  21. X   /*  @(#)getdate.y   2.17    11/30/87            */
  22. X
  23. /* #include "defs.h" JF not used any more */
  24. #include <sys/types.h>
  25. #ifdef USG
  26. struct timeb
  27. {
  28. X   time_t  time;
  29. X   unsigned short millitm;
  30. X   short   timezone;
  31. X   short   dstflag;
  32. };
  33. #else
  34. #include <sys/timeb.h>
  35. #endif
  36. #include <ctype.h>
  37. X
  38. #if defined(BSD4_2) || defined (BSD4_1C)
  39. #include <sys/time.h>
  40. #else /* sane */
  41. #include <time.h>
  42. #endif /* sane */
  43. X
  44. #ifdef __GNUC__
  45. #define alloca __builtin_alloca
  46. #else
  47. #ifdef sparc
  48. #include <alloca.h>
  49. #endif
  50. #endif
  51. X
  52. #define NULL    0
  53. #define daysec (24L*60L*60L)
  54. X   static int timeflag, zoneflag, dateflag, dayflag, relflag;
  55. X   static time_t relsec, relmonth;
  56. X   static int hh, mm, ss, merid, day_light;
  57. X   static int dayord, dayreq;
  58. X   static int month, day, year;
  59. X   static int ourzone;
  60. #define AM 1
  61. #define PM 2
  62. #define DAYLIGHT 1
  63. #define STANDARD 2
  64. #define MAYBE    3
  65. X
  66. static time_t timeconv();
  67. static time_t daylcorr();
  68. static lookup();
  69. X
  70. %}
  71. X
  72. %%
  73. timedate:       /* empty */
  74. X   | timedate item
  75. X   ;
  76. X
  77. item:   tspec
  78. X       {timeflag++;}
  79. X   | zone
  80. X       {zoneflag++;}
  81. X   | dtspec
  82. X       {dateflag++;}
  83. X   | dyspec
  84. X       {dayflag++;}
  85. X   | rspec
  86. X       {relflag++;}
  87. X   | nspec;
  88. X
  89. nspec:  NUMBER
  90. X       {if (timeflag && dateflag && !relflag) year = $1;
  91. X       else if ($1 > 10000) {
  92. X           dateflag++;
  93. X           day= $1%100;
  94. X           month= ($1/100)%100;
  95. X           year = month/10000;
  96. X       } else {timeflag++;hh = $1/100;mm = $1%100;ss = 0;merid = 24;}};
  97. X
  98. tspec:  NUMBER MERIDIAN
  99. X       {hh = $1; mm = 0; ss = 0; merid = $2;}
  100. X   | NUMBER ':' NUMBER
  101. X       {hh = $1; mm = $3; merid = 24;}
  102. X   | NUMBER ':' NUMBER MERIDIAN
  103. X       {hh = $1; mm = $3; merid = $4;}
  104. X   | NUMBER ':' NUMBER NUMBER
  105. X       {hh = $1; mm = $3; merid = 24;
  106. X       day_light = STANDARD; ourzone = -($4%100 + 60*($4/100));}
  107. X   | NUMBER ':' NUMBER ':' NUMBER
  108. X       {hh = $1; mm = $3; ss = $5; merid = 24;}
  109. X   | NUMBER ':' NUMBER ':' NUMBER MERIDIAN
  110. X       {hh = $1; mm = $3; ss = $5; merid = $6;}
  111. X   | NUMBER ':' NUMBER ':' NUMBER NUMBER
  112. X       {hh = $1; mm = $3; ss = $5; merid = 24;
  113. X       day_light = STANDARD; ourzone = -($6%100 + 60*($6/100));};
  114. X
  115. zone:   ZONE
  116. X       {ourzone = $1; day_light = STANDARD;}
  117. X   | DAYZONE
  118. X       {ourzone = $1; day_light = DAYLIGHT;};
  119. X
  120. dyspec: DAY
  121. X       {dayord = 1; dayreq = $1;}
  122. X   | DAY ','
  123. X       {dayord = 1; dayreq = $1;}
  124. X   | NUMBER DAY
  125. X       {dayord = $1; dayreq = $2;};
  126. X
  127. dtspec: NUMBER '/' NUMBER
  128. X       {month = $1; day = $3;}
  129. X   | NUMBER '/' NUMBER '/' NUMBER
  130. X       {month = $1; day = $3; year = $5;}
  131. X   | MONTH NUMBER
  132. X       {month = $1; day = $2;}
  133. X   | MONTH NUMBER ',' NUMBER
  134. X       {month = $1; day = $2; year = $4;}
  135. X   | NUMBER MONTH
  136. X       {month = $2; day = $1;}
  137. X   | NUMBER MONTH NUMBER
  138. X       {month = $2; day = $1; year = $3;};
  139. X
  140. X
  141. rspec:  NUMBER UNIT
  142. X       {relsec +=  60L * $1 * $2;}
  143. X   | NUMBER MUNIT
  144. X       {relmonth += $1 * $2;}
  145. X   | NUMBER SUNIT
  146. X       {relsec += $1;}
  147. X   | UNIT
  148. X       {relsec +=  60L * $1;}
  149. X   | MUNIT
  150. X       {relmonth += $1;}
  151. X   | SUNIT
  152. X       {relsec++;}
  153. X   | rspec AGO
  154. X       {relsec = -relsec; relmonth = -relmonth;};
  155. %%
  156. X
  157. static int mdays[12] =
  158. X   {31, 0, 31,  30, 31, 30,  31, 31, 30,  31, 30, 31};
  159. #define epoch 1970
  160. X
  161. extern struct tm *localtime();
  162. X
  163. static time_t
  164. dateconv(mm, dd, yy, h, m, s, mer, zone, dayflag)
  165. int mm, dd, yy, h, m, s, mer, zone, dayflag;
  166. {
  167. X   time_t tod, jdate;
  168. X   register int i;
  169. X
  170. X   if (yy < 0) yy = -yy;
  171. X   if (yy < 100) yy += 1900;
  172. X   mdays[1] = 28 + (yy%4 == 0 && (yy%100 != 0 || yy%400 == 0));
  173. X   if (yy < epoch || yy > 1999 || mm < 1 || mm > 12 ||
  174. X       dd < 1 || dd > mdays[--mm]) return (-1);
  175. X   jdate = dd-1;
  176. X        for (i=0; i<mm; i++) jdate += mdays[i];
  177. X   for (i = epoch; i < yy; i++) jdate += 365 + (i%4 == 0);
  178. X   jdate *= daysec;
  179. X   jdate += zone * 60L;
  180. X   if ((tod = timeconv(h, m, s, mer)) < 0) return (-1);
  181. X   jdate += tod;
  182. X   if (dayflag==DAYLIGHT || (dayflag==MAYBE&&localtime(&jdate)->tm_isdst))
  183. X       jdate += -1*60*60;
  184. X   return (jdate);
  185. }
  186. X
  187. static time_t
  188. dayconv(ord, day, now)
  189. int ord, day; time_t now;
  190. {
  191. X   register struct tm *loctime;
  192. X   time_t tod;
  193. X
  194. X   tod = now;
  195. X   loctime = localtime(&tod);
  196. X   tod += daysec * ((day - loctime->tm_wday + 7) % 7);
  197. X   tod += 7*daysec*(ord<=0?ord:ord-1);
  198. X   return daylcorr(tod, now);
  199. }
  200. X
  201. static time_t
  202. timeconv(hh, mm, ss, mer)
  203. register int hh, mm, ss, mer;
  204. {
  205. X   if (mm < 0 || mm > 59 || ss < 0 || ss > 59) return (-1);
  206. X   switch (mer) {
  207. X       case AM: if (hh < 1 || hh > 12) return(-1);
  208. X            return (60L * ((hh%12)*60L + mm)+ss);
  209. X       case PM: if (hh < 1 || hh > 12) return(-1);
  210. X            return (60L * ((hh%12 +12)*60L + mm)+ss);
  211. X       case 24: if (hh < 0 || hh > 23) return (-1);
  212. X            return (60L * (hh*60L + mm)+ss);
  213. X       default: return (-1);
  214. X   }
  215. }
  216. X
  217. static time_t
  218. monthadd(sdate, relmonth)
  219. time_t sdate, relmonth;
  220. {
  221. X   struct tm *ltime;
  222. X   time_t dateconv();
  223. X   int mm, yy;
  224. X
  225. X   if (relmonth == 0) return 0;
  226. X   ltime = localtime(&sdate);
  227. X   mm = 12*ltime->tm_year + ltime->tm_mon + relmonth;
  228. X   yy = mm/12;
  229. X   mm = mm%12 + 1;
  230. X   return daylcorr(dateconv(mm, ltime->tm_mday, yy, ltime->tm_hour,
  231. X       ltime->tm_min, ltime->tm_sec, 24, ourzone, MAYBE), sdate);
  232. }
  233. X
  234. static time_t
  235. daylcorr(future, now)
  236. time_t future, now;
  237. {
  238. X   int fdayl, nowdayl;
  239. X
  240. X   nowdayl = (localtime(&now)->tm_hour+1) % 24;
  241. X   fdayl = (localtime(&future)->tm_hour+1) % 24;
  242. X   return (future-now) + 60L*60L*(nowdayl-fdayl);
  243. }
  244. X
  245. static char *lptr;
  246. X
  247. static yylex()
  248. {
  249. X   extern int yylval;
  250. X   int sign;
  251. X   register char c;
  252. X   register char *p;
  253. X   char idbuf[20];
  254. X   int pcnt;
  255. X
  256. X   for (;;) {
  257. X       while (isspace(*lptr))
  258. X           lptr++;
  259. X
  260. X       if (isdigit(c = *lptr) || c == '-' || c == '+') {
  261. X           if (c== '-' || c == '+') {
  262. X               if (c=='-') sign = -1;
  263. X               else sign = 1;
  264. X               if (!isdigit(*++lptr)) {
  265. X                   /* yylval = sign; return (NUMBER); */
  266. X                   return yylex(); /* skip the '-' sign */
  267. X               }
  268. X           } else sign = 1;
  269. X           yylval = 0;
  270. X           while (isdigit(c = *lptr++))
  271. X               yylval = 10*yylval + c - '0';
  272. X           yylval *= sign;
  273. X           lptr--;
  274. X           return (NUMBER);
  275. X
  276. X       } else if (isalpha(c)) {
  277. X           p = idbuf;
  278. X           while (isalpha(c = *lptr++) || c=='.')
  279. X               if (p < &idbuf[sizeof(idbuf)-1]) *p++ = c;
  280. X           *p = '\0';
  281. X           lptr--;
  282. X           return (lookup(idbuf));
  283. X       }
  284. X
  285. X       else if (c == '(') {
  286. X           pcnt = 0;
  287. X           do {
  288. X               c = *lptr++;
  289. X               if (c == '\0') return(c);
  290. X               else if (c == '(') pcnt++;
  291. X               else if (c == ')') pcnt--;
  292. X           } while (pcnt > 0);
  293. X       }
  294. X
  295. X       else return (*lptr++);
  296. X   }
  297. }
  298. X
  299. struct table {
  300. X   char *name;
  301. X   int type, value;
  302. };
  303. X
  304. static struct table mdtab[] = {
  305. X   {"january", MONTH, 1},
  306. X   {"february", MONTH, 2},
  307. X   {"march", MONTH, 3},
  308. X   {"april", MONTH, 4},
  309. X   {"may", MONTH, 5},
  310. X   {"june", MONTH, 6},
  311. X   {"july", MONTH, 7},
  312. X   {"august", MONTH, 8},
  313. X   {"september", MONTH, 9},
  314. X   {"sept", MONTH, 9},
  315. X   {"october", MONTH, 10},
  316. X   {"november", MONTH, 11},
  317. X   {"december", MONTH, 12},
  318. X
  319. X   {"sunday", DAY, 0},
  320. X   {"monday", DAY, 1},
  321. X   {"tuesday", DAY, 2},
  322. X   {"tues", DAY, 2},
  323. X   {"wednesday", DAY, 3},
  324. X   {"wednes", DAY, 3},
  325. X   {"thursday", DAY, 4},
  326. X   {"thur", DAY, 4},
  327. X   {"thurs", DAY, 4},
  328. X   {"friday", DAY, 5},
  329. X   {"saturday", DAY, 6},
  330. X   {0, 0, 0}};
  331. X
  332. #define HRS *60
  333. #define HALFHR 30
  334. X
  335. static struct table mztab[] = {
  336. X   {"a.m.", MERIDIAN, AM},
  337. X   {"am", MERIDIAN, AM},
  338. X   {"p.m.", MERIDIAN, PM},
  339. X   {"pm", MERIDIAN, PM},
  340. X   {"nst", ZONE, 3 HRS + HALFHR},      /* Newfoundland */
  341. X   {"n.s.t.", ZONE, 3 HRS + HALFHR},
  342. X   {"ast", ZONE, 4 HRS},       /* Atlantic */
  343. X   {"a.s.t.", ZONE, 4 HRS},
  344. X   {"adt", DAYZONE, 4 HRS},
  345. X   {"a.d.t.", DAYZONE, 4 HRS},
  346. X   {"est", ZONE, 5 HRS},       /* Eastern */
  347. X   {"e.s.t.", ZONE, 5 HRS},
  348. X   {"edt", DAYZONE, 5 HRS},
  349. X   {"e.d.t.", DAYZONE, 5 HRS},
  350. X   {"cst", ZONE, 6 HRS},       /* Central */
  351. X   {"c.s.t.", ZONE, 6 HRS},
  352. X   {"cdt", DAYZONE, 6 HRS},
  353. X   {"c.d.t.", DAYZONE, 6 HRS},
  354. X   {"mst", ZONE, 7 HRS},       /* Mountain */
  355. X   {"m.s.t.", ZONE, 7 HRS},
  356. X   {"mdt", DAYZONE, 7 HRS},
  357. X   {"m.d.t.", DAYZONE, 7 HRS},
  358. X   {"pst", ZONE, 8 HRS},       /* Pacific */
  359. X   {"p.s.t.", ZONE, 8 HRS},
  360. X   {"pdt", DAYZONE, 8 HRS},
  361. X   {"p.d.t.", DAYZONE, 8 HRS},
  362. X   {"yst", ZONE, 9 HRS},       /* Yukon */
  363. X   {"y.s.t.", ZONE, 9 HRS},
  364. X   {"ydt", DAYZONE, 9 HRS},
  365. X   {"y.d.t.", DAYZONE, 9 HRS},
  366. X   {"hst", ZONE, 10 HRS},      /* Hawaii */
  367. X   {"h.s.t.", ZONE, 10 HRS},
  368. X   {"hdt", DAYZONE, 10 HRS},
  369. X   {"h.d.t.", DAYZONE, 10 HRS},
  370. X
  371. X   {"gmt", ZONE, 0 HRS},
  372. X   {"g.m.t.", ZONE, 0 HRS},
  373. X   {"bst", DAYZONE, 0 HRS},        /* British Summer Time */
  374. X   {"b.s.t.", DAYZONE, 0 HRS},
  375. X   {"eet", ZONE, 0 HRS},       /* European Eastern Time */
  376. X   {"e.e.t.", ZONE, 0 HRS},
  377. X   {"eest", DAYZONE, 0 HRS},   /* European Eastern Summer Time */
  378. X   {"e.e.s.t.", DAYZONE, 0 HRS},
  379. X   {"met", ZONE, -1 HRS},      /* Middle European Time */
  380. X   {"m.e.t.", ZONE, -1 HRS},
  381. X   {"mest", DAYZONE, -1 HRS},  /* Middle European Summer Time */
  382. X   {"m.e.s.t.", DAYZONE, -1 HRS},
  383. X   {"wet", ZONE, -2 HRS },     /* Western European Time */
  384. X   {"w.e.t.", ZONE, -2 HRS },
  385. X   {"west", DAYZONE, -2 HRS},  /* Western European Summer Time */
  386. X   {"w.e.s.t.", DAYZONE, -2 HRS},
  387. X
  388. X   {"jst", ZONE, -9 HRS},      /* Japan Standard Time */
  389. X   {"j.s.t.", ZONE, -9 HRS},   /* Japan Standard Time */
  390. X                   /* No daylight savings time */
  391. X
  392. X   {"aest", ZONE, -10 HRS},    /* Australian Eastern Time */
  393. X   {"a.e.s.t.", ZONE, -10 HRS},
  394. X   {"aesst", DAYZONE, -10 HRS},    /* Australian Eastern Summer Time */
  395. X   {"a.e.s.s.t.", DAYZONE, -10 HRS},
  396. X   {"acst", ZONE, -(9 HRS + HALFHR)},  /* Australian Central Time */
  397. X   {"a.c.s.t.", ZONE, -(9 HRS + HALFHR)},
  398. X   {"acsst", DAYZONE, -(9 HRS + HALFHR)},  /* Australian Central Summer */
  399. X   {"a.c.s.s.t.", DAYZONE, -(9 HRS + HALFHR)},
  400. X   {"awst", ZONE, -8 HRS},     /* Australian Western Time */
  401. X   {"a.w.s.t.", ZONE, -8 HRS}, /* (no daylight time there, I'm told */
  402. X   {0, 0, 0}};
  403. X
  404. static struct table unittb[] = {
  405. X   {"year", MUNIT, 12},
  406. X   {"month", MUNIT, 1},
  407. X   {"fortnight", UNIT, 14*24*60},
  408. X   {"week", UNIT, 7*24*60},
  409. X   {"day", UNIT, 1*24*60},
  410. X   {"hour", UNIT, 60},
  411. X   {"minute", UNIT, 1},
  412. X   {"min", UNIT, 1},
  413. X   {"second", SUNIT, 1},
  414. X   {"sec", SUNIT, 1},
  415. X   {0, 0, 0}};
  416. X
  417. static struct table othertb[] = {
  418. X   {"tomorrow", UNIT, 1*24*60},
  419. X   {"yesterday", UNIT, -1*24*60},
  420. X   {"today", UNIT, 0},
  421. X   {"now", UNIT, 0},
  422. X   {"last", NUMBER, -1},
  423. X   {"this", UNIT, 0},
  424. X   {"next", NUMBER, 2},
  425. X   {"first", NUMBER, 1},
  426. X   /* {"second", NUMBER, 2}, */
  427. X   {"third", NUMBER, 3},
  428. X   {"fourth", NUMBER, 4},
  429. X   {"fifth", NUMBER, 5},
  430. X   {"sixth", NUMBER, 6},
  431. X   {"seventh", NUMBER, 7},
  432. X   {"eigth", NUMBER, 8},
  433. X   {"ninth", NUMBER, 9},
  434. X   {"tenth", NUMBER, 10},
  435. X   {"eleventh", NUMBER, 11},
  436. X   {"twelfth", NUMBER, 12},
  437. X   {"ago", AGO, 1},
  438. X   {0, 0, 0}};
  439. X
  440. static struct table milzone[] = {
  441. X   {"a", ZONE, 1 HRS},
  442. X   {"b", ZONE, 2 HRS},
  443. X   {"c", ZONE, 3 HRS},
  444. X   {"d", ZONE, 4 HRS},
  445. X   {"e", ZONE, 5 HRS},
  446. X   {"f", ZONE, 6 HRS},
  447. X   {"g", ZONE, 7 HRS},
  448. X   {"h", ZONE, 8 HRS},
  449. X   {"i", ZONE, 9 HRS},
  450. X   {"k", ZONE, 10 HRS},
  451. X   {"l", ZONE, 11 HRS},
  452. X   {"m", ZONE, 12 HRS},
  453. X   {"n", ZONE, -1 HRS},
  454. X   {"o", ZONE, -2 HRS},
  455. X   {"p", ZONE, -3 HRS},
  456. X   {"q", ZONE, -4 HRS},
  457. X   {"r", ZONE, -5 HRS},
  458. X   {"s", ZONE, -6 HRS},
  459. X   {"t", ZONE, -7 HRS},
  460. X   {"u", ZONE, -8 HRS},
  461. X   {"v", ZONE, -9 HRS},
  462. X   {"w", ZONE, -10 HRS},
  463. X   {"x", ZONE, -11 HRS},
  464. X   {"y", ZONE, -12 HRS},
  465. X   {"z", ZONE, 0 HRS},
  466. X   {0, 0, 0}};
  467. X
  468. static 
  469. lookup(id)
  470. char *id;
  471. {
  472. #define gotit (yylval=i->value,  i->type)
  473. X
  474. X   char idvar[128];
  475. X   register char *j, *k;
  476. X   register struct table *i;
  477. X   int abbrev;
  478. X
  479. X   (void) strcpy(idvar, id);
  480. X   j = idvar;
  481. X   k = id - 1;
  482. X   while (*++k)
  483. X       *j++ = isupper(*k) ? tolower(*k) : *k;
  484. X   *j = '\0';
  485. X
  486. X   if (strlen(idvar) == 3)
  487. X       abbrev = 1;
  488. X   else
  489. X       if (strlen(idvar) == 4 && idvar[3] == '.') {
  490. X           abbrev = 1;
  491. X           idvar[3] = '\0';
  492. X       }
  493. X   else
  494. X       abbrev = 0;
  495. X
  496. X   for (i = mdtab; i->name; i++) {
  497. X       k = idvar;
  498. X       for (j = i->name; *j++ == *k++;) {
  499. X           if (abbrev && j == i->name+3)
  500. X               return gotit;
  501. X           if (j[-1] == 0)
  502. X               return gotit;
  503. X       }
  504. X   }
  505. X
  506. X   for (i = mztab; i->name; i++)
  507. X       if (strcmp(i->name, idvar) == 0)
  508. X           return gotit;
  509. X
  510. X   for (i=mztab; i->name; i++)
  511. X       if (strcmp(i->name, idvar) == 0)
  512. X           return gotit;
  513. X
  514. X   for (i=unittb; i->name; i++)
  515. X       if (strcmp(i->name, idvar) == 0)
  516. X           return gotit;
  517. X
  518. X   if (idvar[strlen(idvar)-1] == 's')
  519. X       idvar[strlen(idvar)-1] = '\0';
  520. X
  521. X   for (i=unittb; i->name; i++)
  522. X       if (strcmp(i->name, idvar) == 0)
  523. X           return gotit;
  524. X
  525. X   for (i = othertb; i->name; i++)
  526. X       if (strcmp(i->name, idvar) == 0)
  527. X           return gotit;
  528. X
  529. X   if (strlen(idvar) == 1 && isalpha(*idvar)) {
  530. X       for (i = milzone; i->name; i++)
  531. X           if (strcmp(i->name, idvar) == 0)
  532. X               return gotit;
  533. X   }
  534. X
  535. X   return ID;
  536. }
  537. X
  538. time_t
  539. getdate(p, now)
  540. char *p;
  541. struct timeb *now;
  542. {
  543. #define mcheck(f)   if (f>1) err++
  544. X   time_t monthadd();
  545. X   int err;
  546. X   struct tm *lt;
  547. X   struct timeb ftz;
  548. X
  549. X   time_t sdate, tod;
  550. X
  551. X   lptr = p;
  552. X   if (now == ((struct timeb *) NULL)) {
  553. X       now = &ftz;
  554. X       ftime(&ftz);
  555. X   }
  556. X   lt = localtime(&now->time);
  557. X   year = lt->tm_year;
  558. X   month = lt->tm_mon+1;
  559. X   day = lt->tm_mday;
  560. X   relsec = 0; relmonth = 0;
  561. X   timeflag=zoneflag=dateflag=dayflag=relflag=0;
  562. X   ourzone = now->timezone;
  563. X   day_light = MAYBE;
  564. X   hh = mm = ss = 0;
  565. X   merid = 24;
  566. X
  567. X   if (err = yyparse()) return (-1);
  568. X
  569. X   mcheck(timeflag);
  570. X   mcheck(zoneflag);
  571. X   mcheck(dateflag);
  572. X   mcheck(dayflag);
  573. X
  574. X   if (err) return (-1);
  575. X   if (dateflag || timeflag || dayflag) {
  576. X       sdate = dateconv(month,day,year,hh,mm,ss,merid,ourzone,day_light);
  577. X       if (sdate < 0) return -1;
  578. X   }
  579. X   else {
  580. X       sdate = now->time;
  581. X       if (relflag == 0)
  582. X           sdate -= (lt->tm_sec + lt->tm_min*60 +
  583. X               lt->tm_hour*(60L*60L));
  584. X   }
  585. X
  586. X   sdate += relsec;
  587. X   sdate += monthadd(sdate, relmonth);
  588. X
  589. X   if (dayflag && !dateflag) {
  590. X       tod = dayconv(dayord, dayreq, sdate);
  591. X       sdate += tod;
  592. X   }
  593. X
  594. X   /*
  595. X   ** Have to do *something* with a legitimate -1 so it's distinguishable
  596. X   ** from the error return value.  (Alternately could set errno on error.)
  597. X   */
  598. X   return (sdate == -1) ? 0 : sdate;
  599. }
  600. X
  601. static
  602. yyerror(s)
  603. char *s;
  604. {
  605. }
  606. X
  607. #ifdef USG
  608. ftime(timeb)
  609. struct timeb *timeb;
  610. {
  611. X   extern long timezone;
  612. X   extern int daylight;
  613. X   long t = 0;
  614. X
  615. X   localtime(&t);  /* Dummy to init timzeone */
  616. X   ctime(&t);      /* Dummy to init timzeone (XENIX) */
  617. X   time(&(timeb->time));
  618. X   timeb->millitm=0;
  619. X   timeb->timezone=timezone/60;    /* Timezone is in seconds! */
  620. X   timeb->dstflag=daylight;
  621. }
  622. #endif
  623. SHAR_EOF
  624. chmod 0644 getdate.y ||
  625. echo 'restore of getdate.y failed'
  626. Wc_c="`wc -c < 'getdate.y'`"
  627. test 13426 -eq "$Wc_c" ||
  628.     echo 'getdate.y: original size 13426, current size' "$Wc_c"
  629. fi
  630. # ============= frecv.sh ==============
  631. if test -f 'frecv.sh' -a X"$1" != X"-c"; then
  632.     echo 'x - skipping frecv.sh (File already exists)'
  633. else
  634. echo 'x - extracting frecv.sh (Text)'
  635. sed 's/^X//' << 'SHAR_EOF' > 'frecv.sh' &&
  636. :
  637. #!/bin/sh
  638. #
  639. # $Id: frecv.sh,v 1.5 91/03/29 18:10:43 mj Exp $
  640. #
  641. # This shell script feeds the msg in SPOOL/unpacked to
  642. # either rnews or rmail, depending on their destination:
  643. #
  644. #     N.xxxx  -> rnews
  645. #     M.xxxx  -> rmail
  646. #
  647. # Must be used after fido mail packets were processed
  648. # with funpack.
  649. #
  650. X
  651. SPOOL=??SPOOL??
  652. X
  653. #
  654. # Test for addresses allowed to FIDONET users
  655. #
  656. #     name
  657. #     name@hippo
  658. #     name@hippo.uucp
  659. #     name@slcdec               (UUCP feed)
  660. #     name@system.domain.de     (DNet)
  661. #
  662. name="[#$%&*+-/0-9=?A-Z_a-z.]+"
  663. pattern1="^${name}$"
  664. pattern2="^${name}@hippo(\.uucp)?$"
  665. pattern3="^${name}@${name}\.de$"
  666. pattern4="^${name}@slcdec$"
  667. pattern="$pattern1 $pattern2 $pattern3 $pattern4"
  668. addrok="no"
  669. X
  670. testaddr() {
  671. # Im Moment sind erstmal wieder alle Adressen erlaubt!
  672. addrok="yes"
  673. #   addrok="no"
  674. #   for p in $pattern
  675. #   do
  676. #       echo $1 | egrep "$p" >/dev/null
  677. #       if [ $? -eq 0 ]; then addrok="yes"; break; fi
  678. #   done
  679. }
  680. X
  681. X
  682. X
  683. cd ${SPOOL}/unpacked
  684. X
  685. #
  686. # Process news messages
  687. #
  688. for f in N.*
  689. do
  690. X   if [ -f $f ]
  691. X   then
  692. X       rnews < $f
  693. X       status=$?
  694. X       if [ $status -eq 0 ]
  695. X       then
  696. X           rm -f $f
  697. X       else
  698. X           mv $f ../bad
  699. X       fi
  700. X   fi
  701. done
  702. X
  703. #
  704. # Process messages for mail
  705. #
  706. for f in M.*
  707. do
  708. X   if [ -f $f ]
  709. X   then
  710. X       set X `sed <$f -n -e '/^To:/{' -e 's/To: *//p' -e q -e '}'`
  711. X       shift
  712. X       set X "$@" `sed <$f -n -e '/^Cc:/{' -e 's/Cc: *//p' -e q -e '}'`
  713. X       shift
  714. X       set X "$@" `sed <$f -n -e '/^Bcc:/{' -e 's/Bcc: *//p' -e q -e '}'`
  715. X       shift
  716. X       recv=`echo $@ | sed -e 's/ *(.*)//g'`
  717. X       for i in $recv
  718. X       do
  719. X           testaddr $i
  720. X           if [ $addrok = "no" ]; then break; fi
  721. X       done
  722. X       if [ $addrok = "yes" ]; then
  723. X           rmail $recv < $f
  724. X           status=$?
  725. X           if [ $status -eq 0 ]
  726. X           then
  727. X               rm -f $f
  728. X           else
  729. X               mv $f ../bad
  730. X           fi
  731. X       else
  732. X           mv $f ../bad
  733. X       fi
  734. X   fi
  735. done
  736. X
  737. Xexit 0
  738. SHAR_EOF
  739. chmod 0755 frecv.sh ||
  740. echo 'restore of frecv.sh failed'
  741. Wc_c="`wc -c < 'frecv.sh'`"
  742. test 1722 -eq "$Wc_c" ||
  743.     echo 'frecv.sh: original size 1722, current size' "$Wc_c"
  744. fi
  745. # ============= config.h ==============
  746. if test -f 'config.h' -a X"$1" != X"-c"; then
  747.     echo 'x - skipping config.h (File already exists)'
  748. else
  749. echo 'x - extracting config.h (Text)'
  750. sed 's/^X//' << 'SHAR_EOF' > 'config.h' &&
  751. /*:ts=4*/
  752. /*****************************************************************************
  753. X * FIDOGATE --- Gateway software UNIX <-> FIDO
  754. X *
  755. X * $Id: config.h,v 1.17 91/05/22 22:14:08 mj Exp $
  756. X *
  757. X * Configuration header file
  758. X *
  759. X * $Log:   config.h,v $
  760. X * Revision 1.17  91/05/22  22:14:08  mj
  761. X * Some clean-up for new release.
  762. X * 
  763. X * Revision 1.16  91/03/29  18:08:11  mj
  764. X * New #define for generation of special Reply-To: adresses.
  765. X * 
  766. X * Revision 1.15  91/01/28  19:32:34  mj
  767. X * New #define ERRORS_TO: return address for bounced mail.
  768. X * 
  769. X * Revision 1.14  91/01/05  13:05:29  mj
  770. X * Changed domain name to ".dfv.rwth-aachen.de"
  771. X * 
  772. X * Revision 1.13  90/12/10  16:33:31  mj
  773. X * Moved define of LOCK_LOCKF from Makefile to config.h.
  774. X * 
  775. X * Revision 1.12  90/12/09  17:32:03  mj
  776. X * New #define's for mail forwarding in rmail (UUCPFEED). Removed
  777. X * GATEWAY definition.
  778. X * 
  779. X * Revision 1.11  90/12/02  21:21:44  mj
  780. X * Changed program header to mention both authors of the original
  781. X * software posted to alt.sources.
  782. X * 
  783. X * Revision 1.10  90/12/01  17:48:26  mj
  784. X * Removed unnecessary #defines of JUNK and JUNK_AREA.
  785. X * 
  786. X * Revision 1.9  90/11/23  21:51:19  mj
  787. X * Removed #define's of INT16 and SWAB_BYTES. Not necessary any more
  788. X * because of the rewrite of fpack.
  789. X * 
  790. X * Revision 1.8  90/11/05  20:49:31  mj
  791. X * Changed my signature in all program headers.
  792. X * 
  793. X * Revision 1.7  90/09/16  17:35:27  mj
  794. X * Changed FIDODOMAIN to ".fidonet.org".
  795. X * 
  796. X * Revision 1.6  90/09/03  17:50:45  mj
  797. X * Changed to new address.
  798. X * 2:242/6.1  aka  6000/1
  799. X * 
  800. X * Revision 1.5  90/08/12  14:13:31  mj
  801. X * Added definition for FIDO MSGID sequencer (MSGIDSEQ).
  802. X * 
  803. X * Revision 1.4  90/07/30  20:00:16  mj
  804. X * Added support for new style FIDO addresses:
  805. X *     p<point>.f<node>.n<net>.z<zone>.FIDODOMAIN
  806. X * FIDODOMAIN is defined in config.h
  807. X * 
  808. X * Revision 1.3  90/07/15  10:22:15  mj
  809. X * Changed MAX_LINELEN to 80.
  810. X * 
  811. X * Revision 1.2  90/06/28  22:03:53  mj
  812. X * Much rework of the sources, no more hsu.h and other clean up.
  813. X * rmail improved, now handles special XENIX quirks.
  814. X * 
  815. X * Revision 1.1  90/06/21  21:06:05  mj
  816. X * Everything seems to work, so this delta was made.
  817. X * 
  818. X * Revision 1.0  90/06/21  18:52:36  mj
  819. X * Initial revision
  820. X * 
  821. X *
  822. X *****************************************************************************
  823. X * This version hacked and maintained by:
  824. X *    _____ _____
  825. X *   |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  826. X *   | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  827. X *   |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  828. X *
  829. X * Original version of these programs and files:
  830. X *
  831. X *   Teemu Torma
  832. X *   Heikki Suonsivu   FIDO: 2:504/1   UUCP: ...!mcsun!santra!hsu
  833. X *
  834. X *****************************************************************************/
  835. X
  836. /*
  837. X * This is our net and node number
  838. X *
  839. X * We're 2:242/6.1 with fake address 2:6000/1
  840. X */
  841. #define REAL_ZONE       2
  842. #define REAL_REGION     24
  843. #define REAL_NET        242
  844. #define REAL_NODE       6
  845. #define REAL_POINT      1
  846. X
  847. #define MY_ZONE         2
  848. #define MY_REGION       24
  849. #define MY_NET          6000
  850. #define MY_NODE         1
  851. #define MY_POINT        0
  852. X
  853. #define MY_NAME         "Hipposoft"
  854. X
  855. X
  856. /*
  857. X * This is where our mail goes to ...
  858. X */
  859. #define REM_ZONE        2
  860. #define REM_REGION      24
  861. #define REM_NET         242
  862. #define REM_NODE        6
  863. #define REM_POINT       0
  864. #define REM_NAME        "Bossnode"
  865. /*
  866. X * Echo feed (currently not used)
  867. X */
  868. #define ECHOFEED_NET    242
  869. #define ECHOFEED_NODE   6
  870. X
  871. /*
  872. X * Domain suffix (added to hostname)
  873. X */
  874. #define MY_HOSTNAME     "hippo"
  875. #define MY_DOMAIN       ".dfv.rwth-aachen.de"
  876. X
  877. /*
  878. X * UUCP feed (i.e. system we send UUCP mail to)
  879. X */
  880. #define UUCPFEED        "slcdec"
  881. #define UUCPFEED_DOMAIN ".dfv.rwth-aachen.de"
  882. X
  883. /*
  884. X * Domain suffix for FIDO net addresses
  885. X */
  886. #define FIDODOMAIN      ".fidonet.org"
  887. X
  888. /*
  889. X * Enable generation of Reply-To addresses
  890. X */
  891. #define LOCAL_REPLY_TO                  /**/
  892. X
  893. /*
  894. X * Return address for bounced mail. An `Errors-To:' header will
  895. X * be inserted for mail addressed via `To:' from FIDO if defined.
  896. X */
  897. #define ERRORS_TO       "root@hippo.dfv.rwth-aachen.de"
  898. X
  899. X
  900. X
  901. /*
  902. X * Directories the various programs work on
  903. X */
  904. X
  905. #define SPOOL           "/u/spool/fidonet"          /* main spool directory */
  906. #define SPOOL_BAD       "/u/spool/fidonet/bad"      /* rejected by rnews/rmail */
  907. #define SPOOL_IN        "/u/spool/fidonet/in"       /* incoming packets */
  908. #define SPOOL_OUT       "/u/spool/fidonet/out"      /* outgoing mail */
  909. #define SPOOL_UNPACKED  "/u/spool/fidonet/unpacked" /* output of funpack */
  910. #define SPOOL_SENT      "/u/spool/fidonet/sent"     /* sent packets */
  911. X
  912. #define LIBDIR          "/u/lib/fidonet"            /* config files / progs */
  913. #define LOGFILE         "/u/lib/fidonet/log"        /* log file */
  914. #define IDSEQUENCE      "/u/lib/fidonet/idseq"      /* message id sequence */
  915. #define IPACKETSEQUENCE "/u/lib/fidonet/ipacketseq" /* input packet sequence */
  916. #define OPACKETSEQUENCE "/u/lib/fidonet/opacketseq" /* output packet sequence */
  917. #define BADSEQ          "/u/lib/fidonet/badseq"     /* bad messages sequence */
  918. #define JOBSEQ          "/u/lib/fidonet/seq"        /* job number sequence */
  919. #define MSGIDSEQ        "/u/lib/fidonet/msgidseq"   /* for generating ^AMSGID:*/
  920. #define ALIAS           "/u/lib/fidonet/Alias"      /* alias file */
  921. #define AREAS           "/u/lib/fidonet/Areas"      /* areas file */
  922. X
  923. X
  924. /*
  925. X * Enable nodelist support
  926. X */
  927. /*#define NODELIST_SUPPORT                          /* Use FIDO nodelist */
  928. X
  929. X
  930. /*
  931. X * mail receiver for fidonet
  932. X */
  933. #define RFMAIL "/u/lib/fidonet/rfmail"              /* fido mail receiver */
  934. /*#define RFMAIL "/u/mj/news/fidogate/rfmail"           /* test version */
  935. X
  936. /*
  937. X * Program which receives unpacked news articles
  938. X */
  939. #define RNEWS "/bin/rnews"                          /* News receiver */
  940. X
  941. /*
  942. X * Program which receives mail from fido net
  943. X */
  944. #define RMAIL "/usr/bin/rmail"                      /* Mail receiver */
  945. /*
  946. X * There is a replacement for rmail
  947. X * included in this package, which accepts fido net
  948. X * domain addresses and feeds this mail to rfmail.
  949. X * If you use the included rmail, you must rename
  950. X * the old rmail to ormail and install the included
  951. X * rmail as /usr/bin/rmail.
  952. X */
  953. /*#define RECVMAIL "/usr/bin/ormail"                    /* Mail receiver */
  954. #define RECVMAIL "/usr/lib/mail/execmail"           /* XENIX */
  955. /*
  956. X * Define this if you want rfmail to return underlivered mail. You do
  957. X * not need this if you are running sendmail or similiar which returns
  958. X * undelivered mail.
  959. X */
  960. #define RETURN_FAILED_MAIL /**/
  961. X
  962. X
  963. /*
  964. X * Lowest user id
  965. X */
  966. #define USERUID 50
  967. X
  968. /*
  969. X * System dependend configuration
  970. X */
  971. X
  972. /***** Operating system *****/
  973. #define USG                                     /* System V */
  974. /*#define BSD                                   /* BSD 4.2+ */
  975. X
  976. /***** File locking *****/
  977. #define LOCK_LOCKF                              /* Use lockf(), else locking() */
  978. X
  979. X
  980. /*
  981. X * parameters for fcall
  982. X */
  983. X
  984. /* How many seconds wait before starting up fidonet handshake */
  985. #define PREWAIT 5
  986. X
  987. /* How many seconds to wait for line to clear */
  988. #define WAITCLEAR 2
  989. X
  990. /* How many tries to give for xmodem startup in send. This should be low
  991. X   value, it just gives possibility to retry xmodem startup if modems
  992. X   handshaked too fast (really a acu configuration problems, dial should
  993. X   return after it has a working line available!) */
  994. #define MAX_SEND_RETRIES 1
  995. X
  996. /* Maximum baud rate to use when calling out */
  997. #define MAXBAUD 1200
  998. X
  999. /* Define minimum baud rate to use when calling out */
  1000. #define MINBAUD 300
  1001. X
  1002. /* Width of formatted messages. Lines will be wrapped to be less
  1003. X   than this. If word is longer than 2/3s of MAX_LINELEN, it will be
  1004. X   cut instead of correct wrapping. */
  1005. #define MAX_LINELEN 80
  1006. X
  1007. /* Dial translation table. first string stripped out, second one replaced */
  1008. X
  1009. #define DIALTABLE "358-0-", "",  "358-", "9",  "", "990"
  1010. SHAR_EOF
  1011. chmod 0644 config.h ||
  1012. echo 'restore of config.h failed'
  1013. Wc_c="`wc -c < 'config.h'`"
  1014. test 7440 -eq "$Wc_c" ||
  1015.     echo 'config.h: original size 7440, current size' "$Wc_c"
  1016. fi
  1017. # ============= packet.h ==============
  1018. if test -f 'packet.h' -a X"$1" != X"-c"; then
  1019.     echo 'x - skipping packet.h (File already exists)'
  1020. else
  1021. echo 'x - extracting packet.h (Text)'
  1022. sed 's/^X//' << 'SHAR_EOF' > 'packet.h' &&
  1023. /*:ts=4*/
  1024. /*****************************************************************************
  1025. X * FIDOGATE --- Gateway software UNIX <-> FIDO
  1026. X *
  1027. X * $Id: packet.h,v 1.3 90/12/09 18:36:16 mj Exp $
  1028. X *
  1029. X * FIDOnet packet definitions
  1030. X *
  1031. X * $Log:   packet.h,v $
  1032. X * Revision 1.3  90/12/09  18:36:16  mj
  1033. X * Reformatted code and added #define's for sizes of FIDO header fields.
  1034. X * 
  1035. X * Revision 1.2  90/12/02  21:22:20  mj
  1036. X * Changed program header to mention both authors of the original
  1037. X * software posted to alt.sources.
  1038. X * 
  1039. X * Revision 1.1  90/11/05  20:50:53  mj
  1040. X * Changed my signature in all program headers.
  1041. X * 
  1042. X * Revision 1.0  90/06/21  19:15:14  mj
  1043. X * Initial revision
  1044. X * 
  1045. X *
  1046. X *****************************************************************************
  1047. X * This version hacked and maintained by:
  1048. X *    _____ _____
  1049. X *   |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  1050. X *   | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  1051. X *   |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  1052. X *
  1053. X * Original version of these programs and files:
  1054. X *
  1055. X *   Teemu Torma
  1056. X *   Heikki Suonsivu   FIDO: 2:504/1   UUCP: ...!mcsun!santra!hsu
  1057. X *
  1058. X *****************************************************************************/
  1059. X
  1060. /* Structure for packet header. */
  1061. X
  1062. typedef struct _packet {
  1063. X   short orig_node;                /* originating node */
  1064. X   short dest_node;                /* destinating mode */
  1065. X   short year;                     /* packing year (e.g. 1986) */
  1066. X   short month;                    /* 0-11 for Jan - Dec */
  1067. X   short day;                      /* 1-31 */
  1068. X   short hour;                     /* 0-23 */
  1069. X   short minute;                   /* 0-59 */
  1070. X   short second;                   /* 0-59 */
  1071. X   short rate;                     /* maximum baud rate */
  1072. X   short ver;                      /* header version */
  1073. X   short orig_net;                 /* originating net */
  1074. X   short dest_net;                 /* destination net */
  1075. X   char product;                   /* product */
  1076. X   char x1;                        /* Extra byte */
  1077. #ifdef FIDO_V11w
  1078. X   short fill[16];                 /* extra space */
  1079. #else
  1080. X   char pwd_kludge[8];
  1081. X   short orig_zone;
  1082. X   short dest_zone;
  1083. X   char B_fill2[16];
  1084. X   long B_fill3;
  1085. #endif
  1086. } Packet;
  1087. X
  1088. /* Attributes tranferred via mail. */
  1089. X
  1090. #define ATTR_PRIVATE    0000001     /* private msg */
  1091. #define ATTR_CRASH      0000002     /* crash mail */
  1092. #define ATTR_FILE       0000020     /* files attached */
  1093. #define ATTR_UNUSED     0002000     /* unused */
  1094. #define ATTR_RRR        0010000     /* SEAdog only */
  1095. #define ATTR_IRR        0020000     /* SEAdog only */
  1096. #define ATTR_AUDREQ     0040000     /* SEAdog only */
  1097. X
  1098. /* Packet and message types. */
  1099. X
  1100. #define HDRVER          2
  1101. #define MSGTYPE         2
  1102. X
  1103. /* Sizes of to/from/subject/date field */
  1104. #define SIZE_FROM       36
  1105. #define SIZE_TO         36
  1106. #define SIZE_SUBJECT    72
  1107. #define SIZE_DATE       20
  1108. SHAR_EOF
  1109. chmod 0644 packet.h ||
  1110. echo 'restore of packet.h failed'
  1111. Wc_c="`wc -c < 'packet.h'`"
  1112. test 2561 -eq "$Wc_c" ||
  1113.     echo 'packet.h: original size 2561, current size' "$Wc_c"
  1114. fi
  1115. # ============= shuffle.h ==============
  1116. if test -f 'shuffle.h' -a X"$1" != X"-c"; then
  1117.     echo 'x - skipping shuffle.h (File already exists)'
  1118. else
  1119. echo 'x - extracting shuffle.h (Text)'
  1120. sed 's/^X//' << 'SHAR_EOF' > 'shuffle.h' &&
  1121. /*:ts=4*/
  1122. /*****************************************************************************
  1123. X * FIDOGATE --- Gateway software UNIX <-> FIDO
  1124. X *
  1125. X * $Id: shuffle.h,v 1.3 90/12/02 21:22:39 mj Exp $
  1126. X *
  1127. X * Something very special ... ;-)
  1128. X *
  1129. X * $Log:   shuffle.h,v $
  1130. X * Revision 1.3  90/12/02  21:22:39  mj
  1131. X * Changed program header to mention both authors of the original
  1132. X * software posted to alt.sources.
  1133. X * 
  1134. X * Revision 1.2  90/11/05  20:51:08  mj
  1135. X * Changed my signature in all program headers.
  1136. X * 
  1137. X * Revision 1.1  90/06/28  22:05:04  mj
  1138. X * Much rework of the sources, no more hsu.h and other clean up.
  1139. X * rmail improved, now handles special XENIX quirks.
  1140. X * 
  1141. X * Revision 1.0  90/06/21  19:08:09  mj
  1142. X * Initial revision
  1143. X * 
  1144. X *
  1145. X *****************************************************************************
  1146. X * This version hacked and maintained by:
  1147. X *    _____ _____
  1148. X *   |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  1149. X *   | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  1150. X *   |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  1151. X *
  1152. X * Original version of these programs and files:
  1153. X *
  1154. X *   Teemu Torma
  1155. X *   Heikki Suonsivu   FIDO: 2:504/1   UUCP: ...!mcsun!santra!hsu
  1156. X *
  1157. X *****************************************************************************/
  1158. X
  1159. #define loop_increment(x,y) (x = (++x >= (y)) ? 0 : x)
  1160. #define loop_decrement(x,y) (x = (--x < 0) ? (y)-1 : x)
  1161. X
  1162. #define MAX_CONVERT_BUFFERS     40
  1163. #define MAX_CONVERT_BUFLEN      80
  1164. X
  1165. static char bufs[MAX_CONVERT_BUFFERS][MAX_CONVERT_BUFLEN], *tcharp;
  1166. static int bflag;
  1167. X
  1168. #define SHUFFLEBUFFERS \
  1169. loop_increment(bflag, MAX_CONVERT_BUFFERS); tcharp = bufs[bflag]
  1170. SHAR_EOF
  1171. chmod 0644 shuffle.h ||
  1172. echo 'restore of shuffle.h failed'
  1173. Wc_c="`wc -c < 'shuffle.h'`"
  1174. test 1637 -eq "$Wc_c" ||
  1175.     echo 'shuffle.h: original size 1637, current size' "$Wc_c"
  1176. fi
  1177. # ============= sysexits.h ==============
  1178. if test -f 'sysexits.h' -a X"$1" != X"-c"; then
  1179.     echo 'x - skipping sysexits.h (File already exists)'
  1180. else
  1181. echo 'x - extracting sysexits.h (Text)'
  1182. sed 's/^X//' << 'SHAR_EOF' > 'sysexits.h' &&
  1183. /*:ts=4*/
  1184. /*****************************************************************************
  1185. X * FIDOGATE --- Gateway software UNIX <-> FIDO
  1186. X *
  1187. X * $Id: sysexits.h,v 1.2 90/12/02 21:22:44 mj Exp $
  1188. X *
  1189. X * Exit statuses for systems that doesn't have /usr/include/sysexits.h
  1190. X *
  1191. X * $Log:   sysexits.h,v $
  1192. X * Revision 1.2  90/12/02  21:22:44  mj
  1193. X * Changed program header to mention both authors of the original
  1194. X * software posted to alt.sources.
  1195. X * 
  1196. X * Revision 1.1  90/11/05  20:51:12  mj
  1197. X * Changed my signature in all program headers.
  1198. X * 
  1199. X * Revision 1.0  90/06/21  19:12:34  mj
  1200. X * Initial revision
  1201. X * 
  1202. X *
  1203. X *****************************************************************************
  1204. X * This version hacked and maintained by:
  1205. X *    _____ _____
  1206. X *   |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  1207. X *   | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  1208. X *   |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  1209. X *
  1210. X * Original version of these programs and files:
  1211. X *
  1212. X *   Teemu Torma
  1213. X *   Heikki Suonsivu   FIDO: 2:504/1   UUCP: ...!mcsun!santra!hsu
  1214. X *
  1215. X *****************************************************************************/
  1216. X
  1217. #define EX_OK            0              /* successful termination */
  1218. #define EX_USAGE        64              /* command line usage error */
  1219. #define EX_DATAERR      65              /* data format error */
  1220. #define EX_NOINPUT      66              /* cannot open input */
  1221. #define EX_NOHOST       68              /* host name unknown */
  1222. #define EX_UNAVAILABLE  69              /* service unavailable */
  1223. #define EX_SOFTWARE     70              /* internal software error */
  1224. #define EX_OSERR        71              /* system error (e.g., can't fork) */
  1225. #define EX_OSFILE       72              /* critical OS file missing */
  1226. #define EX_CANTCREAT    73              /* can't create (user) output file */
  1227. #define EX_IOERR        74              /* input/output error */
  1228. SHAR_EOF
  1229. chmod 0644 sysexits.h ||
  1230. echo 'restore of sysexits.h failed'
  1231. Wc_c="`wc -c < 'sysexits.h'`"
  1232. test 1760 -eq "$Wc_c" ||
  1233.     echo 'sysexits.h: original size 1760, current size' "$Wc_c"
  1234. fi
  1235. # ============= nodelist.h ==============
  1236. if test -f 'nodelist.h' -a X"$1" != X"-c"; then
  1237.     echo 'x - skipping nodelist.h (File already exists)'
  1238. else
  1239. echo 'x - extracting nodelist.h (Text)'
  1240. sed 's/^X//' << 'SHAR_EOF' > 'nodelist.h' &&
  1241. /*:ts=4*/
  1242. /*****************************************************************************
  1243. X * FIDOGATE --- Gateway software UNIX <-> FIDO
  1244. X *
  1245. X * $Id: nodelist.h,v 1.2 90/12/02 21:22:18 mj Exp $
  1246. X *
  1247. X * Structures and definitions for nodelist.
  1248. X *
  1249. X * $Log:   nodelist.h,v $
  1250. X * Revision 1.2  90/12/02  21:22:18  mj
  1251. X * Changed program header to mention both authors of the original
  1252. X * software posted to alt.sources.
  1253. X * 
  1254. X * Revision 1.1  90/11/05  20:50:51  mj
  1255. X * Changed my signature in all program headers.
  1256. X * 
  1257. X * Revision 1.0  90/06/21  19:14:27  mj
  1258. X * Initial revision
  1259. X * 
  1260. X *
  1261. X *****************************************************************************
  1262. X * This version hacked and maintained by:
  1263. X *    _____ _____
  1264. X *   |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  1265. X *   | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  1266. X *   |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  1267. X *
  1268. X * Original version of these programs and files:
  1269. X *
  1270. X *   Teemu Torma
  1271. X *   Heikki Suonsivu   FIDO: 2:504/1   UUCP: ...!mcsun!santra!hsu
  1272. X *
  1273. X *****************************************************************************/
  1274. X
  1275. /* Change these if you wish. */
  1276. X
  1277. /* Name of nodelist in LIBDIR */
  1278. #define NODELIST "nodelist"
  1279. X
  1280. /* Name of nodelist index file in LIBDIR */
  1281. #define INODELIST "nodelist.idx"
  1282. X
  1283. /* Name of sysop name index file in LIBDIR */
  1284. #define NAMELIST "name.idx"
  1285. X
  1286. /* Compare two node entried to see if they are same node (ignoring
  1287. X   possible other information */
  1288. #define samenode(n1, n2) ((n1).zone == (n2).zone && (n1).net == (n2).net && \
  1289. X              (n1).node == (n2).node && (n1).point == (n2).point)
  1290. X
  1291. /* Structure for nodelist entry. Routines to get one node from nodelist
  1292. X   will return this structure. */
  1293. X
  1294. typedef struct _node {
  1295. X  int type; /* type of entry (see below) */
  1296. X  int region; /* region (not necessarily used/set) */
  1297. X  int net; /* net/region of node */
  1298. X  int zone; /* Zone of node (not really supported yet) */
  1299. X  int node; /* number of node */
  1300. X  int point; /* Point of node (not really supported yet) */
  1301. X  char name[20]; /* name of fido */
  1302. X  char city[40]; /* city */
  1303. X  char sysop[36]; /* name of sysop */
  1304. X  char phone[40]; /* phone-number */
  1305. X  int speed; /* speeds */
  1306. X  char flags[60]; /* flags-string */
  1307. } Node;
  1308. X
  1309. typedef struct _indexnode {
  1310. X  int zone;
  1311. X  int net;
  1312. X  int node;
  1313. X  long offset;
  1314. } NODEINDEX;
  1315. X
  1316. typedef struct _indexname {
  1317. X  char name[36]; /* Sysop name */
  1318. X  long offset; /* Refers to nodelist index entry */
  1319. X  int zone;
  1320. X  int net;
  1321. } NAMEINDEX;
  1322. X
  1323. /* Entry types. */
  1324. X
  1325. #define REGION (1) /* region-host */
  1326. #define HOST (2) /* net-host */
  1327. #define HUB (3) /* local-host */
  1328. #define PVT (4) /* private node */
  1329. #define HOLD (5) /* no mail to this node */
  1330. #define DOWN (6) /* node is down */
  1331. #define KENL (7) /* should not be comminucated */
  1332. #define NORMAL (8) /* normal node */
  1333. #define ZONE (9) /* Zone */
  1334. #define POINT (10) /* point (points are not in nodelist but this is used
  1335. X              elsewhere. */
  1336. X
  1337. /* Declarations for routines. */
  1338. X
  1339. Node *node_entry(); /* get entry from nodelist */
  1340. char *update_index(); /* update index-file */
  1341. extern Node *parse_entry();
  1342. X
  1343. extern Node originnode;
  1344. extern NODEINDEX *nodeindex;
  1345. extern NAMEINDEX *nameindex;
  1346. extern int nodes;
  1347. SHAR_EOF
  1348. chmod 0644 nodelist.h ||
  1349. echo 'restore of nodelist.h failed'
  1350. Wc_c="`wc -c < 'nodelist.h'`"
  1351. test 3209 -eq "$Wc_c" ||
  1352.     echo 'nodelist.h: original size 3209, current size' "$Wc_c"
  1353. fi
  1354. # ============= fidogate.h ==============
  1355. if test -f 'fidogate.h' -a X"$1" != X"-c"; then
  1356.     echo 'x - skipping fidogate.h (File already exists)'
  1357. else
  1358. echo 'x - extracting fidogate.h (Text)'
  1359. sed 's/^X//' << 'SHAR_EOF' > 'fidogate.h' &&
  1360. /*:ts=4*/
  1361. /*****************************************************************************
  1362. X * FIDOGATE --- Gateway software UNIX <-> FIDO
  1363. X *
  1364. X * $Id: fidogate.h,v 1.10 91/05/07 23:58:10 mj Exp $
  1365. X *
  1366. X * Common header file
  1367. X *
  1368. X * $Log:   fidogate.h,v $
  1369. X * Revision 1.10  91/05/07  23:58:10  mj
  1370. X * Changed declaration for function parse_address() from address.c, new
  1371. X * function isfido().
  1372. X * 
  1373. X * Revision 1.9  91/03/29  18:09:11  mj
  1374. X * Some changes. (what?)
  1375. X * 
  1376. X * Revision 1.8  90/12/02  21:21:47  mj
  1377. X * Changed program header to mention both authors of the original
  1378. X * software posted to alt.sources.
  1379. X * 
  1380. X * Revision 1.7  90/12/01  17:48:52  mj
  1381. X * Fixed an extern function declaration of ascnoden().
  1382. X * 
  1383. X * Revision 1.6  90/11/20  21:08:13  mj
  1384. X * Changed some extern definitions.
  1385. X * 
  1386. X * Revision 1.5  90/11/05  20:49:34  mj
  1387. X * Changed my signature in all program headers.
  1388. X * 
  1389. X * Revision 1.4  90/09/08  18:45:08  mj
  1390. X * Added definition of strsaveline() in xalloc.c
  1391. X * 
  1392. X * Revision 1.3  90/07/01  13:45:19  mj
  1393. X * Removed all calls to alloca(). All unsave malloc()'s without
  1394. X * checking the returned pointer are now done via xmalloc().
  1395. X * Fixed a malloc() error in rmail.
  1396. X * 
  1397. X * Revision 1.2  90/06/28  22:04:01  mj
  1398. X * Much rework of the sources, no more hsu.h and other clean up.
  1399. X * rmail improved, now handles special XENIX quirks.
  1400. X * 
  1401. X * Revision 1.1  90/06/21  21:08:29  mj
  1402. X * Everything seems to work, so this delta was made.
  1403. X * 
  1404. X * Revision 1.0  90/06/21  18:56:20  mj
  1405. X * Initial revision
  1406. X * 
  1407. X *
  1408. X *****************************************************************************
  1409. X * This version hacked and maintained by:
  1410. X *    _____ _____
  1411. X *   |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  1412. X *   | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  1413. X *   |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  1414. X *
  1415. X * Original version of these programs and files:
  1416. X *
  1417. X *   Teemu Torma
  1418. X *   Heikki Suonsivu   FIDO: 2:504/1   UUCP: ...!mcsun!santra!hsu
  1419. X *
  1420. X *****************************************************************************/
  1421. X
  1422. #include "config.h"
  1423. X
  1424. /*
  1425. X * default level of debug output
  1426. X */
  1427. #ifndef INIT_VERBOSE
  1428. # ifdef DEBUG
  1429. #  define INIT_VERBOSE 3 /*20*/
  1430. # else
  1431. #  define INIT_VERBOSE 0
  1432. # endif
  1433. #endif
  1434. X
  1435. X
  1436. /*
  1437. X * heavy includin' ...
  1438. X */
  1439. X
  1440. /***** System *****/
  1441. #include <stdio.h>
  1442. #include <ctype.h>
  1443. #include <string.h>
  1444. #include <sys/types.h>
  1445. #include <time.h>
  1446. #include <errno.h>
  1447. #ifdef M_XENIX
  1448. # include <sys/ndir.h>
  1449. # define dirent direct
  1450. #else
  1451. # include <dirent.h>
  1452. #endif
  1453. X
  1454. /***** Local *****/
  1455. #include "packet.h"                     /* FIDO mail packet definition */
  1456. #include "nodelist.h"                   /* nodelist definitions */
  1457. #include "sysexits.h"                   /* EX_* defines */
  1458. X
  1459. X
  1460. X
  1461. /*
  1462. X * Config file sections
  1463. X */
  1464. #define SECT_NETNODE    1               /* Net/node for receiving node */
  1465. #define SECT_NG_AREA    2               /* Newsgroup -> area conversions */
  1466. #define SECT_HEADERS    3               /* Header-field definitions */
  1467. #define SECT_ENDMSG     4               /* Text to be placed at the end of msg */
  1468. #define SECT_AREA_NG    5               /* Area -> newsgroup conversions */
  1469. X
  1470. X
  1471. X
  1472. /*
  1473. X * External functions and variables
  1474. X */
  1475. X
  1476. /***** System *****/
  1477. extern char *mktemp(), *getenv();
  1478. extern long time();
  1479. extern unsigned short getuid();
  1480. extern unsigned short geteuid();
  1481. extern unsigned short getgid();
  1482. extern unsigned short getegid();
  1483. X
  1484. /***** errno *****/
  1485. extern int errno;
  1486. extern char *strerror();
  1487. X
  1488. X
  1489. X
  1490. /*
  1491. X * Defines
  1492. X */
  1493. #define TRUE    1
  1494. #define FALSE   0
  1495. #define BUFLEN 256
  1496. #define OK      0
  1497. #define ERROR   (-1)
  1498. X
  1499. #define bool    int
  1500. X
  1501. /* Global variables. */
  1502. X
  1503. extern bool verbose;
  1504. extern int line;
  1505. extern int receiving_data;
  1506. X
  1507. /* Function declarations. */
  1508. X
  1509. /* address.c */
  1510. extern int parse_address();
  1511. extern int isfido();
  1512. extern int parseinternode();
  1513. extern int parsefnetaddress();
  1514. extern char *ascnode();
  1515. extern char *ascnoden();
  1516. extern char *internode();
  1517. extern char *internodex();
  1518. extern char *ascnodei();
  1519. X
  1520. extern int fine_convert();
  1521. extern char *ascii_convert();
  1522. extern int stricmp();
  1523. extern int strnicmp();
  1524. extern time_t getdate();
  1525. extern void flush();
  1526. extern void sendline();
  1527. extern char *getcl();
  1528. extern void section();
  1529. extern void log();
  1530. extern void debug();
  1531. extern int lock();
  1532. extern int unlock();
  1533. extern char *spoolfile();
  1534. extern int quit();
  1535. extern char *basename();
  1536. extern FILE *pfopen();
  1537. extern char *date();
  1538. extern long job_number();
  1539. extern long sequencer();
  1540. extern char *mheader();
  1541. X
  1542. /* sprintfs.c */
  1543. extern char *sstrcat(), *sprintfs();
  1544. X
  1545. /* strempty.c */
  1546. extern char *strclean(), *strsclean();
  1547. X
  1548. /* xalloc.c */
  1549. extern char *xmalloc(), *xrealloc(), *strsave(), *strsaveline();
  1550. SHAR_EOF
  1551. chmod 0644 fidogate.h ||
  1552. echo 'restore of fidogate.h failed'
  1553. Wc_c="`wc -c < 'fidogate.h'`"
  1554. test 4512 -eq "$Wc_c" ||
  1555.     echo 'fidogate.h: original size 4512, current size' "$Wc_c"
  1556. fi
  1557. true || echo 'restore of rfmail.c failed'
  1558. echo End of part 2, continue with part 3
  1559. exit 0
  1560.  
  1561. --
  1562.  _____ _____
  1563. |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  1564. | | | |   | |   Republikplatz 3   DOMAIN:  mj@dfv.rwth-aachen.de
  1565. |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  1566.