dal (03/04/83)
Here is an awk program that will take input produced by "readnews -p" and write out commands to nroff to produce something that is reminiscent of a regular (you know, the old style hardcopy kind) newspaper. It has a newspaper-like heading, four column output, title and by-line for each article, and also gives the city of origin and posting date. It really is useless, but I thought some news junkies out there might get a kick out of it. There are some other files that go along with it. One is a list of usenet sites and cities. It is not complete, but then again no list of usenet sites is ever complete. Most sites are listed, and, of those, most have cities associated with them. Also included is a program that allows the multi-column stuff to work on the line printer. Nroff seems to require a device which can move the paper in both directions. Ours doesn't do that so I wrote a small program to buffer up a page at a time and put the characters in the right places. This program turns out to be useful for tbl output also. In order for it to work, an nroff device table needs to be installed which will send the right characters for doing reverse linefeeds -- this is also included. Finally, there is a file which contains the newspaper-like heading. Here is a list of the files and what they are. Some of them have lines longer than 80 characters -- I hope they get to your site intact! newsprint.awk program to format "readnews -p" output for processing by nroff (using -me macros) cities list of most usenet sites and the city in which they are located lpbuf.c program to buffer up multi-column and tbl output for the line printer tablpr.c nroff driver table which goes along with lpbuf. Must be put in /usr/src/cmd/troff/term and installed via makefile heading used by nroff to make newspaper heading The way to use this thing is first put the news into a file by typing readnews -p > newspaper This is necessary since the cities file must be pre-pended to the news, and is just as well since if something gets messed up you can always go back and see what it said. Then, cat the cities file and news file just created and pipe it through awk, nroff and lpbuf to the line printer. The following command will work: cat -s cities newspaper | awk -f newsprint.awk | nroff -me -Tlpr | lpbuf | lpr Then sit back, drink a cup of coffee, and imagine you're back in the good old days. When you finish your coffee, the thing will probably just be beginning to print! :-) Actually, some of this stuff might even be useful. I extracted the part that figures out the author of the articles and found that in the last two weeks of February, there were articles submitted by 364 different authors. The top 10 were: 12 guy rlgvax!guy 12 Adam L. Buchsbaum alice!alb 9 silver csu-cs!silver 7 M Terribile hou5e!mat 7 Floyd Miller burdvax!floyd 6 berry zinfandel!berry 6 Wm Leler unc!wm 6 Wayne Christopher ucbvax!faustus 6 Lady Arwen sdccsu3!iy47ab 6 Andrew Koenig rabbit!ark Guy and Adam each averaged about an article a day. Keep those keyboards hot, folks! The awk program tries to make some sense out of the mass (mess?) of different formats in 2.9 news. It attempts to remove notesfile headers by deleting lines that start with "#" and the two lines that follow. Needless to say, it can be fooled. Stuff with source code in it looks really far out, and, of course, something that is already formatted won't look quite the same. Droodles don't make it either. It really does best with the discussion groups, but don't overdo it -- you'll find yourself wasting too much paper. (I recycle mine...I give it to my father who uses the back of the sheet for drawing.) Enjoy! Dan Lorenzini philabs!dal ---------------------------------------------------------------------------- File: newsprint.awk You will have to change localsite to your site name and columnwidth if necessary. --------------------- BEGIN { noteskip = 0 cities = 1 columnwidth = 26 localsite = "philabs" group = "abcdefg" print ".ll 11.5i" print ".tp" print ".he '\*(dw'The Network News'%'" print ".nf" print ".so heading" print ".fi" print ".hl" print ".ce" print "\*(dw, \*(td" print ".hl" print ".2c +0 4" } /CITIES/,/ENDCITIES/ { if (NF < 2) s = "Erewhon" else { s = $2 for ( i=3 ; i <= NF ; ++i ) s = s " " $i } city[$1]=s } $1 == ENDCITIES { cities = 0 } $1 == "From" { hops = split($2,source,"!") sourceid = source[hops] if (hops > 1) if ( split(sourceid,sourcefields,".") > 1 ) { authorid = sourcefields[1] x = split(sourcefields[2],sourcesite,"@") site = sourcesite[1] handle = authorid "@" site } else if ( split(sourceid,sourcefields,"@") > 1 ) { authorid = sourcefields[1] x = split(sourcefields[2],sourcesite,"@") site = sourcesite[1] handle = authorid "@" site } else { site = source[hops-1] authorid = source[hops] handle = site "!" authorid } else { site = localsite authorid = source[hops] handle = authorid } if (substr($3,1,1) == "(") { i = 3 while (substr($i,length($i),1) != ")" ) i++ weekday = $(i+1) month = $(i+2) day = $(i+3) namestart = index($0,"(") namend = index($0,")") author = substr($0,namestart+1,namend-namestart-1) } else { weekday = $3 month = $4 day = $5 author = authorid } } $1 == "Subject:" { title = substr($0,10,80) } $1 == "Newsgroups:" { print ".hl" if (index($2,group) == 0) { print ".ce" x = split($2,groups,",") group = groups[1] print group print ".hl" } print ".(b I F" print title print ".)b" print ".ce 2" print "by",author print "(" handle ")" print ".sp" print city[site] ",",weekday,month,day,"-- " } $1 != "From" && $1 != "Subject:" && $1 != "Newsgroups:" && substr($0,1,1) != "#" && noteskip == 0 && cities == 0 && $1 != ENDCITIES { if ( NF != 0 ) { for (i = 1; i <= NF; ++i) printf "%s ", $i printf "\n" } } NF == 0 { printf "\n" } substr($0,1,1) == "#" { noteskip = 1 nscount = 1 } noteskip == 1 { ++nscount if (nscount == 3) noteskip = 0 } ---------------------------------------------------------------------------- File: cities -------------- CITIES 5941ux Holmdel, NJ IM60 Enschede, Netherlands acf2 New York City, NY adec23 Saskatoon, Saskatchewan, Canada adiron Rome, NY alberta Edmonton, Alberta, Canada alice Murray Hill, NJ allegra Murray Hill, NJ altos86 San Jose, CA aluxz Allentown, PA amd70 Santa Clara, CA ariel Holmdel, NJ arizona Tucson, AZ atd Redwood City, CA avsdF Redwood City, CA avsdS Redwood City, CA avsdT Redwood City, CA az70 Tucson, AZ bpa Philadelphia, PA brl-bmd MD bronze Beaverton, OR brunix Providence, RI bunker Trumbull, CT burdvax Paoli, PA burl Burlington, NC bwkna Murray Hill, NJ cbosg Columbus, OH cbosgd Columbus, OH cca Cambridge, MA cdi Beaverton, OR cfiB Newton, MA cg-d Wilmington, MA chico Whippany, NJ cincy Cincinnati, OH cires Boulder, CO cmcl1 New York City, NY cmcl2 New York City, NY cornell Ithaca, NY crystal csin Cambridge, MA csu-cs Ft. Collins, CO cubs45 New York City, NY cwruecmp Cleveland, OH cwrunix Cleveland, OH dadla Beaverton, OR dadla-a Beaverton, OR dadla-b Beaverton, OR dadla-d Beaverton, OR dcdwest San Diego, CA dciem Downsview, Ontario, Canada decvax Merrimack, NH decwrl Los Altos, CA deimos Holmdel, NJ desoto Piscataway, NJ druxa Northglenn, CO druxb Northglenn, CO druxc Northglenn, CO druxd Northglenn, CO druxe Northglenn, CO druxh Northglenn, CO druxi Northglenn, CO druxj Northglenn, CO druxk Northglenn, CO druxl Northglenn, CO druxm Northglenn, CO druxn Northglenn, CO druxo Northglenn, CO druxp Northglenn, CO druxq Northglenn, CO druxr Northglenn, CO druxs Northglenn, CO druxt Northglenn, CO druxu Northglenn, CO druxv Northglenn, CO druxw Northglenn, CO druxx Northglenn, CO druxy Northglenn, CO druxz Northglenn, CO dsd Redwood City, CA duke Durham, NC dutesta dvlcn Saskatoon, Saskatchewan, Canada eagle Murray Hill, NJ ecn-ed West Lafayette, IN ecn-pa West Lafayette, IN ecn-pb West Lafayette, IN ecs Research Triangle Park, NC edee Edinburgh, U.K. edee60 Edinburgh, U.K. eiss Piscataway, NJ eisx Piscataway, NJ esquire New York City, NY floyd Whippany, NJ fluke Everett, WA fortune San Carlos, CA genradbolton Bolton, MA genradbo Bolton, MA gi Chandler, AZ grkermit Concord, MA gsp86 Santa Clara, CA hao Boulder, CO harpo Whippany, NJ hcr Toronto, Ontario, Canada hlexa Short Hills, NJ hocda NJ hocsb Holmdel NJ hocsd Holmdel NJ hocse Holmdel NJ hocsf Holmdel NJ hocsg Holmdel NJ hocsj Holmdel NJ hocsk Holmdel NJ hogpc Holmdel, NJ hoh-2 Murray Hill, NJ hou5a Holmdel, NJ hou5b Holmdel, NJ hou5c Holmdel, NJ hou5d Holmdel, NJ hou5e Holmdel, NJ hou5f Holmdel, NJ houca Holmdel, NJ hound Holmdel, NJ houti Holmdel, NJ houxa Holmdel, NJ houxb Holmdel, NJ houxc Holmdel, NJ houxd Holmdel, NJ houxe Holmdel, NJ houxf Holmdel, NJ houxg Holmdel, NJ houxh Holmdel, NJ houxi Holmdel, NJ houxj Holmdel, NJ houxk Holmdel, NJ houxm Holmdel, NJ houxn Holmdel, NJ houxo Holmdel, NJ houxp Holmdel, NJ houxq Holmdel, NJ houxr Holmdel, NJ houxs Holmdel, NJ houxt Holmdel, NJ houxv Holmdel, NJ houxw Holmdel, NJ houxy Holmdel, NJ houxz Holmdel, NJ hp-cvd Corvallis, OR hp-pcd Corvallis, OR hpda CA hpda2 CA hpda3 CA hplabs Palo Alto, CA hplabsb Palo Alto, CA hplabsc Palo Alto, CA hpuxa South Plainfield, NJ hssg40 Saskatoon, Saskatchewan, Canada icalqa CA ico Estes Park, CO iddic Wilsonville, OR idis Pittsburgh, PA ih1ap Naperville, IL ih4ep Naperville, IL iham1 Naperville, IL iheds Naperville, IL ihhfl Naperville, IL ihima Naperville, IL ihldt Naperville, IL ihlpb Naperville, IL ihlts Naperville, IL ihn5i Naperville, IL ihnet Naperville, IL ihnp1 Naperville, IL ihnp4 Naperville, IL ihnss Naperville, IL ihpad Naperville, IL ihps1 Naperville, IL ihps2 Naperville, IL ihps3 Naperville, IL ihps4 Naperville, IL ihtnt Naperville, IL ihtpa Naperville, IL ihuxa Naperville, IL ihuxb Naperville, IL ihuxc Naperville, IL ihuxd Naperville, IL ihuxe Naperville, IL ihuxf Naperville, IL ihuxg Naperville, IL ihuxh Naperville, IL ihuxi Naperville, IL ihuxj Naperville, IL ihuxk Naperville, IL ihuxl Naperville, IL ihuxm Naperville, IL ihuxn Naperville, IL ihuxo Naperville, IL ihuxp Naperville, IL ihuxq Naperville, IL ihuxr Naperville, IL ihuxs Naperville, IL ihuxt Naperville, IL ihuxu Naperville, IL ihuxv Naperville, IL ihuxw Naperville, IL ihuxx Naperville, IL ihwld Naperville, IL ikogsmb Amsterdam, Netherlands ikonas Raleigh, NC ima Cambridge, MA images Woburn, MA imd Gaithersburg, MD inmet Cambridge, MA intelqa Santa Clara, CA inuxa Indianapolis, IN inuxb Indianapolis, IN inuxc Indianapolis, IN inuxd Indianapolis, IN ipa Palo Alto, CA ism750 Santa Monica, CA ism780 Santa Monica, CA isrnix Bloomington, IN ittapp Corinth, MS ittvax Stratford, CT iuvax Bloomington, IN iwlc6 Naperville, IL iwlc7 Naperville, IL iwlc8 Naperville, IL iwsl1 Naperville, IL iwsl2 Naperville, IL iwsl3 Naperville, IL iwsl4 Naperville, IL iwsl5 Naperville, IL iwsl6 Naperville, IL ixlpa Naperville, IL ixlpc Naperville, IL ixn5c Naperville, IL ixn5d Naperville, IL ixn5e Naperville, IL ixn5h Naperville, IL ixn5k Naperville, IL kirk Corvallis, OR kpno Tucson, AZ laidbak Westmont, IL lanl-a Los Alamos, NM lime Holmdel, NJ linus Bedford, MA ll1 Chicago, IL machaids Holmdel, NJ maxvax Holmdel, NJ mb2b Southfield, MI mcnc Research Triangle Park, NC mcvax Amsterdam, Netherlands medman Cleveland, OH megatest Santa Clara, CA menlo70 Menlo Park, CA metheus Hillsboro, OR mh3bs Murray Hill, NJ mhb5c Murray Hill, NJ mhtsa Murray Hill, NJ mhuxa Murray Hill, NJ mhuxd Murray Hill, NJ mhuxh Murray Hill, NJ mhuxi Murray Hill, NJ mhuxj Murray Hill, NJ mhuxm Murray Hill, NJ mhuxt Murray Hill, NJ mhuxv Murray Hill, NJ mi-cec Pittsburgh, PA micomvax Montreal, Quebec, Canada microsoft Belleview, WA microsof Belleview, WA minn-ua Lauderdale, MN mit-vax Cambridge, MA mitccc Cambridge, MA mork-cb Columbus, OH mprvaxa Burnaby, British Columbia, Canada msdc Atlanta, GA n44a Boston, MA nmtvax Socorro, NM regi Canterbury, U.K. uofm-hfh Detroit, MI rlgvax Reston, VA nbires Boulder, CO psupdp1 raven NJ ncrday Dayton, OH ncsu Raleigh, NC nlgvax Geldrop, Netherlands noscvax San Diego, CA npois Holmdel, NJ npoiv NJ nsc Sunnyvale CA nscs Columbus, OH nwuxc Lisle, IL nybca NY nybcb New York City, NY oberon Holmdel, NJ odin Holmdel, NJ ogcvax OR omsvax Hillsboro, OR orion Holmdel, NJ orstcs Corvallis, OR osu-dbs Columbus, OH otuxa Oakbrook Terrace, IL p500vax CA pegasus Holmdel, NJ peri Bohemia, NY philabs Briarcliff Manor, NY phonlab La Jolla, CA phs Durham, NC pitt Pittsburgh, PA pmds Eindhoven, Netherlands populi Berkeley, CA presby Philadelphia, PA princeton Princeton, NJ psi Salt Lake City, UT psuvax University Park, PA pucc-h West Lafayette, IN pucc-i West Lafayette, IN pur-ee West Lafayette, IN pur-phy West Lafayette, IN purdue West Lafayette, IN pwa-b Hartford, CT pyuxbb Piscataway, NJ pyuxcc Piscataway, NJ pyuxdd Piscataway, NJ pyuxjj Piscataway, NJ pyuxk Piscatawa, NJ pyuxl Piscatawa, NJ pyuxll Piscataway, NJ pyuxmm Piscataway, NJ pyuxss Piscatawa, NJ pyuxvv Piscataway, NJ qumix San Jose, CA rabbit Murray Hill, NJ reed Portland, OR research Murray Hill, NJ riv570 Bilthoven, Netherlands rmas70 Columbus, OH rochester Rochester, NY rocheste Rochester, NY rocksvax Rochester, NY rti hptabu Cupertino, CA bmcg San Diego, CA diku Copenhagen, Denmark ibt Copenhagen, Denmark trsvax Ft. Worth, TX parsec Richardson, TX tpsa Holmdel, NJ rocky2 New York City, NY sara70 Amsterdam, Netherlands sask Saskatoon, Saskatchewan, Canada sb1 Atlanta, GA sb6 Atlanta, GA sbcs Stony Brook, NY scbhq sdcarl La Jolla, CA sdcatta La Jolla, CA sdcattb La Jolla, CA sdccsu3 La Jolla, CA sdchema La Jolla, CA sdcsla La Jolla, CA sdcsvax La Jolla, CA sdcvax Santa Monica, CA security Bedford, MA seismo Arlington, VA sescent Columbus, OH sfucmpt Burnaby, British Columbia, Canada sii Nashua, NH slinac Saskatoon, Saskatchewan, Canada spanky Holmdel, NJ src-unix Alexandria, VA sri-unix CA ssc-vax WA ssovax Aloha, OR stolaf Northfield, MN sultan Nashua, NH sun Mountain View, CA sytek CA syteka CA tekcad Beaverton, OR tekchips Beaverton, OR tekid Beaverton, OR teklabs Beaverton, OR tekmdp Beaverton, OR tektinker Beaverton, OR tektronix Beaverton, OR tpdcvax Des Plaines, IL trigraph Toronto, Ontario, Canada trw-unix Redondo Beach, CA trwspf Redondo Beach, CA trwspp Redondo Beach, CA tucc Research Triangle Park, NC turtlevax Palo Alto, CA turtleva Palo Alto, CA twg Palo Alto, CA u1100a Piscataway, NJ u1100s Piscataway, NJ ubc-medgen Vancouver, British Columbia, Canada ubc-vision Vancouver, British Columbia, Canada ubc-medg Vancouver, British Columbia, Canada ubc-visi Vancouver, British Columbia, Canada ubvax Santa Clara, CA ucb Berkeley, CA ucbarpa Berkeley, CA ucbcad Berkeley, CA ucbernie Berkeley, CA ucbonyx Berkeley, CA ucbopt Berkeley, CA ucbvax Berkeley, CA ucf-cs Orlando, FL ucsfcgl San Francisco, CA vaxwalle vub Brussels, Belgium zinfandel udrelay DE uf-che Gainesville, FL uicsovax Urbana, IL uiucdcs Urbana, IL uiuceml Champaign, IL ukc Canterbury, U.K. umn-cs MN unc Chapel Hill, NC uniq Batavia, IL unm-ivax Albuquerque, NM uofm-cv Ann Arbor, MI uofp Philadelphia, PA utah-cs Salt Lake City, UT utah-gr Salt Lake City, UT utcsrgv Toronto, Ontario, Canada utcsstat Toronto, Ontario, Canada utzoo Toronto, Ontario, Canada uvacs Charlottesville, VA uvapsy Amsterdam, Netherlands uw-beaver Seattle, WA uw-beave Seattle, WA uw-june Seattle, WA uw-vlsi Seattle, WA uw70 WA uwvax Madison, WI varian Walnut Creek, CA vax1 WA vax135 Holmdel, NJ vax2 WA vortex Culver City, CA vtxa NJ vu44 Amsterdam, Netherlands vu45 Amsterdam, Netherlands vu60 Amsterdam, Netherlands watarts Waterloo, Ontario, Canada watcgl Waterloo, Ontario, Canada watdaisy Waterloo, Ontario, Canada watmath Waterloo, Ontario, Canada wb2 West Long Branch, NJ wbux1 West Long Branch, NJ wbux5 West Long Branch, NJ wdl1 we04-3b Hopewell, NJ we13 Aurora, IL we53 Ballwin, MO web40 Charlotte, NC wheps Whippany, NJ whonxa NJ whuxk NJ whuxlb NJ win Lee's Summitt, MO wivax Tyngsboro, MA wjh12 Cambridge, MA yale-comix New Haven, CT yale-com New Haven, CT zehntel Walnut Creek, CA zeppo Whippany, NJ zps CA ENDCITIES ---------------------------------------------------------------------------- File: lpbuf.c --------------- /* program lpbuf*/ /**/ /* reads standard input and buffers up a full page before*/ /* writing to standard output*/ /**/ /* simulates platen motion as follows:*/ /* right <space>*/ /* left <backspace>*/ /* up <ascii VT (vertical tab)>*/ /* down <linefeed> (goes to beginning of next line)*/ /**/ /* D. Lorenzini philabs!dal*/ #include <stdio.h> #define NROWS 66 #define NCOLUMNS 132 char pagebuf[NROWS][NCOLUMNS]; int row,col; pageinit(){ register i,j; row = 0; col = 0; for(i = 0; i < NROWS; ++i){ for(j = 0; j < NCOLUMNS; ++j){ pagebuf[i][j] = ' '; } } } pagedump(){ register i,j,k; for(i = 0; i < NROWS; ++i){ for(k = NCOLUMNS-1; k >= 0; --k){ if(pagebuf[i][k] != ' '){ break; } } for(j = 0; j <= k; ++j){ putchar(pagebuf[i][j]); } putchar('\n'); } } main(){ register i,c; pageinit(); for(;;){ c = getchar(); if(c == EOF){ pagedump(); break; } else if(c == ' '){ ++col; } else if(c == '\n'){ ++row; if(row == NROWS){ pagedump(); pageinit(); } else{ col = 0; } } else if(c == 013 /* ascii VT*/){ --row; } else if(c == 8 /* ascii backspace*/){ --col; } else{ pagebuf[row][col++] = c; } } } ---------------------------------------------------------------------------- File: tablpr.c ---------------- #define INCH 240 /* Printronix Line Printer VT (013) used for reverse line feed nroff driving tables width and code tables */ struct { int bset; int breset; int Hor; int Vert; int Newline; int Char; int Em; int Halfline; int Adj; char *twinit; char *twrest; char *twnl; char *hlr; char *hlf; char *flr; char *bdon; char *bdoff; char *ploton; char *plotoff; char *up; char *down; char *right; char *left; char *codetab[256-32]; int zzz; } t = { /*bset*/ 0, /*breset*/ 0177420, /*Hor*/ INCH/10, /*Vert*/ INCH/6, /*Newline*/ INCH/6, /*Char*/ INCH/10, /*Em*/ INCH/10, /*Halfline*/ INCH/12, /*Adj*/ INCH/10, /*twinit*/ "", /*twrest*/ "", /*twnl*/ "\n", /*hlr*/ "", /*hlf*/ "", /*flr*/ "\013", /*bdon*/ "", /*bdoff*/ "", /*ploton*/ "", /*plotoff*/ "", /*up*/ "\013", /*down*/ "\n", /*right*/ " ", /*left*/ "\b", /*codetab*/ #include "code.300" ---------------------------------------------------------------------------- File: heading --------------- ----------------- /---\\ | | ---\\ \\ | ---\\ /---\\ | | --- --- | / \\ | ---\\ | | --\\ Weather: sunny, | "All The News | | | | | |\\ | | | | | | | | | | / |\\ | | | | | cloudy, windy, | That Fits On | | |--| |-- | \\ | |--| | | ^ | | | |-- |\\ | \\ | |-- | ^ | -- snow, rain. More | The Printer!" | | | | | | \\| | | |/ \\| | | | \\ | \\ | \\| | |/ \\| | weather expected ----------------- | | | ---/ | | ---/ | / \\ --- | \\ | \\ | | ---/ / \\ \\-- tomorrow. ********************************END******************************************