1STRFILE(1)                 4th Berkeley Distribution                STRFILE(1)
2
3
4

NAME

6       strfile - create a random access file for storing strings
7       unstr - dump strings in pointer order
8
9

SYNOPSIS

11
12
13                 strfile     [-iorsx]
14                    [-c char]
15                    sourcefile
16                    [outputfile]
17
18
19
20
21               unstr     [-c char]
22                  datafile.[ext]
23                  [outputfile]
24
25

DESCRIPTION

27       strfile reads a file containing groups of lines separated by a line
28       containing a single percent `%' sign (or other specified delimiter
29       character) and creates a data file which contains a header structure
30       and a table of file offsets for each group of lines. This allows random
31       access of the strings.
32
33
34       The output file, if not specified on the command line, is named
35       sourcefile.dat.
36
37
38       The purpose of unstr is to undo the work of strfile. It prints out the
39       strings contained in the sourcefile, which is datafile.ext without its
40       extension, or datafile if no extension is specified (in this case, the
41       extension .dat is added to the name of the datafile) in the order that
42       they are listed in the header file datafile. If no outputfile is
43       specified, it prints to standard output; otherwise it prints to the
44       file specified.  unstr can also universally change the delimiter
45       character in a strings file. It is possible to create sorted versions
46       of input files by using strfile -o and then using unstr to dump them
47       out in the table order.
48
49
50   Options
51       The options are as follows:
52
53
54       -c char
55
56           Change the delimiting character from the percent sign to char. This
57           option is available for both strfile and unstr.
58
59
60       -i
61
62           Ignore case when ordering the strings.
63
64
65       -o
66
67           Order the strings in alphabetical order. The offset table will be
68           sorted in the alphabetical order of the groups of lines referenced.
69           Any initial non-alphanumeric characters are ignored. This option
70           causes the STR_ORDERED bit in the header str_flags field to be set.
71           (It also now really does sort! It didn't used to).
72
73
74       -r
75
76           Randomize access to the strings. Entries in the offset table will
77           be randomly ordered. This option causes the STR_RANDOM bit in the
78           header str_flags field to be set. (And really does randomize)
79
80
81       -s
82
83           Run silently; don't give a summary message when finished.
84
85
86       -x
87
88           Note that each alphabetic character in the groups of lines is
89           rotated 13 positions in a simple caesar cypher. This option causes
90           the STR_ROTATED bit in the header str_flags field to be set. Note
91           that it does not rotate the strings--that operation must be
92           performed separately.
93
94
95
96   Header
97       The format of the header is:
98
99
100       #define VERSION 1 unsigned long str_version; /* version number */
101       unsigned long str_numstr; /* # of strings in the file */ unsigned long
102       str_longlen; /* length of longest string */ unsigned long str_shortlen;
103       /* shortest string length */ #define STR_RANDOM 0x1 /* randomized
104       pointers */ #define STR_ORDERED 0x2 /* ordered pointers */ #define
105       STR_ROTATED 0x4 /* rot-13'd text */ unsigned long str_flags; /* bit
106       field for flags */ char str_delim; /* delimiting character */
107
108
109       All fields are written in network byte order.
110
111

BUGS

113       Fewer now, one hopes. However, fortunes (text strings) beginning with a
114       blank line appear to be sorted between random letters. This includes
115       ASCII art that contains no letters, and first lines that are solely
116       non-alphanumeric, apparently. I've no idea why this should be.
117
118

OTHER USES

120       What can you do with this besides printing sarcastic and obscene
121       messages to the screens of lusers at login or logout?
122
123
124       There are some other possibilities. Source code for a sample program,
125       randstr, is included with this distribution: randstr splits the
126       difference between unstr and fortune. It reads a single, specified
127       file, and randomly selects a single text string.
128
129
130       1
131
132           Include strfile.h into a news reading/posting program, to generate
133           random signatures.  Tin(1) does something similar, in a much more
134           complex manner.
135
136
137       2
138
139           Include it in a game. While strfile doesn't support 'fields' or
140           'records', there's no reason that the text strings can't be
141           consistent: first line, a die roll; second line, a score; third and
142           subsequent lines, a text message.
143
144
145       3
146
147           Use it to store your address book. Hell, some of the guys I know
148           would be as well off using it to decide who to call on Friday
149           nights (and for some, it wouldn't matter whether there were phone
150           numbers in it or not).
151
152
153       4
154
155           Use it in 'lottery' situations. If you're an ISP, write a script to
156           store login names and GECOS from /etc/passwd in strfile format,
157           write another to send 'congratulations, you've won' to the lucky
158           login selected. The prize might be a month's free service, or if
159           you're AOL, a month free on a real service provider.
160
161
162

SEE ALSO

164       byteorder(3), fortune(6)
165
166

HISTORY

168       The strfile utility first appeared in 4.4BSD. This version was heavily
169       modified, much of it in ways peculiar to Linux. Work has since been
170       done to make the code more generic, and has so far been tested to work
171       with SunOS 4.x. More platforms are expected to be supported as work
172       continues.
173
174
175
176
177June 9, 1993 [Apr. 1997]          06/03/2023                        STRFILE(1)
Impressum