[net.sources.games] Newspaper Generator

gancarz@decvax.UUCP (07/12/86)

[ All the GNU's, er, news that's unfit to print...]

Over a week ago, I posted a feeler in net.sources.d to find out if
folks would be interested in this.  Since I've received more than
20 "aye's" and not a single "nay", I've decided to post it.

This program prints news stories by combining peoples' names, actions,
times, and places.  The results are often funny, somewhat off-the-wall,
and occasionally downright scandalous.

WARNING: SOME PERSONS MIGHT FIND SOME OF THE STORIES PRINTED BY THE
NEWSPAPER GENERATOR OFFENSIVE.  FEEL FREE TO MODIFY THE PHRASES CONTAINED
WITHIN TO SUIT YOUR PARTICULAR SENSITIVITIES.

I am grateful to the unknown hacker who created the original version of this
program.  His version printed out random "soft-porn" paragraphs.  Some
jokers had a great time with it--they aliased it to the 'more' command
in the secretaries' accounts.

Other notes:
1. Use "cc -O -s newsgen.c -o newsgen" to compile it.
2. Invoke it as 'newsgen' for a single story; 'newsgen lp' prints
   multiple stories.
3. For a real scandal sheet, substitute your local phone list for
   the list of names in the first array.
4. It should be fairly portable code.  Please post any portability problems.
5. A number of extra arrays are included as stubs.  If someone feels
   especially creative, they could expand the printouts considerably.
   Please mail or post any such enhancements.

Finally, neither I nor my employer assume any responsibility for the
suitability of this software for anything.  It is distributed without
malicious intent, and no harm is intended or should be inferred by the
program's output.

Have fun!

Mike Gancarz
DEC Ultrix Engineering Group
decvax!gancarz

============================CUT HERE======================================

/*
 * newsgen.c  --  print random newspaper stories
 */

#include <sys/time.h>
#define printr(p) (putout(ptab[(p)].pptr[(rand()%ptab[(p)].size)]))

char *p0[] = {
	"Jimmy Carter",
	"President Reagan",
	"Prince Charles",
	"Lady Diana",
	"Don Rickles",
	"Lou Grant",
	"Dean Martin",
	"Johnny Carson",
	"Jane Fonda",
	"Bo Derek",
	"Sophia Loren",
	"John Travolta",
	"Barbra Streisand",
	"Wilt Chamberlain",
	"Superman",
	"Batman",
	"Cheryl Ladd",
	"Farrah Fawcett",
	"Burt Reynolds",
	"Jerry Lewis",
	"Richard Pryor",
	"Mary Poppins",
	"Hugh Hefner",
	"Loni Anderson",
	"Queen Elizabeth",
	"Paul McCartney",
	"Ringo Starr",
	"George Harrison",
	"Mick Jagger",
	"Ted Kennedy",
	"Santa Claus",
	"King Kong",
	"Kermit",
	"Miss Piggy",
	"Stevie Wonder",
	"Sugar Ray Leonard",
	"Muhammad Ali",
	"Suzanne Somers",
	"Barney Miller",
	"Snoopy",
	"Charlie Brown",
	"Raquel Welch",
	"Bob Hope",
	"Billy Carter",
	"Robert Redford",
	"Tiny Tim",
	"Richard Nixon",
	"Chesty Morgan",
	"Linda Lovelace",
	"Henry Kissinger",
	"Sylvester Stallone",
	"James Bond",
	"Brigitte Bardot",
	"Phyllis Diller",
	"Clint Eastwood"
};

char *p1[] = {
	" attended a Hugh Hefner slumber party with ",
	" found the perfect 10 in ",
	" sold the Empire State Building for $5000 to ",
	" decided \'Enough was enough!\' and split for California with ",
	" signed up to join the Foreign Legion with ",
	" went snipe hunting with ",
	" was brutually beaten by ",
	" was raped by ",
	" left on an African surfari with ",
	" just completed a bizarre documentary film with ",
	" was murdered by ",
	" was caught trying to rob the Chase Manhattan bank with ",
	" was shot by ",
	" found true love with ",
	" was found in a drunken stupor along with ",
	" filed suit against ",
	" was caught red-handed with ",
	" went for a walk about the town with ",
	" flew down to Antarctica to club penguins with ",
	", in a fit of passion, wedded ",
	" was involved in a skateboard accident with ",
	" reportedly scraped doggie-doo off the shoes of ",
	" was seen shouting obscenities at ",
	" was seen kissing ",
	" went to a gay bar for the first time with ",
	" was found in a very touchy situation with ",
	" made mud pies for ",
	" tried constructing a home-brew nuclear device with ",
	" would rather be dead than alive after what happened with ",
	" danced up a storm at a local disco with ",
	" was seen smoking pot with ",
	" did a belly dance for ",
	" finally went on a hayride with ",
	" mysteriously broke a leg while cross-country skiing with ",
	" is reputed to have burgularized the home of ",
	" threw snowballs filled with rocks at ",
	" climbed the World Trade Center building with "
};
char *p2[] = {
	" early this morning",
	" today",
	" in the wee hours of the morning",
	" shortly after dusk last night",
	" about 4 o'clock this morning",
	" shortly after midnight last night",
	" late this afternoon",
	" early this evening",
	" during the city-wide blackout last night",
	" during yesterday afternoon's rush hour"
};

