home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume19 / cnews2 / part11 < prev    next >
Text File  |  1989-06-29  |  55KB  |  2,455 lines

  1. Subject:  v19i088:  Cnews production release, Part11/19
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: utzoo!henry
  7. Posting-number: Volume 19, Issue 88
  8. Archive-name: cnews2/part11
  9.  
  10. : ---CUT HERE---
  11. echo 'libfake/memcmp.c':
  12. sed 's/^X//' >'libfake/memcmp.c' <<'!'
  13. X/*
  14. X * memcmp - compare bytes
  15. X */
  16. X
  17. Xint                /* <0, == 0, >0 */
  18. Xmemcmp(s1, s2, size)
  19. X char * s1;
  20. X char * s2;
  21. Xint size;
  22. X{
  23. X    register  char *scan1;
  24. X    register  char *scan2;
  25. X    register int n;
  26. X
  27. X    scan1 = s1;
  28. X    scan2 = s2;
  29. X    for (n = size; n > 0; n--)
  30. X        if (*scan1 == *scan2) {
  31. X            scan1++;
  32. X            scan2++;
  33. X        } else
  34. X            return(*scan1 - *scan2);
  35. X
  36. X    return(0);
  37. X}
  38. !
  39. echo 'libfake/memcpy.c':
  40. sed 's/^X//' >'libfake/memcpy.c' <<'!'
  41. X/*
  42. X * memcpy - copy bytes
  43. X */
  44. X
  45. Xchar *
  46. Xmemcpy(dst, src, size)
  47. Xchar * dst;
  48. X char * src;
  49. Xint size;
  50. X{
  51. X    register char *d;
  52. X    register  char *s;
  53. X    register int n;
  54. X
  55. X    if (size <= 0)
  56. X        return(dst);
  57. X
  58. X    s = src;
  59. X    d = dst;
  60. X    if (s <= d && s + (size-1) >= d) {
  61. X        /* Overlap, must copy right-to-left. */
  62. X        s += size-1;
  63. X        d += size-1;
  64. X        for (n = size; n > 0; n--)
  65. X            *d-- = *s--;
  66. X    } else
  67. X        for (n = size; n > 0; n--)
  68. X            *d++ = *s++;
  69. X
  70. X    return(dst);
  71. X}
  72. !
  73. echo 'libfake/memset.c':
  74. sed 's/^X//' >'libfake/memset.c' <<'!'
  75. X/*
  76. X * memset - set bytes
  77. X *
  78. X * CHARBITS should be defined only if the compiler lacks "unsigned char".
  79. X * It should be a mask, e.g. 0377 for an 8-bit machine.
  80. X */
  81. X
  82. X#ifndef CHARBITS
  83. X#    define    UNSCHAR(c)    ((unsigned char)(c))
  84. X#else
  85. X#    define    UNSCHAR(c)    ((c)&CHARBITS)
  86. X#endif
  87. X
  88. Xchar *
  89. Xmemset(s, ucharfill, size)
  90. X char * s;
  91. Xregister int ucharfill;
  92. Xint size;
  93. X{
  94. X    register  char *scan;
  95. X    register int n;
  96. X    register int uc;
  97. X
  98. X    scan = s;
  99. X    uc = UNSCHAR(ucharfill);
  100. X    for (n = size; n > 0; n--)
  101. X        *scan++ = uc;
  102. X
  103. X    return(s);
  104. X}
  105. !
  106. echo 'libfake/index.c':
  107. sed 's/^X//' >'libfake/index.c' <<'!'
  108. X/*
  109. X * index - find first occurrence of a character in a string
  110. X */
  111. X
  112. X#define    NULL    0
  113. X
  114. Xchar *                /* found char, or NULL if none */
  115. Xindex(s, charwanted)
  116. Xchar *s;
  117. Xchar charwanted;
  118. X{
  119. X    extern char *strchr();
  120. X
  121. X    return(strchr(s, charwanted));
  122. X}
  123. !
  124. echo 'libfake/strchr.c':
  125. sed 's/^X//' >'libfake/strchr.c' <<'!'
  126. X/*
  127. X * strchr - find first occurrence of a character in a string
  128. X */
  129. X
  130. X#define    NULL    0
  131. X
  132. Xchar *                /* found char, or NULL if none */
  133. Xstrchr(s, charwanted)
  134. X char *s;
  135. Xregister char charwanted;
  136. X{
  137. X    register  char *scan;
  138. X
  139. X    /*
  140. X     * The odd placement of the two tests is so NUL is findable.
  141. X     */
  142. X    for (scan = s; *scan != charwanted;)    /* ++ moved down for opt. */
  143. X        if (*scan++ == '\0')
  144. X            return(NULL);
  145. X    return(scan);
  146. X}
  147. !
  148. echo 'libfake/rindex.c':
  149. sed 's/^X//' >'libfake/rindex.c' <<'!'
  150. X/*
  151. X * rindex - find last occurrence of a character in a string
  152. X */
  153. X
  154. X#define    NULL    0
  155. X
  156. Xchar *                /* found char, or NULL if none */
  157. Xrindex(s, charwanted)
  158. Xchar *s;
  159. Xchar charwanted;
  160. X{
  161. X    extern char *strrchr();
  162. X
  163. X    return(strrchr(s, charwanted));
  164. X}
  165. !
  166. echo 'libfake/strcspn.c':
  167. sed 's/^X//' >'libfake/strcspn.c' <<'!'
  168. X/*
  169. X * strcspn - find length of initial segment of s consisting entirely
  170. X * of characters not from reject
  171. X */
  172. X
  173. Xint
  174. Xstrcspn(s, reject)
  175. X char *s;
  176. X char *reject;
  177. X{
  178. X    register  char *scan;
  179. X    register  char *rscan;
  180. X    register int count;
  181. X
  182. X    count = 0;
  183. X    for (scan = s; *scan != '\0'; scan++) {
  184. X        for (rscan = reject; *rscan != '\0';)    /* ++ moved down. */
  185. X            if (*scan == *rscan++)
  186. X                return(count);
  187. X        count++;
  188. X    }
  189. X    return(count);
  190. X}
  191. !
  192. echo 'libfake/strpbrk.c':
  193. sed 's/^X//' >'libfake/strpbrk.c' <<'!'
  194. X/*
  195. X * strpbrk - find first occurrence of any char from breakat in s
  196. X */
  197. X
  198. X#define    NULL    0
  199. X
  200. Xchar *                /* found char, or NULL if none */
  201. Xstrpbrk(s, breakat)
  202. X char *s;
  203. X char *breakat;
  204. X{
  205. X    register  char *sscan;
  206. X    register  char *bscan;
  207. X
  208. X    for (sscan = s; *sscan != '\0'; sscan++) {
  209. X        for (bscan = breakat; *bscan != '\0';)    /* ++ moved down. */
  210. X            if (*sscan == *bscan++)
  211. X                return(sscan);
  212. X    }
  213. X    return(NULL);
  214. X}
  215. !
  216. echo 'libfake/strrchr.c':
  217. sed 's/^X//' >'libfake/strrchr.c' <<'!'
  218. X/*
  219. X * strrchr - find last occurrence of a character in a string
  220. X */
  221. X
  222. X#define    NULL    0
  223. X
  224. Xchar *                /* found char, or NULL if none */
  225. Xstrrchr(s, charwanted)
  226. X char *s;
  227. Xregister char charwanted;
  228. X{
  229. X    register  char *scan;
  230. X    register  char *place;
  231. X
  232. X    place = NULL;
  233. X    for (scan = s; *scan != '\0'; scan++)
  234. X        if (*scan == charwanted)
  235. X            place = scan;
  236. X    if (charwanted == '\0')
  237. X        return(scan);
  238. X    return(place);
  239. X}
  240. !
  241. echo 'libfake/strspn.c':
  242. sed 's/^X//' >'libfake/strspn.c' <<'!'
  243. X/*
  244. X * strspn - find length of initial segment of s consisting entirely
  245. X * of characters from accept
  246. X */
  247. X
  248. Xint
  249. Xstrspn(s, accept)
  250. X char *s;
  251. X char *accept;
  252. X{
  253. X    register  char *sscan;
  254. X    register  char *ascan;
  255. X    register int count;
  256. X
  257. X    count = 0;
  258. X    for (sscan = s; *sscan != '\0'; sscan++) {
  259. X        for (ascan = accept; *ascan != '\0'; ascan++)
  260. X            if (*sscan == *ascan)
  261. X                break;
  262. X        if (*ascan == '\0')
  263. X            return(count);
  264. X        count++;
  265. X    }
  266. X    return(count);
  267. X}
  268. !
  269. echo 'libfake/strtok.c':
  270. sed 's/^X//' >'libfake/strtok.c' <<'!'
  271. X/*
  272. X * Get next token from string s (NULL on 2nd, 3rd, etc. calls),
  273. X * where tokens are nonempty strings separated by runs of
  274. X * chars from delim.  Writes NULs into s to end tokens.  delim need not
  275. X * remain constant from call to call.
  276. X */
  277. X
  278. X#define    NULL    0
  279. X
  280. Xstatic char *scanpoint = NULL;
  281. X
  282. Xchar *                /* NULL if no token left */
  283. Xstrtok(s, delim)
  284. Xchar *s;
  285. Xregister  char *delim;
  286. X{
  287. X    register char *scan;
  288. X    char *tok;
  289. X    register  char *dscan;
  290. X
  291. X    if (s == NULL && scanpoint == NULL)
  292. X        return(NULL);
  293. X    if (s != NULL)
  294. X        scan = s;
  295. X    else
  296. X        scan = scanpoint;
  297. X
  298. X    /*
  299. X     * Scan leading delimiters.
  300. X     */
  301. X    for (; *scan != '\0'; scan++) {
  302. X        for (dscan = delim; *dscan != '\0'; dscan++)
  303. X            if (*scan == *dscan)
  304. X                break;
  305. X        if (*dscan == '\0')
  306. X            break;
  307. X    }
  308. X    if (*scan == '\0') {
  309. X        scanpoint = NULL;
  310. X        return(NULL);
  311. X    }
  312. X
  313. X    tok = scan;
  314. X
  315. X    /*
  316. X     * Scan token.
  317. X     */
  318. X    for (; *scan != '\0'; scan++) {
  319. X        for (dscan = delim; *dscan != '\0';)    /* ++ moved down. */
  320. X            if (*scan == *dscan++) {
  321. X                scanpoint = scan+1;
  322. X                *scan = '\0';
  323. X                return(tok);
  324. X            }
  325. X    }
  326. X
  327. X    /*
  328. X     * Reached end of string.
  329. X     */
  330. X    scanpoint = NULL;
  331. X    return(tok);
  332. X}
  333. !
  334. echo 'libsmall/active.slow.c':
  335. sed 's/^X//' >'libsmall/active.slow.c' <<'!'
  336. X/*
  337. X * active file access functions (small, slow, on-disk version)
  338. X */
  339. X
  340. X#include <stdio.h>
  341. X#include <sys/types.h>
  342. X#include "news.h"
  343. X#include "fgetmfs.h"
  344. X
  345. X/* private */
  346. Xstatic long fpos = -1;        /* set by actfind, read by actwrnum */
  347. X
  348. X/* ARGSUSED */
  349. Xstatust
  350. Xactfload(fp)
  351. XFILE *fp;
  352. X{
  353. X    return ST_OKAY;
  354. X}
  355. X
  356. X/* ARGSUSED */
  357. Xstatust
  358. Xactfsync(fp)
  359. XFILE *fp;
  360. X{
  361. X    return ST_OKAY;
  362. X}
  363. X
  364. X/*
  365. X * search on stream "fp" for group "ng" and return a pointer
  366. X * to the active file line for it, or 0 if none.
  367. X * actload has previously been called.
  368. X */
  369. Xchar *
  370. Xactfind(fp, ng, nglen)
  371. Xregister FILE *fp;
  372. Xregister char *ng;
  373. Xregister int nglen;
  374. X{
  375. X    static char *line = NULL;
  376. X
  377. X    if (line != NULL)
  378. X        free(line);
  379. X    rewind(fp);
  380. X    for (fpos = ftell(fp); (line = fgetms(fp)) != NULL;
  381. X         fpos = ftell(fp), free(line))
  382. X        if (STREQN(line, ng, nglen) && line[nglen] == ' ')
  383. X            return line;        /* free on next entry */
  384. X    return NULL;
  385. X}
  386. X
  387. Xstatust
  388. Xactfwrnum(fp, line)        /* overwrite last line found with "line" */
  389. Xregister FILE *fp;
  390. Xchar *line;
  391. X{
  392. X    if (fseek(fp, fpos, 0) != EOF &&    /* back up */
  393. X        fputs(line, fp) != EOF && fflush(fp) != EOF)
  394. X        return ST_OKAY;
  395. X    else
  396. X        return ST_DROPPED;
  397. X}
  398. !
  399. echo 'libsmall/sys.slow.c':
  400. sed 's/^X//' >'libsmall/sys.slow.c' <<'!'
  401. X/*
  402. X * news sys file reading functions (slow, small, on-disk version)
  403. X */
  404. X
  405. X#include <stdio.h>
  406. X#include <sys/types.h>
  407. X#include "news.h"
  408. X#include "system.h"
  409. X
  410. X/* exports */
  411. Xboolean justone = YES;
  412. X
  413. X/* imports */
  414. Xextern struct system *currsys, *firstsys;
  415. X
  416. Xstruct system *
  417. Xmysysincache()
  418. X{
  419. X    return NULL;
  420. X}
  421. X
  422. Xvoid
  423. Xremmysys(sys)
  424. Xstruct system *sys;
  425. X{
  426. X    /* no cache */
  427. X}
  428. X
  429. Xvoid
  430. Xrewsys(fp)
  431. XFILE *fp;
  432. X{
  433. X    if (fp != NULL)
  434. X        (void) rewind(fp);
  435. X}
  436. X
  437. X/*
  438. X * Free current sys entry & associated memory.  Zero currsys too.
  439. X */
  440. Xvoid
  441. Xfreecurrsys()
  442. X{
  443. X    if (currsys == NULL)
  444. X        return;
  445. X    nnfree(&currsys->sy_name);
  446. X    nnfree(&currsys->sy_ngs);
  447. X    nnfree(&currsys->sy_cmd);
  448. X    nnafree(&currsys);
  449. X}
  450. !
  451. echo 'libsmall/Makefile':
  452. sed 's/^X//' >'libsmall/Makefile' <<'!'
  453. X# libsmall makefile
  454. XINCLUDE=../include
  455. XDEFINES=-I$(INCLUDE) -I../relay
  456. XCOPTS= -O # -pg -p
  457. XCFLAGS= $(COPTS) $(DEFINES)
  458. XLINTFLAGS=-hau $(DEFINES)
  459. XLIB=libcnews.a
  460. X# RANLIB is ranlib on non-USG systems, echo on USG systems
  461. XRANLIB=ranlib
  462. X#RANLIB=:
  463. XSRCS=active.slow.c sys.slow.c
  464. XOBJS=active.slow.o sys.slow.o
  465. X# workaround for System V make bug
  466. XSHELL = /bin/sh
  467. X
  468. Xu:    $(OBJS)
  469. X    ar ruv ../libcnews.a $(OBJS)
  470. X
  471. Xall:    $(OBJS)
  472. X
  473. X$(LIB): $(SRCS)
  474. X    $(CC) $(CFLAGS) -c $?
  475. X    ar rv $@ *.o
  476. X    rm *.o
  477. X    $(RANLIB) $@
  478. X
  479. Xlint:
  480. X    lint $(LINTFLAGS) $(SRCS)
  481. X
  482. Xclean:
  483. X    rm -f *.o
  484. !
  485. echo 'libstdio/Makefile':
  486. sed 's/^X//' >'libstdio/Makefile' <<'!'
  487. XSRC=fgets.c fputs.c rdwr.c
  488. XOBJ=fgets.o fputs.o rdwr.o
  489. X# PTR_TYPE is the type of _ptr in stdio.h, if not "char *"
  490. XDEFINES = '-DPTR_TYPE=unsigned char *'
  491. XCOPTS = -O
  492. XCFLAGS = $(DEFINES) $(COPTS)
  493. XLINTFLAGS = $(DEFINES) -ha
  494. XLIBS = ../libcnews.a
  495. X# workaround for System V make bug
  496. XSHELL = /bin/sh
  497. X
  498. Xu:    $(OBJ)
  499. X    ar ruv ../libcnews.a $(OBJ)
  500. X
  501. Xall:    $(OBJ) stdiock.stock stdiock.fast runtrials
  502. X
  503. Xtrials:    all
  504. X    chmod +x runtrials
  505. X    ./runtrials >junk
  506. X    test ! -s junk
  507. X    rm stdiock.stock stdiock.fast junk trial.out
  508. X
  509. Xlint:
  510. X    lint $(LINTFLAGS) -u $(SRC)
  511. Xlintport:
  512. X    lint -p $(LINTFLAGS) -u $(SRC)
  513. X
  514. Xstdiock.stock: stdiock.o $(LIBS)
  515. X    $(CC) $(CFLAGS) stdiock.o $(LIBS) -o $@
  516. Xstdiock.fast: stdiock.o $(OBJ) $(LIBS)
  517. X    $(CC) $(CFLAGS) stdiock.o $(OBJ) $(LIBS) -o $@
  518. X
  519. Xclean:
  520. X    rm -f *.o stdiock stdiock.fast stdiock.stock *mon.out trial.out
  521. !
  522. echo 'libstdio/fgets.c':
  523. sed 's/^X//' >'libstdio/fgets.c' <<'!'
  524. X#include <stdio.h>
  525. X#ifndef PTR_TYPE
  526. X#define    PTR_TYPE    char *        /* type of _ptr in stdio.h */
  527. X#endif
  528. X
  529. X#define THRESHOLD 12            /* memcpy vs in-line threshold */
  530. X
  531. Xchar *
  532. Xfgets(s, lim, fp)            /* optimised version */
  533. Xchar *s;
  534. Xint lim;
  535. Xregister FILE *fp;
  536. X{
  537. X    char *rets = s;            /* normal return by default */
  538. X
  539. X    --lim;                /* leave room for terminating null */
  540. X    while (lim > 0) {        /* room left in s */
  541. X        int origbytesleft;
  542. X        char *nlp = NULL;    /* points at newline */
  543. X
  544. X        /*
  545. X         * Find next newline (if any) by running through the
  546. X         * stdio buffer until it runs out or a newline is seen.
  547. X         * This dominates the running time for long lines.
  548. X         */
  549. X        {
  550. X            register char *bp = (char *)fp->_ptr;
  551. X            register int loops;
  552. X            /* bytes to the end of s or the stdio buffer */
  553. X            register int bytesleft = fp->_cnt;    /* to EOB */
  554. X
  555. X            if (bytesleft > lim)    /* buffer longer than s */
  556. X                bytesleft = lim; /* only copy to s's end */
  557. X            origbytesleft = bytesleft;
  558. X
  559. X            /*
  560. X             * This code uses Duff's Device (tm Tom Duff)
  561. X             * to unroll the newline recogniser:
  562. X             * for (++bytesleft; --bytesleft > 0; )
  563. X             *    if (*bp++ == '\n') {
  564. X             *        nlp = bp;    # NB points after \n
  565. X             *        break;
  566. X             *    }
  567. X             * Sorry the code is so ugly.
  568. X             */
  569. X            if (bytesleft > 0) {
  570. X                /*
  571. X                 * warning: this will need to be changed for
  572. X                 * non-binary machines, if they exist.
  573. X                 */
  574. X                loops = (bytesleft+8-1) >> 3;    /* /8 round up */
  575. X
  576. X                switch (bytesleft&(8-1)) {    /* %8 */
  577. X                case 0: do {
  578. X#define SPOTNL if (*bp++ == '\n') { nlp = bp; break; }
  579. X                        SPOTNL;
  580. X                    case 7:    SPOTNL;
  581. X                    case 6:    SPOTNL;
  582. X                    case 5:    SPOTNL;
  583. X                    case 4:    SPOTNL;
  584. X                    case 3:    SPOTNL;
  585. X                    case 2:    SPOTNL;
  586. X                    case 1:    SPOTNL;
  587. X                    } while (--loops > 0);
  588. X                }
  589. X            }
  590. X        }
  591. X        /*
  592. X         * If no newline was seen, copy remaining bytes from stdio
  593. X         * buffer; else copy up to and including the newline.
  594. X         * Adjust counts, then copy the bytes & adjust pointers.
  595. X         * This dominates the running time for short lines.
  596. X         */
  597. X        {
  598. X            register int copy;
  599. X
  600. X            if (nlp == NULL)
  601. X                copy = origbytesleft;
  602. X            else
  603. X                copy = nlp - (char *)fp->_ptr;
  604. X            lim -= copy;
  605. X            fp->_cnt -= copy;
  606. X            if (copy < THRESHOLD) {
  607. X                register char *rs = s, *bp = (char *)fp->_ptr;
  608. X
  609. X                for (++copy; --copy > 0; )
  610. X                    *rs++ = *bp++;
  611. X                s = rs;
  612. X                fp->_ptr = (PTR_TYPE)bp;
  613. X            } else {
  614. X                memcpy(s, (char *)fp->_ptr, copy);
  615. X                s += copy;
  616. X                fp->_ptr += copy;
  617. X            }
  618. X        }
  619. X        /*
  620. X         * Quit if we saw a newline or "s" is full,
  621. X         * else refill the stdio buffer and go again.
  622. X         */
  623. X        if (nlp != NULL || lim <= 0)
  624. X            break;
  625. X        else if (fp->_cnt <= 0) {        /* buffer empty */
  626. X            register int c = getc(fp);    /* fill buffer */
  627. X
  628. X            if (c == EOF) {
  629. X                if (s == rets)        /* s is empty */
  630. X                    rets = NULL;
  631. X                break;            /* EOF return */
  632. X            } else {
  633. X                if ((*s++ = c) == '\n')
  634. X                    break;        /* newline return */
  635. X                --lim;
  636. X            }
  637. X        }
  638. X    }
  639. X    *s = '\0';    /* terminate s */
  640. X    return rets;
  641. X}
  642. !
  643. echo 'libstdio/fputs.c':
  644. sed 's/^X//' >'libstdio/fputs.c' <<'!'
  645. X#include <stdio.h>
  646. X
  647. Xfputs(s, fp)
  648. Xregister char *s;
  649. Xregister FILE *fp;
  650. X{
  651. X    unsigned len = strlen(s);
  652. X
  653. X    if (fwrite(s, 1, len, fp) < len)
  654. X        return EOF;
  655. X    return 0;
  656. X}
  657. !
  658. echo 'libstdio/rdwr.c':
  659. sed 's/^X//' >'libstdio/rdwr.c' <<'!'
  660. X/*
  661. X * fread and fwrite (optimised version)
  662. X * Could do i/o to/from the user's buffer directly if the transfer is long
  663. X * enough.  If there's a block-aligned block (or more) in the middle, could
  664. X * transfer it directly.
  665. X */
  666. X
  667. X#include <stdio.h>
  668. X#ifndef PTR_TYPE
  669. X#define    PTR_TYPE    char *        /* type of _ptr in stdio.h */
  670. X#endif
  671. X
  672. X#define THRESHOLD 12            /* memcpy vs in-line threshold */
  673. X
  674. Xtypedef unsigned char putc_t;        /* cast putc args to this type */
  675. X
  676. Xint
  677. Xfread(ptr, size, count, fp)
  678. Xchar *ptr;
  679. Xint size, count;
  680. Xregister FILE *fp;
  681. X{
  682. X    register unsigned bytes = count * size;
  683. X    unsigned origbytes = bytes;
  684. X
  685. X    while (bytes > 0) {    /* bytes still to be read */
  686. X        {
  687. X            /* all of bytes in buffer */
  688. X            register int copy = fp->_cnt;
  689. X
  690. X            if (copy > bytes)    /* buffer longer than ptr */
  691. X                copy = bytes;    /* only fill ptr */
  692. X            bytes -= copy;    /* adjust to reflect next loop */
  693. X            fp->_cnt -= copy;
  694. X            if (copy < THRESHOLD) {
  695. X                register char *rptr = ptr, *bp = (char *)fp->_ptr;
  696. X
  697. X                for (++copy; --copy > 0; )
  698. X                    *rptr++ = *bp++;
  699. X                ptr = rptr;
  700. X                fp->_ptr = (PTR_TYPE)bp;
  701. X            } else {
  702. X                memcpy(ptr, (char *)fp->_ptr, copy);
  703. X                ptr += copy;
  704. X                fp->_ptr += copy;
  705. X            }
  706. X        }
  707. X        if (bytes > 0) {    /* more to read, but buffer is empty */
  708. X            register int c = getc(fp);    /* refill buffer */
  709. X
  710. X            if (c == EOF)
  711. X                break;
  712. X            else {
  713. X                *ptr++ = c;
  714. X                --bytes;
  715. X            }
  716. X        }
  717. X    }
  718. X    if (size == 0)
  719. X        return count;            /* or 0 */
  720. X    else
  721. X        return (origbytes - bytes) / size;
  722. X}
  723. X
  724. Xint
  725. Xfwrite(ptr, size, count, fp)
  726. Xchar *ptr;
  727. Xint size, count;
  728. Xregister FILE *fp;
  729. X{
  730. X    register unsigned bytes = count * size;
  731. X    unsigned origbytes = bytes;
  732. X
  733. X    while (bytes > 0) {    /* bytes still to be written */
  734. X        {
  735. X            register int copy = fp->_cnt;
  736. X
  737. X            if (copy > bytes)    /* buffer longer than ptr */
  738. X                copy = bytes;    /* only empty ptr */
  739. X            bytes -= copy;    /* adjust to reflect next loop */
  740. X            fp->_cnt -= copy;
  741. X            if (copy < THRESHOLD) {
  742. X                register char *rptr = ptr, *bp = (char *)fp->_ptr;
  743. X
  744. X                for (++copy; --copy > 0; )
  745. X                    *bp++ = *rptr++;
  746. X                ptr = rptr;
  747. X                fp->_ptr = (PTR_TYPE)bp;
  748. X            } else {
  749. X                memcpy((char *)fp->_ptr, ptr, copy);
  750. X                ptr += copy;
  751. X                fp->_ptr += copy;
  752. X            }
  753. X        }
  754. X        if (bytes > 0)    /* more to write, but buffer is full */
  755. X            if (putc((putc_t)*ptr, fp) == EOF) /* flush buffer */
  756. X                break;
  757. X            else {
  758. X                ptr++;
  759. X                --bytes;
  760. X            }
  761. X    }
  762. X    if (size == 0)
  763. X        return count;            /* or 0 */
  764. X    else
  765. X        return (origbytes - bytes) / size;
  766. X}
  767. !
  768. echo 'libstdio/stdiock.c':
  769. sed 's/^X//' >'libstdio/stdiock.c' <<'!'
  770. X/*
  771. X * If this compiles and runs successfully, your stdio is very probably
  772. X * compatible with stdio.fast, except on SunOS 4.x, for unknown reasons.
  773. X * Buffers by default; -u stops buffering.
  774. X * Writes on stdout by default; -i read from stdin.
  775. X */
  776. X#include <stdio.h>
  777. X
  778. XFILE *fp = stdout;
  779. X
  780. Xmain(argc, argv)
  781. Xchar **argv;
  782. X{
  783. X    int wantbuf = 1, usestdin = 0;
  784. X    char line[1024];
  785. X    static char buf[BUFSIZ];
  786. X    static char buggered[] =
  787. X"Your stdio appears to be buggered: fwrite of 4 bytes doesn't yield 4.\n";
  788. X
  789. X    for (; argc > 1; argv++, argc--) {
  790. X        if (strcmp(argv[1], "-u") == 0)
  791. X            wantbuf = 0;
  792. X        if (strcmp(argv[1], "-i") == 0) {
  793. X            usestdin = 1;
  794. X            fp = stdin;
  795. X        }
  796. X    }
  797. X
  798. X    evalfile("start");
  799. X
  800. X    if (wantbuf) {
  801. X        setbuf(fp, buf);
  802. X        evalfile("setbuf(buf)");
  803. X    } else {
  804. X        setbuf(fp, (char *)NULL);
  805. X        evalfile("setbuf(0)");
  806. X    }
  807. X
  808. X    if (usestdin) {
  809. X        (void) fgets(line, sizeof line, fp);
  810. X        evalfile("fgets");
  811. X    } else {
  812. X        if (fwrite("your", 1, 4, fp) != 4)
  813. X            (void) write(1, buggered, strlen(buggered));
  814. X        evalfile("fwrite");
  815. X
  816. X        (void) fputs(" stdio seems to be ", stdout);
  817. X        evalfile("fputs");
  818. X    }
  819. X
  820. X    if (wantbuf && fp->_ptr == NULL)
  821. X        (void) fputs("incompatible (_ptr) ", stdout);
  822. X    else
  823. X        (void) fputs("compatible (_ptr) ", stdout);
  824. X    if (fp->_cnt >= 0 && fp->_cnt <= BUFSIZ)
  825. X        (void) fputs("compatible (_cnt)", stdout);
  826. X    else
  827. X        (void) fputs("incompatible (_cnt)", stdout);
  828. X    evalfile("test");
  829. X
  830. X    (void) fputs(" with stdio.fast\n", stdout);
  831. X    evalfile("fputs");
  832. X
  833. X    (void) fflush(fp);
  834. X    (void) fflush(stdout);
  835. X    evalfile("fflush");
  836. X
  837. X    exit(0);
  838. X}
  839. X
  840. X/* write on stdout with using stdio. ugh */
  841. Xevalfile(s)
  842. Xchar *s;
  843. X{
  844. X    static char ptr[] = "ptr ";
  845. X    static char cnt[] = " cnt ";
  846. X    static char *bufend = NULL;
  847. X    static char buggered[] =
  848. X"Your stdio appears to be buggered: _ptr+_cnt does not yield a constant.\n";
  849. X
  850. X    if (fp->_ptr != NULL && fp->_cnt != 0) {
  851. X        if (bufend == NULL)
  852. X            bufend = (char *)fp->_ptr + fp->_cnt;
  853. X        if (bufend != (char *)fp->_ptr + fp->_cnt)
  854. X            (void) write(1, buggered, strlen(buggered));
  855. X    }
  856. X
  857. X    (void) write(1, s, strlen(s));
  858. X    (void) write(1, "\t", 1);
  859. X    (void) write(1, ptr, strlen(ptr));
  860. X    prn((int)fp->_ptr, 10);
  861. X    (void) write(1, cnt, strlen(cnt));
  862. X    prn((int)fp->_cnt, 10);
  863. X    (void) write(1, "\n", 1);
  864. X}
  865. X
  866. Xprn(i, rad)
  867. Xint i, rad;
  868. X{
  869. X    int quot, rem;
  870. X    char c;
  871. X
  872. X    if (i < 0) {
  873. X        (void) write(1, "-", 1);
  874. X        i = -i;
  875. X    }
  876. X    quot = i / rad;
  877. X    rem = i % rad;
  878. X    if (quot > 0)
  879. X        prn(quot, rad);
  880. X    c = rem + '0';
  881. X    (void) write(1, &c, 1);
  882. X}
  883. !
  884. echo 'libstdio/LEGAL.STDIO':
  885. sed 's/^X//' >'libstdio/LEGAL.STDIO' <<'!'
  886. XPage 165 of The C Programming Language describes some of the workings
  887. Xof the UNIX stdio implementation. In particular, it describes the
  888. Xfunction of _ptr and _cnt.
  889. !
  890. echo 'libstdio/LEGAL.NOTICE':
  891. sed 's/^X//' >'libstdio/LEGAL.NOTICE' <<'!'
  892. X/*
  893. X * Copyright (c) 1985, 1986 by Geoffrey Collyer.
  894. X * Written by Geoffrey Collyer.  Not derived from AT&T code.
  895. X *
  896. X * Permission is granted to anyone to use this software for any
  897. X * purpose on any computer system, and to redistribute it freely,
  898. X * subject to the following restrictions:
  899. X *
  900. X * 1. The author is not responsible for the consequences of use of
  901. X *    this software, no matter how awful, even if they arise
  902. X *    from imperfections in it.
  903. X *
  904. X * 2. The origin of this software must not be misrepresented, either
  905. X *    by explicit claim or by omission.
  906. X *
  907. X * 3. Altered versions must be plainly marked as such, and must not
  908. X *    be misrepresented as being the original software.
  909. X */
  910. !
  911. echo 'libstdio/README':
  912. sed 's/^X//' >'libstdio/README' <<'!'
  913. XThis directory does not form a library; fgets.o, fputs.o and rdwr.o
  914. Xconstitute re-written stdio guts, thought to be compatible with the
  915. Xusual UNIX stdio implementation but a good deal faster than old
  916. Xversions.
  917. !
  918. echo 'libstdio/runtrials':
  919. sed 's/^X//' >'libstdio/runtrials' <<'!'
  920. X#! /bin/sh
  921. Xfor whose in stock fast
  922. Xdo
  923. X    for fp in "" -i
  924. X    do
  925. X        for buf in "" -u
  926. X        do
  927. X            echo stdiock.$whose $fp $buf:
  928. X            ./stdiock.$whose $fp $buf <<!
  929. Xa line
  930. X!
  931. X            echo ''
  932. X        done
  933. X    done
  934. Xdone | tee trial.out | egrep 'incompat|bugger'
  935. Xexit 0                # exit status of pipe is unportable anyway
  936. !
  937. echo 'libusg/Makefile':
  938. sed 's/^X//' >'libusg/Makefile' <<'!'
  939. X# C news libusg makefile
  940. XINCLUDE = ../include
  941. XDEFINES=-I$(INCLUDE)
  942. XCOPTS=-O # -p
  943. XCFLAGS=$(COPTS) $(DEFINES)
  944. XLINTFLAGS=-hau $(DEFINES)
  945. X# workaround for System V make bug
  946. XSHELL = /bin/sh
  947. X
  948. XSRCS=clsexec.c fopenexcl.c ftime.c gethostname.c
  949. XOBJS=clsexec.o fopenexcl.o ftime.o gethostname.o
  950. X
  951. X# RANLIB is ranlib on non-USG systems, echo on USG systems
  952. XRANLIB=echo
  953. X
  954. Xu:    $(OBJS)
  955. X    ar ruv ../libcnews.a $(OBJS)
  956. X
  957. Xall:    $(OBJS)
  958. X
  959. Xlibusg.a: $(SRCS)
  960. X    $(CC) $(CFLAGS) -c $?
  961. X    ar ru $@ *.o
  962. X    rm *.o
  963. X    $(RANLIB) $@
  964. Xlint:
  965. X    lint $(LINTFLAGS) $(SRCS)
  966. X
  967. Xclean:
  968. X    rm -f *.o
  969. !
  970. echo 'libusg/ftime.c':
  971. sed 's/^X//' >'libusg/ftime.c' <<'!'
  972. X/*
  973. X * Uglix ftime simulation
  974. X */
  975. X
  976. X#include <ctype.h>
  977. X#include <sys/types.h>
  978. X#include <sys/timeb.h>        /* see news/include */
  979. X#include <sys/times.h>
  980. X
  981. X#define NULL 0
  982. X#ifndef HZ
  983. X#define HZ 60
  984. X#endif
  985. X
  986. X/* imports from libc */
  987. Xextern time_t time();
  988. Xextern time_t times();            /* only true on Uglix */
  989. Xextern char *getenv();
  990. X
  991. Xftime(tp)
  992. Xstruct timeb *tp;
  993. X{
  994. X    register char *tz;
  995. X#ifdef SANE
  996. X    /*
  997. X     * Since times() is not required to use the same time base for its
  998. X     * return value as time() uses, we can't easily get sub-second resolution.
  999. X     */
  1000. X    struct tms timesbuf;
  1001. X    register int hz = times(×buf) % HZ;    /* hertz beyond time(0) */
  1002. X
  1003. X    tp->millitm = (hz*1000L)/HZ;
  1004. X#else
  1005. X    tp->millitm = 0;
  1006. X#endif
  1007. X    tp->time = time(&tp->time);
  1008. X    tz = getenv("TZ");
  1009. X    if (tz == NULL)            /* just pick one */
  1010. X        tz = "EST5EDT";
  1011. X    while (*tz != '\0' && isascii(*tz) && !isdigit(*tz) && *tz != '-')
  1012. X        tz++;            /* find hrs from greenwich */
  1013. X    tp->timezone = atoi(tz) * 60;    /* in minutes */
  1014. X    while (*tz != '\0' && isascii(*tz) && (isdigit(*tz) || *tz == '-'))
  1015. X        tz++;            /* find DST, if any */
  1016. X    tp->dstflag = (*tz != '\0');
  1017. X}
  1018. !
  1019. echo 'libusg/fopenexcl.c':
  1020. sed 's/^X//' >'libusg/fopenexcl.c' <<'!'
  1021. X/*
  1022. X * fopenexcl(name) - fopen(name, "w") with error if name exists (USG)
  1023. X */
  1024. X
  1025. X#include <stdio.h>
  1026. X#include <sys/types.h>
  1027. X#include <fcntl.h>
  1028. X
  1029. XFILE *
  1030. Xfopenexcl(name)
  1031. Xregister char *name;
  1032. X{
  1033. X    /* This is the cheaper way. */
  1034. X    register int fd = open(name, O_WRONLY|O_CREAT|O_EXCL, 0666);
  1035. X
  1036. X    if (fd < 0)
  1037. X        return NULL;        /* name existed or couldn't be made */
  1038. X    else
  1039. X        return fdopen(fd, "w");
  1040. X}
  1041. !
  1042. echo 'libusg/gethostname.c':
  1043. sed 's/^X//' >'libusg/gethostname.c' <<'!'
  1044. X/*
  1045. X * Uglix gethostname simulation
  1046. X */
  1047. X
  1048. X#include <sys/types.h>
  1049. X#include <sys/utsname.h>
  1050. X
  1051. X#define min(a, b) ((a) < (b)? (a): (b))
  1052. X
  1053. Xint
  1054. Xgethostname(buf, size)
  1055. Xchar *buf;
  1056. Xint size;
  1057. X{
  1058. X    struct utsname ugnm;
  1059. X    char *strncpy();
  1060. X
  1061. X    if (uname(&ugnm) < 0)
  1062. X        return -1;
  1063. X    (void) strncpy(buf, ugnm.nodename, min(sizeof ugnm.nodename, size));
  1064. X    return 0;
  1065. X}
  1066. !
  1067. echo 'libusg/clsexec.c':
  1068. sed 's/^X//' >'libusg/clsexec.c' <<'!'
  1069. X/*
  1070. X * set close on exec (on Uglix)
  1071. X */
  1072. X
  1073. X#include <stdio.h>
  1074. X#include <fcntl.h>
  1075. X
  1076. Xvoid
  1077. Xfclsexec(fp)
  1078. XFILE *fp;
  1079. X{
  1080. X    (void) fcntl(fileno(fp), F_SETFD, 1);
  1081. X}
  1082. !
  1083. echo 'libv7/Makefile':
  1084. sed 's/^X//' >'libv7/Makefile' <<'!'
  1085. X# C news libv7 makefile
  1086. XINCLUDE = ../include
  1087. XDEFINES=-I$(INCLUDE)
  1088. XCOPTS=-O # -p
  1089. XCFLAGS=$(COPTS) $(DEFINES)
  1090. XLINTFLAGS=-hau $(DEFINES)
  1091. X# workaround for System V make bug
  1092. XSHELL = /bin/sh
  1093. X
  1094. XSRCS = clsexec.c fopenexcl.c gethostname.c getcwd.c
  1095. XOBJS = clsexec.o fopenexcl.o gethostname.o getcwd.o
  1096. X
  1097. X# RANLIB is ranlib on non-USG systems, echo on USG systems
  1098. XRANLIB=ranlib
  1099. X
  1100. Xu:    $(OBJS)
  1101. X    ar ruv ../libcnews.a $(OBJS)
  1102. X
  1103. Xall:    $(OBJS)
  1104. X
  1105. Xlibv7.a: $(SRCS)
  1106. X    $(CC) $(CFLAGS) -c $?
  1107. X    ar ru $@ *.o
  1108. X    rm *.o
  1109. X    $(RANLIB) $@
  1110. Xlint:
  1111. X    lint $(LINTFLAGS) $(SRCS)
  1112. X
  1113. Xclean:
  1114. X    rm -f *.o
  1115. !
  1116. echo 'libv7/gethostname.c':
  1117. sed 's/^X//' >'libv7/gethostname.c' <<'!'
  1118. X/*
  1119. X * v7 gethostname simulation
  1120. X *    taken from pathalias and cleaned up.  Thanks, peter.
  1121. X */
  1122. X
  1123. X#include <stdio.h>
  1124. X
  1125. X/* imports from libc */
  1126. Xextern char *index(), *strncpy();
  1127. Xextern FILE *fopen(), *popen();
  1128. X
  1129. X/* forwards */
  1130. Xvoid readhostfile();
  1131. X
  1132. X#define MAXHOST 256
  1133. X#define min(a,b) ((a) < (b)? (a): (b))
  1134. X
  1135. Xstatic char defhost[] = "INSERT-YOUR-HOST-NAME-HERE";
  1136. Xstatic char *namefiles[] = {
  1137. X    "/etc/whoami",
  1138. X    "/etc/systemid",
  1139. X    NULL
  1140. X};
  1141. X
  1142. Xint
  1143. Xgethostname(hostname, size)
  1144. Xregister char *hostname;
  1145. Xint size;
  1146. X{
  1147. X    register FILE *whoami;
  1148. X    register char **namep;
  1149. X
  1150. X    *hostname = '\0';
  1151. X
  1152. X    /* try files in namefiles */
  1153. X    for (namep = namefiles; *namep != NULL; namep++) {
  1154. X        readhostfile(hostname, size, *namep);
  1155. X        if (*hostname != '\0')
  1156. X            return 0;
  1157. X    }
  1158. X
  1159. X    /* try /usr/include/whoami.h */
  1160. X    if ((whoami = fopen("/usr/include/whoami.h", "r")) != NULL) {
  1161. X        while (!feof(whoami)) {
  1162. X            char sysname[MAXHOST];
  1163. X
  1164. X            if (fgets(sysname, MAXHOST, whoami) == NULL)
  1165. X                break;
  1166. X            if (sscanf(sysname, "#define sysname \"%[^\"]\"",
  1167. X                hostname) > 0)
  1168. X                break;
  1169. X        }
  1170. X        (void) fclose(whoami);
  1171. X        if (*hostname != '\0')
  1172. X            return 0;
  1173. X    }
  1174. X
  1175. X    /* ask uucp */
  1176. X    if ((whoami = popen("PATH=/bin:/usr/bin:/usr/ucb uuname -l", "r")) != NULL) {
  1177. X        register char *ptr;
  1178. X
  1179. X        (void) fgets(hostname, size, whoami);
  1180. X        (void) pclose(whoami);
  1181. X        if ((ptr = index(hostname, '\n')) != NULL)
  1182. X            *ptr = '\0';
  1183. X    }
  1184. X    if (*hostname != '\0')
  1185. X        return 0;
  1186. X
  1187. X    /* aw hell, i give up!  is this a real unix? */
  1188. X    (void) strncpy(hostname, defhost, min(sizeof defhost, size));
  1189. X    return 0;
  1190. X}
  1191. X
  1192. Xstatic void
  1193. Xreadhostfile(hostname, size, file)    /* read host name from file */
  1194. Xchar *hostname, *file;
  1195. Xint size;
  1196. X{
  1197. X    register FILE *whoami;
  1198. X
  1199. X    if ((whoami = fopen(file, "r")) != NULL) {
  1200. X        register char *ptr;
  1201. X
  1202. X        (void) fgets(hostname, size, whoami);
  1203. X        (void) fclose(whoami);
  1204. X        if ((ptr = index(hostname, '\n')) != NULL)
  1205. X            *ptr = '\0';
  1206. X    }
  1207. X}
  1208. !
  1209. echo 'libv7/getcwd.c':
  1210. sed 's/^X//' >'libv7/getcwd.c' <<'!'
  1211. X/*
  1212. X * SystemV getcwd simulation, courtesy peter honeyman
  1213. X */
  1214. X
  1215. X#include <stdio.h>
  1216. X
  1217. X/* imports from libc */
  1218. Xextern FILE *popen();
  1219. Xextern char *rindex();
  1220. X
  1221. Xchar *
  1222. Xgetcwd(path, size)
  1223. Xregister char *path;
  1224. Xint size;
  1225. X{
  1226. X    register char *nlp;
  1227. X    register FILE *fp;
  1228. X
  1229. X    fp = popen("PATH=/bin:/usr/bin pwd", "r");
  1230. X    if (fp == NULL)
  1231. X        return 0;
  1232. X    if (fgets(path, size, fp) == NULL) {
  1233. X        (void) pclose(fp);
  1234. X        return 0;
  1235. X    }
  1236. X    if ((nlp = rindex(path, '\n')) != NULL)
  1237. X        *nlp = '\0';
  1238. X    (void) pclose(fp);
  1239. X    return path;
  1240. X}
  1241. !
  1242. echo 'libv7/fopenexcl.c':
  1243. sed 's/^X//' >'libv7/fopenexcl.c' <<'!'
  1244. X/*
  1245. X * fopenexcl(name) - fopen(name, "w") with error and errno==EEXIST,
  1246. X *    if name exists (V7/V8/V9)
  1247. X */
  1248. X
  1249. X#include <stdio.h>
  1250. X#include <errno.h>
  1251. X
  1252. X#define F_OK 0
  1253. X
  1254. Xextern int errno;
  1255. X
  1256. XFILE *
  1257. Xfopenexcl(name)
  1258. Xregister char *name;
  1259. X{
  1260. X    if (access(name, F_OK) >= 0) {    /* name exists */
  1261. X        errno = EEXIST;
  1262. X        return NULL;        /* refuse to write on name */
  1263. X    } else        
  1264. X        return fopen(name, "w");    /* try to create name */
  1265. X}
  1266. !
  1267. echo 'libv7/clsexec.c':
  1268. sed 's/^X//' >'libv7/clsexec.c' <<'!'
  1269. X/*
  1270. X * set close on exec (on Unix)
  1271. X */
  1272. X
  1273. X#include <stdio.h>
  1274. X#include <sgtty.h>
  1275. X
  1276. Xvoid
  1277. Xfclsexec(fp)
  1278. XFILE *fp;
  1279. X{
  1280. X    (void) ioctl(fileno(fp), FIOCLEX, (struct sgttyb *)NULL);
  1281. X}
  1282. X
  1283. !
  1284. echo 'libv8/Makefile':
  1285. sed 's/^X//' >'libv8/Makefile' <<'!'
  1286. X# C news libv8 makefile
  1287. XINCLUDE = ../include
  1288. XDEFINES=-I$(INCLUDE)
  1289. XCOPTS=-O # -p
  1290. XCFLAGS=$(COPTS) $(DEFINES)
  1291. XLINTFLAGS=-hau $(DEFINES)
  1292. X# workaround for System V make bug
  1293. XSHELL = /bin/sh
  1294. X
  1295. XSRCS = clsexec.c fopenexcl.c gethostname.c
  1296. XOBJS = clsexec.o fopenexcl.o gethostname.o
  1297. X
  1298. X# RANLIB is ranlib on non-USG systems, echo on USG systems
  1299. XRANLIB=ranlib
  1300. X
  1301. Xu:    $(OBJS)
  1302. X    ar ruv ../libcnews.a $(OBJS)
  1303. X
  1304. Xall:    $(OBJS)
  1305. X
  1306. Xlibv8.a: $(SRCS)
  1307. X    $(CC) $(CFLAGS) -c $?
  1308. X    ar ru $@ *.o
  1309. X    rm *.o
  1310. X    $(RANLIB) $@
  1311. Xlint:
  1312. X    lint $(LINTFLAGS) $(SRCS)
  1313. X
  1314. Xclean:
  1315. X    rm -f *.o
  1316. !
  1317. echo 'libv8/README':
  1318. sed 's/^X//' >'libv8/README' <<'!'
  1319. XThough it is undocumented, V8 contains an Uglix uname(3) emulation
  1320. Xin the C library.  In V9, uname(3) is documented.
  1321. !
  1322. echo 'libv8/fopenexcl.c':
  1323. sed 's/^X//' >'libv8/fopenexcl.c' <<'!'
  1324. X/*
  1325. X * fopenexcl(name) - fopen(name, "w") with error and errno==EEXIST,
  1326. X *    if name exists (V7/V8/V9)
  1327. X */
  1328. X
  1329. X#include <stdio.h>
  1330. X#include <errno.h>
  1331. X
  1332. X#define F_OK 0
  1333. X
  1334. Xextern int errno;
  1335. X
  1336. XFILE *
  1337. Xfopenexcl(name)
  1338. Xregister char *name;
  1339. X{
  1340. X    if (access(name, F_OK) >= 0) {    /* name exists */
  1341. X        errno = EEXIST;
  1342. X        return NULL;        /* refuse to write on name */
  1343. X    } else        
  1344. X        return fopen(name, "w");    /* try to create name */
  1345. X}
  1346. !
  1347. echo 'libv8/clsexec.c':
  1348. sed 's/^X//' >'libv8/clsexec.c' <<'!'
  1349. X/*
  1350. X * set close on exec (on Unix)
  1351. X */
  1352. X
  1353. X#include <stdio.h>
  1354. X#include <sgtty.h>
  1355. X
  1356. Xvoid
  1357. Xfclsexec(fp)
  1358. XFILE *fp;
  1359. X{
  1360. X    (void) ioctl(fileno(fp), FIOCLEX, (struct sgttyb *)NULL);
  1361. X}
  1362. X
  1363. !
  1364. echo 'libv8/gethostname.c':
  1365. sed 's/^X//' >'libv8/gethostname.c' <<'!'
  1366. X/*
  1367. X * Uglix gethostname simulation
  1368. X */
  1369. X
  1370. X#include <sys/types.h>
  1371. X#include <sys/utsname.h>
  1372. X
  1373. X#define min(a, b) ((a) < (b)? (a): (b))
  1374. X
  1375. Xint
  1376. Xgethostname(buf, size)
  1377. Xchar *buf;
  1378. Xint size;
  1379. X{
  1380. X    struct utsname ugnm;
  1381. X    char *strncpy();
  1382. X
  1383. X    if (uname(&ugnm) < 0)
  1384. X        return -1;
  1385. X    (void) strncpy(buf, ugnm.nodename, min(sizeof ugnm.nodename, size));
  1386. X    return 0;
  1387. X}
  1388. !
  1389. echo 'man/inews.1':
  1390. sed 's/^X//' >'man/inews.1' <<'!'
  1391. X.\" =()<.ds a @<NEWSARTS>@>()=
  1392. X.ds a /usr/spool/news
  1393. X.\" =()<.ds b @<NEWSBIN>@>()=
  1394. X.ds b /usr/lib/newsbin
  1395. X.\" =()<.ds c @<NEWSCTL>@>()=
  1396. X.ds c /usr/lib/news
  1397. X.\" =()<.ds m @<NEWSMASTER>@>()=
  1398. X.ds m usenet
  1399. X.TH INEWS 1 "7 June 1989" "C News"
  1400. X.SH NAME
  1401. Xinews \- `user-friendly' news-posting front-end for rnews
  1402. X.SH SYNOPSIS
  1403. X.B inews
  1404. X.B \-p
  1405. X[ file ... ]
  1406. X.br
  1407. X.B inews
  1408. X[
  1409. X.B \-h
  1410. X]
  1411. X[
  1412. X.B \-x
  1413. Xexcluded-site
  1414. X]
  1415. X[
  1416. X.B \-A
  1417. X]
  1418. X[
  1419. X.B \-M
  1420. X]
  1421. X[
  1422. X.B \-V
  1423. X]
  1424. X[
  1425. X.B \-W
  1426. X]
  1427. X.br
  1428. X.\" silly B options follow
  1429. X[
  1430. X.B \-a
  1431. XApproved:-contents
  1432. X]
  1433. X[
  1434. X.B \-c
  1435. XControl:-contents
  1436. X]
  1437. X[
  1438. X.B \-d
  1439. XDistribution:-contents
  1440. X]
  1441. X[
  1442. X.B \-e
  1443. XExpires:-contents
  1444. X]
  1445. X[
  1446. X.B \-f
  1447. XFrom:-contents
  1448. X]
  1449. X[
  1450. X.B \-n
  1451. XNewsgroups:-contents
  1452. X]
  1453. X[
  1454. X.B \-o
  1455. XOrganization:-contents
  1456. X]
  1457. X[
  1458. X.B \-r
  1459. XReply-To:-contents
  1460. X]
  1461. X[
  1462. X.B \-t
  1463. XSubject:-contents
  1464. X]
  1465. X[
  1466. X.B \-C
  1467. Xnewsgroup
  1468. X]
  1469. X[
  1470. X.B \-F
  1471. XReferences:-contents
  1472. X]
  1473. X[
  1474. Xfile ...
  1475. X]
  1476. X.SH DESCRIPTION
  1477. X.I Inews
  1478. Xinstalls locally
  1479. Xand
  1480. Xbroadcasts a (network) news article
  1481. X(\fIi\fPnjects it into the
  1482. X.I news
  1483. Xflow),
  1484. Xread from
  1485. X.IR file s
  1486. Xor standard input if none,
  1487. Xnormally
  1488. Xby giving it as standard input to
  1489. X.IR rnews (1),
  1490. Xafter adding and altering headers,
  1491. Xnotably
  1492. X.BR Message-ID: ,
  1493. X.BR From:
  1494. Xand
  1495. X.BR Path: ,
  1496. Xdeleting invisible characters,
  1497. Xand
  1498. Xappending the first four lines of
  1499. X.BR $HOME/.signature ,
  1500. Xif any.
  1501. XThe article will instead be mailed
  1502. Xto the moderators of the moderated newsgroups in the
  1503. X.B Newsgroups:
  1504. Xheader,
  1505. Xif any are found.
  1506. X.PP
  1507. X.B "inews -p"
  1508. Xis exactly equivalent to
  1509. X.BR rnews .
  1510. XNormal usage is simply
  1511. X.BR "inews -h" ,
  1512. Xwhich assumes the presence of at least
  1513. X.B Subject:
  1514. Xand
  1515. X.B Newsgroups:
  1516. Xheaders.
  1517. X.B \-h
  1518. Xtells
  1519. X.I inews
  1520. Xthat the article starts with headers;
  1521. Xotherwise it starts with the article body.
  1522. X.B \-x
  1523. Xprevents transmission to site
  1524. X.IR excluded-site .
  1525. X.B \-A
  1526. Xwaits until enough space becomes free in
  1527. X.BR \*a .
  1528. X.B \-M
  1529. Xdoes nothing,
  1530. Xfor B news compatibility.
  1531. X.B \-V
  1532. Xcauses
  1533. X.I relaynews
  1534. Xto emit a log file line on stdout
  1535. Xafter processing is complete,
  1536. Xby having
  1537. X.I relaynews
  1538. Xnot redirect stdout and stderr
  1539. Xto
  1540. X.B \*c/log
  1541. Xand
  1542. X.B \*c/errlog.
  1543. X.B \-W
  1544. Xwaits for
  1545. X.I relaynews
  1546. Xto complete,
  1547. Xinstead of running it in the background and not waiting.
  1548. X.PP
  1549. XThe remaining options are inherited from B news
  1550. Xand exist only for backward-compatibility with news readers.
  1551. X.I "They should not be used by humans,"
  1552. Xas they are equivalent to
  1553. Xadding the obvious headers,
  1554. Xwith two small twists:
  1555. X.B \-f
  1556. Xgenerates
  1557. X.BI "From:" " From:-contents"
  1558. Xwhich generates a
  1559. X.BI "Sender:" " user" @ "host"
  1560. Xheader
  1561. Xif there is no
  1562. X.B Sender:
  1563. Xheader in the input,
  1564. Xand
  1565. X.B \-C
  1566. Xgenerates
  1567. X.BI "Control: newgroup" " newsgroup"
  1568. Xand
  1569. X.BI "Newsgroups:" " newsgroup"
  1570. Xheaders.
  1571. X.SH FILES
  1572. X.PD 0
  1573. X.TP 2i
  1574. X.B \*c/active
  1575. Xcontains (un)moderated flag
  1576. X.TP
  1577. X.B \*c/mailpaths
  1578. Xroutes to moderators, Internet gateway
  1579. X.TP
  1580. X.B \*c/mailname
  1581. Xthe name of this cluster of machines for purposes of mail,
  1582. Xincluding any domain
  1583. X.TP
  1584. X.B \*c/server
  1585. Xthe hostname of this cluster's server
  1586. X.TP
  1587. X.B \*c/whoami
  1588. Xthe name of this cluster for purposes of news
  1589. X.TP
  1590. X.B \*b/inject/anne.jones
  1591. Xheader censor
  1592. X.TP
  1593. X.IB $HOME /.signature
  1594. Xyour name and network addresses
  1595. X(no line-printer graphics, please)
  1596. X.TP
  1597. X.BR /tmp/in *
  1598. Xtemporaries
  1599. X.PD
  1600. X.SH "SEE ALSO"
  1601. X.IR mail (1),
  1602. X.IR rnews (1)
  1603. X.SH DIAGNOSTICS
  1604. X.I inews
  1605. Xcan take several seconds to run,
  1606. Xso it almost immediately begins running in the background;
  1607. Xerror messages may appear somewhat later,
  1608. Xperhaps in the midst of other activity.
  1609. X.SH HISTORY
  1610. XWritten by Geoff Collyer
  1611. Xat the University of Toronto
  1612. Xas part of the C news project.
  1613. X.SH BUGS
  1614. X.I Inews
  1615. Xshould be unnecessary;
  1616. Xits only useful function is adding
  1617. X.B Message-ID:
  1618. Xheaders
  1619. Xand
  1620. Xmost novices use
  1621. X.IR Pnews ,
  1622. Xwhich could invoke
  1623. X.I rnews
  1624. Xdirectly.
  1625. !
  1626. echo 'man/README':
  1627. sed 's/^X//' >'man/README' <<'!'
  1628. XThese are the manual pages for C News proper; one or two other pages for
  1629. Xauxiliary programs that you might want to install in their own right are
  1630. Xscattered here and there in other directories.
  1631. X
  1632. XThese pages use the .TH macro in the following way:
  1633. X
  1634. X    .TH <title> <chapter> "<date>" "C News"
  1635. X
  1636. XOn some systems the last argument gets ignored, or put in a funny place
  1637. Xin headers or footers.  There is no portable fix, as people have messed
  1638. Xwith the -man macros in too many different ways.
  1639. X
  1640. XThe only fonts used are the standard R, I, and B.
  1641. !
  1642. echo 'man/postnews.1':
  1643. sed 's/^X//' >'man/postnews.1' <<'!'
  1644. X.\" =()<.ds c @<NEWSCTL>@>()=
  1645. X.ds c /usr/lib/news
  1646. X.TH POSTNEWS 1 "9 June 1989" "C News"
  1647. X.SH NAME
  1648. Xpostnews \- simple interactive news-posting interface
  1649. X.SH SYNOPSIS
  1650. X.B postnews
  1651. X[newsgroup]
  1652. X.SH DESCRIPTION
  1653. X.I Postnews
  1654. Xprovides a simple interactive interface for posting news.
  1655. XIt prompts the user for the \fInewsgroup\fR if it is not given as an argument
  1656. X(more than one group can be given, with groups separated by commas but no
  1657. Xwhite space),
  1658. Xprompts for the article's subject,
  1659. Xdrops the user into his choice of text editor with a prototype
  1660. Xarticle,
  1661. Xchecks (when the editor terminates) that the article has been edited
  1662. Xreasonably, and then posts it.
  1663. X.PP
  1664. XIf the article has not been written out from the editor, or if the
  1665. Xediting instructions in the prototype do not appear to have been
  1666. Xfollowed, \fIpostnews\fR gives the user a choice between abandoning
  1667. Xthe posting or re-editing it.
  1668. X.SH FILES
  1669. X\*c/postdefltgroup    default newsgroup (nonexistent means no default)
  1670. X.br
  1671. X\*c/postdefltdist    default distribution (nonexistent means `world')
  1672. X.SH SEE ALSO
  1673. Xinews(1)
  1674. X.SH HISTORY
  1675. XWritten at U of Toronto by Henry Spencer.
  1676. X.SH BUGS
  1677. XThere are zillions of marginally-useful features that it could have
  1678. Xbut doesn't.
  1679. !
  1680. echo 'man/newsaux.8':
  1681. sed 's/^X//' >'man/newsaux.8' <<'!'
  1682. X.\" =()<.ds a @<NEWSARTS>@>()=
  1683. X.ds a /usr/spool/news
  1684. X.\" =()<.ds b @<NEWSBIN>@>()=
  1685. X.ds b /usr/lib/newsbin
  1686. X.\" =()<.ds c @<NEWSCTL>@>()=
  1687. X.ds c /usr/lib/news
  1688. X.\" =()<.ds m @<NEWSMASTER>@>()=
  1689. X.ds m usenet
  1690. X.TH NEWSAUX 8 "22 June 1989" "C News"
  1691. X.SH NAME
  1692. Xspacefor \- check available space for news
  1693. X.br
  1694. Xqueuelen \- get length of outbound-news uucp queues
  1695. X.br
  1696. Xsizeof \- get size of file(s) for news
  1697. X.br
  1698. Xctime, getdate \- convert dates to and from internal representation for news
  1699. X.br
  1700. Xnewshostname \- get host name for news
  1701. X.br
  1702. Xgngp \- search text using a newsgroup pattern
  1703. X.br
  1704. Xnewshist \- extract history line for news article(s)
  1705. X.br
  1706. Xnewslock \- do locking for news
  1707. X.br
  1708. Xnewsdaily \- maintain news log files and report problems
  1709. X.br
  1710. Xnewswatch \- keep an eye on news system for difficulties
  1711. X.br
  1712. Xnewsboot \- clean up news debris on reboot
  1713. X.br
  1714. Xlocknews \- lock news system for manual tinkering
  1715. X.br
  1716. Xaddgroup, delgroup \- add and delete newsgroups, locally only
  1717. X.SH SYNOPSIS
  1718. X.B \*b/spacefor
  1719. Xfilesize location [ site ]
  1720. X.br
  1721. X.B \*b/queuelen
  1722. Xsite
  1723. X.br
  1724. X.B \*b/sizeof
  1725. Xfile ...
  1726. X.br
  1727. X.B \*b/ctime
  1728. Xdecimaldate
  1729. X.br
  1730. X.B \*b/getdate
  1731. Xprintabledate
  1732. X.br
  1733. X.B \*b/newshostname
  1734. X.br
  1735. X.B \*b/gngp
  1736. X[
  1737. X.B \-a
  1738. X]
  1739. Xngpattern file ...
  1740. X.br
  1741. X.B \*b/maint/newshist
  1742. Xmsgid ...
  1743. X.br
  1744. X.B \*b/newslock
  1745. Xlocktemp lockname
  1746. X.br
  1747. X.B \*b/maint/newsdaily
  1748. X[ guru ... ]
  1749. X.br
  1750. X.B \*b/maint/newswatch
  1751. X[ guru ... ]
  1752. X.br
  1753. X.B \*b/maint/newsboot
  1754. X.br
  1755. X.B \*b/maint/locknews
  1756. X.br
  1757. X.B \*b/maint/addgroup
  1758. Xgroup {\fBy\fR|\fBn\fR|\fBm\fR|\fBx\fR|\fB=\fIrealgroup\fR}
  1759. X.br
  1760. X.B \*b/maint/delgroup
  1761. Xgroup
  1762. X.SH DESCRIPTION
  1763. XThese programs are minor utilities used by various parts of C News.
  1764. X.PP
  1765. X.I Spacefor
  1766. Xdetermines how many files of size \fIfilesize\fR can fit in \fIlocation\fR
  1767. X(\fBincoming\fR, \fBarticles\fR, \fBcontrol\fR, \fBarchive\fR,
  1768. Xor \fBoutbound\fR to \fIsite\fR)
  1769. Xwithout cramping things unduly.
  1770. XThe precise locations of these places, and how low space gets before
  1771. Xit is unduly cramped, are site-specific.
  1772. X.I Spacefor
  1773. Xinvokes \fIdf\fR(1) to determine the available space.
  1774. X.PP
  1775. X.I Queuelen
  1776. Xreports how many news batches \fIuucp\fR has queued up for \fIsite\fR.
  1777. X.PP
  1778. X.I Sizeof
  1779. Xreports the total number of bytes in the \fIfile\fR(s).
  1780. X(This may seem redundant with \fIls\ \-l\fR, but the format of \fIls\ \-l\fR
  1781. Xvaries between systems and \fIsizeof\fR looks after all that.)
  1782. X.PP
  1783. X.I Ctime
  1784. Xand
  1785. X.I getdate
  1786. Xconvert dates in human-readable form
  1787. Xto (\fIgetdate\fR) and from (\fIctime\fR) decimal ASCII representations
  1788. Xof Unix's internal integer dates.
  1789. XTheir functionality resembles that of their namesakes in the C library.
  1790. X.PP
  1791. X.I Newshostname
  1792. Xreports the name of this system for news purposes.
  1793. XThis may differ from the name of the particular CPU it is run on;
  1794. Xa cluster of CPUs sharing a filesystem tree would all have the same
  1795. X\fInewshostname\fR name.
  1796. XTypically \fInewshostname\fR gets the name from \fI\*c/whoami\fR;
  1797. Xfailing that, it consults various other possible sources
  1798. X(e.g. the \fIhostname\fR command).
  1799. X.PP
  1800. X.I Gngp
  1801. Xresembles \fIgrep\fR except that its search is based on newsgroup patterns
  1802. X(e.g. `comp', which matches `comp', `comp.lang', `comp.lang.c', ...;
  1803. X`comp,!comp.lang.c' which matches `comp' and `comp.lang' but not
  1804. X`comp.lang.c'; etc.).
  1805. X\fIGngp\fR prints only the line(s) that
  1806. Xcontain a substring that matches the \fIngpattern\fR.
  1807. XNormally the substring must run from a point in the line to its end.
  1808. XIf the
  1809. X\fB\-a\fR
  1810. Xflag is given, the eligible substrings start at the beginning of the
  1811. Xline and end at white space or the end of the line.
  1812. X.PP
  1813. X.I Newshist
  1814. Xprints the history line for each article identified by a \fImsgid\fR.
  1815. X.PP
  1816. X.I Newslock
  1817. Xmakes a link named \fIlockname\fR to the file \fIlocktemp\fR,
  1818. Xand returns exit status 0 for success, 1 if the link could not be made
  1819. X(typically because \fIlockname\fR already existed).
  1820. XThis is used for shell-file locking in C News.
  1821. XIt is a subset of \fIln\fR(1) except that (a) no error messages are
  1822. Xever produced and (b) the link is guaranteed to fail if \fIlockname\fR
  1823. Xalready exists.
  1824. X(Some brain-damaged versions of \fIln\fR helpfully remove \fIlockname\fR
  1825. Xin that case, making them useless for locking.)
  1826. X.PP
  1827. X.I Newsdaily
  1828. Xperforms minor maintenance chores
  1829. Xthat typically should be done once a day for the news system:
  1830. Xsaving copies of log files and truncating them,
  1831. Xreporting logged errors, and checking for anomalies suggesting something
  1832. Xis wrong.
  1833. X\fINewsdaily\fR saves one generation of old \fIlog\fR files and three
  1834. Xgenerations of old \fIerrlog\fR files.
  1835. XIt reports problems to the named \fIguru\fRs
  1836. X(default:  `\*m').
  1837. X.PP
  1838. X.I Newswatch
  1839. Xlooks for indications of news problems on a shorter time scale than those
  1840. Xreported by \fInewsdaily\fR, notably strangely-persistent lock files that
  1841. Xmay indicate a news-system failure.
  1842. XIt typically should be run a few times a day.
  1843. X.PP
  1844. X.I Newsboot
  1845. Xshould be run from \fI/etc/rc\fR or the system's equivalent on reboot.
  1846. XIt cleans up files that the news system might have left lying about
  1847. Xif the system crashed while news was being processed,
  1848. Xnotably old lock files.
  1849. X.PP
  1850. X.I Locknews
  1851. Xlocks the news system, starts up a shell for the user, and waits around to
  1852. Xunlock the news system when that shell terminates.
  1853. XThis simplifies manual maintenance.
  1854. X.PP
  1855. X.I Addgroup
  1856. Xand
  1857. X.I delgroup
  1858. Xrespectively add a newsgroup (with a specified flags field for the
  1859. X\fIactive\fR file, normally `y' [see \fInews\fR(5)]) and delete a
  1860. Xnewsgroup manually, with proper locking.
  1861. XThe effect is purely local; no control message (to propagate the
  1862. Xchange to other machines) is sent.
  1863. X.SH FILES
  1864. X.ta 6c
  1865. X.nf
  1866. X/usr/spool/uucp/*    uucp queues
  1867. X\*c/whoami    news host name
  1868. X\*c/history    history file
  1869. X\*c/history.pag    \fIdbm\fR database for history file
  1870. X\*c/history.dir    \fIdbm\fR database for history file
  1871. X\*c/L.*    lock temporaries
  1872. X\*c/LOCK*    lock files
  1873. X\*c/log    current news log
  1874. X\*c/log.o    previous news log
  1875. X\*c/errlog    current news-error log
  1876. X\*c/errlog.o*    old news-error logs
  1877. X\*a/in.coming    input-spooling area
  1878. X\*a/out.going    output-batching area
  1879. X\*c/watchtime    last time \fInewswatch\fR was run
  1880. X\*c/active    list of current newsgroups
  1881. X\*c/active.old    backup copy created by \fIaddgroup\fR and \fIdelgroup\fR
  1882. X.SH SEE ALSO
  1883. Xdf(1), uucp(1), ls(1), ctime(3), getdate(3), hostname(1),
  1884. Xgrep(1), news(5), expire(8), newsbatch(8), rnews(8)
  1885. X.SH DIAGNOSTICS
  1886. X.I Locknews
  1887. Xcomplains and exits if it is unable to lock the news system; this is
  1888. Xtypically a matter of either inadequate permissions or news activity
  1889. Xalready in progress.
  1890. X.SH HISTORY
  1891. XWritten at U of Toronto by Henry Spencer and Geoff Collyer.
  1892. X.SH BUGS
  1893. X.I Spacefor
  1894. Xand
  1895. X.I queuelen
  1896. Xare unfortunately somewhat system-specific, since \fIdf\fR output and
  1897. X\fIuucp\fR file layout vary between different versions.
  1898. X.PP
  1899. XThe need for \fIsizeof\fR and \fInewslock\fR is a botch.
  1900. X.PP
  1901. X\fILocknews\fR is a bit crude.
  1902. X.PP
  1903. X\fIAddgroup\fR does not create the directory(-ies) for the new group;
  1904. XC News creates them as necessary but some news-reader programs disapprove.
  1905. X.PP
  1906. X\fIDelgroup\fR does not remove files or directories from \*a, although it
  1907. Xprints a reminder to do so.
  1908. !
  1909. echo 'man/newsmail.8':
  1910. sed 's/^X//' >'man/newsmail.8' <<'!'
  1911. X.\" =()<.ds a @<NEWSARTS>@>()=
  1912. X.ds a /usr/spool/news
  1913. X.\" =()<.ds b @<NEWSBIN>@>()=
  1914. X.ds b /usr/lib/newsbin
  1915. X.\" =()<.ds c @<NEWSCTL>@>()=
  1916. X.ds c /usr/lib/news
  1917. X.\" =()<.ds m @<NEWSMASTER>@>()=
  1918. X.ds m usenet
  1919. X.TH NEWSMAIL 8 "22 June 1989" "C News"
  1920. X.SH NAME
  1921. Xmailnews, sendnews \- send unbatched news as mail
  1922. X.br
  1923. Xrecenews, recpnews \- receive mailed news
  1924. X.br
  1925. Xbdecode \- decode encoded mailed news
  1926. X.SH SYNOPSIS
  1927. X.B \*b/relay/mailnews
  1928. Xaddress ...
  1929. X.br
  1930. X.B \*b/relay/sendnews
  1931. Xaddress ...
  1932. X.br
  1933. X.B \*b/input/recenews
  1934. X.br
  1935. X.B \*b/input/recpnews
  1936. X.br
  1937. X.B \*b/input/bdecode
  1938. X[ file ]
  1939. X.SH DESCRIPTION
  1940. XSometimes it is necessary to transmit news via mail,
  1941. Xto deal with network connections that have no notion of arbitrary file
  1942. Xtransfer or non-mail traffic.
  1943. XThese programs handle unbatched transmission and
  1944. Xbatched or unbatched reception.
  1945. X(Batched transmission is handled by the batching subsystem;
  1946. Xsee \fInewsbatch\fR(8).)
  1947. X.PP
  1948. X.I Mailnews
  1949. Xaccepts news from its standard input, encodes it using \fIbencode\fR
  1950. X(see \fIbencode\fR(1) or \fInewsbatch\fR(8)) to ensure that stupid mailers
  1951. Xdo not corrupt it, and mails it to the \fIaddress\fRes.
  1952. X.PP
  1953. X.I Sendnews
  1954. Xdoes likewise, but uses an inferior method of mailer protection
  1955. X(prepending `N' to each line) which does not protect against all forms
  1956. Xof mailer brain-damage.
  1957. XIt is provided for backward compatibility; its use is discouraged.
  1958. X.PP
  1959. X.I Mailnews
  1960. Xand
  1961. X.I sendnews
  1962. Xare located in the default path of transmission commands in the \fIsys\fR
  1963. Xfile (see \fInews\fR(5)) so that they can be used from there without
  1964. Xgiving a full pathname.
  1965. X.PP
  1966. X.I Recenews
  1967. Xreceives encoded news sent by \fImailnews\fR or a batcher,
  1968. Xdecodes it, and feeds it to \fIrnews\fR (see \fIrnews\fR(8)).
  1969. X.I Recpnews
  1970. Xdoes likewise for mail protected with `N'.
  1971. XNormally one should arrange that mail arriving at the mailbox ``enews''
  1972. Xis sent to \fIrecenews\fR
  1973. Xand likewise for ``rnews'' (the name is historical, for compatibility
  1974. Xagain) and \fIrecpnews\fR.
  1975. X.PP
  1976. X.I Bdecode
  1977. Xpasses standard input, or the \fIfile\fR if there is one, to standard
  1978. Xoutput, decoding the \fIbencode\fR encoding and stripping off
  1979. Xdebris prepended and appended by mailers.
  1980. X.SH SEE ALSO
  1981. Xbencode(1), mail(1), news(5), newsbatch(8), rnews(8)
  1982. X.SH HISTORY
  1983. XWritten at U of Toronto by Henry Spencer, with contributions by Geoff Collyer.
  1984. X.I Bdecode
  1985. Xwritten at University of Waterloo by Reg Quinton and Ken Lalonde.
  1986. !
  1987. echo 'man/news.5':
  1988. sed 's/^X//' >'man/news.5' <<'!'
  1989. X.\" =()<.ds a @<NEWSARTS>@>()=
  1990. X.ds a /usr/spool/news
  1991. X.\" =()<.ds b @<NEWSBIN>@>()=
  1992. X.ds b /usr/lib/newsbin
  1993. X.\" =()<.ds c @<NEWSCTL>@>()=
  1994. X.ds c /usr/lib/news
  1995. X.\" =()<.ds m @<NEWSMASTER>@>()=
  1996. X.ds m usenet
  1997. X.de Is\" indentation start
  1998. X.in +0.5i
  1999. X..
  2000. X.de Ie\" indentation end
  2001. X.in -0.5i
  2002. X..
  2003. X.de Es\" example start
  2004. X.LP
  2005. X.nf
  2006. X.ft B
  2007. X.Is
  2008. X..
  2009. X.de Ee\" example end
  2010. X.Ie
  2011. X.ft R
  2012. X.fi
  2013. X.LP
  2014. X..
  2015. X.TH NEWS 5 "8 June 1989" "C News"
  2016. X.SH NAME
  2017. Xnews \- USENET network news articles, batches, related files
  2018. X.SH DESCRIPTION
  2019. XThere are two formats of news articles:
  2020. X.BR A " and " B.
  2021. X.B A
  2022. Xformat is obsolete,
  2023. Xbut
  2024. Xlooks like this:
  2025. X.Es
  2026. XA\fIarticle-ID
  2027. Xnewsgroups
  2028. Xpath
  2029. Xdate
  2030. Xtitle
  2031. XBody of article
  2032. X.Ee
  2033. XA
  2034. X.B B
  2035. Xformat
  2036. X.I article
  2037. Xconsists of a series of headers
  2038. Xand then the body.
  2039. XA header
  2040. Xline is defined
  2041. X(approximately)
  2042. Xas a line
  2043. Xat the start of the article
  2044. Xor immediately following a header line
  2045. Xwith a capital letter
  2046. Xas the first character and
  2047. Xa colon immediately following the first word,
  2048. Xof alphanumerics and dashes,
  2049. Xon the line
  2050. X(a specialisation of RFC 822 format).
  2051. XContinued headers are as per RFC 822.
  2052. XUnrecognized headers are ignored.
  2053. XNews is stored in the same format transmitted,
  2054. Xsee ``Standard for the Interchange of USENET Messages''
  2055. X(RFC 1036 nee 850)
  2056. Xfor a full description.
  2057. XThe following headers are among those recognized:
  2058. X.LP
  2059. X.Is
  2060. X.B From:
  2061. X.IB user @ "host.domain[.domain ...]" " ("
  2062. X.IB "Full Name" )
  2063. X.br
  2064. X.B Newsgroups:
  2065. X.I "news groups"
  2066. X.br
  2067. X.B Message-ID:
  2068. X.BI < "Unique RFC822 message-id" >
  2069. X.br
  2070. X.B Subject:
  2071. X.I descriptive title
  2072. X.br
  2073. X.B Date:
  2074. X.I date posted
  2075. X.br
  2076. X.B Expires:
  2077. X.I expiration date
  2078. X.br
  2079. X.B Reply-To:
  2080. X.I address for mail replies
  2081. X.br
  2082. X.B References:
  2083. X.IR "Message-ID of article this is a follow-up to" .
  2084. X.br
  2085. X.B Control:
  2086. X.I text of a control message
  2087. X.Ie
  2088. X.LP
  2089. XHere is an example of an article:
  2090. X.Es
  2091. XPath: att!eagle!jerry
  2092. XFrom: jerry@eagle.uucp (Jerry Schwarz)
  2093. XNewsgroups: news.announce
  2094. XSubject: Usenet Etiquette -- Please Read
  2095. XMessage-ID: <642@eagle.UUCP>
  2096. XDate: Friday, 19 Nov 82 16:14:55 EST
  2097. XFollowup-To: news.misc
  2098. XExpires: Saturday, 1 Jan 83 00:00:00 EST
  2099. XOrganization: Bell Labs, Murray Hill
  2100. X
  2101. XThe body of the article comes here, after a blank line.
  2102. X.Ee
  2103. XA
  2104. X.I "news batch"
  2105. Xconsists of zero or more articles,
  2106. Xeach preceded by a line of the form
  2107. X.Es
  2108. X.BI "#! rnews" " byte-count"
  2109. X.Ee
  2110. Xwhere
  2111. X.I byte-count
  2112. Xis the number of bytes in the following article,
  2113. Xwhere each newline is counted as a single byte,
  2114. Xeven if it is stored as a CR-LF or
  2115. Xsome other representation.
  2116. XSpaces are significant:
  2117. Xone before and one after
  2118. X.BR rnews .
  2119. XNews batches are usually transmitted
  2120. X.IR compress ed.
  2121. X.LP
  2122. XVarious peculiar optional encapsulations of news batches exist
  2123. Xwhich consist of doing something to the
  2124. X(probably compressed)
  2125. Xbatch,
  2126. Xthen prepending a
  2127. X.BI #! " goo"
  2128. Xline to the output,
  2129. Xwhere
  2130. X.I goo
  2131. Xreflects the form of encapsulation;
  2132. Xknown values of
  2133. X.I goo
  2134. Xinclude
  2135. X.B cunbatch
  2136. X(the null encapsulation),
  2137. Xand
  2138. X.B c7unbatch
  2139. X(encode the batch using only seven bits per character).
  2140. X.LP
  2141. XThe
  2142. X.I sys
  2143. Xfile line has four fields,
  2144. Xeach separated by colons:
  2145. X.LP
  2146. X.IB system-name / exclusion1 ,\c
  2147. X.IB exclusion2... : subscriptions /\c
  2148. X.IB distributions :\c
  2149. X.IB flags : "transmission command"
  2150. X.PP
  2151. XA
  2152. X.B #
  2153. Xas the first character in a line denotes a comment.
  2154. XBlank lines are ignored.
  2155. XA logical line may be continued to the next physical line by
  2156. Xputting a
  2157. X.B \e
  2158. Xat the end of the line.
  2159. X.PP
  2160. XOf the \fIsys\fR fields,
  2161. Xonly the
  2162. X.I system-name
  2163. Xneed be present.
  2164. XIf a field and all the fields after it are omitted,
  2165. Xthe colon immediately before that field and all the colons
  2166. Xafter it may be omitted too.
  2167. XThe optional subfields
  2168. X(\c
  2169. X.IR exclusion s
  2170. Xand
  2171. X.IR distributions )
  2172. Xand their leading slashes
  2173. Xmay be omitted.
  2174. X.PP
  2175. XThe
  2176. X.I system name
  2177. Xis the name of the system being sent to,
  2178. Xand
  2179. Xis checked against site names in
  2180. X.B Path:
  2181. Xheaders to avoid sending an article back
  2182. Xto a site that has seen it.
  2183. XThe special name
  2184. X.B ME
  2185. Xstands for the name of the machine news is running on,
  2186. Xas determined by some operating-system dependent means
  2187. Xsuch as
  2188. X.IR hostname (2)
  2189. Xor
  2190. X.IR uname (2).
  2191. XThe
  2192. X.IR exclusion s
  2193. Xare also checked against the
  2194. X.B Path:
  2195. Xheader and articles are not sent to
  2196. X.I system name
  2197. Xif they have visited any of the
  2198. X.IR exclusions .
  2199. X.PP
  2200. XThe
  2201. X.I subscriptions
  2202. Xis the list of newsgroups to be transmitted to the
  2203. X.IR system
  2204. X(or received if
  2205. X.I system
  2206. Xis the current site);
  2207. Xthey are matched against the
  2208. X.B Newsgroups:
  2209. Xheader of each article
  2210. Xand any matching articles are transmitted:
  2211. X.B all
  2212. Xmatches any single word,
  2213. Xstopping at periods and commas;
  2214. X.B comp
  2215. Xalso implies
  2216. X.BR comp.all ,
  2217. Xrecursively;
  2218. X.B !talk
  2219. X.I mismatches
  2220. Xall the
  2221. X.B talk
  2222. Xgroups;
  2223. Xorder is unimportant;
  2224. X.B comp,comp.sys.sun,!comp.sys
  2225. Xmatches all the
  2226. X.B comp
  2227. Xgroups,
  2228. X.I except
  2229. Xthe
  2230. X.B comp.sys
  2231. Xgroups
  2232. X.I "but including"
  2233. X.BR comp.sys.sun .
  2234. XThe
  2235. X.I distributions
  2236. Xare matched similarly with the
  2237. X.B Distribution:
  2238. Xheader,
  2239. Xbut only when sending articles;
  2240. X.I distributions
  2241. Xdo not affect receipt of articles.
  2242. XIf no
  2243. X.I distributions
  2244. Xare supplied,
  2245. Xthe
  2246. X.I subscriptions
  2247. Xwill be matched against
  2248. X.B Distribution:
  2249. Xinstead.
  2250. X.PP
  2251. XThe
  2252. X.I flags
  2253. Xare a set of letters describing how the article should be transmitted.
  2254. XValid flags include
  2255. X.B f
  2256. X(interpret
  2257. X.I "transmission command"
  2258. Xas a file name and write the name and size in bytes of each
  2259. Xarticle on the end of it),
  2260. X.B F
  2261. X(like
  2262. X.B f
  2263. Xbut omit the size),
  2264. X.B I
  2265. X(like
  2266. X.B F
  2267. Xbut write Message-ID:s instead of filenames),
  2268. X.B n
  2269. X(like
  2270. X.B F
  2271. Xbut write a Message-ID: after each filename),
  2272. X.BI L n
  2273. X(only send articles
  2274. Xgenerated within
  2275. X.I n
  2276. Xhops of here;
  2277. X0 is the default value for
  2278. X.IR n ),
  2279. X.B m
  2280. X(transmit only moderated groups),
  2281. X.B u
  2282. X(transmit only unmoderated groups).
  2283. XThere are other obsolete ones.
  2284. X.LP
  2285. XThe
  2286. X.I transmission command
  2287. Xis executed by the shell with the article
  2288. Xto be transmitted as the standard input.
  2289. XThe default is
  2290. X.RI "`uux \- \-z \-r " sysname !rnews'
  2291. Xfor a command;
  2292. Xthe PATH searched includes \*b/relay,
  2293. Xso that the commands described in \fInewsmail\fR(8)
  2294. Xare available as alternatives to \fIuux\fR.
  2295. XIf one of the \fIflags\fR has caused
  2296. Xthis field to be taken as a filename,
  2297. Xthe default is
  2298. X.RI \*a/out.going/ sysname /togo;
  2299. Xif a filename is given but it does not start with `/', it is assumed
  2300. Xto be relative to the
  2301. X\*a/out.going
  2302. Xdirectory.
  2303. X.LP
  2304. XSome examples:
  2305. X.Es
  2306. X# line indicating what we are willing to receive; note local groups on end
  2307. XME:comp,news,sci,rec,misc,soc,talk,to,can,ont,tor,ut
  2308. X
  2309. X# sample insignificant feed not using batching
  2310. Xhuey:news.config,to.huey/all::uux - -r -gd huey!rnews
  2311. X
  2312. X# sample major batched feed, including (unnecessary) explicit file name
  2313. Xdewey:comp,news,sci,rec,misc,soc,talk,to.dewey,can,ont,tor,ut/all:f:dewey/togo
  2314. X
  2315. X# sample long-haul feed; note no local groups
  2316. Xdonald:comp,news,sci,rec,misc,soc,talk,to.donald/all:f:
  2317. X
  2318. X# sample local-postings-only feed direct to major site (gets them out fast)
  2319. Xscrooge:comp,news,sci,rec,misc,soc,talk,to.scrooge/all:Lf:
  2320. X
  2321. X# sample ihave/sendme link
  2322. X# Send ihave telling louie what we have -- batcher turns the batch into a
  2323. X# giant control message and posts it to "to.louie".  (#1)
  2324. Xlouie:rec.music.synth/all,!sendme,!ihave:I:louie.ihave/togo
  2325. X# Send sendme in response to ihave from louie -- again, turned by batcher
  2326. X# into giant control message posted to "to.louie".  (#3)
  2327. Xlouie-send-ids:to.louie/ihave:I:louie.sendme/togo
  2328. X# Transmit said giant control messages by normal batching.  (#2,#4)
  2329. Xlouie-ctl:to.louie/all,!sendme,!ihave:f:louie/togo
  2330. X# Send articles in response to sendme messages from louie. (#5)
  2331. Xlouie-real:to.louie/sendme:f:louie/togo
  2332. X# Actually the last two could be combined.
  2333. X.Ee
  2334. X(The ``to.\fIsysname\fR'' groups are normal newsgroups used for testing
  2335. Xindividual news feeds.)
  2336. X.PP
  2337. XSomewhere in the
  2338. X.I sys
  2339. Xfile,
  2340. Xthere must be a line for the host system.
  2341. XThis line has no
  2342. X.IR flags " or " commands .
  2343. X.LP
  2344. XThe
  2345. X.I active
  2346. Xfile contains one line per
  2347. Xlocally-valid news group.
  2348. XEach line consists of four blank-separated fields:
  2349. Xnewsgroup name,
  2350. Xhighest local article number assigned,
  2351. Xlowest local article number in use (approximately),
  2352. Xand
  2353. Xa flag.
  2354. XBoth article-number fields are at least five digits wide.
  2355. X(Some older news software may expect exactly five digits.)
  2356. XThe current flag values are
  2357. X.B y
  2358. X(a normal unmoderated group),
  2359. X.B n
  2360. X(like
  2361. X.B y
  2362. Xbut local postings disallowed),
  2363. X.B m
  2364. X(a normal moderated group),
  2365. X.B x
  2366. X(a locally-disabled group,
  2367. Xno articles will be filed here),
  2368. Xand
  2369. X.B =
  2370. X(followed by the real group
  2371. Xunder which to file articles in this group;
  2372. Xarticles are treated exactly as if their
  2373. X.B Newsgroups:
  2374. Xheader specified the real group instead of the original one;
  2375. Xhighest and lowest fields are ignored).
  2376. XAn example:
  2377. X.Es
  2378. Xcomp.org.usrgroup 0000000006 00004 y
  2379. Xtalk.bizarre 0000296123 292136 n
  2380. Xcomp.sys.sun 0000000175 00173 m
  2381. Xlist.sun-spots 0000000076 00076 =comp.sys.sun
  2382. Xcomp.os.vms 0000000000 00000 x
  2383. X.Ee
  2384. XThe
  2385. X.I history
  2386. Xfile contains one line for each article received.
  2387. XEach line consists of three tab-separated fields:
  2388. Xa
  2389. X.IR Message-ID: ,
  2390. Xthe arrival time as seconds since midnight,
  2391. XJan 1, 1970
  2392. Xand
  2393. Xthe
  2394. X.B Expires:
  2395. Xvalue
  2396. X(a dash indicates there was none)
  2397. Xseparated by a tilde,
  2398. Xand
  2399. Xthe list of links to this article.
  2400. XIf an article has been expired or cancelled without being seen first,
  2401. Xthe list of links and the tab before it are omitted.
  2402. XAn example:
  2403. X.Es
  2404. X<3451@hcr.UUCP>    581905588~-    comp.text/1317 comp.sources.wanted/4200
  2405. X<9383@alice.UUCP>    611934511~-
  2406. X.Ee
  2407. X.SH SEE ALSO
  2408. X.IR checknews (1),
  2409. X.IR compress (1),
  2410. X.IR inews (1),
  2411. X.IR postnews (1),
  2412. X.IR readnews (1),
  2413. X.IR rn (1),
  2414. X.IR vnews (1),
  2415. X.IR getdate (3),
  2416. X.IR expire (8),
  2417. X.IR newsbatch (8),
  2418. X.IR newsmail (8),
  2419. X.IR relaynews (8),
  2420. X.IR recnews (8),
  2421. X.IR rnews (8),
  2422. X.IR sendnews (8),
  2423. X.IR uurec (8),
  2424. X.IR newsinvaders (9.1)
  2425. X.br
  2426. XARPA Internet RFCs 1036 and 850
  2427. X.SH BUGS
  2428. XB format articles must not start with
  2429. X.BR A ,
  2430. Xto distinguish them from
  2431. X.B A
  2432. Xformat,
  2433. Xwhich is only a problem if moderators put
  2434. X.B Approved:
  2435. Xfirst.
  2436. X.br
  2437. X.B Control:
  2438. Xand
  2439. X.B Newsgroups:
  2440. Xare not required to be the first headers,
  2441. Xif present.
  2442. X.br
  2443. XPeople insist on making their whacko local encapsulation schemes
  2444. X.RB ( cunbatch ,
  2445. Xetc.)
  2446. X.IR rnews 's
  2447. Xproblem.
  2448. X.br
  2449. XOne could argue that RFC 822
  2450. Xis less than an ideal base for article format.
  2451. !
  2452. echo done
  2453.  
  2454.  
  2455.