xref: /386bsd/usr/src/games/fortune/strfile/strfile.8 (revision a2142627)
1.\" Copyright (c) 1989, 1991 The Regents of the University of California.
2.\" 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	5.9 (Berkeley) 3/16/91
37.\"
38.Dd March 16, 1991
39.Dt STRFILE 8
40.Os BSD 4
41.Sh NAME
42.Nm strfile ,
43.Nm unstr
44.Nd "create a random access file for storing strings"
45.Sh SYNOPSIS
46.Nm strfile
47.Op Fl iorsx
48.Op Fl c Ar char
49.Ar source_file
50.Op Ar output_file
51.Nm unstr
52.Ar source_file
53.Sh DESCRIPTION
54.Nm Strfile
55reads a file containing groups of lines separated by a line containing
56a single percent
57.Ql \&%
58sign and creates a data file which contains
59a header structure and a table of file offsets for each group of lines.
60This allows random access of the strings.
61.Pp
62The output file, if not specified on the command line, is named
63.Ar source_file Ns Sy .out .
64.Pp
65The options are as follows:
66.Bl -tag -width "-c char"
67.It Fl c Ar char
68Change the delimiting character from the percent sign to
69.Ar char .
70.It Fl i
71Ignore case when ordering the strings.
72.It Fl o
73Order the strings in alphabetical order.
74The offset table will be sorted in the alphabetical order of the
75groups of lines referenced.
76Any initial non-alphanumeric characters are ignored.
77This option causes the
78.Dv STR_ORDERED
79bit in the header
80.Ar str_flags
81field to be set.
82.It Fl r
83Randomize access to the strings.
84Entries in the offset table will be randomly ordered.
85This option causes the
86.Dv STR_RANDOM
87bit in the header
88.Ar str_flags
89field to be set.
90.It Fl s
91Run silently; don't give a summary message when finished.
92.It Fl x
93Note that each alphabetic character in the groups of lines is rotated
9413 positions in a simple caesar cypher.
95This option causes the
96.Dv STR_ROTATED
97bit in the header
98.Ar str_flags
99field to be set.
100.El
101.Pp
102The format of the header is:
103.Bd -literal
104#define	VERSION	1
105unsigned long	str_version;	/* version number */
106unsigned long	str_numstr;	/* # of strings in the file */
107unsigned long	str_longlen;	/* length of longest string */
108unsigned long	str_shortlen;	/* length of shortest string */
109#define	STR_RANDOM	0x1	/* randomized pointers */
110#define	STR_ORDERED	0x2	/* ordered pointers */
111#define	STR_ROTATED	0x4	/* rot-13'd text */
112unsigned long	str_flags;	/* bit field for flags */
113char str_delim;			/* delimiting character */
114.Ed
115.Pp
116All fields are written in network byte order.
117.Pp
118The purpose of
119.Nm unstr
120is to undo the work of
121.Nm strfile .
122It prints out the strings contained in the file
123.Ar source_file
124in the order that they are listed in
125the header file
126.Ar source_file Ns Pa .dat
127to standard output.
128It is possible to create sorted versions of input files by using
129.Fl o
130when
131.Nm strfile
132is run and then using
133.Nm unstr
134to dump them out in the table order.
135.Sh SEE ALSO
136.Xr byteorder 3 ,
137.Xr fortune 6
138.Sh FILES
139.Bl -tag -width strfile.out -compact
140.It Pa strfile.out
141default output file.
142.El
143.Sh HISTORY
144The
145.Nm
146command
147.Ud
148