Initial commit

main
Andrew Hills 2015-06-04 15:07:06 -04:00
commit 0aec050102
22 changed files with 90481 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/datfiles/*.dat
/fortune/fortune
/strfile/strfile

29
LICENSE Normal file
View File

@ -0,0 +1,29 @@
Copyright (c) 1986, 1993
The Regents of the University of California. All rights reserved.
This code is derived from software contributed to Berkeley by
Ken Arnold.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

13
Makefile Normal file
View File

@ -0,0 +1,13 @@
PREFIX ?= /usr/local
SUBDIRS = fortune strfile datfiles
all :
for subdir in $(SUBDIRS); do $(MAKE) -C $$subdir PREFIX=$(PREFIX); done
install : all
for subdir in $(SUBDIRS); do $(MAKE) -C $$subdir DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) install; done
clean :
for subdir in $(SUBDIRS); do $(MAKE) -C $$subdir clean; done

179
Notes Normal file
View File

@ -0,0 +1,179 @@
# $OpenBSD: Notes,v 1.3 2004/09/28 20:40:01 jmc Exp $
# $NetBSD: Notes,v 1.2 1995/03/23 08:28:26 cgd Exp $
# @(#)Notes 8.1 (Berkeley) 5/31/93
Warning:
The fortunes contained in the fortune database have been collected
haphazardly from a cacophony of sources, in number so huge it
boggles the mind. It is impossible to do any meaningful quality
control on attributions, or lack thereof, or exactness of the quote.
Since this database is not used for profit, and since entire works
are not published, it falls under fair use, as we understand it.
However, if any half-assed idiot decides to make a profit off of
this, they will need to double check it all, and nobody not involved
of such an effort makes any warranty that anything in the database
bears any relation to the real world of literature, law, or other
bizzarrity.
==> GENERAL INFORMATION
By default, fortune retrieves its fortune files from the directory
/usr/share/games/fortune. A fortune file has two parts: the source file
(which contains the fortunes themselves) and the data file which describes
the fortunes. The data file always has the same name as the fortune file
with the string ".dat" concatenated, i.e. "fort" is the standard fortune
database, and "fort.dat" is the data file which describes it. See
strfile(8) for more information on creating the data files.
Fortunes are split into potentially offensive and not potentially
offensive parts. The offensive version of a file has the same name as the
non-offensive version with "-o" concatenated, i.e. "fort" is the standard
fortune database, and "fort-o" is the standard offensive database. The
fortune program automatically assumes that any file with a name ending in
"-o" is potentially offensive, and should therefore only be displayed if
explicitly requested, either with the -o option or by specifying a file name
on the command line.
Potentially offensive fortune files should NEVER be maintained in
clear text on the system. They are rotated (see caesar(6)) 13 positions.
To create a new, potentially offensive database, use caesar to rotate it,
and then create its data file with the -x option to strfile(8). The fortune
program automatically decrypts the text when it prints entries from such
databases.
Anything which would not make it onto network prime time programming
(or which would only be broadcast if some discredited kind of guy said it)
MUST be in the potentially offensive database. Fortunes containing any
explicit language (see George Carlin's recent updated list) MUST be in the
potentially offensive database. Political and religious opinions are often
sequestered in the potentially offensive section as well. Anything which
assumes as a world view blatantly racist, mysogynist (sexist), or homophobic
ideas should not be in either, since they are not really funny unless *you*
are racist, mysogynist, or homophobic.
The point of this is that people have should have a reasonable
expectation that, should they just run "fortune", they will not be offended.
We know that some people take offense at anything, but normal people do have
opinions, too, and have a right not to have their sensibilities offended by
a program which is supposed to be entertaining. People who run "fortune
-o" or "fortune -a" are saying, in effect, that they are willing to have
their sensibilities tweaked. However, they should not have their personal
worth seriously (i.e., not in jest) assaulted. Jokes which depend for their
humor on racist, mysogynist, or homophobic stereotypes *do* seriously
assault individual personal worth, and in an general entertainment medium
we should be able to get by without it.
==> FORMATTING
This file describes the format for fortunes in the database. This
is done in detail to make it easier to keep track of things. Any rule given
here may be broken to make a better joke.
[All examples are indented by one tab stop -- KCRCA]
Numbers should be given in parentheses, e.g.,
(1) Everything depends.
(2) Nothing is always.
(3) Everything is sometimes.
Attributions are two tab stops, followed by two hyphens, followed by a
space, followed by the attribution, and are *not* preceded by blank
lines. Book, journal, movie, and all other titles are in quotes, e.g.,
$100 invested at 7% interest for 100 years will become $100,000, at
which time it will be worth absolutely nothing.
-- Lazarus Long, "Time Enough for Love"
Attributions which do not fit on one (72 char) line should be continued
on a line which lines up below the first text of the attribution, e.g.,
-- A very long attribution which might not fit on one
line, "Ken Arnold's Stupid Sayings"
Single paragraph fortunes are in left justified (non-indented) paragraphs
unless they fall into another category listed below (see example above).
Longer fortunes should also be in left justified paragraphs, but if this
makes it too long, try indented paragraphs, with indentations of either one
tab stop or 5 chars. Indentations of less than 5 are too hard to read.
Laws have the title left justified and capitalized, followed by a colon,
with all the text of the law itself indented one tab stop, initially
capitalized, e.g.,
A Law of Computer Programming:
Make it possible for programmers to write in English and
you will find the programmers cannot write in English.
Limericks are indented as follows, all lines capitalized:
A computer, to print out a fact,
Will divide, multiply, and subtract.
But this output can be
No more than debris,
If the input was short of exact.
Accents precede the letter they are over, e.g., "`^He" for e with a grave
accent. Underlining is done on a word-by-word basis, with the underlines
preceding the word, e.g., "__^H^Hhi ____^H^H^H^Hthere".
No fortune should run beyond 72 characters on a single line without good
justification (er, no pun intended). And no right margin justification,
either. Sorry. For BSD people, there is a program called "fmt" which can
make this kind of formatting easier.
Definitions are given with the word or phrase left justified, followed by
the part of speech (if appropriate) and a colon. The definition starts
indented by one tab stop, with subsequent lines left justified, e.g.,
Afternoon, n.:
That part of the day we spend worrying about how we wasted
the morning.
Quotes are sometimes put around statements which are funnier or make more
sense if they are understood as being spoken, rather than written,
communication, e.g.,
"All my friends and I are crazy. That's the only thing that
keeps us sane."
Ellipses are always surrounded by spaces, except when next to punctuation,
and are three dots long.
"... all the modern inconveniences ..."
-- Mark Twain
Human initials always have spaces after the periods, e.g, "P. T. Barnum",
not "P.T. Barnum". However, "P.T.A.", not "P. T. A.".
All fortunes should be attributed, but if and only if they are original with
somebody. Many people have said things that are folk sayings (i.e., are
common among the folk (i.e., us common slobs)). There is nothing wrong with
this, of course, but such statements should not be attributed to individuals
who did not invent them.
Horoscopes should have the sign indented by one tab stop, followed by the
dates of the sign, with the text left justified below it, e.g.,
AQUARIUS (Jan 20 - Feb 18)
You have an inventive mind and are inclined to be progressive. You
lie a great deal. On the other hand, you are inclined to be
careless and impractical, causing you to make the same mistakes over
and over again. People think you are stupid.
Single quotes should not be used except as quotes within quotes. Not even
single quotes masquerading as double quotes are to be used, e.g., don't say
``hi there'' or `hi there' or 'hi there', but "hi there". However, you
*can* say "I said, `hi there'".
A long poem or song can be ordered as follows in order to make it fit on a
screen (fortunes should be 19 lines or less if at all possible) (numbers
here are stanza numbers):
11111111111111111111
11111111111111111111
11111111111111111111 22222222222222222222
11111111111111111111 22222222222222222222
22222222222222222222
33333333333333333333 22222222222222222222
33333333333333333333
33333333333333333333 44444444444444444444
33333333333333333333 44444444444444444444
44444444444444444444
44444444444444444444

21
README.md Normal file
View File

@ -0,0 +1,21 @@
# fortune
This code was torn directly out of OpenBSD 5.7's source package and modified
to build on [Alpine Linux](http://alpinelinux.org) against
[libbsd](http://libbsd.freedesktop.org) 0.7.0. Please see `LICENSE` for
details.
## Differences
The two C source files, `strfile.c` and `fortune.c`, have had
`#include <sys/types.h>` added near the top of the file. Additionally, all of
the `Makefile`s have been replaced to work with GNU Make.
Notably, there is no option to disable "offensive" fortunes. Just erase the
`fortune-o`, `fortune2-o`, and `limerick` files from the `datfiles` directory
and remove the references from `datfiles/Makefile`.
## Known Issues
- [ ] *strfile* fails with a segmentation fault in random mode (the `-r` flag)

41
README.orig Normal file
View File

@ -0,0 +1,41 @@
# $OpenBSD: README,v 1.3 2002/04/02 02:06:25 pjanzen Exp $
# $NetBSD: README,v 1.2 1995/03/23 08:28:29 cgd Exp $
# @(#)README 8.1 (Berkeley) 5/31/93
The potentially offensive fortunes ARE installed by default. To avoid
installing them, whack the Makefile in the subdirectory datfiles, and
do "make all install".
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Some years ago, my neighbor Avery said to me: "There has not been an
adequate jokebook published since "Joe_Miller", which came out in 1739 and
which, incidentally, was the most miserable no-good ... jokebook in the
history of the printed word."
In a subsequent conversation, Avery said: "A funny story is a funny
story, no matter who is in it - whether it's about Catholics or Protestants,
Jews or Gentiles, blacks or whites, browns or yellows. If a story is genuinely
funny it makes no difference how dirty it is. Shout it from the rooftops.
Let the chips fall all over the prairie and let the bonehead wowsers yelp.
... on them."
It is a nice thing to have a neighbor of Avery's grain. He has
believed in the aforestated principles all his life. A great many other
people nowadays are casting aside the pietistic attitude that has led them
to plug up their ears against the facts of life. We of The Brotherhood
believe as Avery believes; we have never been intimidated by the pharisaical
meddlers who have been smelling up the American landscape since the time of
the bundling board. Neither has any one of our members ever been called a
racist. Still, we have been in unremitting revolt against the ignorant
propensity which ordains, in effect, that "The Green Pastures" should never
have been written; the idiot attitude which compelled Arthur Kober to abandon
his delightful Bella Gross, and Octavius Roy Cohen to quit writing about the
splendiferous Florian Slappey; the moronic frame of mind which, if carried
to its logical end, would have forbidden Ring Lardner from writing in the
language of the masses.
-- H. Allen Smith, "Rude Jokes"
... let us keep in mind the basic governing philosophy of The
Brotherhood, as handsomely summarized in these words: we believe in
healthy, hearty laughter -- at the expense of the whole human race, if
needs be.
Needs be.
-- H. Allen Smith, "Rude Jokes"

17
datfiles/Makefile Normal file
View File

@ -0,0 +1,17 @@
SRCS = fortunes fortunes2 startrek zippy recipes fortunes-o limerick fortunes2-o
BLDS = $(addsuffix .dat,$(SRCS))
STRFILE ?= ../strfile/strfile
all : $(BLDS)
install :
mkdir -p $(DESTDIR)$(PREFIX)/share/fortune
install -m0644 $(SRCS) $(BLDS) $(DESTDIR)$(PREFIX)/share/fortune/
# Bug in strfile means we can't use -r
%.dat:%
$(STRFILE) $< $@
clean :
$(RM) *.dat

16211
datfiles/fortunes Normal file

File diff suppressed because it is too large Load Diff

2015
datfiles/fortunes-o Normal file

File diff suppressed because it is too large Load Diff

47274
datfiles/fortunes2 Normal file

File diff suppressed because it is too large Load Diff

15224
datfiles/fortunes2-o Normal file

File diff suppressed because it is too large Load Diff

5138
datfiles/limerick Normal file

File diff suppressed because it is too large Load Diff

46
datfiles/recipes Normal file
View File

@ -0,0 +1,46 @@
Hackathon Moose (or other Ex-Magnificent-Forest-Creature) Barbecue
30 cups oil
15 cups Soy sauce
5 cups Worcestershire Sauce
40 tsp dry mustard
20 tsp black pepper
10 cups lemon juice
10 cups white vinegar
80 cloves crushed garlic
About 75 pounds of boneless meat (moose, deer, elk, beef - try chicken
too). For reference this is roughly an entire large dressed (Alberta
size) whitetail deer, with some moose and beef thrown in for good
measure. I've never tried finding enough chickens for a hackathon.
Mix all of the above together, and marinate meat for a few hours
before grilling. Dribble marinade over meat while grilling. Also
works well with vegetables on the grill, or meat and vegetable
kebabs. The above proportions will require about 50 bell peppers and
25 large onions to make decent kebabs (for a large family meal, divide
everything by about 20, and leave out the drunk Germans providing the
ambience while you grill).
%
Hackathon Raisin Rice
10 cups rice
5 Onions, chopped fine
10 cloves garlic, crushed
Butter
2.5 cups raisins
2.5 tsp oregano
22 cups water
40 chicken bouillon cubes (or equivalent - you want to make double
strength chicken stock - chicken-in-a-mug
works well made double strength).
Saute Rice, onion and garlic in a little butter until slightly brown.
I manage this in the (large) pot(s) necessary by throwing together
the onion, garlic, and butter to brown up, then faking it a bit with
the dry rice thrown in while threatening kitchen interlopers with
sharp instruments if they come in to ask how it's going.
Dissolve bouillon in water, add along with remaining ingredients.
Cook until rice is done (for more intimate proportions, divide down
to an appropriate amount of rice for your occasion).

757
datfiles/startrek Normal file
View File

@ -0,0 +1,757 @@
A father doesn't destroy his children.
-- Lt. Carolyn Palamas, "Who Mourns for Adonais?",
stardate 3468.1.
%
A little suffering is good for the soul.
-- Kirk, "The Corbomite Maneuver", stardate 1514.0
%
A man either lives life as it happens to him, meets it head-on and
licks it, or he turns his back on it and starts to wither away.
-- Dr. Boyce, "The Menagerie" ("The Cage"), stardate unknown
%
A princess should not be afraid -- not with a brave knight to protect
her.
-- McCoy, "Shore Leave", stardate 3025.3
%
A star captain's most solemn oath is that he will give his life, even
his entire crew, rather than violate the Prime Directive.
-- Kirk, "The Omega Glory", stardate unknown
%
A Vulcan can no sooner be disloyal than he can exist without
breathing.
-- Kirk, "The Menagerie", stardate 3012.4
%
A woman should have compassion.
-- Kirk, "Catspaw", stardate 3018.2
%
Actual war is a very messy business. Very, very messy business.
-- Kirk, "A Taste of Armageddon", stardate 3193.0
%
After a time, you may find that "having" is not so pleasing a thing,
after all, as "wanting." It is not logical, but it is often true.
-- Spock, "Amok Time", stardate 3372.7
%
All your people must learn before you can reach for the stars.
-- Kirk, "The Gamesters of Triskelion", stardate 3259.2
%
Another Armenia, Belgium ... the weak innocents who always seem to be
located on a natural invasion route.
-- Kirk, "Errand of Mercy", stardate 3198.4
%
Another dream that failed. There's nothing sadder.
-- Kirk, "This side of Paradise", stardate 3417.3
%
Another war ... must it always be so? How many comrades have we lost
in this way? ... Obedience. Duty. Death, and more death ...
-- Romulan Commander, "Balance of Terror", stardate 1709.2
%
... bacteriological warfare ... hard to believe we were once foolish
enough to play around with that.
-- McCoy, "The Omega Glory", stardate unknown
%
"Beauty is transitory."
"Beauty survives."
-- Spock and Kirk, "That Which Survives", stardate unknown
%
Behind every great man, there is a woman -- urging him on.
-- Harry Mudd, "I, Mudd", stardate 4513.3
%
Blast medicine anyway! We've learned to tie into every organ in the
human body but one. The brain! The brain is what life is all about.
-- McCoy, "The Menagerie", stardate 3012.4
%
But it's real. And if it's real it can be affected ... we may not be
able to break it, but, I'll bet you credits to Navy Beans we can put a
dent in it.
-- deSalle, "Catspaw", stardate 3018.2
%
"Can you imagine how life could be improved if we could do away with
jealousy, greed, hate ..."
"It can also be improved by eliminating love, tenderness, sentiment --
the other side of the coin"
-- Dr. Roger Corby and Kirk, "What are Little Girls Made Of?",
stardate 2712.4
%
Change is the essential process of all existence.
-- Spock, "Let That Be Your Last Battlefield", stardate 5730.2
%
Compassion -- that's the one things no machine ever had. Maybe it's
the one thing that keeps men ahead of them.
-- McCoy, "The Ultimate Computer", stardate 4731.3
%
Computers make excellent and efficient servants, but I have no wish to
serve under them. Captain, a starship also runs on loyalty to one
man. And nothing can replace it or him.
-- Spock, "The Ultimate Computer", stardate 4729.4
%
Conquest is easy. Control is not.
-- Kirk, "Mirror, Mirror", stardate unknown
%
Death, when unnecessary, is a tragic thing.
-- Flint, "Requiem for Methuselah", stardate 5843.7
%
Death. Destruction. Disease. Horror. That's what war is all about.
That's what makes it a thing to be avoided.
-- Kirk, "A Taste of Armageddon", stardate 3193.0
%
Do you know about being with somebody? Wanting to be? If I had the
whole universe, I'd give it to you, Janice. When I see you, I feel
like I'm hungry all over. Do you know how that feels?
-- Charlie Evans, "Charlie X", stardate 1535.8
%
Do you know the one -- "All I ask is a tall ship, and a star to steer
her by ..." You could feel the wind at your back, about you ... the
sounds of the sea beneath you. And even if you take away the wind and
the water, it's still the same. The ship is yours ... you can feel her
... and the stars are still there.
-- Kirk, "The Ultimate Computer", stardate 4729.4
%
[Doctors and Bartenders], We both get the same two kinds of customers
-- the living and the dying.
-- Dr. Boyce, "The Menagerie" ("The Cage"), stardate unknown
%
Each kiss is as the first.
-- Miramanee, Kirk's wife, "The Paradise Syndrome",
stardate 4842.6
%
Earth -- mother of the most beautiful women in the universe.
-- Apollo, "Who Mourns for Adonais?" stardate 3468.1
%
Either one of us, by himself, is expendable. Both of us are not.
-- Kirk, "The Devil in the Dark", stardate 3196.1
%
Emotions are alien to me. I'm a scientist.
-- Spock, "This Side of Paradise", stardate 3417.3
%
Even historians fail to learn from history -- they repeat the same
mistakes.
-- John Gill, "Patterns of Force", stardate 2534.7
%
Every living thing wants to survive.
-- Spock, "The Ultimate Computer", stardate 4731.3
%
"Evil does seek to maintain power by suppressing the truth."
"Or by misleading the innocent."
-- Spock and McCoy, "And The Children Shall Lead",
stardate 5029.5.
%
Extreme feminine beauty is always disturbing.
-- Spock, "The Cloud Minders", stardate 5818.4
%
Fascinating is a word I use for the unexpected.
-- Spock, "The Squire of Gothos", stardate 2124.5
%
Fascinating, a totally parochial attitude.
-- Spock, "Metamorphosis", stardate 3219.8
%
First study the enemy. Seek weakness.
-- Romulan Commander, "Balance of Terror", stardate 1709.2
%
Four thousand throats may be cut in one night by a running man.
-- Klingon Soldier, "Day of the Dove", stardate unknown
%
"... freedom ... is a worship word..."
"It is our worship word too."
-- Cloud William and Kirk, "The Omega Glory", stardate unknown
%
Genius doesn't work on an assembly line basis. You can't simply say,
"Today I will be brilliant."
-- Kirk, "The Ultimate Computer", stardate 4731.3
%
"Get back to your stations!"
"We're beaming down to the planet, sir."
-- Kirk and Mr. Leslie, "This Side of Paradise",
stardate 3417.3
%
He's dead, Jim
-- McCoy, "The Devil in the Dark", stardate 3196.1
%
History tends to exaggerate.
-- Col. Green, "The Savage Curtain", stardate 5906.4
%
Humans do claim a great deal for that particular emotion [love].
-- Spock, "The Lights of Zetar", stardate 5725.6
%
I am pleased to see that we have differences. May we together become
greater than the sum of both of us.
-- Surak of Vulcan, "The Savage Curtain", stardate 5906.4
%
I have never understood the female capacity to avoid a direct answer to
any question.
-- Spock, "This Side of Paradise", stardate 3417.3
%
I object to intellect without discipline; I object to power without
constructive purpose.
-- Spock, "The Squire of Gothos", stardate 2124.5
%
I realize that command does have its fascination, even under
circumstances such as these, but I neither enjoy the idea of command
nor am I frightened of it. It simply exists, and I will do whatever
logically needs to be done.
-- Spock, "The Galileo Seven", stardate 2812.7
%
"I think they're going to take all this money that we spend now on war
and death --"
"And make them spend it on life."
-- Edith Keeler and Kirk, "The City on the Edge of Forever",
stardate unknown.
%
I thought my people would grow tired of killing. But you were right,
they see it is easier than trading. And it has its pleasures. I feel
it myself. Like the hunt, but with richer rewards.
-- Apella, "A Private Little War", stardate 4211.8
%
I'm a soldier, not a diplomat. I can only tell the truth.
-- Kirk, "Errand of Mercy", stardate 3198.9
%
I'm frequently appalled by the low regard you Earthmen have for life.
-- Spock, "The Galileo Seven", stardate 2822.3
%
I've already got a female to worry about. Her name is the Enterprise.
-- Kirk, "The Corbomite Maneuver", stardate 1514.0
%
If a man had a child who'd gone anti-social, killed perhaps, he'd still
tend to protect that child.
-- McCoy, "The Ultimate Computer", stardate 4731.3
%
If I can have honesty, it's easier to overlook mistakes.
-- Kirk, "Space Seed", stardate 3141.9
%
If some day we are defeated, well, war has its fortunes, good and bad.
-- Commander Kor, "Errand of Mercy", stardate 3201.7
%
If there are self-made purgatories, then we all have to live in them.
-- Spock, "This Side of Paradise", stardate 3417.7
%
Immortality consists largely of boredom.
-- Zefrem Cochrane, "Metamorphosis", stardate 3219.8
%
In the strict scientific sense we all feed on death -- even
vegetarians.
-- Spock, "Wolf in the Fold", stardate 3615.4
%
Insufficient facts always invite danger.
-- Spock, "Space Seed", stardate 3141.9
%
Insults are effective only where emotion is present.
-- Spock, "Who Mourns for Adonais?" stardate 3468.1
%
Intuition, however illogical, is recognized as a command prerogative.
-- Kirk, "Obsession", stardate 3620.7
%
Is not that the nature of men and women -- that the pleasure is in the
learning of each other?
-- Natira, the High Priestess of Yonada, "For the World is
Hollow and I Have Touched the Sky", stardate 5476.3.
%
Is truth not truth for all?
-- Natira, "For the World is Hollow and I have Touched
the Sky", stardate 5476.4.
%
It [being a Vulcan] means to adopt a philosophy, a way of life which is
logical and beneficial. We cannot disregard that philosophy merely for
personal gain, no matter how important that gain might be.
-- Spock, "Journey to Babel", stardate 3842.4
%
It is a human characteristic to love little animals, especially if
they're attractive in some way.
-- McCoy, "The Trouble with Tribbles", stardate 4525.6
%
It is more rational to sacrifice one life than six.
-- Spock, "The Galileo Seven", stardate 2822.3
%
It is necessary to have purpose.
-- Alice #1, "I, Mudd", stardate 4513.3
%
It is undignified for a woman to play servant to a man who is not
hers.
-- Spock, "Amok Time", stardate 3372.7
%
It would be illogical to assume that all conditions remain stable
-- Spock, "The Enterprise" Incident", stardate 5027.3
%
It would be illogical to kill without reason
-- Spock, "Journey to Babel", stardate 3842.4
%
It would seem that evil retreats when forcibly confronted
-- Yarnek of Excalbia, "The Savage Curtain", stardate 5906.5
%
"It's hard to believe that something which is neither seen nor felt can
do so much harm."
"That's true. But an idea can't be seen or felt. And that's what kept
the Troglytes in the mines all these centuries. A mistaken idea."
-- Vanna and Kirk, "The Cloud Minders", stardate 5819.0
%
Killing is stupid; useless!
-- McCoy, "A Private Little War", stardate 4211.8
%
Killing is wrong.
-- Losira, "That Which Survives", stardate unknown
%
Knowledge, sir, should be free to all!
-- Harry Mudd, "I, Mudd", stardate 4513.3
%
Landru! Guide us!
-- A Beta 3-oid, "The Return of the Archons", stardate 3157.4
%
Leave bigotry in your quarters; there's no room for it on the bridge.
-- Kirk, "Balance of Terror", stardate 1709.2
%
"Life and death are seldom logical."
"But attaining a desired goal always is."
-- McCoy and Spock, "The Galileo Seven", stardate 2821.7
%
Live long and prosper.
-- Spock, "Amok Time", stardate 3372.7
%
"Logic and practical information do not seem to apply here."
"You admit that?"
"To deny the facts would be illogical, Doctor"
-- Spock and McCoy, "A Piece of the Action", stardate unknown
%
Lots of people drink from the wrong bottle sometimes.
-- Edith Keeler, "The City on the Edge of Forever",
stardate unknown
%
Love sometimes expresses itself in sacrifice.
-- Kirk, "Metamorphosis", stardate 3220.3
%
Madness has no purpose. Or reason. But it may have a goal.
-- Spock, "The Alternative Factor", stardate 3088.7
%
Many Myths are based on truth
-- Spock, "The Way to Eden", stardate 5832.3
%
Men don't talk peace unless they're ready to back it up with war.
-- Col. Green, "The Savage Curtain", stardate 5906.4
%
Men of peace usually are [brave].
-- Spock, "The Savage Curtain", stardate 5906.5
%
Men will always be men -- no matter where they are.
-- Harry Mudd, "Mudd's Women", stardate 1329.8
%
Military secrets are the most fleeting of all.
-- Spock, "The Enterprise Incident", stardate 5027.4
%
Most legends have their basis in facts.
-- Kirk, "And The Children Shall Lead", stardate 5029.5
%
Murder is contrary to the laws of man and God.
-- M-5 Computer, "The Ultimate Computer", stardate 4731.3
%
No more blah, blah, blah!
-- Kirk, "Miri", stardate 2713.6
%
No one can guarantee the actions of another.
-- Spock, "Day of the Dove", stardate unknown
%
No one may kill a man. Not for any purpose. It cannot be condoned.
-- Kirk, "Spock's Brain", stardate 5431.6
%
"No one talks peace unless he's ready to back it up with war."
"He talks of peace if it is the only way to live."
-- Colonel Green and Surak of Vulcan, "The Savage Curtain",
stardate 5906.5.
%
No one wants war.
-- Kirk, "Errand of Mercy", stardate 3201.7
%
No problem is insoluble.
-- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4
%
Not one hundred percent efficient, of course ... but nothing ever is.
-- Kirk, "Metamorphosis", stardate 3219.8
%
Oblivion together does not frighten me, beloved.
-- Thalassa (in Anne Mulhall's body), "Return to Tomorrow",
stardate 4770.3.
%
Oh, that sound of male ego. You travel halfway across the galaxy and
it's still the same song.
-- Eve McHuron, "Mudd's Women", stardate 1330.1
%
On my planet, to rest is to rest -- to cease using energy. To me, it
is quite illogical to run up and down on green grass, using energy,
instead of saving it.
-- Spock, "Shore Leave", stardate 3025.2
%
One does not thank logic.
-- Sarek, "Journey to Babel", stardate 3842.4
%
One of the advantages of being a captain is being able to ask for
advice without necessarily having to take it.
-- Kirk, "Dagger of the Mind", stardate 2715.2
%
Only a fool fights in a burning house.
-- Kang the Klingon, "Day of the Dove", stardate unknown
%
Our missions are peaceful -- not for conquest. When we do battle, it
is only because we have no choice.
-- Kirk, "The Squire of Gothos", stardate 2124.5
%
Our way is peace.
-- Septimus, the Son Worshiper, "Bread and Circuses",
stardate 4040.7.
%
Pain is a thing of the mind. The mind can be controlled.
-- Spock, "Operation -- Annihilate!" stardate 3287.2
%
Peace was the way.
-- Kirk, "The City on the Edge of Forever", stardate unknown
%
Power is danger.
-- The Centurion, "Balance of Terror", stardate 1709.2
%
Prepare for tomorrow -- get ready.
-- Edith Keeler, "The City On the Edge of Forever",
stardate unknown
%
Punishment becomes ineffective after a certain point. Men become
insensitive.
-- Eneg, "Patterns of Force", stardate 2534.7
%
Respect is a rational process
-- McCoy, "The Galileo Seven", stardate 2822.3
%
Romulan women are not like Vulcan females. We are not dedicated to
pure logic and the sterility of non-emotion.
-- Romulan Commander, "The Enterprise Incident",
stardate 5027.3
%
Schshschshchsch.
-- The Gorn, "Arena", stardate 3046.2
%
Sometimes a feeling is all we humans have to go on.
-- Kirk, "A Taste of Armageddon", stardate 3193.9
%
Sometimes a man will tell his bartender things he'll never tell his doctor.
-- Dr. Phillip Boyce, "The Menagerie" ("The Cage"),
stardate unknown.
%
Star Trek Lives!
%
Suffocating together ... would create heroic camaraderie.
-- Khan Noonian Singh, "Space Seed", stardate 3142.8
%
Superior ability breeds superior ambition.
-- Spock, "Space Seed", stardate 3141.9
%
"That unit is a woman."
"A mass of conflicting impulses."
-- Spock and Nomad, "The Changeling", stardate 3541.9
%
"The combination of a number of things to make existence worthwhile."
"Yes, the philosophy of `none', meaning `all'."
-- Spock and Lincoln, "The Savage Curtain", stardate 5906.4
%
The face of war has never changed. Surely it is more logical to heal
than to kill.
-- Surak of Vulcan, "The Savage Curtain", stardate 5906.5
%
The games have always strengthened us. Death becomes a familiar
pattern. We don't fear it as you do.
-- Proconsul Marcus Claudius, "Bread and Circuses",
stardate 4041.2
%
"The glory of creation is in its infinite diversity."
"And in the way our differences combine to create meaning and beauty."
-- Dr. Miranda Jones and Spock, "Is There in Truth No Beauty?",
stardate 5630.8
%
The heart is not a logical organ.
-- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4
%
The idea of male and female are universal constants.
-- Kirk, "Metamorphosis", stardate 3219.8
%
The joys of love made her human and the agonies of love destroyed her.
-- Spock, "Requiem for Methuselah", stardate 5842.8
%
The man on tops walks a lonely street; the "chain" of command is often
a noose.
- McCoy, "The Conscience of the King," stardate 2818.9
%
The more complex the mind, the greater the need for the simplicity of
play.
-- Kirk, "Shore Leave", stardate 3025.8
%
The only solution is ... a balance of power. We arm our side with
exactly that much more. A balance of power -- the trickiest, most
difficult, dirtiest game of them all. But the only one that preserves
both sides.
-- Kirk, "A Private Little War", stardate 4211.8
%
The people of Gideon have always believed that life is sacred. That
the love of life is the greatest gift ... We are incapable of
destroying or interfering with the creation of that which we love so
deeply -- life in every form from fetus to developed being.
-- Hodin of Gideon, "The Mark of Gideon", stardate 5423.4
%
... The prejudices people feel about each other disappear when then get
to know each other.
-- Kirk, "Elaan of Troyius", stardate 4372.5
%
"The release of emotion is what keeps us healthy. Emotionally healthy."
"That may be, Doctor. However, I have noted that the healthy release
of emotion is frequently unhealthy for those closest to you."
-- McCoy and Spock, "Plato's Stepchildren", stardate 5784.3
%
The sight of death frightens them [Earthers].
-- Kras the Klingon, "Friday's Child", stardate 3497.2
%
The sooner our happiness together begins, the longer it will last.
-- Miramanee, "The Paradise Syndrome", stardate 4842.6
%
... The things love can drive a man to -- the ecstasies, the
the miseries, the broken rules, the desperate chances, the glorious
failures and the glorious victories.
-- McCoy, "Requiem for Methuselah", stardate 5843.7
%
There are always alternatives.
-- Spock, "The Galileo Seven", stardate 2822.3
%
There are certain things men must do to remain men.
-- Kirk, "The Ultimate Computer", stardate 4929.4
%
There are some things worth dying for.
-- Kirk, "Errand of Mercy", stardate 3201.7
%
There comes to all races an ultimate crisis which you have yet to face
.... One day our minds became so powerful we dared think of ourselves
as gods.
-- Sargon, "Return to Tomorrow", stardate 4768.3
%
There is a multi-legged creature crawling on your shoulder.
-- Spock, "A Taste of Armageddon", stardate 3193.9
%
There is an old custom among my people. When a woman saves a man's
life, he is grateful.
-- Nona, the Kanuto which woman, "A Private Little War",
stardate 4211.8.
%
There is an order of things in this universe.
-- Apollo, "Who Mourns for Adonais?" stardate 3468.1
%
There's a way out of any cage.
-- Captain Christopher Pike, "The Menagerie" ("The Cage"),
stardate unknown.
%
There's another way to survive. Mutual trust -- and help.
-- Kirk, "Day of the Dove", stardate unknown
%
There's no honorable way to kill, no gentle way to destroy. There is
nothing good in war. Except its ending.
-- Abraham Lincoln, "The Savage Curtain", stardate 5906.5
%
There's nothing disgusting about it [the Companion]. It's just another
life form, that's all. You get used to those things.
-- McCoy, "Metamorphosis", stardate 3219.8
%
"There's only one kind of woman ..."
"Or man, for that matter. You either believe in yourself or you don't."
-- Kirk and Harry Mudd, "Mudd's Women", stardate 1330.1
%
This cultural mystique surrounding the biological function -- you
realize humans are overly preoccupied with the subject.
-- Kelinda the Kelvan, "By Any Other Name", stardate 4658.9
%
Those who hate and fight must stop themselves -- otherwise it is not
stopped.
-- Spock, "Day of the Dove", stardate unknown
%
Time is fluid ... like a river with currents, eddies, backwash.
-- Spock, "The City on the Edge of Forever", stardate 3134.0
%
To live is always desirable.
-- Eleen the Capellan, "Friday's Child", stardate 3498.9
%
Too much of anything, even love, isn't necessarily a good thing.
-- Kirk, "The Trouble with Tribbles", stardate 4525.6
%
Totally illogical, there was no chance.
-- Spock, "The Galileo Seven", stardate 2822.3
%
Uncontrolled power will turn even saints into savages. And we can all
be counted on to live down to our lowest impulses.
-- Parmen, "Plato's Stepchildren", stardate 5784.3
%
Violence in reality is quite different from theory.
-- Spock, "The Cloud Minders", stardate 5818.4
%
Virtue is a relative term.
-- Spock, "Friday's Child", stardate 3499.1
%
Vulcans believe peace should not depend on force.
-- Amanda, "Journey to Babel", stardate 3842.3
%
Vulcans do not approve of violence.
-- Spock, "Journey to Babel", stardate 3842.4
%
Vulcans never bluff.
-- Spock, "The Doomsday Machine", stardate 4202.1
%
Vulcans worship peace above all.
-- McCoy, "Return to Tomorrow", stardate 4768.3
%
Wait! You have not been prepared!
-- Mr. Atoz, "Tomorrow is Yesterday", stardate 3113.2
%
War is never imperative.
-- McCoy, "Balance of Terror", stardate 1709.2
%
War isn't a good life, but it's life.
-- Kirk, "A Private Little War", stardate 4211.8
%
[War] is instinctive. But the instinct can be fought. We're human
beings with the blood of a million savage years on our hands! But we
can stop it. We can admit that we're killers ... but we're not going
to kill today. That's all it takes! Knowing that we're not going to
kill today!
-- Kirk, "A Taste of Armageddon", stardate 3193.0
%
We do not colonize. We conquer. We rule. There is no other way for
us.
-- Rojan, "By Any Other Name", stardate 4657.5
%
We fight only when there is no other choice. We prefer the ways of
peaceful contact.
-- Kirk, "Spectre of the Gun", stardate 4385.3
%
We have found all life forms in the galaxy are capable of superior
development.
-- Kirk, "The Gamesters of Triskelion", stardate 3211.7
%
We have phasers, I vote we blast 'em!
-- Bailey, "The Corbomite Maneuver", stardate 1514.2
%
"We have the right to survive!"
"Not by killing others."
-- Deela and Kirk, "Wink of An Eye", stardate 5710.5
%
We Klingons believe as you do -- the sick should die. Only the strong
should live.
-- Kras, "Friday's Child", stardate 3497.2
%
We're all sorry for the other guy when he loses his job to a machine.
But when it comes to your job -- that's different. And it always will
be different.
-- McCoy, "The Ultimate Computer", stardate 4729.4
%
"What happened to the crewman?"
"The M-5 computer needed a new power source, the crewman merely got in
the way."
-- Kirk and Dr. Richard Daystrom, "The Ultimate Computer",
stardate 4731.3.
%
What kind of love is that? Not to be loved; never to have shown love.
-- Commissioner Nancy Hedford, "Metamorphosis",
stardate 3219.8
%
"What terrible way to die."
"There are no good ways."
-- Sulu and Kirk, "That Which Survives", stardate unknown
%
When a child is taught ... it's programmed with simple instructions --
and at some point, if its mind develops properly, it exceeds the sum of
what it was taught, thinks independently.
-- Dr. Richard Daystrom, "The Ultimate Computer",
stardate 4731.3.
%
When dreams become more important than reality, you give up travel,
building, creating; you even forget how to repair the machines left
behind by your ancestors. You just sit living and reliving other lives
left behind in the thought records.
-- Vina, "The Menagerie" ("The Cage"), stardate unknown
%
Where there's no emotion, there's no motive for violence.
-- Spock, "Dagger of the Mind", stardate 2715.1
%
Witch! Witch! They'll burn ya!
-- Hag, "Tomorrow is Yesterday", stardate unknown
%
Without facts, the decision cannot be made logically. You must rely on
your human intuition.
-- Spock, "Assignment: Earth", stardate unknown
%
Without followers, evil cannot spread.
-- Spock, "And The Children Shall Lead", stardate 5029.5
%
Without freedom of choice there is no creativity.
-- Kirk, "The return of the Archons", stardate 3157.4
%
Women are more easily and more deeply terrified ... generating more
sheer horror than the male of the species.
-- Spock, "Wolf in the Fold", stardate 3615.4
%
Women professionals do tend to over-compensate.
-- Dr. Elizabeth Dehner, "Where No Man Has Gone Before",
stardate 1312.9.
%
Worlds are conquered, galaxies destroyed -- but a woman is always a
woman.
-- Kirk, "Conscience of the King", stardate unknown
%
Worlds may change, galaxies disintegrate, but a woman always remains a
woman.
-- Kirk, "The Conscience of the King", stardate 2818.9
%
Yes, it is written. Good shall always destroy evil.
-- Sirah the Yang, "The Omega Glory", stardate unknown
%
You are an excellent tactician, Captain. You let your second in
command attack while you sit and watch for weakness.
-- Khan Noonian Singh, "Space Seed", stardate 3141.9
%
You can't evaluate a man by logic alone.
-- McCoy, "I, Mudd", stardate 4513.3
%
You Earth people glorified organized violence for forty centuries. But
you imprison those who employ it privately.
-- Spock, "Dagger of the Mind", stardate 2715.1
%
You go slow, be gentle. It's no one-way street -- you know how you
feel and that's all. It's how the girl feels too. Don't press. If
the girl feels anything for you at all, you'll know.
-- Kirk, "Charlie X", stardate 1535.8
%
You humans have that emotional need to express gratitude. "You're
welcome," I believe, is the correct response.
-- Spock, "Bread and Circuses", stardate 4041.2
%
You say you are lying. But if everything you say is a lie, then you
are telling the truth. You cannot tell the truth because everything
you say is a lie. You lie, you tell the truth ... but you cannot, for
you lie.
-- Norman the android, "I, Mudd", stardate 4513.3
%
You speak of courage. Obviously you do not know the difference between
courage and foolhardiness. Always it is the brave ones who die, the
soldiers.
-- Kor, the Klingon Commander, "Errand of Mercy",
stardate 3201.7
%
You! What PLANET is this!
-- McCoy, "The City on the Edge of Forever", stardate 3134.0
%
You'll learn something about men and women -- the way they're supposed
to be. Caring for each other, being happy with each other, being good
to each other. That's what we call love. You'll like that a lot.
-- Kirk, "The Apple", stardate 3715.6
%
You're dead, Jim.
-- McCoy, "Amok Time", stardate 3372.7
%
You're dead, Jim.
-- McCoy, "The Tholian Web", stardate unknown
%
You're too beautiful to ignore. Too much woman.
-- Kirk to Yeoman Rand, "The Enemy Within", stardate unknown
%
Youth doesn't excuse everything.
-- Dr. Janice Lester (in Kirk's body), "Turnabout Intruder",
stardate 5928.5.

1365
datfiles/zippy Normal file

File diff suppressed because it is too large Load Diff

14
fortune/Makefile Normal file
View File

@ -0,0 +1,14 @@
FORTDIR?= $(PREFIX)/share/fortune
CFLAGS+= -I../strfile -DFORTDIR=\"$(FORTDIR)\"
LDFLAGS+= -lbsd
fortune : fortune.c
install :
mkdir -p $(DESTDIR)$(PREFIX)/bin
install -m0755 fortune $(DESTDIR)$(PREFIX)/bin/
mkdir -p $(DESTDIR)$(PREFIX)/share/man/man6
install -m0644 fortune.6 $(DESTDIR)$(PREFIX)/share/man/man6/
clean :
$(RM) fortune

183
fortune/fortune.6 Normal file
View File

@ -0,0 +1,183 @@
.\" $OpenBSD: fortune.6,v 1.13 2015/02/06 09:30:04 tedu Exp $
.\"
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Ken Arnold.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)fortune.6 8.3 (Berkeley) 4/19/94
.\"
.Dd $Mdocdate: February 6 2015 $
.Dt FORTUNE 6
.Os
.Sh NAME
.Nm fortune
.Nd print a random, hopefully interesting, adage
.Sh SYNOPSIS
.Nm fortune
.Op Fl aefilosw
.Op Fl m Ar pattern
.Oo
.Op Ar N Ns %
.Sm off
.Ar file No / Ar directory No / Ar all
.Sm on
.Oc
.Sh DESCRIPTION
When
.Nm
is run with no arguments it prints out a random epigram.
Epigrams are divided into several categories, where each category
is subdivided into those which are potentially offensive and those
which are not.
The options are as follows:
.Bl -tag -width flag
.It Fl a
Choose from all lists of maxims, both offensive and not.
(See the
.Fl o
option for more information on offensive fortunes.)
.It Fl e
Consider all fortune files to be of equal size (see discussion below
on multiple files).
.It Fl f
Print out the list of files which would be searched, but don't
print a fortune.
.It Fl i
Ignore case for
.Fl m
patterns.
.It Fl l
Long dictums only.
.It Fl m Ar pattern
Print out all fortunes which match the regular expression
.Ar pattern .
See
.Xr re_format 7
for a description of patterns.
.It Fl o
Choose only from potentially offensive aphorisms.
.Bf -symbolic
Please, please, please request a potentially offensive fortune if and
only if you believe, deep down in your heart, that you are willing
to be offended.
(And that if you are, you'll just quit using
.Fl o
rather than give us
grief about it, okay?)
.Ef
.Bd -unfilled -offset indent
\&... let us keep in mind the basic governing philosophy
of The Brotherhood, as handsomely summarized in these words:
we believe in healthy, hearty laughter -- at the expense of
the whole human race, if needs be. Needs be.
--H. Allen Smith, "Rude Jokes"
.Ed
.It Fl s
Short apothegms only.
.It Fl w
Wait before termination for an amount of time calculated from the
number of characters in the message.
This is useful if it is executed as part of the logout procedure
to guarantee that the message can be read before the screen is cleared.
.El
.Pp
The user may specify alternate sayings.
You can specify a specific file, a directory which contains one or
more files, or the special word
.Em all ,
which says to use all the standard databases.
Any of these may be preceded by a percentage, which is a number
.Ar N
between 0 and 100 inclusive, followed by a
.Sq %
character.
If it is, there will be an
.Ar N
percent probability that an adage will be picked from that file
or directory.
If the percentages do not sum to 100, and there are specifications
without percentages, the remaining percent will apply to those files
and/or directories, in which case the probability of selecting from
one of them will be based on their relative sizes.
.Pp
As an example, given two databases
.Em funny
and
.Em not-funny ,
with
.Em funny
twice as big, saying
.Bd -literal -offset indent
$ fortune funny not-funny
.Ed
.Pp
will get you fortunes out of
.Em funny
two-thirds of the time.
The command
.Bd -literal -offset indent
$ fortune 90% funny 10% not-funny
.Ed
.Pp
will pick out 90% of its fortunes from
.Em funny
(the
.Dq 10%
is unnecessary, since 10% is all that's left).
The
.Fl e
option says to consider all files equal;
thus
.Bd -literal -offset indent
$ fortune -e
.Ed
.Pp
is equivalent to
.Bd -literal -offset indent
$ fortune 50% funny 50% not-funny
.Ed
.Pp
Datafiles for
.Nm
are created by a utility called
.Nm strfile .
Although not installed by default,
the source code and a manual page for this utility
can be found in
.Pa /usr/src/games/fortune/strfile/ ,
if it exists.
.Sh FILES
.Bl -tag -width "/usr/share/games/fortune/*XX" -compact
.It Pa /usr/share/games/fortune/*
Fortune files.
.El
.Sh SEE ALSO
.Xr random 6 ,
.Xr rot13 6 ,
.Xr re_format 7

1291
fortune/fortune.c Normal file

File diff suppressed because it is too large Load Diff

12
strfile/Makefile Normal file
View File

@ -0,0 +1,12 @@
LDFLAGS+= -lbsd
strfile : strfile.c
install :
mkdir -p $(DESTDIR)$(PREFIX)/bin
install -m0755 strfile $(DESTDIR)$(PREFIX)/bin/
mkdir -p $(DESTDIR)$(PREFIX)/share/man/man8
install -m0644 strfile.8 $(DESTDIR)$(PREFIX)/share/man/man8/
clean :
$(RM) strfile

149
strfile/strfile.8 Normal file
View File

@ -0,0 +1,149 @@
.\" $OpenBSD: strfile.8,v 1.15 2013/08/14 06:32:38 jmc Exp $
.\" $NetBSD: strfile.8,v 1.3 1995/03/23 08:28:45 cgd Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Ken Arnold.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)strfile.8 8.1 (Berkeley) 6/9/93
.\"
.Dd $Mdocdate: August 14 2013 $
.Dt STRFILE 8
.Os
.Sh NAME
.Nm strfile ,
.Nm unstr
.Nd create a random access file for storing strings
.Sh SYNOPSIS
.Nm strfile
.Op Fl iorsx
.Op Fl c Ar char
.Ar source_file
.Op Ar output_file
.Nm unstr
.Ar source_file
.Sh DESCRIPTION
.Nm
reads a file containing groups of lines separated by a line containing
a single percent
.Ql \&%
sign and creates a data file which contains
a header structure and a table of file offsets for each group of lines.
This allows random access of the strings.
.Pp
The output file, if not specified on the command line, is named
.Ar source_file Ns Sy .dat .
.Pp
The options are as follows:
.Bl -tag -width "-c char"
.It Fl c Ar char
Change the delimiting character from the percent sign to
.Ar char .
.It Fl i
Ignore case when ordering the strings.
.It Fl o
Order the strings in alphabetical order.
The offset table will be sorted in the alphabetical order of the
groups of lines referenced.
Any initial non-alphanumeric characters are ignored.
This option causes the
.Dv STR_ORDERED
bit in the header
.Ar str_flags
field to be set.
.It Fl r
Randomize access to the strings.
Entries in the offset table will be randomly ordered.
This option causes the
.Dv STR_RANDOM
bit in the header
.Ar str_flags
field to be set.
.It Fl s
Run silently; don't give a summary message when finished.
.It Fl x
Note that each alphabetic character in the groups of lines is rotated
13 positions in a simple caesar cypher.
This option causes the
.Dv STR_ROTATED
bit in the header
.Ar str_flags
field to be set.
.El
.Pp
The format of the header is:
.Bd -literal -offset indent
#define VERSION 2
u_int32_t str_version; /* version number */
u_int32_t str_numstr; /* # of strings in the file */
u_int32_t str_longlen; /* length of longest string */
u_int32_t str_shortlen; /* length of shortest string */
#define STR_RANDOM 0x1 /* randomized pointers */
#define STR_ORDERED 0x2 /* ordered pointers */
#define STR_ROTATED 0x4 /* rot-13'd text */
u_int32_t str_flags; /* bit field for flags */
u_int8_t str_delim; /* delimiting character */
u_int8_t str_pad[3]; /* padding */
.Ed
.Pp
All fields are written in network byte order.
Each field is also written independently so as to avoid structure padding
problems on some architectures.
.Pp
The purpose of
.Nm unstr
is to undo the work of
.Nm strfile .
It prints out the strings contained in the file
.Ar source_file
in the order that they are listed in
the header file
.Ar source_file Ns Sy .dat
to standard output.
It is possible to create sorted versions of input files by using
.Fl o
when
.Nm strfile
is run and then using
.Nm unstr
to dump them out in the table order.
.Sh FILES
.Bl -tag -width source_file.dat -compact
.It Ar source_file Ns Sy .dat
default output file.
.El
.Sh SEE ALSO
.Xr byteorder 3 ,
.Xr fortune 6
.Sh HISTORY
The
.Nm strfile
utility first appeared in
.Bx 4.4 .

