1*6ae1554aSColin Percival.\" Copyright (c) 1989, 1991, 1993 2*6ae1554aSColin Percival.\" The Regents of the University of California. All rights reserved. 3*6ae1554aSColin Percival.\" 4*6ae1554aSColin Percival.\" 5*6ae1554aSColin Percival.\" This code is derived from software contributed to Berkeley by 6*6ae1554aSColin Percival.\" Ken Arnold. 7*6ae1554aSColin Percival.\" 8*6ae1554aSColin Percival.\" Redistribution and use in source and binary forms, with or without 9*6ae1554aSColin Percival.\" modification, are permitted provided that the following conditions 10*6ae1554aSColin Percival.\" are met: 11*6ae1554aSColin Percival.\" 1. Redistributions of source code must retain the above copyright 12*6ae1554aSColin Percival.\" notice, this list of conditions and the following disclaimer. 13*6ae1554aSColin Percival.\" 2. Redistributions in binary form must reproduce the above copyright 14*6ae1554aSColin Percival.\" notice, this list of conditions and the following disclaimer in the 15*6ae1554aSColin Percival.\" documentation and/or other materials provided with the distribution. 16*6ae1554aSColin Percival.\" 3. Neither the name of the University nor the names of its contributors 17*6ae1554aSColin Percival.\" may be used to endorse or promote products derived from this software 18*6ae1554aSColin Percival.\" without specific prior written permission. 19*6ae1554aSColin Percival.\" 20*6ae1554aSColin Percival.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21*6ae1554aSColin Percival.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22*6ae1554aSColin Percival.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23*6ae1554aSColin Percival.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24*6ae1554aSColin Percival.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25*6ae1554aSColin Percival.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26*6ae1554aSColin Percival.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27*6ae1554aSColin Percival.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28*6ae1554aSColin Percival.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29*6ae1554aSColin Percival.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30*6ae1554aSColin Percival.\" SUCH DAMAGE. 31*6ae1554aSColin Percival.\" 32*6ae1554aSColin Percival.Dd February 17, 2005 33*6ae1554aSColin Percival.Dt STRFILE 8 34*6ae1554aSColin Percival.Os 35*6ae1554aSColin Percival.Sh NAME 36*6ae1554aSColin Percival.Nm strfile , 37*6ae1554aSColin Percival.Nm unstr 38*6ae1554aSColin Percival.Nd "create a random access file for storing strings" 39*6ae1554aSColin Percival.Sh SYNOPSIS 40*6ae1554aSColin Percival.Nm 41*6ae1554aSColin Percival.Op Fl Ciorsx 42*6ae1554aSColin Percival.Op Fl c Ar char 43*6ae1554aSColin Percival.Ar source_file 44*6ae1554aSColin Percival.Op Ar output_file 45*6ae1554aSColin Percival.Nm unstr 46*6ae1554aSColin Percival.Ar source_file 47*6ae1554aSColin Percival.Sh DESCRIPTION 48*6ae1554aSColin PercivalThe 49*6ae1554aSColin Percival.Nm 50*6ae1554aSColin Percivalutility 51*6ae1554aSColin Percivalreads a file containing groups of lines separated by a line containing 52*6ae1554aSColin Percivala single percent 53*6ae1554aSColin Percival.Ql % 54*6ae1554aSColin Percivalsign and creates a data file which contains 55*6ae1554aSColin Percivala header structure and a table of file offsets for each group of lines. 56*6ae1554aSColin PercivalThis allows random access of the strings. 57*6ae1554aSColin Percival.Pp 58*6ae1554aSColin PercivalThe output file, if not specified on the command line, is named 59*6ae1554aSColin Percival.Ar source_file Ns Pa .dat . 60*6ae1554aSColin Percival.Pp 61*6ae1554aSColin PercivalThe options are as follows: 62*6ae1554aSColin Percival.Bl -tag -width ".Fl c Ar char" 63*6ae1554aSColin Percival.It Fl C 64*6ae1554aSColin PercivalFlag the file as containing comments. 65*6ae1554aSColin PercivalThis option cases the 66*6ae1554aSColin Percival.Dv STR_COMMENTS 67*6ae1554aSColin Percivalbit in the header 68*6ae1554aSColin Percival.Va str_flags 69*6ae1554aSColin Percivalfield to be set. 70*6ae1554aSColin PercivalComments are designated by two delimiter characters at the 71*6ae1554aSColin Percivalbeginning of the line, though 72*6ae1554aSColin Percival.Nm 73*6ae1554aSColin Percivaldoes not give any special 74*6ae1554aSColin Percivaltreatment to comment lines. 75*6ae1554aSColin Percival.It Fl c Ar char 76*6ae1554aSColin PercivalChange the delimiting character from the percent sign to 77*6ae1554aSColin Percival.Ar char . 78*6ae1554aSColin Percival.It Fl i 79*6ae1554aSColin PercivalIgnore case when ordering the strings. 80*6ae1554aSColin Percival.It Fl o 81*6ae1554aSColin PercivalOrder the strings in alphabetical order. 82*6ae1554aSColin PercivalThe offset table will be sorted in the alphabetical order of the 83*6ae1554aSColin Percivalgroups of lines referenced. 84*6ae1554aSColin PercivalAny initial non-alphanumeric characters are ignored. 85*6ae1554aSColin PercivalThis option causes the 86*6ae1554aSColin Percival.Dv STR_ORDERED 87*6ae1554aSColin Percivalbit in the header 88*6ae1554aSColin Percival.Va str_flags 89*6ae1554aSColin Percivalfield to be set. 90*6ae1554aSColin Percival.It Fl r 91*6ae1554aSColin PercivalRandomize access to the strings. 92*6ae1554aSColin PercivalEntries in the offset table will be randomly ordered. 93*6ae1554aSColin PercivalThis option causes the 94*6ae1554aSColin Percival.Dv STR_RANDOM 95*6ae1554aSColin Percivalbit in the header 96*6ae1554aSColin Percival.Va str_flags 97*6ae1554aSColin Percivalfield to be set. 98*6ae1554aSColin Percival.It Fl s 99*6ae1554aSColin PercivalRun silently; do not give a summary message when finished. 100*6ae1554aSColin Percival.It Fl x 101*6ae1554aSColin PercivalNote that each alphabetic character in the groups of lines is rotated 102*6ae1554aSColin Percival13 positions in a simple caesar cypher. 103*6ae1554aSColin PercivalThis option causes the 104*6ae1554aSColin Percival.Dv STR_ROTATED 105*6ae1554aSColin Percivalbit in the header 106*6ae1554aSColin Percival.Va str_flags 107*6ae1554aSColin Percivalfield to be set. 108*6ae1554aSColin Percival.El 109*6ae1554aSColin Percival.Pp 110*6ae1554aSColin PercivalThe format of the header is: 111*6ae1554aSColin Percival.Bd -literal 112*6ae1554aSColin Percival#define VERSION 1 113*6ae1554aSColin Percivaluint32_t str_version; /* version number */ 114*6ae1554aSColin Percivaluint32_t str_numstr; /* # of strings in the file */ 115*6ae1554aSColin Percivaluint32_t str_longlen; /* length of longest string */ 116*6ae1554aSColin Percivaluint32_t str_shortlen; /* length of shortest string */ 117*6ae1554aSColin Percival#define STR_RANDOM 0x1 /* randomized pointers */ 118*6ae1554aSColin Percival#define STR_ORDERED 0x2 /* ordered pointers */ 119*6ae1554aSColin Percival#define STR_ROTATED 0x4 /* rot-13'd text */ 120*6ae1554aSColin Percival#define STR_COMMENTS 0x8 /* embedded comments */ 121*6ae1554aSColin Percivaluint32_t str_flags; /* bit field for flags */ 122*6ae1554aSColin Percivalchar str_delim; /* delimiting character */ 123*6ae1554aSColin Percival.Ed 124*6ae1554aSColin Percival.Pp 125*6ae1554aSColin PercivalAll fields are written in network byte order. 126*6ae1554aSColin Percival.Pp 127*6ae1554aSColin PercivalThe purpose of 128*6ae1554aSColin Percival.Nm unstr 129*6ae1554aSColin Percivalis to undo the work of 130*6ae1554aSColin Percival.Nm . 131*6ae1554aSColin PercivalIt prints out the strings contained in the file 132*6ae1554aSColin Percival.Ar source_file 133*6ae1554aSColin Percivalin the order that they are listed in 134*6ae1554aSColin Percivalthe header file 135*6ae1554aSColin Percival.Ar source_file Ns Pa .dat 136*6ae1554aSColin Percivalto standard output. 137*6ae1554aSColin PercivalIt is possible to create sorted versions of input files by using 138*6ae1554aSColin Percival.Fl o 139*6ae1554aSColin Percivalwhen 140*6ae1554aSColin Percival.Nm 141*6ae1554aSColin Percivalis run and then using 142*6ae1554aSColin Percival.Nm unstr 143*6ae1554aSColin Percivalto dump them out in the table order. 144*6ae1554aSColin Percival.Sh FILES 145*6ae1554aSColin Percival.Bl -tag -width ".Pa strfile.dat" -compact 146*6ae1554aSColin Percival.It Pa strfile.dat 147*6ae1554aSColin Percivaldefault output file. 148*6ae1554aSColin Percival.El 149*6ae1554aSColin Percival.Sh SEE ALSO 150*6ae1554aSColin Percival.Xr byteorder 3 , 151*6ae1554aSColin Percival.Xr fortune 6 152*6ae1554aSColin Percival.Sh HISTORY 153*6ae1554aSColin PercivalThe 154*6ae1554aSColin Percival.Nm 155*6ae1554aSColin Percivalutility first appeared in 156*6ae1554aSColin Percival.Bx 4.4 . 157