Debian Codegraph @

upstream/fedora-44/man1/strfile.1

raw
1 '\" t
2 .\" Title: STRFILE
3 .\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\" Date: 01/19/2026
6 .\" Manual: 4th Berkeley Distribution
7 .\" Source: June 9, 1993 [Apr. 1997]
8 .\" Language: English
9 .\"
10 .TH "STRFILE" "1" "01/19/2026" "June 9, 1993 [Apr\&. 1997]" "4th Berkeley Distribution"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30
31 .SH "NAME"
32 strfile \- create a random access file for storing strings
33 .br
34 unstr \- dump strings in pointer order
35
36 .SH "SYNOPSIS"
37 .HP \w'\fBstrfile\fR\ 'u
38
39 \fBstrfile\fR [\-iorsx]
40 [\-c\ \fIchar\fR]
41 \fIsourcefile\fR
42 [\fIoutputfile\fR]
43
44 .HP \w'\fBunstr\fR\ 'u
45
46 \fBunstr\fR [\-c\ \fIchar\fR]
47 \fIdatafile\&.[ext]\fR
48 [\fIoutputfile\fR]
49
50 .SH "DESCRIPTION"
51 .PP
52 \fBstrfile\fR
53 reads a file containing groups of lines separated by a line containing a single percent `%\*(Aq sign (or other specified delimiter character) and creates a data file which contains a header structure and a table of file offsets for each group of lines\&. This allows random access of the strings\&.
54
55 .PP
56 The output file, if not specified on the command line, is named
57 \fIsourcefile\&.dat\fR\&.
58
59 .PP
60 The purpose of
61 \fBunstr\fR
62 is to undo the work of
63 \fBstrfile\fR\&. It prints out the strings contained in the sourcefile, which is
64 \fIdatafile\&.ext\fR
65 without its extension, or
66 \fIdatafile\fR
67 if no extension is specified (in this case, the extension
68 \fB\&.dat\fR
69 is added to the name of the datafile) in the order that they are listed in the header file
70 \fIdatafile\fR\&. If no
71 \fIoutputfile\fR
72 is specified, it prints to standard output; otherwise it prints to the file specified\&.
73 \fBunstr\fR
74 can also universally change the delimiter character in a strings file\&. It is possible to create sorted versions of input files by using
75 \fBstrfile \-o\fR
76 and then using
77 \fBunstr\fR
78 to dump them out in the table order\&.
79
80 .SS "Options"
81 .PP
82 The options are as follows:
83
84 .PP
85 \fB\-c \fR\fIchar\fR
86 .RS 4
87
88 Change the delimiting character from the percent sign to
89 \fIchar\fR\&. This option is available for both
90 \fBstrfile\fR
91 and
92 \fBunstr\fR\&.
93
94 .RE
95 .PP
96 \fB\-i\fR
97 .RS 4
98
99 Ignore case when ordering the strings\&.
100
101 .RE
102 .PP
103 \fB\-o\fR
104 .RS 4
105
106 Order the strings in alphabetical order\&. The offset table will be sorted in the alphabetical order of the groups of lines referenced\&. Any initial non\-alphanumeric characters are ignored\&. This option causes the STR_ORDERED bit in the header
107 \fIstr_flags\fR
108 field to be set\&. (It also now really does sort! It didn\*(Aqt used to)\&.
109
110 .RE
111 .PP
112 \fB\-r\fR
113 .RS 4
114
115 Randomize access to the strings\&. Entries in the offset table will be randomly ordered\&. This option causes the STR_RANDOM bit in the header
116 \fIstr_flags\fR
117 field to be set\&. (And really does randomize)
118
119 .RE
120 .PP
121 \fB\-s\fR
122 .RS 4
123
124 Run silently; don\*(Aqt give a summary message when finished\&.
125
126 .RE
127 .PP
128 \fB\-x\fR
129 .RS 4
130
131 Note that each alphabetic character in the groups of lines is rotated 13 positions in a simple caesar cypher\&. This option causes the STR_ROTATED bit in the header
132 \fIstr_flags\fR
133 field to be set\&. Note that it
134 \fBdoes not\fR
135 rotate the strings\-\-that operation must be performed separately\&.
136
137 .RE
138
139 .SS "Header"
140 .PP
141 The format of the header is:
142
143 .PP
144 #define VERSION 1
145 unsigned long str_version; /* version number */
146 unsigned long str_numstr; /* # of strings in the file */
147 unsigned long str_longlen; /* length of longest string */
148 unsigned long str_shortlen; /* shortest string length */
149 #define STR_RANDOM 0x1 /* randomized pointers */
150 #define STR_ORDERED 0x2 /* ordered pointers */
151 #define STR_ROTATED 0x4 /* rot\-13\*(Aqd text */
152 unsigned long str_flags; /* bit field for flags */
153 char str_delim; /* delimiting character */
154
155 .PP
156 All fields are written in network byte order\&.
157
158 .SH "BUGS"
159 .PP
160 Fewer now, one hopes\&. However, fortunes (text strings) beginning with a blank line appear to be sorted between random letters\&. This includes ASCII art that contains no letters, and first lines that are solely non\-alphanumeric, apparently\&. I\*(Aqve no idea why this should be\&.
161
162 .SH "OTHER USES"
163 .PP
164 What can you do with this besides printing sarcastic and obscene messages to the screens of lusers at login or logout?
165
166 .PP
167 There
168 \fBare\fR
169 some other possibilities\&. Source code for a sample program,
170 \fBrandstr\fR, is included with this distribution: randstr splits the difference between
171 \fBunstr\fR
172 and
173 \fBfortune\fR\&. It reads a single, specified file, and randomly selects a single text string\&.
174
175 .PP
176 1
177 .RS 4
178
179 Include
180 \fIstrfile\&.h\fR
181 into a news reading/posting program, to generate random signatures\&.
182 \fBTin\fR(1)
183 does something similar, in a much more complex manner\&.
184
185 .RE
186 .PP
187 2
188 .RS 4
189
190 Include it in a game\&. While strfile doesn\*(Aqt support \*(Aqfields\*(Aq or \*(Aqrecords\*(Aq, there\*(Aqs no reason that the text strings can\*(Aqt be consistent: first line, a die roll; second line, a score; third and subsequent lines, a text message\&.
191
192 .RE
193 .PP
194 3
195 .RS 4
196
197 Use it to store your address book\&. Hell, some of the guys I know would be as well off using it to decide who to call on Friday nights (and for some, it wouldn\*(Aqt matter whether there were phone numbers in it or not)\&.
198
199 .RE
200 .PP
201 4
202 .RS 4
203
204 Use it in \*(Aqlottery\*(Aq situations\&. If you\*(Aqre an ISP, write a script to store login names and GECOS from
205 /etc/passwd
206 in strfile format, write another to send \*(Aqcongratulations, you\*(Aqve won\*(Aq to the lucky login selected\&. The prize might be a month\*(Aqs free service, or if you\*(Aqre AOL, a month free on a real service provider\&.
207
208 .RE
209
210 .SH "SEE ALSO"
211 .PP
212 \fBbyteorder\fR(3),
213 \fBfortune\fR(6)
214
215 .SH "HISTORY"
216 .PP
217 The
218 \fBstrfile\fR
219 utility first appeared in 4\&.4BSD\&. This version was heavily modified, much of it in ways peculiar to Linux\&. Work has since been done to make the code more generic, and has so far been tested to work with SunOS 4\&.x\&. More platforms are expected to be supported as work continues\&.
220