char *p3[] = {
	"Experts say there was no underlying motive. ",
	"According to recent reports, both enjoyed it immensely. ",
	"Several prominent psychologists are busy looking into their problem. ",
	"Their closest friends were amazed--even shocked--by the incident. ",
	"The authorities have decided not to prosecute them on this one. ",
	"It was quite a surprise for the both of them. ",
	"The entire population of New York City witnessed the incident. ",
	"Both were very fortunate in that they were able to get away with it.  One would have to suppose that that's one of the benefits of being famous. ",
	"The parents of both were on hand to offer needed advice. ",
	"They encountered some difficulty due to a technical malfunction. ",
	"Two construction workers offered to lend a hand in return for a piece of the action. ",
	"Sources say that this is the first in a series of similar occurences. ",
	"Although it may have surprised a few people, most of their close friends knew it was going to happen. ",
	"It was a most enjoyable experience for both of them. ",
	"Those in the know say this could be the big break both have been waiting for. ",
	"It is rumored to have been quite a mistake. ",
	"Both are now recuperating at Boston City Hospital. ",
	"Both claim that they were fully cognizant of their action, although a Cambridge doctor feels that something was lacking. ",
	"Although many might disagree, they felt it was the best time to do it. ",
	"Many rumors are now spreading concerning their relationship in the past. ",
	"Police were standing by, ready to move in at any moment and render assistance. ",
	"There were no witnesses, save for the brother of the latter. "
};

char *p4[] = {
	"'s only regrets are that it didn't happen sooner than it did.",
	" hopes to settle the entire matter out of court.",
	" intends to sue for $1 million in damages.",
	" wishes that everyone would \"bug off and let me live my life the way I want!\".",
	" claimed that it took very little effort at all.",
	" blames it all on a San Bernadino psychotherapist.",
	" feels that this was due to the latter's recent interest in health foods.",
	" was later found wandering through a Brooklyn suburb, apparently suffering from amnesia.",
	" found it difficult to face up to the authorities after that one.",
	" neither denies nor confirms the allegation.",
	" has decided that things went a bit too far.",
	" would like to designate a holiday in honor of the incident.",
	" has concluded that \"people are funny\".",
	", after thinking it over, decided it might have been better to wait until the payoff check had arrived in the mail.",
	" later said, \"It was one of life's greatest moments.\"",
	" would be interested in doing it again.",
	" was later seen running down the street shouting, \"I got the sucker this time!\"",
	" refused to comment on the matter.",
	" has disappeared and is presumed dead.",
	" found the entire matter utterly disgusting.",
	" now walks with a slight limp.",
	" admits involvement in a conspiracy to propagate the incident.",
	" later had said, \"I did the right thing...I think.\"",
	" was later seen in a local restaurant with several persons known to be members of the Mafia.",
	" has tried unsuccessfully to keep the matter confidential.",
	" wants to bring along the Dallas Cowboys next time.",
	" has decided to bring along the Los Angeles Rams Cheerleaders next time.",
	" wants to bring along friends  to \"share the experience\" next time.",
	" has agreed to be more discreet next time.",
	" says it's amazing what something like that can do for your life.",
	" was later prevented from jumping off the Notre Dame bridge in Manchester, N.H.",
	" has explained the incident in great detail to the FBI in the hopes of being let off easy.",
	" denies any statements to the effect that this was due to personal involvement with the Ku Klux Klan and the Moonies.",
	" claims that it was done out of service to humanity.",
	" commented, \"That's the last time I ever get bombed on that rotgut Mexican tequila!\".",
	" says that \"Next time I'll do it right!.\"",
	" admits that it was done in the interest of selfish personal gain.",
	", when asked to comment about it later, said, \"I'll never do that again.\"",
	" just can't seem to get enough.",
	" is going to have a hard time explaining that one.",
	", who had never done such a thing before, swears it'll never happen again.",
	" says that everyone has to learn the facts of life sometime."
};