446
strfile/strfile.c Normal file
View File

@ -0,0 +1,446 @@
/* $OpenBSD: strfile.c,v 1.21 2014/11/16 04:49:48 guenther Exp $ */
/* $NetBSD: strfile.c,v 1.4 1995/04/24 12:23:09 cgd Exp $ */
/*-
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ken Arnold.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/types.h>
#include <ctype.h>
#include <err.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "strfile.h"
/*
* This program takes a file composed of strings separated by
* lines starting with two consecutive delimiting character (default
* character is '%') and creates another file which consists of a table
* describing the file (structure from "strfile.h"), a table of seek
* pointers to the start of the strings, and the strings, each terminated
* by a null byte. Usage:
*
* % strfile [-iorsx] [ -cC ] sourcefile [ datafile ]
*
* c - Change delimiting character from '%' to 'C'
* s - Silent. Give no summary of data processed at the end of
* the run.
* o - order the strings in alphabetic order
* i - if ordering, ignore case
* r - randomize the order of the strings
* x - set rotated bit
*
* Ken Arnold Sept. 7, 1978 --
*
* Added ordering options.
*/
#define TRUE 1
#define FALSE 0
#define STORING_PTRS (Oflag || Rflag)
#define CHUNKSIZE 512
# define ALLOC(ptr,sz) do { \
if (ptr == NULL) \
ptr = calloc(CHUNKSIZE, sizeof *ptr); \
else if (((sz) + 1) % CHUNKSIZE == 0) \
ptr = realloc(ptr, \
(sz) + CHUNKSIZE * \
sizeof(*ptr)); \
if (ptr == NULL) \
err(1, NULL); \
} while (0)
typedef struct {
char first;
int32_t pos;
} STR;
char *Infile = NULL, /* input file name */
Outfile[PATH_MAX] = "", /* output file name */
Delimch = '%'; /* delimiting character */
int Sflag = FALSE; /* silent run flag */
int Oflag = FALSE; /* ordering flag */
int Iflag = FALSE; /* ignore case flag */
int Rflag = FALSE; /* randomize order flag */
int Xflag = FALSE; /* set rotated bit */
long Num_pts = 0; /* number of pointers/strings */
int32_t *Seekpts;
FILE *Sort_1, *Sort_2; /* pointers for sorting */
STRFILE Tbl; /* statistics table */
STR *Firstch; /* first chars of each string */
void add_offset(FILE *, int32_t);
int cmp_str(const void *, const void *);
void do_order(void);
void getargs(int, char **);
void randomize(void);
char *unctrl(char);
void usage(void);
/*
* main:
* Drive the sucker. There are two main modes -- either we store
* the seek pointers, if the table is to be sorted or randomized,
* or we write the pointer directly to the file, if we are to stay
* in file order. If the former, we allocate and re-allocate in
* CHUNKSIZE blocks; if the latter, we just write each pointer,
* and then seek back to the beginning to write in the table.
*/
int
main(int ac, char *av[])
{
char *sp, dc;
FILE *inf, *outf;
int32_t last_off, length, pos;
int32_t *p;
int first, cnt;
char *nsp;
STR *fp;
static char string[257];
getargs(ac, av); /* evalute arguments */
dc = Delimch;
if ((inf = fopen(Infile, "r")) == NULL)
err(1, "%s", Infile);
if ((outf = fopen(Outfile, "w")) == NULL)
err(1, "%s", Outfile);
if (!STORING_PTRS)
(void) fseek(outf, sizeof Tbl, SEEK_SET);
/*
* Write the strings onto the file
*/
Tbl.str_longlen = 0;
Tbl.str_shortlen = (unsigned int) 0xffffffff;
Tbl.str_delim = dc;
Tbl.str_version = VERSION;
first = Oflag;
add_offset(outf, ftell(inf));
last_off = 0;
do {
sp = fgets(string, sizeof(string), inf);
if (sp == NULL || (sp[0] == dc && sp[1] == '\n')) {
pos = ftell(inf);
length = pos - last_off - (sp ? strlen(sp) : 0);
last_off = pos;
if (!length)
continue;
add_offset(outf, pos);
if (Tbl.str_longlen < (u_int32_t)length)
Tbl.str_longlen = length;
if (Tbl.str_shortlen > (u_int32_t)length)
Tbl.str_shortlen = length;
first = Oflag;
}
else if (first) {
for (nsp = sp; !isalnum(*nsp); nsp++)
continue;
ALLOC(Firstch, Num_pts);
fp = &Firstch[Num_pts - 1];
if (Iflag && isupper(*nsp))
fp->first = tolower(*nsp);
else
fp->first = *nsp;
fp->pos = Seekpts[Num_pts - 1];
first = FALSE;
}
} while (sp != NULL);
/*
* write the tables in
*/
(void) fclose(inf);
Tbl.str_numstr = Num_pts - 1;
if (Tbl.str_numstr == 0)
Tbl.str_shortlen = 0;
if (Oflag)
do_order();
else if (Rflag)
randomize();
if (Xflag)
Tbl.str_flags |= STR_ROTATED;
if (!Sflag) {
printf("\"%s\" created\n", Outfile);
if (Tbl.str_numstr == 1)
puts("There was 1 string");
else
printf("There were %u strings\n", Tbl.str_numstr);
printf("Longest string: %lu byte%s\n",
(unsigned long) Tbl.str_longlen,
Tbl.str_longlen == 1 ? "" : "s");
printf("Shortest string: %lu byte%s\n",
(unsigned long) Tbl.str_shortlen,
Tbl.str_shortlen == 1 ? "" : "s");
}
(void) fseek(outf, 0, SEEK_SET);
Tbl.str_version = htonl(Tbl.str_version);
Tbl.str_numstr = htonl(Tbl.str_numstr);
Tbl.str_longlen = htonl(Tbl.str_longlen);
Tbl.str_shortlen = htonl(Tbl.str_shortlen);
Tbl.str_flags = htonl(Tbl.str_flags);
(void) fwrite(&Tbl.str_version, sizeof(Tbl.str_version), 1, outf);
(void) fwrite(&Tbl.str_numstr, sizeof(Tbl.str_numstr), 1, outf);
(void) fwrite(&Tbl.str_longlen, sizeof(Tbl.str_longlen), 1, outf);
(void) fwrite(&Tbl.str_shortlen, sizeof(Tbl.str_shortlen), 1, outf);
(void) fwrite(&Tbl.str_flags, sizeof(Tbl.str_flags), 1, outf);
(void) fwrite( Tbl.stuff, sizeof(Tbl.stuff), 1, outf);
if (STORING_PTRS)
for (p = Seekpts, cnt = Num_pts; cnt--; ++p) {
*p = htonl(*p);
(void) fwrite(p, sizeof(*p), 1, outf);
}
if (fclose(outf))
err(1, "fclose `%s'", Outfile);
exit(0);
}
/*
* This routine evaluates arguments from the command line
*/
void
getargs(int argc, char *argv[])
{
extern char *optarg;
extern int optind;
int ch;
while ((ch = getopt(argc, argv, "c:iorsx")) != -1)
switch(ch) {
case 'c': /* new delimiting char */
Delimch = *optarg;
if (!isascii(Delimch)) {
printf("bad delimiting character: '\\%o\n'",
Delimch);
}
break;
case 'i': /* ignore case in ordering */
Iflag++;
break;
case 'o': /* order strings */
Oflag++;
break;
case 'r': /* randomize pointers */
Rflag++;
break;
case 's': /* silent */
Sflag++;
break;
case 'x': /* set the rotated bit */
Xflag++;
break;
case '?':
default:
usage();
}
argv += optind;
if (*argv) {
Infile = *argv;
if (*++argv)
(void) strlcpy(Outfile, *argv, sizeof Outfile);
}
if (!Infile) {
puts("No input file name");
usage();
}
if (*Outfile == '\0') {
(void) strlcpy(Outfile, Infile, sizeof(Outfile));
if (strlcat(Outfile, ".dat", sizeof(Outfile)) >= sizeof(Outfile))
errx(1, "`%s': name too long", Infile);
}
}
void
usage(void)
{
(void) fprintf(stderr,
"strfile [-iorsx] [-c char] sourcefile [datafile]\n");
exit(1);
}
/*
* add_offset:
* Add an offset to the list, or write it out, as appropriate.
*/
void
add_offset(FILE *fp, int32_t off)
{
int32_t net;
if (!STORING_PTRS) {
net = htonl(off);
fwrite(&net, 1, sizeof net, fp);
} else {
ALLOC(Seekpts, Num_pts + 1);
Seekpts[Num_pts] = off;
}
Num_pts++;
}
/*
* do_order:
* Order the strings alphabetically (possibly ignoring case).
*/
void
do_order(void)
{
int i;
int32_t *lp;
STR *fp;
Sort_1 = fopen(Infile, "r");
Sort_2 = fopen(Infile, "r");
qsort((char *) Firstch, (int) Tbl.str_numstr, sizeof *Firstch, cmp_str);
i = Tbl.str_numstr;
lp = Seekpts;
fp = Firstch;
while (i--)
*lp++ = fp++->pos;
(void) fclose(Sort_1);
(void) fclose(Sort_2);
Tbl.str_flags |= STR_ORDERED;
}
/*
* cmp_str:
* Compare two strings in the file
*/
char *
unctrl(char c)
{
static char buf[3];
if (isprint(c)) {
buf[0] = c;
buf[1] = '\0';
}
else if (c == 0177) {
buf[0] = '^';
buf[1] = '?';
}
else {
buf[0] = '^';
buf[1] = c + 'A' - 1;
}
return buf;
}
int
cmp_str(const void *p1, const void *p2)
{
int c1, c2;
int n1, n2;
# define SET_N(nf,ch) (nf = (ch == '\n'))
# define IS_END(ch,nf) (ch == Delimch && nf)
c1 = ((STR *)p1)->first;
c2 = ((STR *)p2)->first;
if (c1 != c2)
return c1 - c2;
(void) fseek(Sort_1, ((STR *)p1)->pos, SEEK_SET);
(void) fseek(Sort_2, ((STR *)p2)->pos, SEEK_SET);
n1 = FALSE;
n2 = FALSE;
while (!isalnum(c1 = getc(Sort_1)) && c1 != '\0')
SET_N(n1, c1);
while (!isalnum(c2 = getc(Sort_2)) && c2 != '\0')
SET_N(n2, c2);
while (!IS_END(c1, n1) && !IS_END(c2, n2)) {
if (Iflag) {
if (isupper(c1))
c1 = tolower(c1);
if (isupper(c2))
c2 = tolower(c2);
}
if (c1 != c2)
return c1 - c2;
SET_N(n1, c1);
SET_N(n2, c2);
c1 = getc(Sort_1);
c2 = getc(Sort_2);
}
if (IS_END(c1, n1))
c1 = 0;
if (IS_END(c2, n2))
c2 = 0;
return c1 - c2;
}
/*
* randomize:
* Randomize the order of the string table. We must be careful
* not to randomize across delimiter boundaries. All
* randomization is done within each block.
*/
void
randomize(void)
{
int cnt, i;
int32_t tmp;
int32_t *sp;
Tbl.str_flags |= STR_RANDOM;
cnt = Tbl.str_numstr;
/*
* move things around randomly
*/
for (sp = Seekpts; cnt > 0; cnt--, sp++) {
i = arc4random_uniform(cnt);
tmp = sp[0];
sp[0] = sp[i];
sp[i] = tmp;
}
}

53
strfile/strfile.h Normal file
View File

@ -0,0 +1,53 @@
/* $OpenBSD: strfile.h,v 1.4 2003/06/03 03:01:39 millert Exp $ */
/* $NetBSD: strfile.h,v 1.3 1995/03/23 08:28:49 cgd Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ken Arnold.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)strfile.h 8.1 (Berkeley) 5/31/93
*/
#define STR_ENDSTRING(line,tbl) \
((line)[0] == (tbl).str_delim && (line)[1] == '\n')
typedef struct { /* information table */
#define VERSION 2
u_int32_t str_version; /* version number */
u_int32_t str_numstr; /* # of strings in the file */
u_int32_t str_longlen; /* length of longest string */
u_int32_t str_shortlen; /* length of shortest string */
#define STR_RANDOM 0x1 /* randomized pointers */
#define STR_ORDERED 0x2 /* ordered pointers */
#define STR_ROTATED 0x4 /* rot-13'd text */
u_int32_t str_flags; /* bit field for flags */
u_int8_t stuff[4]; /* long aligned space */
#define str_delim stuff[0] /* delimiting character */
} STRFILE;