home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2637 < prev    next >
Internet Message Format  |  1991-01-30  |  40KB

  1. From: mj@dfv.rwth-aachen.de (Martin Junius)
  2. Newsgroups: alt.sources
  3. Subject: FIDOGATE Part 2/6
  4. Message-ID: <mj.665055145@suntex>
  5. Date: 28 Jan 91 09:32:25 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 ==============
  631. if test -f 'frecv' -a X"$1" != X"-c"; then
  632.     echo 'x - skipping frecv (File already exists)'
  633. else
  634. echo 'x - extracting frecv (Text)'
  635. sed 's/^X//' << 'SHAR_EOF' > 'frecv' &&
  636. :
  637. #!/bin/sh
  638. #
  639. # $Id: frecv.sh,v 1.4 91/01/27 15:36:40 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=/u/spool/fidonet
  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. X    addrok="no"
  672. X    for p in $pattern
  673. X    do
  674. X        echo $1 | egrep "$p" >/dev/null
  675. X        if [ $? -eq 0 ]; then addrok="yes"; break; fi
  676. X    done
  677. }
  678. X
  679. X
  680. X
  681. cd ${SPOOL}/unpacked
  682. X
  683. #
  684. # Process news messages
  685. #
  686. for f in N.*
  687. do
  688. X    if [ -f $f ]
  689. X    then
  690. X        rnews < $f
  691. X        status=$?
  692. X        if [ $status -eq 0 ]
  693. X        then
  694. X            rm -f $f
  695. X        else
  696. X            mv $f ../bad
  697. X        fi
  698. X    fi
  699. done
  700. X
  701. #
  702. # Process messages for mail
  703. #
  704. for f in M.*
  705. do
  706. X    if [ -f $f ]
  707. X    then
  708. X        set X `sed <$f -n -e '/^To:/{' -e 's/To: *//p' -e q -e '}'`
  709. X        shift
  710. X        set X "$@" `sed <$f -n -e '/^Cc:/{' -e 's/Cc: *//p' -e q -e '}'`
  711. X        shift
  712. X        set X "$@" `sed <$f -n -e '/^Bcc:/{' -e 's/Bcc: *//p' -e q -e '}'`
  713. X        shift
  714. X        recv=`echo $@ | sed -e 's/ *(.*)//g'`
  715. X        for i in $recv
  716. X        do
  717. X            testaddr $i
  718. X            if [ $addrok = "no" ]; then break; fi
  719. X        done
  720. X        if [ $addrok = "yes" ]; then
  721. X            rmail $recv < $f
  722. X            status=$?
  723. X            if [ $status -eq 0 ]
  724. X            then
  725. X                rm -f $f
  726. X            else
  727. X                mv $f ../bad
  728. X            fi
  729. X        else
  730. X            mv $f ../bad
  731. X        fi
  732. X    fi
  733. done
  734. X
  735. Xexit 0
  736. SHAR_EOF
  737. chmod 0755 frecv ||
  738. echo 'restore of frecv failed'
  739. Wc_c="`wc -c < 'frecv'`"
  740. test 1655 -eq "$Wc_c" ||
  741.     echo 'frecv: original size 1655, current size' "$Wc_c"
  742. fi
  743. # ============= config.h ==============
  744. if test -f 'config.h' -a X"$1" != X"-c"; then
  745.     echo 'x - skipping config.h (File already exists)'
  746. else
  747. echo 'x - extracting config.h (Text)'
  748. sed 's/^X//' << 'SHAR_EOF' > 'config.h' &&
  749. /*:ts=4*/
  750. /*****************************************************************************
  751. X * FIDOGATE --- Gateway software UNIX <-> FIDO
  752. X *
  753. X * $Id: config.h,v 1.14 91/01/05 13:05:29 mj Exp $
  754. X *
  755. X * Configuration header file
  756. X *
  757. X * $Log:    config.h,v $
  758. X * Revision 1.14  91/01/05  13:05:29  mj
  759. X * Changed domain name to ".dfv.rwth-aachen.de"
  760. X * 
  761. X * Revision 1.13  90/12/10  16:33:31  mj
  762. X * Moved define of LOCK_LOCKF from Makefile to config.h.
  763. X * 
  764. X * Revision 1.12  90/12/09  17:32:03  mj
  765. X * New #define's for mail forwarding in rmail (UUCPFEED). Removed
  766. X * GATEWAY definition.
  767. X * 
  768. X * Revision 1.11  90/12/02  21:21:44  mj
  769. X * Changed program header to mention both authors of the original
  770. X * software posted to alt.sources.
  771. X * 
  772. X * Revision 1.10  90/12/01  17:48:26  mj
  773. X * Removed unnecessary #defines of JUNK and JUNK_AREA.
  774. X * 
  775. X * Revision 1.9  90/11/23  21:51:19  mj
  776. X * Removed #define's of INT16 and SWAB_BYTES. Not necessary any more
  777. X * because of the rewrite of fpack.
  778. X * 
  779. X * Revision 1.8  90/11/05  20:49:31  mj
  780. X * Changed my signature in all program headers.
  781. X * 
  782. X * Revision 1.7  90/09/16  17:35:27  mj
  783. X * Changed FIDODOMAIN to ".fidonet.org".
  784. X * 
  785. X * Revision 1.6  90/09/03  17:50:45  mj
  786. X * Changed to new address.
  787. X * 2:242/6.1  aka  6000/1
  788. X * 
  789. X * Revision 1.5  90/08/12  14:13:31  mj
  790. X * Added definition for FIDO MSGID sequencer (MSGIDSEQ).
  791. X * 
  792. X * Revision 1.4  90/07/30  20:00:16  mj
  793. X * Added support for new style FIDO addresses:
  794. X *     p<point>.f<node>.n<net>.z<zone>.FIDODOMAIN
  795. X * FIDODOMAIN is defined in config.h
  796. X * 
  797. X * Revision 1.3  90/07/15  10:22:15  mj
  798. X * Changed MAX_LINELEN to 80.
  799. X * 
  800. X * Revision 1.2  90/06/28  22:03:53  mj
  801. X * Much rework of the sources, no more hsu.h and other clean up.
  802. X * rmail improved, now handles special XENIX quirks.
  803. X * 
  804. X * Revision 1.1  90/06/21  21:06:05  mj
  805. X * Everything seems to work, so this delta was made.
  806. X * 
  807. X * Revision 1.0  90/06/21  18:52:36  mj
  808. X * Initial revision
  809. X * 
  810. X *
  811. X *****************************************************************************
  812. X * This version hacked and maintained by:
  813. X *    _____ _____
  814. X *   |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  815. X *   | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  816. X *   |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  817. X *
  818. X * Original version of these programs and files:
  819. X *
  820. X *   Teemu Torma
  821. X *   Heikki Suonsivu   FIDO: 2:504/1   UUCP: ...!mcsun!santra!hsu
  822. X *
  823. X *****************************************************************************/
  824. X
  825. /*
  826. X * This is our net and node number
  827. X *
  828. X * We're 2:242/6.1 with fake address 2:6000/1
  829. X */
  830. #define REAL_ZONE        2
  831. #define REAL_REGION        24
  832. #define REAL_NET        242
  833. #define REAL_NODE        6
  834. #define REAL_POINT        1
  835. X
  836. #define MY_ZONE            2
  837. #define MY_REGION        24
  838. #define MY_NET            6000
  839. #define MY_NODE            1
  840. #define MY_POINT        0
  841. X
  842. #define MY_NAME            "Hipposoft"
  843. X
  844. X
  845. /*
  846. X * This is where our mail goes to ...
  847. X */
  848. #define REM_ZONE        2
  849. #define REM_REGION        24
  850. #define REM_NET            242
  851. #define REM_NODE        6
  852. #define REM_POINT        0
  853. #define REM_NAME        "Bossnode"
  854. /*
  855. X * Echo feed (currently not used)
  856. X */
  857. #define ECHOFEED_NET    242
  858. #define ECHOFEED_NODE    6
  859. X
  860. /*
  861. X * Domain suffix (added to hostname)
  862. X */
  863. #define MY_HOSTNAME        "hippo"
  864. #define MY_DOMAIN        ".dfv.rwth-aachen.de"
  865. X
  866. /*
  867. X * UUCP feed (i.e. system we send UUCP mail to)
  868. X */
  869. #define UUCPFEED        "slcdec"
  870. #define UUCPFEED_DOMAIN    ".dfv.rwth-aachen.de"
  871. X
  872. /*
  873. X * Domain suffix for FIDO net addresses
  874. X */
  875. #define FIDODOMAIN        ".fidonet.org"
  876. X
  877. /*
  878. X * Enable new style addresses
  879. X *     p<point>.f<node>.n<net>.z<zone>.FIDODOMAIN
  880. X * versus old style ones
  881. X *     <point>.<node>.<net>.<zone>.fidonet
  882. X */
  883. #define NEW_STYLE_ADDRESS                /**/
  884. X
  885. X
  886. /*
  887. X * Directories the various programs work on
  888. X */
  889. X
  890. #define SPOOL            "/u/spool/fidonet"            /* main spool directory */
  891. #define SPOOL_BAD        "/u/spool/fidonet/bad"        /* rejected by rnews/rmail */
  892. #define SPOOL_IN        "/u/spool/fidonet/in"        /* incoming packets */
  893. #define SPOOL_OUT        "/u/spool/fidonet/out"        /* outgoing mail */
  894. #define SPOOL_UNPACKED    "/u/spool/fidonet/unpacked"    /* output of funpack */
  895. #define SPOOL_SENT        "/u/spool/fidonet/sent"        /* sent packets */
  896. X
  897. #define LIBDIR            "/u/lib/fidonet"            /* config files / progs */
  898. #define LOGFILE            "/u/lib/fidonet/log"        /* log file */
  899. #define IDSEQUENCE        "/u/lib/fidonet/idseq"        /* message id sequence */
  900. #define IPACKETSEQUENCE "/u/lib/fidonet/ipacketseq"    /* input packet sequence */
  901. #define OPACKETSEQUENCE "/u/lib/fidonet/opacketseq" /* output packet sequence */
  902. #define BADSEQ            "/u/lib/fidonet/badseq"        /* bad messages sequence */
  903. #define JOBSEQ            "/u/lib/fidonet/seq"        /* job number sequence */
  904. #define MSGIDSEQ        "/u/lib/fidonet/msgidseq"    /* for generating ^AMSGID:*/
  905. #define ALIAS            "/u/lib/fidonet/Alias"        /* alias file */
  906. #define AREAS            "/u/lib/fidonet/Areas"        /* areas file */
  907. X
  908. X
  909. /*
  910. X * Enable nodelist support
  911. X */
  912. /*#define NODELIST_SUPPORT                            /* Use FIDO nodelist */
  913. X
  914. X
  915. /*
  916. X * mail receiver for fidonet
  917. X */
  918. #define RFMAIL "/u/lib/fidonet/rfmail"                /* fido mail receiver */
  919. /*#define RFMAIL "/u/mj/news/fidogate/rfmail"            /* test version */
  920. X
  921. /*
  922. X * Program which receives unpacked news articles
  923. X */
  924. #define RNEWS "/bin/rnews"                            /* News receiver */
  925. X
  926. /*
  927. X * Program which receives mail from fido net
  928. X */
  929. #define RMAIL "/usr/bin/rmail"                        /* Mail receiver */
  930. /*
  931. X * There is a replacement for rmail
  932. X * included in this package, which accepts fido net
  933. X * domain addresses and feeds this mail to rfmail.
  934. X * If you use the included rmail, you must rename
  935. X * the old rmail to ormail and install the included
  936. X * rmail as /usr/bin/rmail.
  937. X */
  938. /*#define RECVMAIL "/usr/bin/ormail"                    /* Mail receiver */
  939. #define RECVMAIL "/usr/lib/mail/execmail"            /* XENIX */
  940. /*
  941. X * Define this if you want rfmail to return underlivered mail. You do
  942. X * not need this if you are running sendmail or similiar which returns
  943. X * undelivered mail.
  944. X */
  945. #define RETURN_FAILED_MAIL /**/
  946. X
  947. X
  948. /*
  949. X * Lowest user id
  950. X */
  951. #define USERUID 50
  952. X
  953. /*
  954. X * System dependend configuration
  955. X */
  956. X
  957. /***** Operating system *****/
  958. #define USG                                        /* System V */
  959. /*#define BSD                                    /* BSD 4.2+ */
  960. X
  961. /***** File locking *****/
  962. #define LOCK_LOCKF                                /* Use lockf(), else locking() */
  963. X
  964. X
  965. /*
  966. X * parameters for fcall
  967. X */
  968. X
  969. /* How many seconds wait before starting up fidonet handshake */
  970. #define PREWAIT 5
  971. X
  972. /* How many seconds to wait for line to clear */
  973. #define WAITCLEAR 2
  974. X
  975. /* How many tries to give for xmodem startup in send. This should be low
  976. X   value, it just gives possibility to retry xmodem startup if modems
  977. X   handshaked too fast (really a acu configuration problems, dial should
  978. X   return after it has a working line available!) */
  979. #define MAX_SEND_RETRIES 1
  980. X
  981. /* Maximum baud rate to use when calling out */
  982. #define MAXBAUD 1200
  983. X
  984. /* Define minimum baud rate to use when calling out */
  985. #define MINBAUD 300
  986. X
  987. /* Width of formatted messages. Lines will be wrapped to be less
  988. X   than this. If word is longer than 2/3s of MAX_LINELEN, it will be
  989. X   cut instead of correct wrapping. */
  990. #define MAX_LINELEN 80
  991. X
  992. /* Dial translation table. first string stripped out, second one replaced */
  993. X
  994. #define DIALTABLE "358-0-", "",  "358-", "9",  "", "990"
  995. SHAR_EOF
  996. chmod 0644 config.h ||
  997. echo 'restore of config.h failed'
  998. Wc_c="`wc -c < 'config.h'`"
  999. test 7068 -eq "$Wc_c" ||
  1000.     echo 'config.h: original size 7068, current size' "$Wc_c"
  1001. fi
  1002. # ============= packet.h ==============
  1003. if test -f 'packet.h' -a X"$1" != X"-c"; then
  1004.     echo 'x - skipping packet.h (File already exists)'
  1005. else
  1006. echo 'x - extracting packet.h (Text)'
  1007. sed 's/^X//' << 'SHAR_EOF' > 'packet.h' &&
  1008. /*:ts=4*/
  1009. /*****************************************************************************
  1010. X * FIDOGATE --- Gateway software UNIX <-> FIDO
  1011. X *
  1012. X * $Id: packet.h,v 1.3 90/12/09 18:36:16 mj Exp $
  1013. X *
  1014. X * FIDOnet packet definitions
  1015. X *
  1016. X * $Log:    packet.h,v $
  1017. X * Revision 1.3  90/12/09  18:36:16  mj
  1018. X * Reformatted code and added #define's for sizes of FIDO header fields.
  1019. X * 
  1020. X * Revision 1.2  90/12/02  21:22:20  mj
  1021. X * Changed program header to mention both authors of the original
  1022. X * software posted to alt.sources.
  1023. X * 
  1024. X * Revision 1.1  90/11/05  20:50:53  mj
  1025. X * Changed my signature in all program headers.
  1026. X * 
  1027. X * Revision 1.0  90/06/21  19:15:14  mj
  1028. X * Initial revision
  1029. X * 
  1030. X *
  1031. X *****************************************************************************
  1032. X * This version hacked and maintained by:
  1033. X *    _____ _____
  1034. X *   |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  1035. X *   | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  1036. X *   |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  1037. X *
  1038. X * Original version of these programs and files:
  1039. X *
  1040. X *   Teemu Torma
  1041. X *   Heikki Suonsivu   FIDO: 2:504/1   UUCP: ...!mcsun!santra!hsu
  1042. X *
  1043. X *****************************************************************************/
  1044. X
  1045. /* Structure for packet header. */
  1046. X
  1047. typedef struct _packet {
  1048. X    short orig_node;                /* originating node */
  1049. X    short dest_node;                /* destinating mode */
  1050. X    short year;                        /* packing year (e.g. 1986) */
  1051. X    short month;                    /* 0-11 for Jan - Dec */
  1052. X    short day;                        /* 1-31 */
  1053. X    short hour;                        /* 0-23 */
  1054. X    short minute;                    /* 0-59 */
  1055. X    short second;                    /* 0-59 */
  1056. X    short rate;                        /* maximum baud rate */
  1057. X    short ver;                        /* header version */
  1058. X    short orig_net;                    /* originating net */
  1059. X    short dest_net;                    /* destination net */
  1060. X    char product;                    /* product */
  1061. X    char x1;                        /* Extra byte */
  1062. #ifdef FIDO_V11w
  1063. X    short fill[16];                    /* extra space */
  1064. #else
  1065. X    char pwd_kludge[8];
  1066. X    short orig_zone;
  1067. X    short dest_zone;
  1068. X    char B_fill2[16];
  1069. X    long B_fill3;
  1070. #endif
  1071. } Packet;
  1072. X
  1073. /* Attributes tranferred via mail. */
  1074. X
  1075. #define ATTR_PRIVATE    0000001        /* private msg */
  1076. #define ATTR_CRASH        0000002        /* crash mail */
  1077. #define ATTR_FILE        0000020        /* files attached */
  1078. #define ATTR_UNUSED        0002000        /* unused */
  1079. #define ATTR_RRR        0010000        /* SEAdog only */
  1080. #define ATTR_IRR        0020000        /* SEAdog only */
  1081. #define ATTR_AUDREQ        0040000        /* SEAdog only */
  1082. X
  1083. /* Packet and message types. */
  1084. X
  1085. #define HDRVER            2
  1086. #define MSGTYPE            2
  1087. X
  1088. /* Sizes of to/from/subject/date field */
  1089. #define SIZE_FROM        36
  1090. #define SIZE_TO            36
  1091. #define SIZE_SUBJECT    72
  1092. #define SIZE_DATE        20
  1093. SHAR_EOF
  1094. chmod 0644 packet.h ||
  1095. echo 'restore of packet.h failed'
  1096. Wc_c="`wc -c < 'packet.h'`"
  1097. test 2561 -eq "$Wc_c" ||
  1098.     echo 'packet.h: original size 2561, current size' "$Wc_c"
  1099. fi
  1100. # ============= shuffle.h ==============
  1101. if test -f 'shuffle.h' -a X"$1" != X"-c"; then
  1102.     echo 'x - skipping shuffle.h (File already exists)'
  1103. else
  1104. echo 'x - extracting shuffle.h (Text)'
  1105. sed 's/^X//' << 'SHAR_EOF' > 'shuffle.h' &&
  1106. /*:ts=4*/
  1107. /*****************************************************************************
  1108. X * FIDOGATE --- Gateway software UNIX <-> FIDO
  1109. X *
  1110. X * $Id: shuffle.h,v 1.3 90/12/02 21:22:39 mj Exp $
  1111. X *
  1112. X * Something very special ... ;-)
  1113. X *
  1114. X * $Log:    shuffle.h,v $
  1115. X * Revision 1.3  90/12/02  21:22:39  mj
  1116. X * Changed program header to mention both authors of the original
  1117. X * software posted to alt.sources.
  1118. X * 
  1119. X * Revision 1.2  90/11/05  20:51:08  mj
  1120. X * Changed my signature in all program headers.
  1121. X * 
  1122. X * Revision 1.1  90/06/28  22:05:04  mj
  1123. X * Much rework of the sources, no more hsu.h and other clean up.
  1124. X * rmail improved, now handles special XENIX quirks.
  1125. X * 
  1126. X * Revision 1.0  90/06/21  19:08:09  mj
  1127. X * Initial revision
  1128. X * 
  1129. X *
  1130. X *****************************************************************************
  1131. X * This version hacked and maintained by:
  1132. X *    _____ _____
  1133. X *   |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  1134. X *   | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  1135. X *   |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  1136. X *
  1137. X * Original version of these programs and files:
  1138. X *
  1139. X *   Teemu Torma
  1140. X *   Heikki Suonsivu   FIDO: 2:504/1   UUCP: ...!mcsun!santra!hsu
  1141. X *
  1142. X *****************************************************************************/
  1143. X
  1144. #define loop_increment(x,y) (x = (++x >= (y)) ? 0 : x)
  1145. #define loop_decrement(x,y) (x = (--x < 0) ? (y)-1 : x)
  1146. X
  1147. #define MAX_CONVERT_BUFFERS        40
  1148. #define MAX_CONVERT_BUFLEN        80
  1149. X
  1150. static char bufs[MAX_CONVERT_BUFFERS][MAX_CONVERT_BUFLEN], *tcharp;
  1151. static int bflag;
  1152. X
  1153. #define SHUFFLEBUFFERS \
  1154. loop_increment(bflag, MAX_CONVERT_BUFFERS); tcharp = bufs[bflag]
  1155. SHAR_EOF
  1156. chmod 0644 shuffle.h ||
  1157. echo 'restore of shuffle.h failed'
  1158. Wc_c="`wc -c < 'shuffle.h'`"
  1159. test 1637 -eq "$Wc_c" ||
  1160.     echo 'shuffle.h: original size 1637, current size' "$Wc_c"
  1161. fi
  1162. # ============= sysexits.h ==============
  1163. if test -f 'sysexits.h' -a X"$1" != X"-c"; then
  1164.     echo 'x - skipping sysexits.h (File already exists)'
  1165. else
  1166. echo 'x - extracting sysexits.h (Text)'
  1167. sed 's/^X//' << 'SHAR_EOF' > 'sysexits.h' &&
  1168. /*:ts=4*/
  1169. /*****************************************************************************
  1170. X * FIDOGATE --- Gateway software UNIX <-> FIDO
  1171. X *
  1172. X * $Id: sysexits.h,v 1.2 90/12/02 21:22:44 mj Exp $
  1173. X *
  1174. X * Exit statuses for systems that doesn't have /usr/include/sysexits.h
  1175. X *
  1176. X * $Log:    sysexits.h,v $
  1177. X * Revision 1.2  90/12/02  21:22:44  mj
  1178. X * Changed program header to mention both authors of the original
  1179. X * software posted to alt.sources.
  1180. X * 
  1181. X * Revision 1.1  90/11/05  20:51:12  mj
  1182. X * Changed my signature in all program headers.
  1183. X * 
  1184. X * Revision 1.0  90/06/21  19:12:34  mj
  1185. X * Initial revision
  1186. X * 
  1187. X *
  1188. X *****************************************************************************
  1189. X * This version hacked and maintained by:
  1190. X *    _____ _____
  1191. X *   |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  1192. X *   | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  1193. X *   |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  1194. X *
  1195. X * Original version of these programs and files:
  1196. X *
  1197. X *   Teemu Torma
  1198. X *   Heikki Suonsivu   FIDO: 2:504/1   UUCP: ...!mcsun!santra!hsu
  1199. X *
  1200. X *****************************************************************************/
  1201. X
  1202. #define EX_OK             0                /* successful termination */
  1203. #define EX_USAGE        64                /* command line usage error */
  1204. #define EX_DATAERR        65                /* data format error */
  1205. #define EX_NOINPUT        66                /* cannot open input */
  1206. #define EX_NOHOST        68                /* host name unknown */
  1207. #define EX_UNAVAILABLE    69                /* service unavailable */
  1208. #define EX_SOFTWARE        70                /* internal software error */
  1209. #define EX_OSERR        71                /* system error (e.g., can't fork) */
  1210. #define EX_OSFILE        72                /* critical OS file missing */
  1211. #define EX_CANTCREAT    73                /* can't create (user) output file */
  1212. #define EX_IOERR        74                /* input/output error */
  1213. SHAR_EOF
  1214. chmod 0644 sysexits.h ||
  1215. echo 'restore of sysexits.h failed'
  1216. Wc_c="`wc -c < 'sysexits.h'`"
  1217. test 1760 -eq "$Wc_c" ||
  1218.     echo 'sysexits.h: original size 1760, current size' "$Wc_c"
  1219. fi
  1220. # ============= nodelist.h ==============
  1221. if test -f 'nodelist.h' -a X"$1" != X"-c"; then
  1222.     echo 'x - skipping nodelist.h (File already exists)'
  1223. else
  1224. echo 'x - extracting nodelist.h (Text)'
  1225. sed 's/^X//' << 'SHAR_EOF' > 'nodelist.h' &&
  1226. /*:ts=4*/
  1227. /*****************************************************************************
  1228. X * FIDOGATE --- Gateway software UNIX <-> FIDO
  1229. X *
  1230. X * $Id: nodelist.h,v 1.2 90/12/02 21:22:18 mj Exp $
  1231. X *
  1232. X * Structures and definitions for nodelist.
  1233. X *
  1234. X * $Log:    nodelist.h,v $
  1235. X * Revision 1.2  90/12/02  21:22:18  mj
  1236. X * Changed program header to mention both authors of the original
  1237. X * software posted to alt.sources.
  1238. X * 
  1239. X * Revision 1.1  90/11/05  20:50:51  mj
  1240. X * Changed my signature in all program headers.
  1241. X * 
  1242. X * Revision 1.0  90/06/21  19:14:27  mj
  1243. X * Initial revision
  1244. X * 
  1245. X *
  1246. X *****************************************************************************
  1247. X * This version hacked and maintained by:
  1248. X *    _____ _____
  1249. X *   |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  1250. X *   | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  1251. X *   |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  1252. X *
  1253. X * Original version of these programs and files:
  1254. X *
  1255. X *   Teemu Torma
  1256. X *   Heikki Suonsivu   FIDO: 2:504/1   UUCP: ...!mcsun!santra!hsu
  1257. X *
  1258. X *****************************************************************************/
  1259. X
  1260. /* Change these if you wish. */
  1261. X
  1262. /* Name of nodelist in LIBDIR */
  1263. #define NODELIST "nodelist"
  1264. X
  1265. /* Name of nodelist index file in LIBDIR */
  1266. #define INODELIST "nodelist.idx"
  1267. X
  1268. /* Name of sysop name index file in LIBDIR */
  1269. #define NAMELIST "name.idx"
  1270. X
  1271. /* Compare two node entried to see if they are same node (ignoring
  1272. X   possible other information */
  1273. #define samenode(n1, n2) ((n1).zone == (n2).zone && (n1).net == (n2).net && \
  1274. X              (n1).node == (n2).node && (n1).point == (n2).point)
  1275. X
  1276. /* Structure for nodelist entry. Routines to get one node from nodelist
  1277. X   will return this structure. */
  1278. X
  1279. typedef struct _node {
  1280. X  int type; /* type of entry (see below) */
  1281. X  int region; /* region (not necessarily used/set) */
  1282. X  int net; /* net/region of node */
  1283. X  int zone; /* Zone of node (not really supported yet) */
  1284. X  int node; /* number of node */
  1285. X  int point; /* Point of node (not really supported yet) */
  1286. X  char name[20]; /* name of fido */
  1287. X  char city[40]; /* city */
  1288. X  char sysop[36]; /* name of sysop */
  1289. X  char phone[40]; /* phone-number */
  1290. X  int speed; /* speeds */
  1291. X  char flags[60]; /* flags-string */
  1292. } Node;
  1293. X
  1294. typedef struct _indexnode {
  1295. X  int zone;
  1296. X  int net;
  1297. X  int node;
  1298. X  long offset;
  1299. } NODEINDEX;
  1300. X
  1301. typedef struct _indexname {
  1302. X  char name[36]; /* Sysop name */
  1303. X  long offset; /* Refers to nodelist index entry */
  1304. X  int zone;
  1305. X  int net;
  1306. } NAMEINDEX;
  1307. X
  1308. /* Entry types. */
  1309. X
  1310. #define REGION (1) /* region-host */
  1311. #define HOST (2) /* net-host */
  1312. #define HUB (3) /* local-host */
  1313. #define PVT (4) /* private node */
  1314. #define HOLD (5) /* no mail to this node */
  1315. #define DOWN (6) /* node is down */
  1316. #define KENL (7) /* should not be comminucated */
  1317. #define NORMAL (8) /* normal node */
  1318. #define ZONE (9) /* Zone */
  1319. #define POINT (10) /* point (points are not in nodelist but this is used
  1320. X              elsewhere. */
  1321. X
  1322. /* Declarations for routines. */
  1323. X
  1324. Node *node_entry(); /* get entry from nodelist */
  1325. char *update_index(); /* update index-file */
  1326. extern Node *parse_entry();
  1327. X
  1328. extern Node originnode;
  1329. extern NODEINDEX *nodeindex;
  1330. extern NAMEINDEX *nameindex;
  1331. extern int nodes;
  1332. SHAR_EOF
  1333. chmod 0644 nodelist.h ||
  1334. echo 'restore of nodelist.h failed'
  1335. Wc_c="`wc -c < 'nodelist.h'`"
  1336. test 3209 -eq "$Wc_c" ||
  1337.     echo 'nodelist.h: original size 3209, current size' "$Wc_c"
  1338. fi
  1339. # ============= fidogate.h ==============
  1340. if test -f 'fidogate.h' -a X"$1" != X"-c"; then
  1341.     echo 'x - skipping fidogate.h (File already exists)'
  1342. else
  1343. echo 'x - extracting fidogate.h (Text)'
  1344. sed 's/^X//' << 'SHAR_EOF' > 'fidogate.h' &&
  1345. /*:ts=4*/
  1346. /*****************************************************************************
  1347. X * FIDOGATE --- Gateway software UNIX <-> FIDO
  1348. X *
  1349. X * $Id: fidogate.h,v 1.8 90/12/02 21:21:47 mj Exp $
  1350. X *
  1351. X * Common header file
  1352. X *
  1353. X * $Log:    fidogate.h,v $
  1354. X * Revision 1.8  90/12/02  21:21:47  mj
  1355. X * Changed program header to mention both authors of the original
  1356. X * software posted to alt.sources.
  1357. X * 
  1358. X * Revision 1.7  90/12/01  17:48:52  mj
  1359. X * Fixed an extern function declaration of ascnoden().
  1360. X * 
  1361. X * Revision 1.6  90/11/20  21:08:13  mj
  1362. X * Changed some extern definitions.
  1363. X * 
  1364. X * Revision 1.5  90/11/05  20:49:34  mj
  1365. X * Changed my signature in all program headers.
  1366. X * 
  1367. X * Revision 1.4  90/09/08  18:45:08  mj
  1368. X * Added definition of strsaveline() in xalloc.c
  1369. X * 
  1370. X * Revision 1.3  90/07/01  13:45:19  mj
  1371. X * Removed all calls to alloca(). All unsave malloc()'s without
  1372. X * checking the returned pointer are now done via xmalloc().
  1373. X * Fixed a malloc() error in rmail.
  1374. X * 
  1375. X * Revision 1.2  90/06/28  22:04:01  mj
  1376. X * Much rework of the sources, no more hsu.h and other clean up.
  1377. X * rmail improved, now handles special XENIX quirks.
  1378. X * 
  1379. X * Revision 1.1  90/06/21  21:08:29  mj
  1380. X * Everything seems to work, so this delta was made.
  1381. X * 
  1382. X * Revision 1.0  90/06/21  18:56:20  mj
  1383. X * Initial revision
  1384. X * 
  1385. X *
  1386. X *****************************************************************************
  1387. X * This version hacked and maintained by:
  1388. X *    _____ _____
  1389. X *   |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  1390. X *   | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  1391. X *   |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  1392. X *
  1393. X * Original version of these programs and files:
  1394. X *
  1395. X *   Teemu Torma
  1396. X *   Heikki Suonsivu   FIDO: 2:504/1   UUCP: ...!mcsun!santra!hsu
  1397. X *
  1398. X *****************************************************************************/
  1399. X
  1400. #include "config.h"
  1401. X
  1402. /*
  1403. X * default level of debug output
  1404. X */
  1405. #ifndef INIT_VERBOSE
  1406. # ifdef DEBUG
  1407. #  define INIT_VERBOSE 3 /*20*/
  1408. # else
  1409. #  define INIT_VERBOSE 0
  1410. # endif
  1411. #endif
  1412. X
  1413. X
  1414. /*
  1415. X * heavy includin' ...
  1416. X */
  1417. X
  1418. /***** System *****/
  1419. #include <stdio.h>
  1420. #include <ctype.h>
  1421. #include <string.h>
  1422. #include <sys/types.h>
  1423. #include <time.h>
  1424. #include <errno.h>
  1425. #ifdef M_XENIX
  1426. # include <sys/ndir.h>
  1427. # define dirent direct
  1428. #else
  1429. # include <dirent.h>
  1430. #endif
  1431. X
  1432. /***** Local *****/
  1433. #include "packet.h"                        /* FIDO mail packet definition */
  1434. #include "nodelist.h"                    /* nodelist definitions */
  1435. #include "sysexits.h"                    /* EX_* defines */
  1436. X
  1437. X
  1438. X
  1439. /*
  1440. X * Config file sections
  1441. X */
  1442. #define SECT_NETNODE    1                /* Net/node for receiving node */
  1443. #define SECT_NG_AREA    2                /* Newsgroup -> area conversions */
  1444. #define SECT_HEADERS    3                /* Header-field definitions */
  1445. #define SECT_ENDMSG        4                /* Text to be placed at the end of msg */
  1446. #define SECT_AREA_NG    5                /* Area -> newsgroup conversions */
  1447. X
  1448. X
  1449. X
  1450. /*
  1451. X * External functions and variables
  1452. X */
  1453. X
  1454. /***** System *****/
  1455. extern char *mktemp(), *getenv();
  1456. extern long time();
  1457. extern unsigned short getuid();
  1458. extern unsigned short geteuid();
  1459. extern unsigned short getgid();
  1460. extern unsigned short getegid();
  1461. X
  1462. /***** errno *****/
  1463. extern int errno;
  1464. extern char *strerror();
  1465. X
  1466. X
  1467. X
  1468. /*
  1469. X * Defines
  1470. X */
  1471. #define TRUE    1
  1472. #define FALSE    0
  1473. #define BUFLEN 256
  1474. #define OK        0
  1475. #define ERROR    (-1)
  1476. X
  1477. #define bool    int
  1478. X
  1479. /* Global variables. */
  1480. X
  1481. extern bool verbose;
  1482. extern int line;
  1483. extern int receiving_data;
  1484. X
  1485. /* Function declarations. */
  1486. X
  1487. /* address.c */
  1488. extern char *parse_address();
  1489. extern int returnbad();
  1490. extern int parseinternode();
  1491. extern int parsefnetaddress();
  1492. extern char *ascnode();
  1493. extern char *ascnoden();
  1494. extern char *internode();
  1495. extern char *ascnodei();
  1496. X
  1497. extern int fine_convert();
  1498. extern char *ascii_convert();
  1499. extern int stricmp();
  1500. extern int strnicmp();
  1501. extern time_t getdate();
  1502. extern void flush();
  1503. extern void sendline();
  1504. extern char *getcl();
  1505. extern void section();
  1506. extern void log();
  1507. extern void debug();
  1508. extern int lock();
  1509. extern int unlock();
  1510. extern char *spoolfile();
  1511. extern int quit();
  1512. extern char *basename();
  1513. extern FILE *pfopen();
  1514. extern char *date();
  1515. extern long job_number();
  1516. extern long sequencer();
  1517. extern char *mheader();
  1518. X
  1519. /* sprintfs.c */
  1520. extern char *sstrcat(), *sprintfs();
  1521. X
  1522. /* strempty.c */
  1523. extern char *strclean(), *strsclean();
  1524. X
  1525. /* xalloc.c */
  1526. extern char *xmalloc(), *xrealloc(), *strsave(), *strsaveline();
  1527. SHAR_EOF
  1528. chmod 0644 fidogate.h ||
  1529. echo 'restore of fidogate.h failed'
  1530. Wc_c="`wc -c < 'fidogate.h'`"
  1531. test 4281 -eq "$Wc_c" ||
  1532.     echo 'fidogate.h: original size 4281, current size' "$Wc_c"
  1533. fi
  1534. true || echo 'restore of rfmail.c failed'
  1535. echo End of part 2, continue with part 3
  1536. exit 0
  1537.  
  1538. --
  1539.  _____ _____
  1540. |     |___  |   Martin Junius     FIDO:    2:242/6.1   2:242/6.0
  1541. | | | |   | |   Republikplatz 3   DOMAIN:  mju@dfv.rwth-aachen.de
  1542. |_|_|_|_____|   D-5100 Aachen     Tel. (Voice) 0241-86931
  1543.