Penguin
Annotated edit history of strfile(1) version 4, including all changes. View license author blame.
Rev Author # Line
1 perry 1 STRFILE
2 !!!STRFILE
3 NAME
4 SYNOPSIS
5 DESCRIPTION
6 BUGS
7 OTHER USES
8 SEE ALSO
9 HISTORY
10 ----
11 !!NAME
12
13
14 strfile - create a random access file for storing strings
15 unstr - dump strings in pointer order
16 !!SYNOPSIS
17
18
19 __strfile__ [[__-iorsx__] [[__-c__ ''char'']
20 ''sourcefile'' [[''outputfile'']__
21 unstr__ [[__-c__ ''char'']
22 ''datafile''[[''.ext'']
23 [[''outputfile'']
24 !!DESCRIPTION
25
26
27 __strfile__ reads a file containing groups of lines
28 separated by a line containing a single percent `%' sign (or
29 other specified delimiter character) and creates a data file
30 which contains a header structure and a table of file
31 offsets for each group of lines. This allows random access
32 of the strings.
33
34
35 The output file, if not specified on the command line, is
36 named ''sourcefile.dat''.
37
38
39 The purpose of __unstr__ is to undo the work of
40 __strfile__. It prints out the strings contained in the
41 sourcefile, which is ''datafile.ext'' without its
42 extension, or ''datafile'' if no extension is specified
43 (in this case, the extension ''.dat'' is added to the
44 name of the datafile) in the order that they are listed in
45 the header file ''datafile''. If no ''outputfile'' is
46 specified, it prints to standard output; otherwise it prints
47 to the file specified. __unstr__ can also universally
48 change the delimiter character in a strings file. It is
49 possible to create sorted versions of input files by using
50 __strfile -o__ and then using __unstr__ to dump them
51 out in the table order.
52
53
54 __Options__
55
56
57 The options are as follows:
58
59
60 __-c__ ''char''
61
62
63 Change the delimiting character from the percent sign to
64 ''char''. This option is available for both
65 __strfile__ and __unstr__.
66
67
68 __-i__
69
70
71 Ignore case when ordering the strings.
72
73
74 __-o__
75
76
77 Order the strings in alphabetical order. The offset table
78 will be sorted in the alphabetical order of the groups of
79 lines referenced. Any initial non-alphanumeric characters
80 are ignored. This option causes the STR_ORDERED bit in the
81 header ''str_flags'' field to be set. (It also now really
82 does sort! It didn't used to).
83
84
85 __-r__
86
87
88 Randomize access to the strings. Entries in the offset table
89 will be randomly ordered. This option causes the STR_RANDOM
90 bit in the header ''str_flags'' field to be set. (And
91 really does randomize)
92
93
94 __-s__
95
96
97 Run silently; don't give a summary message when
98 finished.
99
100
101 __-x__
102
103
104 Note that each alphabetic character in the groups of lines
105 is rotated 13 positions in a simple caesar cypher. This
106 option causes the STR_ROTATED bit in the header
107 ''str_flags'' field to be set. Note that it __does
108 not__ rotate the strings--that operation must be performed
109 separately.
110
111
112 __Header__
113
114
115 The format of the header is:
116
117
118 #define VERSION 1
119 unsigned long str_version; /* version number */
120 unsigned long str_numstr; /* # of strings in the file */
121 unsigned long str_longlen; /* length of longest string
122 */
123 unsigned long str_shortlen; /* shortest string length */
124 #define STR_RANDOM 0x1 /* randomized pointers */
125 #define STR_ORDERED 0x2 /* ordered pointers */
126 #define STR_ROTATED 0x4 /* rot-13'd text */
127 unsigned long str_flags; /* bit field for flags */
128 char str_delim; /* delimiting character */
129
130
131 All fields are written in network byte order.
132 !!BUGS
133
134
135 Fewer now, one hopes. However, fortunes (text strings)
136 beginning with a blank line appear to be sorted between
137 random letters. This includes ASCII art that contains no
138 letters, and first lines that are solely non-alphanumeric,
139 apparently. I've no idea why this should be.
140 !!OTHER USES
141
142
143 What can you do with this besides printing sarcastic and
144 obscene messages to the screens of lusers at login or
145 logout?
146
147
148 There __are__ some other possibilities. Source code for a
149 sample program, __randstr__, is included with this
150 distribution: randstr splits the difference between
151 __unstr__ and __fortune__. It reads a single,
152 specified file, and randomly selects a single text
153 string.
154
155
156 1
157
158
159 Include ''strfile.h'' into a news reading/posting
4 perry 160 program, to generate random signatures. Tin(1) does
1 perry 161 something similar, in a much more complex
162 manner.
163
164
165 2
166
167
168 Include it in a game. While strfile doesn't support 'fields'
169 or 'records', there's no reason that the text strings can't
170 be consistent: first line, a die roll; second line, a score;
171 third and subsequent lines, a text message.
172
173
174 3
175
176
177 Use it to store your address book. Hell, some of the guys I
178 know would be as well off using it to decide who to call on
179 Friday nights (and for some, it wouldn't matter whether
180 there were phone numbers in it or not).
181
182
183 4
184
185
186 Use it in 'lottery' situations. If you're an ISP, write a
187 script to store login names and GECOS from
188 ''/etc/passwd'' in strfile format, write another to send
189 'congratulations, you've won' to the lucky login selected.
190 The prize might be a month's free service, or if you're AOL,
191 a month free on a real service provider.
192 !!SEE ALSO
193
194
195 byteorder(3), fortune(6)
196 !!HISTORY
197
198
199 The __strfile__ utility first appeared in 4.4BSD. This
200 version was heavily modified, much of it in ways peculiar to
201 Linux. Work has since been done to make the code more
202 generic, and has so far been tested to work with SunOS 4.x.
203 More platforms are expected to be supported as work
204 continues.
205 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.