char *p5[] = {
	"Cold, very cold.  Temperature: absolute zero.",
	"Today: Bright.  Tonight: Dark.  Continuing dark, and turning to widely scattered light in the morning.",
	"Long term forecast:  July 4, sunny.  August 13, cloudy.",
	"Small car warning in effect.  Hail (up to 1300 cm. in diameter) predicted later today.",
	"Snow. Snow. Snow.",
	"Sunny and bright.  Good golfing weather.",
	"Warm.  Temperature: 80.",
	"Hot and dry.  Humidity: 140%",
	"Weatherman gone to the men's room.  Ask for weather later.",
	"Weatherperson gone to lunch.  No weather until he/she returns.",
	"Temperature: 85. No, wait. 90. No, it's rising some more. 100. 120. 130.  ARRGGHH!!",	
	"V e    r y    w  i     n      d  y!        !    !",
	"Datsun warning in effect.  High winds combined with flying objects.",
	"Acid rain.",
	"zzzzz....Huh?  You want the weather?.....zzzzzz",
	"Radio CKCF, Montreal.  Il fait du soleil, aujourdhui.",
	"Raining cats, dogs, bears, and mongooses.",
	"Baby twister expected late this afternoon.  All babies stay home.",
	"Hurricane warning in effect in downtown Weare only.",
	"Emergency routes out of Boston:  Use I93 or US3.",
	"Seattle: rain.  Everywhere else: sunny"
};

char *p6[] = {
	"..P6XX"
};

char *p7[] = {
	"..P7XX"
};

char *p8[] = {
	"..P8XX"
};

char *p9[] = {
	"..P9XX"
};

char *p10[] = {
	"..P10XX"
};

char *p11[] = {
	"..P11XX"
};

char *p12[] = {
	"..P12XX"
};

char *p13[] = {
	"..P13XX"
};

struct tabent {
	char	**pptr;
	int	size;
	char	*cptr;
} ptab[] =	{
	p0, (sizeof p0)/(sizeof (char *)), " ",
	p1, (sizeof p1)/(sizeof (char *)), " ",
	p2, (sizeof p2)/(sizeof (char *)), " the ",
	p3, (sizeof p3)/(sizeof (char *)), " as the ",
	p4, (sizeof p4)/(sizeof (char *)), " ",
	p5, (sizeof p5)/(sizeof (char *)), " ",
	p6, (sizeof p6)/(sizeof (char *)), " ",
	p7, (sizeof p7)/(sizeof (char *)), " ",
	p8, (sizeof p8)/(sizeof (char *)), " ",
	p9, (sizeof p9)/(sizeof (char *)), " ",
	p10, (sizeof p10)/(sizeof (char *)), " ",
	p11, (sizeof p11)/(sizeof (char *)), " ",
	p12, (sizeof p12)/(sizeof (char *)), " ",
	p13, (sizeof p13)/(sizeof (char *)), ".\n"
};


main(argc,argv)
int argc;
char **argv;
{
	register int i, flag;
	char nametmp[25];
	char *lastnam;
	char *index();
	long tbuf, time();

	time(&tbuf);
	srand((int)tbuf);

	if( argc == 1)
		flag = 1;
	else if( (argc == 2) && (argv[1][0] == 'l') && (argv[1][1] == 'p') )
		flag = 2;
	else
	{
		printf("\"news\" or \"news lp\"\n");
		flag = 0;
	}
	while( flag )
	{
		if( flag == 1)
			flag = 0;
		putout(0);
		putend(0);
		printf("\n\n\t\t\tT O D A Y ' S    N E W S\n\n");
		time(&tbuf);
		printf("\t\t\t\t%-10.10s\n\n", ctime(&tbuf));

		printf("THE TOP STORY--\n");
		strcpy(nametmp,(ptab[0].pptr[(rand()%ptab[0].size)]));
		putout(nametmp);
		printr(1);
		printr(0);
		printr(2);
		putout(".  ");
		printr(3);
		lastnam=index(nametmp,' ');
		if(lastnam != 0)
			putout(lastnam);
		else putout(nametmp);
		printr(4);
		putchar('\n');

		printf("\nTHE WEATHER--\n");
		printr(5);
		putchar('\n');
	}
}
putout(optr)
char *optr;
{
	static int cntr;
	register char *wptr;
	if( (int) optr == 0 ) /* Initialization */
		cntr = 0;
	else
	{
		wptr = optr;
		while( *optr != '\0' )
		{
			while( ( *wptr != '\0' ) && ( *wptr != ' ' ) )
			{
				wptr++;
				cntr++;
			}
			if( cntr > 78 )
			{
				cntr = 0;
				while(( *optr == '.' ) || ( *optr == ',' ))
					putend( *optr++ );
				putend('\n');
				if( *optr == '\n' )
					optr++;
				while( *optr == ' ' )
					optr++;
				wptr = optr;
			}
			else
			{
				while( optr < wptr )
					putend( *optr++ );
				wptr++;
				cntr++;
			}
		}
		cntr--; /* Adjustment for end of a group */
	}
}
putend(chr)
int chr;
{
	static int cntr1;
	if( chr == 0 )
		cntr1 = 0;
	else if( chr == ' ' )
		cntr1++;
	else
	{
		while (cntr1--)
			putchar(' ');
		cntr1=0;
		putchar(chr);
	}
}