Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / games / fortune / strfile / strfile.8
CommitLineData
984263bc
MD
1.\" Copyright (c) 1989, 1991, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\"
5.\" This code is derived from software contributed to Berkeley by
6.\" Ken Arnold.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the
15.\" documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\" must display the following acknowledgement:
18.\" This product includes software developed by the University of
19.\" California, Berkeley and its contributors.
20.\" 4. Neither the name of the University nor the names of its contributors
21.\" may be used to endorse or promote products derived from this software
22.\" without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\" @(#)strfile.8 8.1 (Berkeley) 6/9/93
37.\" $FreeBSD: src/games/fortune/strfile/strfile.8,v 1.5.2.3 2001/08/16 10:08:23 ru Exp $
1de703da 38.\" $DragonFly: src/games/fortune/strfile/strfile.8,v 1.2 2003/06/17 04:25:24 dillon Exp $
984263bc
MD
39.\"
40.Dd June 9, 1993
41.Dt STRFILE 8
42.Os
43.Sh NAME
44.Nm strfile ,
45.Nm unstr
46.Nd "create a random access file for storing strings"
47.Sh SYNOPSIS
48.Nm
49.Op Fl iorsx
50.Op Fl c Ar char
51.Ar source_file
52.Op Ar output_file
53.Nm unstr
54.Ar source_file
55.Sh DESCRIPTION
56.Nm Strfile
57reads a file containing groups of lines separated by a line containing
58a single percent
59.Ql \&%
60sign and creates a data file which contains
61a header structure and a table of file offsets for each group of lines.
62This allows random access of the strings.
63.Pp
64The output file, if not specified on the command line, is named
65.Ar source_file Ns Sy .dat .
66.Pp
67The options are as follows:
68.Bl -tag -width "-c char"
69.It Fl C
70Flag the file as containing comments. This option cases the
71.Dv STR_COMMENTS
72bit in the header
73.Ar str_flags
74field to be set.
75Comments are designated by two delimiter characters at the
76beginning of the line, though strfile does not give any special
77treatment to comment lines.
78.It Fl c Ar char
79Change the delimiting character from the percent sign to
80.Ar char .
81.It Fl i
82Ignore case when ordering the strings.
83.It Fl o
84Order the strings in alphabetical order.
85The offset table will be sorted in the alphabetical order of the
86groups of lines referenced.
87Any initial non-alphanumeric characters are ignored.
88This option causes the
89.Dv STR_ORDERED
90bit in the header
91.Ar str_flags
92field to be set.
93.It Fl r
94Randomize access to the strings.
95Entries in the offset table will be randomly ordered.
96This option causes the
97.Dv STR_RANDOM
98bit in the header
99.Ar str_flags
100field to be set.
101.It Fl s
102Run silently; don't give a summary message when finished.
103.It Fl x
104Note that each alphabetic character in the groups of lines is rotated
10513 positions in a simple caesar cypher.
106This option causes the
107.Dv STR_ROTATED
108bit in the header
109.Ar str_flags
110field to be set.
111.El
112.Pp
113The format of the header is:
114.Bd -literal
115#define VERSION 1
116unsigned long str_version; /* version number */
117unsigned long str_numstr; /* # of strings in the file */
118unsigned long str_longlen; /* length of longest string */
119unsigned long str_shortlen; /* length of shortest string */
120#define STR_RANDOM 0x1 /* randomized pointers */
121#define STR_ORDERED 0x2 /* ordered pointers */
122#define STR_ROTATED 0x4 /* rot-13'd text */
123unsigned long str_flags; /* bit field for flags */
124char str_delim; /* delimiting character */
125.Ed
126.Pp
127All fields are written in network byte order.
128.Pp
129The purpose of
130.Nm unstr
131is to undo the work of
132.Nm .
133It prints out the strings contained in the file
134.Ar source_file
135in the order that they are listed in
136the header file
137.Ar source_file Ns Pa .dat
138to standard output.
139It is possible to create sorted versions of input files by using
140.Fl o
141when
142.Nm
143is run and then using
144.Nm unstr
145to dump them out in the table order.
146.Sh SEE ALSO
147.Xr byteorder 3 ,
148.Xr fortune 6
149.Sh FILES
150.Bl -tag -width strfile.dat -compact
151.It Pa strfile.dat
152default output file.
153.El
154.Sh HISTORY
155The
156.Nm
157utility first appeared in
158.Bx 4.4 .