Annotation of 43BSD/contrib/news/misc/bncvt-2-unbatch, revision 1.1.1.1

1.1       root        1: From [email protected] (Carl S. Gutekunst) Wed Oct 30 22:12:27 1985
                      2: Relay-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site seismo.UUCP
                      3: Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site pyramid.UUCP
                      4: Path: seismo!lll-crg!dual!pyramid!csg
                      5: From: [email protected] (Carl S. Gutekunst)
                      6: Newsgroups: net.sources
                      7: Subject: bncvt -- filter bnproc batches to unbatch
                      8: Message-ID: <[email protected]>
                      9: Date: 31 Oct 85 03:12:27 GMT
                     10: Date-Received: 31 Oct 85 12:52:30 GMT
                     11: Reply-To: [email protected] (Carl S. Gutekunst)
                     12: Followup-To: net.sources.bugs
                     13: Organization: Pyramid Technology, Mountain View, CA
                     14: Lines: 104
                     15: Keywords: news bnproc unbatch bncvt
                     16: 
                     17: /*===========================================================================**
                     18: **              BBBBBBB   NN    NN    CCCCC   VV    VV  TTTTTTTT             **
                     19: **              BB    BB  NNN   NN   CC   CC  VV    VV     TT                **
                     20: **              BB    BB  NNNN  NN  CC        VV    VV     TT                **
                     21: **              BBBBBBB   NN NN NN  CC        VV    VV     TT                **
                     22: **              BB    BB  NN  NNNN  CC         VV  VV      TT                **
                     23: **              BB    BB  NN   NNN   CC   CC    VVVV       TT                **
                     24: **              BBBBBBB   NN    NN    CCCCC      VV        TT                **
                     25: **===========================================================================**
                     26: **  Copyright (C) 1985 by PYRAMID TECHNOLOGY CORPORATION, Mountain View, CA  **
                     27: **===========================================================================**
                     28: ** Permission is granted to freely use and distribute this software, as long **
                     29: ** as no attempt is made to profit from it, and this notice is included.     **
                     30: **===========================================================================**
                     31: **
                     32: ** ** bncvt.c -- utility to filter bnproc news batches to unbatch.
                     33: **
                     34: **    Written in a fit of desperation by Carl S. Gutekunst
                     35: **
                     36: ** ** Decsription:
                     37: **
                     38: **     This filter accepts uncompressed news batches in "bnproc" format and
                     39: **     writes them out in "unbatch" format. Using 2.10.3 news, its output can
                     40: **     be piped directly into rnews.
                     41: **
                     42: **     The filter also adjusts for the bnproc "article eater" bug, which threw
                     43: **     off the article byte count and caused rnews to discard entire articles.
                     44: **
                     45: ** ** Execution (for 2.10.3 netnews):
                     46: **
                     47: **     uncompress | bncvt | rnews
                     48: **
                     49: ** ** Generation:
                     50: **
                     51: **     cc bncvt.c -o bncvt -s -O
                     52: **
                     53: ** ** $Log:    bncvt.c,v $
                     54: **     Revision 1.1  85/10/30  19:07:13  csg
                     55: **     Initial version, written in a fit of desperation by Carl S. Gutekunst.
                     56: **     
                     57: **===========================================================================*/
                     58: 
                     59: #include <stdio.h>
                     60: 
                     61: #define LINESIZE 128                   /* Size of the input line buffer     */
                     62: 
                     63: static char RCSid[] = "$Header: bncvt.c,v 1.1 85/10/30 19:07:13 csg Rel $";
                     64: 
                     65: main ()
                     66: {
                     67:    char linebuf[LINESIZE], *lp;                /* Single line buffer, and pointer   */
                     68:    int expected, nbytes;               /* Bytes expected and read so far    */
                     69: 
                     70:    nbytes = expected = 0;
                     71:    while (fgets (linebuf, LINESIZE, stdin) != NULL)
                     72:    {
                     73:       /*
                     74:        * Check for an article eater. This is a DEL character, either 0x7F or
                     75:        * 0xFF, in the first column preceeding a new article byte count. It
                     76:        * usually throws off the byte count, so we have to add some padding
                     77:        * to keep rnews from losing sync (and discarding the next article).
                     78:        */
                     79: 
                     80:       if ((linebuf[0] & 0x7F) == 0x7F)
                     81:       {
                     82:         if (expected > 0)
                     83:            while (nbytes++ < expected)
                     84:               putc ('\0', stdout);
                     85:       }
                     86: 
                     87:       /*
                     88:        * If we aren't expecting text, then we're expecting an article byte
                     89:        * count. This is a left-justified integer, immediately followed by a
                     90:        * newline. We ignore leading article-eater DEL characters.
                     91:        */
                     92: 
                     93:       if (nbytes >= expected)
                     94:       {
                     95:         nbytes = expected = 0;
                     96:         lp = linebuf;
                     97:         while ((*lp & 0x7F) == 0x7F)
                     98:            ++lp;
                     99:         while (*lp >= '0' && *lp <= '9')
                    100:            expected = expected * 10 + (*lp++ - '0');
                    101: 
                    102:         if (*lp == '\n' && expected > 0)
                    103:            printf ("#! rnews %d\n", expected);
                    104:         else
                    105:         {  fprintf (stderr, "Sync->%s", linebuf);
                    106:            expected = 0;
                    107:         }
                    108:       }
                    109: 
                    110:       /*
                    111:        * Another normal line of text: write it out.
                    112:        */
                    113: 
                    114:       else
                    115:       {
                    116:         fputs (linebuf, stdout);
                    117:         nbytes += strlen (linebuf);
                    118:       }
                    119:    }
                    120: }
                    121: 
                    122: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.