send ransom notes for fun and profit
perlman at wanginst.UUCP
perlman at wanginst.UUCP
Wed Mar 11 07:10:44 AEST 1987
Just in time to make your April Fools jokes, another wasteful UNIX
filter: ransom! This program will enhance your text with randomly
assigned troff codes to control fonts, sizes and minor vertical
perturbations. The result is text that doesn't look enough like you
cut words out of the Times and glued them to a sheet to make an
untraceable ransom note. Please do not use this program to commit
crimes, but if you happen to collect some money, I think it would be
fair to send a few percent to me (in unmarked bills).
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
# ransom.1
# ransom.c
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'ransom.1'
then
echo shar: "will not over-write existing file 'ransom.1'"
else
cat << \SHAR_EOF > 'ransom.1'
.TH RANSOM 1 "April 1, 1987" "The Hollow Stump" "UNIX Criminal's Manual"
.SH NAME
ransom \- generate a ransom letter for troff
.SH USAGE
.I ransom
[commands]
.SH DESCRIPTION
.I ransom
reads plain text from the standard input for which it
randomly assigns font, size, and vertical motion control codes
to individual words.
The output should be processed by
.I troff.
The goal is to produce text that looks like it has been
cut out from newspapers and haphazardly glued to a ransom note.
Optionally,
.I troff
commands can be supplied on the command line to aid in the
formatting of the ransom note.
.SH EXAMPLE
The following example makes a fortune look like a ransom note.
It puts the fortune in no-file mode, sets the page offset to one inch,
and spaces one inch before the fun begins.
.ce
fortune | ransom .nf .po1i ".sp 1i" | troff
.SH BUGS
The output is hard to read.
.SH "SEE ALSO
jive(1), valspeak(1), fortune(1) for other wastes of time.
.SH AUTHOR
We need not use any names here.
SHAR_EOF
fi
if test -f 'ransom.c'
then
echo shar: "will not over-write existing file 'ransom.c'"
else
cat << \SHAR_EOF > 'ransom.c'
#include <stdio.h>
#include <ctype.h>
char *Font[] =
{
"R", "I", "B", "R", "I", "B", "R", "I", "B"
};
char Size[] =
{
30, 30, 30, 24, 24, 24, 18, 18, 18
};
#define NFONTS 9 /* max number of fonts */
#define MAXSIZE 30 /* 30 point font */
int Gsize; /* global point size */
char *Gfont = ""; /* global font */
#define moveup(points) (points && printf ("\\v'%dp'", points))
#define tofont(name) (strcmp (Gfont,name) && (Gfont=name) && prfont (Gfont))
#define prfont(name) printf (strlen (name) == 2 ? "\\f(%s" : "\\f%s", name)
#define tosize(points) ((points != Gsize) && printf ("\\s%d", Gsize = points))
typedef int Boole;
#define TRUE 1
#define FALSE 0
letter (ioptr)
FILE *ioptr;
{
int c; /* input character */
int curfont = 0; /* current font */
int vertical = 0; /* vertical motion */
Boole inword = FALSE; /* are we in a word */
Boole change = TRUE; /* do we change font? */
while ((c = getc (ioptr)) != EOF)
{
change = !isalnum (c) || !inword;
inword = isalnum (c);
if (change)
{
change = FALSE;
moveup (-vertical); /* correct previous vertical motion */
vertical = 0;
if (!isspace (c))
{
vertical = rand() % 5 - 3;
moveup (vertical);
curfont = rand() % NFONTS;
}
else if (c == ' ')
curfont = 0;
tosize (Size[curfont]);
tofont (Font[curfont]);
}
putchar (c);
}
}
main (argc, argv) char **argv;
{
int i;
long time ();
srand ((int) time (0));
printf (".vs %dp\n", (MAXSIZE*3)/2); /* set vertical spacing */
for (i = 1; i < argc; i++)
printf ("%s\n", argv[i]);
letter (stdin);
exit (0);
}
SHAR_EOF
fi
exit 0
# End of shell archive
--
Gary Perlman Wang Institute Tyngsboro, MA 01879 (617) 649-9731
UUCP: decvax!wanginst!perlman CSNET: perlman at wanginst
More information about the Comp.sources.unix
mailing list