]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - fortune/strfile/strfile.8
initial import of 386bsd-0.1 sources
[bsdgames-darwin.git] / fortune / strfile / strfile.8
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
55 reads a file containing groups of lines separated by a line containing
56 a single percent
57 .Ql \&%
58 sign and creates a data file which contains
59 a header structure and a table of file offsets for each group of lines.
60 This allows random access of the strings.
61 .Pp
62 The output file, if not specified on the command line, is named
63 .Ar source_file Ns Sy .out .
64 .Pp
65 The options are as follows:
66 .Bl -tag -width "-c char"
67 .It Fl c Ar char
68 Change the delimiting character from the percent sign to
69 .Ar char .
70 .It Fl i
71 Ignore case when ordering the strings.
72 .It Fl o
73 Order the strings in alphabetical order.
74 The offset table will be sorted in the alphabetical order of the
75 groups of lines referenced.
76 Any initial non-alphanumeric characters are ignored.
77 This option causes the
78 .Dv STR_ORDERED
79 bit in the header
80 .Ar str_flags
81 field to be set.
82 .It Fl r
83 Randomize access to the strings.
84 Entries in the offset table will be randomly ordered.
85 This option causes the
86 .Dv STR_RANDOM
87 bit in the header
88 .Ar str_flags
89 field to be set.
90 .It Fl s
91 Run silently; don't give a summary message when finished.
92 .It Fl x
93 Note that each alphabetic character in the groups of lines is rotated
94 13 positions in a simple caesar cypher.
95 This option causes the
96 .Dv STR_ROTATED
97 bit in the header
98 .Ar str_flags
99 field to be set.
100 .El
101 .Pp
102 The format of the header is:
103 .Bd -literal
104 #define VERSION 1
105 unsigned long str_version; /* version number */
106 unsigned long str_numstr; /* # of strings in the file */
107 unsigned long str_longlen; /* length of longest string */
108 unsigned 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 */
112 unsigned long str_flags; /* bit field for flags */
113 char str_delim; /* delimiting character */
114 .Ed
115 .Pp
116 All fields are written in network byte order.
117 .Pp
118 The purpose of
119 .Nm unstr
120 is to undo the work of
121 .Nm strfile .
122 It prints out the strings contained in the file
123 .Ar source_file
124 in the order that they are listed in
125 the header file
126 .Ar source_file Ns Pa .dat
127 to standard output.
128 It is possible to create sorted versions of input files by using
129 .Fl o
130 when
131 .Nm strfile
132 is run and then using
133 .Nm unstr
134 to 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
141 default output file.
142 .El
143 .Sh HISTORY
144 The
145 .Nm
146 command
147 .Ud