xref: /freebsd/usr.bin/fortune/strfile/strfile.8 (revision bdcbfde3)
16ae1554aSColin Percival.\" Copyright (c) 1989, 1991, 1993
26ae1554aSColin Percival.\"	The Regents of the University of California.  All rights reserved.
36ae1554aSColin Percival.\"
46ae1554aSColin Percival.\"
56ae1554aSColin Percival.\" This code is derived from software contributed to Berkeley by
66ae1554aSColin Percival.\" Ken Arnold.
76ae1554aSColin Percival.\"
86ae1554aSColin Percival.\" Redistribution and use in source and binary forms, with or without
96ae1554aSColin Percival.\" modification, are permitted provided that the following conditions
106ae1554aSColin Percival.\" are met:
116ae1554aSColin Percival.\" 1. Redistributions of source code must retain the above copyright
126ae1554aSColin Percival.\"    notice, this list of conditions and the following disclaimer.
136ae1554aSColin Percival.\" 2. Redistributions in binary form must reproduce the above copyright
146ae1554aSColin Percival.\"    notice, this list of conditions and the following disclaimer in the
156ae1554aSColin Percival.\"    documentation and/or other materials provided with the distribution.
166ae1554aSColin Percival.\" 3. Neither the name of the University nor the names of its contributors
176ae1554aSColin Percival.\"    may be used to endorse or promote products derived from this software
186ae1554aSColin Percival.\"    without specific prior written permission.
196ae1554aSColin Percival.\"
206ae1554aSColin Percival.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
216ae1554aSColin Percival.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
226ae1554aSColin Percival.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
236ae1554aSColin Percival.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
246ae1554aSColin Percival.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
256ae1554aSColin Percival.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
266ae1554aSColin Percival.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
276ae1554aSColin Percival.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
286ae1554aSColin Percival.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
296ae1554aSColin Percival.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
306ae1554aSColin Percival.\" SUCH DAMAGE.
316ae1554aSColin Percival.\"
326ae1554aSColin Percival.Dd February 17, 2005
336ae1554aSColin Percival.Dt STRFILE 8
346ae1554aSColin Percival.Os
356ae1554aSColin Percival.Sh NAME
366ae1554aSColin Percival.Nm strfile ,
376ae1554aSColin Percival.Nm unstr
386ae1554aSColin Percival.Nd "create a random access file for storing strings"
396ae1554aSColin Percival.Sh SYNOPSIS
406ae1554aSColin Percival.Nm
416ae1554aSColin Percival.Op Fl Ciorsx
426ae1554aSColin Percival.Op Fl c Ar char
436ae1554aSColin Percival.Ar source_file
446ae1554aSColin Percival.Op Ar output_file
456ae1554aSColin Percival.Nm unstr
466ae1554aSColin Percival.Ar source_file
476ae1554aSColin Percival.Sh DESCRIPTION
486ae1554aSColin PercivalThe
496ae1554aSColin Percival.Nm
506ae1554aSColin Percivalutility
516ae1554aSColin Percivalreads a file containing groups of lines separated by a line containing
526ae1554aSColin Percivala single percent
536ae1554aSColin Percival.Ql %
546ae1554aSColin Percivalsign and creates a data file which contains
556ae1554aSColin Percivala header structure and a table of file offsets for each group of lines.
566ae1554aSColin PercivalThis allows random access of the strings.
576ae1554aSColin Percival.Pp
586ae1554aSColin PercivalThe output file, if not specified on the command line, is named
596ae1554aSColin Percival.Ar source_file Ns Pa .dat .
606ae1554aSColin Percival.Pp
616ae1554aSColin PercivalThe options are as follows:
626ae1554aSColin Percival.Bl -tag -width ".Fl c Ar char"
636ae1554aSColin Percival.It Fl C
646ae1554aSColin PercivalFlag the file as containing comments.
656ae1554aSColin PercivalThis option cases the
666ae1554aSColin Percival.Dv STR_COMMENTS
676ae1554aSColin Percivalbit in the header
686ae1554aSColin Percival.Va str_flags
696ae1554aSColin Percivalfield to be set.
706ae1554aSColin PercivalComments are designated by two delimiter characters at the
716ae1554aSColin Percivalbeginning of the line, though
726ae1554aSColin Percival.Nm
736ae1554aSColin Percivaldoes not give any special
746ae1554aSColin Percivaltreatment to comment lines.
756ae1554aSColin Percival.It Fl c Ar char
766ae1554aSColin PercivalChange the delimiting character from the percent sign to
776ae1554aSColin Percival.Ar char .
786ae1554aSColin Percival.It Fl i
796ae1554aSColin PercivalIgnore case when ordering the strings.
806ae1554aSColin Percival.It Fl o
816ae1554aSColin PercivalOrder the strings in alphabetical order.
826ae1554aSColin PercivalThe offset table will be sorted in the alphabetical order of the
836ae1554aSColin Percivalgroups of lines referenced.
846ae1554aSColin PercivalAny initial non-alphanumeric characters are ignored.
856ae1554aSColin PercivalThis option causes the
866ae1554aSColin Percival.Dv STR_ORDERED
876ae1554aSColin Percivalbit in the header
886ae1554aSColin Percival.Va str_flags
896ae1554aSColin Percivalfield to be set.
906ae1554aSColin Percival.It Fl r
916ae1554aSColin PercivalRandomize access to the strings.
926ae1554aSColin PercivalEntries in the offset table will be randomly ordered.
936ae1554aSColin PercivalThis option causes the
946ae1554aSColin Percival.Dv STR_RANDOM
956ae1554aSColin Percivalbit in the header
966ae1554aSColin Percival.Va str_flags
976ae1554aSColin Percivalfield to be set.
986ae1554aSColin Percival.It Fl s
996ae1554aSColin PercivalRun silently; do not give a summary message when finished.
1006ae1554aSColin Percival.It Fl x
1016ae1554aSColin PercivalNote that each alphabetic character in the groups of lines is rotated
1026ae1554aSColin Percival13 positions in a simple caesar cypher.
1036ae1554aSColin PercivalThis option causes the
1046ae1554aSColin Percival.Dv STR_ROTATED
1056ae1554aSColin Percivalbit in the header
1066ae1554aSColin Percival.Va str_flags
1076ae1554aSColin Percivalfield to be set.
1086ae1554aSColin Percival.El
1096ae1554aSColin Percival.Pp
1106ae1554aSColin PercivalThe format of the header is:
1116ae1554aSColin Percival.Bd -literal
1126ae1554aSColin Percival#define	VERSION	1
1136ae1554aSColin Percivaluint32_t	str_version;	/* version number */
1146ae1554aSColin Percivaluint32_t	str_numstr;	/* # of strings in the file */
1156ae1554aSColin Percivaluint32_t	str_longlen;	/* length of longest string */
1166ae1554aSColin Percivaluint32_t	str_shortlen;	/* length of shortest string */
1176ae1554aSColin Percival#define	STR_RANDOM	0x1	/* randomized pointers */
1186ae1554aSColin Percival#define	STR_ORDERED	0x2	/* ordered pointers */
1196ae1554aSColin Percival#define	STR_ROTATED	0x4	/* rot-13'd text */
1206ae1554aSColin Percival#define	STR_COMMENTS	0x8	/* embedded comments */
1216ae1554aSColin Percivaluint32_t	str_flags;	/* bit field for flags */
1226ae1554aSColin Percivalchar		str_delim;	/* delimiting character */
1236ae1554aSColin Percival.Ed
1246ae1554aSColin Percival.Pp
1256ae1554aSColin PercivalAll fields are written in network byte order.
1266ae1554aSColin Percival.Pp
1276ae1554aSColin PercivalThe purpose of
1286ae1554aSColin Percival.Nm unstr
1296ae1554aSColin Percivalis to undo the work of
1306ae1554aSColin Percival.Nm .
1316ae1554aSColin PercivalIt prints out the strings contained in the file
1326ae1554aSColin Percival.Ar source_file
1336ae1554aSColin Percivalin the order that they are listed in
1346ae1554aSColin Percivalthe header file
1356ae1554aSColin Percival.Ar source_file Ns Pa .dat
1366ae1554aSColin Percivalto standard output.
1376ae1554aSColin PercivalIt is possible to create sorted versions of input files by using
1386ae1554aSColin Percival.Fl o
1396ae1554aSColin Percivalwhen
1406ae1554aSColin Percival.Nm
1416ae1554aSColin Percivalis run and then using
1426ae1554aSColin Percival.Nm unstr
1436ae1554aSColin Percivalto dump them out in the table order.
1446ae1554aSColin Percival.Sh FILES
1456ae1554aSColin Percival.Bl -tag -width ".Pa strfile.dat" -compact
1466ae1554aSColin Percival.It Pa strfile.dat
1476ae1554aSColin Percivaldefault output file.
1486ae1554aSColin Percival.El
1496ae1554aSColin Percival.Sh SEE ALSO
1506ae1554aSColin Percival.Xr byteorder 3 ,
1516ae1554aSColin Percival.Xr fortune 6
1526ae1554aSColin Percival.Sh HISTORY
1536ae1554aSColin PercivalThe
1546ae1554aSColin Percival.Nm
1556ae1554aSColin Percivalutility first appeared in
1566ae1554aSColin Percival.Bx 4.4 .
157