]> granicus.if.org Git - fortune-mod/blob - fortune-mod/util/strfile.docbook5.xml
add docbook5 ver using doclifter. "docmake manpages" renders it wrong
[fortune-mod] / fortune-mod / util / strfile.docbook5.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- lifted from man+troff by doclifter -->
3 <refentry xmlns='http://docbook.org/ns/docbook' version='5.0' xml:lang='en' xml:id='strfileman'>
4 <!-- $NetBSD: strfile.8,v 1.3 1995/03/23 08:28:45 cgd Exp $ -->
5
6 <!-- Copyright (c) 1989, 1991, 1993
7 The Regents of the University of California.  All rights reserved. -->
8
9
10 <!-- This code is derived from software contributed to Berkeley by
11 Ken Arnold. -->
12
13 <!-- Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions
15 are met:
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
18 2. Redistributions in binary form must reproduce the above copyright
19 notice, this list of conditions and the following disclaimer in the
20 documentation and/or other materials provided with the distribution.
21 3. All advertising materials mentioning features or use of this software
22 must display the following acknowledgement:
23 This product includes software developed by the University of
24 California, Berkeley and its contributors.
25 4. Neither the name of the University nor the names of its contributors
26 may be used to endorse or promote products derived from this software
27 without specific prior written permission. -->
28
29 <!-- THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 SUCH DAMAGE. -->
40
41 <!-- @(#)strfile.8   8.1 (Berkeley) 6/9/93 -->
42
43 <!-- This man page has been heavily modified, like the files it refers
44 to, by Amy Lewis.  Changes to command line, and a different style of
45 macros for Linux systems. -->
46
47 <refmeta>
48 <refentrytitle>STRFILE</refentrytitle>
49 <manvolnum>1</manvolnum>
50 <refmiscinfo class='source'>June 9, 1993 [Apr. '97]</refmiscinfo>
51 <refmiscinfo class='manual'>4th Berkeley Distribution</refmiscinfo>
52 </refmeta>
53 <refnamediv>
54 <refname>strfile</refname>
55 <refpurpose>create a random access file for storing strings</refpurpose>
56 </refnamediv>
57 <refnamediv>
58 <refname>unstr</refname>
59 <refpurpose>dump strings in pointer order</refpurpose>
60 </refnamediv>
61 <!-- body begins here -->
62 <refsynopsisdiv xml:id='synopsis'>
63 <cmdsynopsis>
64   <command>strfile</command>    <arg choice='opt'>-iorsx </arg>
65     <arg choice='opt'><arg choice='plain'>-c </arg><arg choice='plain'><replaceable>char</replaceable></arg></arg>
66     <arg choice='plain'><replaceable>sourcefile</replaceable></arg>
67     <arg choice='opt'><replaceable>outputfile</replaceable></arg>
68 </cmdsynopsis>
69 <cmdsynopsis>
70   <command>unstr</command>    <arg choice='opt'><arg choice='plain'>-c </arg><arg choice='plain'><replaceable>char</replaceable></arg></arg>
71     <arg choice='plain'><replaceable>datafile.[ext]</replaceable></arg>
72     <arg choice='opt'><replaceable>outputfile</replaceable></arg>
73 </cmdsynopsis>
74 </refsynopsisdiv>
75
76
77 <refsect1 xml:id='description'><title>DESCRIPTION</title>
78 <para><emphasis role='strong' remap='B'>strfile</emphasis>
79 reads a file containing groups of lines separated by a line containing
80 a single percent `%' sign (or other specified delimiter character) and
81 creates a data file which contains a header structure and a table of
82 file offsets for each group of lines. This allows random access of the
83 strings.</para>
84
85 <para>The output file, if not specified on the command line, is named
86 <emphasis remap='I'>sourcefile.dat</emphasis>.</para>
87
88 <para>The purpose of
89 <emphasis role='strong' remap='B'>unstr</emphasis>
90 is to undo the work of
91 <emphasis role='strong' remap='B'>strfile</emphasis>.
92 It prints out the strings contained in the sourcefile, which is
93 <emphasis remap='I'>datafile.ext</emphasis>
94 without its extension, or
95 <emphasis remap='I'>datafile</emphasis>
96 if no extension is specified (in this case, the extension
97 <markup>.dat</markup>
98 is added to the name of the datafile) in the order
99 that they are listed in the header file
100 <emphasis remap='I'>datafile</emphasis>.
101 If no
102 <emphasis remap='I'>outputfile</emphasis>
103 is specified, it prints to standard output; otherwise it prints
104 to the file specified.
105 <emphasis role='strong' remap='B'>unstr</emphasis>
106 can also universally change the delimiter character in a strings file.
107 It is possible to create sorted versions of input files by using
108 <emphasis role='strong' remap='B'>strfile -o</emphasis>
109 and then using
110 <emphasis role='strong' remap='B'>unstr</emphasis>
111 to dump them out in the table order.</para>
112
113 <refsect2 xml:id='options'><title>Options</title>
114 <para>The options are as follows:</para>
115 <variablelist remap='TP'>
116   <varlistentry>
117   <term><emphasis role='strong' remap='B'>-c </emphasis><emphasis remap='I'>char</emphasis></term>
118   <listitem>
119 <para>Change the delimiting character from the percent sign to
120 <emphasis remap='I'>char</emphasis>.
121 This option is available for both
122 <emphasis role='strong' remap='B'>strfile</emphasis> and <emphasis role='strong' remap='B'>unstr</emphasis>.</para>
123   </listitem>
124   </varlistentry>
125   <varlistentry>
126   <term><emphasis role='strong' remap='B'>-i</emphasis></term>
127   <listitem>
128 <para>Ignore case when ordering the strings.</para>
129   </listitem>
130   </varlistentry>
131   <varlistentry>
132   <term><emphasis role='strong' remap='B'>-o</emphasis></term>
133   <listitem>
134 <para>Order the strings in alphabetical order.  The offset table will be
135 sorted in the alphabetical order of the groups of lines referenced.
136 Any initial non-alphanumeric characters are ignored. This option
137 causes the STR_ORDERED bit in the header
138 <emphasis remap='I'>str_flags</emphasis>
139 field to be set. (It also now really does sort! It didn't used to).</para>
140   </listitem>
141   </varlistentry>
142   <varlistentry>
143   <term><emphasis role='strong' remap='B'>-r</emphasis></term>
144   <listitem>
145 <para>Randomize access to the strings.  Entries in the offset table will be
146 randomly ordered.  This option causes the STR_RANDOM bit in the header
147 <emphasis remap='I'>str_flags</emphasis>
148 field to be set. (And really does randomize)</para>
149   </listitem>
150   </varlistentry>
151   <varlistentry>
152   <term><emphasis role='strong' remap='B'>-s</emphasis></term>
153   <listitem>
154 <para>Run silently; don't give a summary message when finished.</para>
155   </listitem>
156   </varlistentry>
157   <varlistentry>
158   <term><emphasis role='strong' remap='B'>-x</emphasis></term>
159   <listitem>
160 <para>Note that each alphabetic character in the groups of lines is rotated
161 13 positions in a simple caesar cypher.  This option causes the
162 STR_ROTATED bit in the header
163 <emphasis remap='I'>str_flags</emphasis>
164 field to be set. Note that it
165 <emphasis role='strong' remap='B'>does not</emphasis>
166 rotate the strings--that operation must be performed separately.</para>
167   </listitem>
168   </varlistentry>
169 </variablelist>
170 </refsect2>
171
172 <refsect2 xml:id='header'><title>Header</title>
173 <para>The format of the header is:</para>
174
175 <para>#define VERSION 1
176 <!-- br -->
177 unsigned long str_version;  /* version number */
178 <!-- br -->
179 unsigned long str_numstr;   /* # of strings in the file */
180 <!-- br -->
181 unsigned long str_longlen;  /* length of longest string */
182 <!-- br -->
183 unsigned long str_shortlen; /* shortest string length */
184 <!-- br -->
185 #define STR_RANDOM    0x1   /* randomized pointers */
186 <!-- br -->
187 #define STR_ORDERED   0x2   /* ordered pointers */
188 <!-- br -->
189 #define STR_ROTATED   0x4   /* rot-13'd text */
190 <!-- br -->
191 unsigned long str_flags;    /* bit field for flags */
192 <!-- br -->
193 char str_delim;             /* delimiting character */</para>
194
195 <para>All fields are written in network byte order.</para>
196 </refsect2>
197 </refsect1>
198
199 <refsect1 xml:id='bugs'><title>BUGS</title>
200 <para>Fewer now, one hopes.  However, fortunes (text strings) beginning with a
201 blank line appear to be sorted between random letters.  This includes
202 ASCII art that contains no letters, and first lines that are solely
203 non-alphanumeric, apparently.  I've no idea why this should be.</para>
204 </refsect1>
205
206 <refsect1 xml:id='other_uses'><title>OTHER USES</title>
207 <para>What can you do with this besides printing sarcastic and obscene messages
208 to the screens of lusers at login or logout?</para>
209
210 <para>There
211 <emphasis role='strong' remap='B'>are</emphasis>
212 some other possibilities.  Source code for a sample program,
213 <emphasis role='strong' remap='B'>randstr</emphasis>,
214 is included with this distribution: randstr splits the difference between
215 <emphasis role='strong' remap='B'>unstr</emphasis> and <emphasis role='strong' remap='B'>fortune</emphasis>.
216 It reads a single, specified file, and randomly selects a single text
217 string.</para>
218 <variablelist remap='IP'>
219   <varlistentry>
220   <term>1</term>
221   <listitem>
222 <para>Include
223 <emphasis remap='I'>strfile.h</emphasis>
224 into a news reading/posting program, to generate random signatures.
225 <citerefentry><refentrytitle>Tin</refentrytitle><manvolnum>1</manvolnum></citerefentry>
226 does something similar, in a much more complex manner.</para>
227   </listitem>
228   </varlistentry>
229   <varlistentry>
230   <term>2</term>
231   <listitem>
232 <para>Include it in a game.  While strfile doesn't support 'fields' or
233 'records', there's no reason that the text strings can't be consistent:
234 first line, a die roll; second line, a score; third and subsequent lines,
235 a text message.</para>
236   </listitem>
237   </varlistentry>
238   <varlistentry>
239   <term>3</term>
240   <listitem>
241 <para>Use it to store your address book.  Hell, some of the guys I know
242 would be as well off using it to decide who to call on Friday nights (and
243 for some, it wouldn't matter whether there were phone numbers in it or not).</para>
244   </listitem>
245   </varlistentry>
246   <varlistentry>
247   <term>4</term>
248   <listitem>
249 <para>Use it in 'lottery' situations.  If you're an ISP, write a script to
250 store login names and GECOS from
251 <filename>/etc/passwd</filename>
252 in strfile format, write another to send 'congratulations, you've won'
253 to the lucky login selected.  The prize might be a month's free service,
254 or if you're AOL, a month free on a real service provider.</para>
255   </listitem>
256   </varlistentry>
257 </variablelist>
258 </refsect1>
259
260 <refsect1 xml:id='see_also'><title>SEE ALSO</title>
261 <para><citerefentry><refentrytitle>byteorder</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>fortune</refentrytitle><manvolnum>6</manvolnum></citerefentry></para>
262 </refsect1>
263
264 <refsect1 xml:id='history'><title>HISTORY</title>
265 <para>The
266 <emphasis role='strong' remap='B'>strfile</emphasis>
267 utility first appeared in 4.4BSD. This version was heavily modified,
268 much of it in ways peculiar to Linux.  Work has since been done to make
269 the code more generic, and has so far been tested to work with SunOS
270 4.x.  More platforms are expected to be supported as work continues.</para>
271 </refsect1>
272 </refentry>
273