1*62855Selan.\" Copyright (c) 1989, 1991, 1993 2*62855Selan.\" The Regents of the University of California. All rights reserved. 347462Scael.\" 439026Sbostic.\" 539026Sbostic.\" This code is derived from software contributed to Berkeley by 639026Sbostic.\" Ken Arnold. 739026Sbostic.\" 843762Strent.\" %sccs.include.redist.man% 939026Sbostic.\" 10*62855Selan.\" @(#)strfile.8 8.1 (Berkeley) 06/09/93 1139026Sbostic.\" 1247462Scael.Dd 1347462Scael.Dt STRFILE 8 1447462Scael.Os BSD 4 1547462Scael.Sh NAME 1647462Scael.Nm strfile , 1747462Scael.Nm unstr 1847462Scael.Nd "create a random access file for storing strings" 1947462Scael.Sh SYNOPSIS 2047462Scael.Nm strfile 2147462Scael.Op Fl iorsx 2247462Scael.Op Fl c Ar char 2347462Scael.Ar source_file 2447462Scael.Op Ar output_file 2547462Scael.Nm unstr 2647462Scael.Ar source_file 2747462Scael.Sh DESCRIPTION 2847462Scael.Nm Strfile 2939082Sbosticreads a file containing groups of lines separated by a line containing 3047462Scaela single percent 3147462Scael.Ql \&% 3247462Scaelsign and creates a data file which contains 3339082Sbostica header structure and a table of file offsets for each group of lines. 3439011SbosticThis allows random access of the strings. 3547462Scael.Pp 3639082SbosticThe output file, if not specified on the command line, is named 3747462Scael.Ar source_file Ns Sy .out . 3847462Scael.Pp 3939027SbosticThe options are as follows: 4047462Scael.Bl -tag -width "-c char" 4147462Scael.It Fl c Ar char 4239027SbosticChange the delimiting character from the percent sign to 4347462Scael.Ar char . 4447462Scael.It Fl i 4539027SbosticIgnore case when ordering the strings. 4647462Scael.It Fl o 4739011SbosticOrder the strings in alphabetical order. 4839082SbosticThe offset table will be sorted in the alphabetical order of the 4939082Sbosticgroups of lines referenced. 5039082SbosticAny initial non-alphanumeric characters are ignored. 5147462ScaelThis option causes the 5247462Scael.Dv STR_ORDERED 5347462Scaelbit in the header 5447462Scael.Ar str_flags 5539082Sbosticfield to be set. 5647462Scael.It Fl r 5739082SbosticRandomize access to the strings. 5839082SbosticEntries in the offset table will be randomly ordered. 5947462ScaelThis option causes the 6047462Scael.Dv STR_RANDOM 6147462Scaelbit in the header 6247462Scael.Ar str_flags 6339082Sbosticfield to be set. 6447462Scael.It Fl s 6539082SbosticRun silently; don't give a summary message when finished. 6647462Scael.It Fl x 6739082SbosticNote that each alphabetic character in the groups of lines is rotated 6839082Sbostic13 positions in a simple caesar cypher. 6947462ScaelThis option causes the 7047462Scael.Dv STR_ROTATED 7147462Scaelbit in the header 7247462Scael.Ar str_flags 7339082Sbosticfield to be set. 7447462Scael.El 7547462Scael.Pp 7639027SbosticThe format of the header is: 7747462Scael.Bd -literal 7839082Sbostic#define VERSION 1 7939071Sbosticunsigned long str_version; /* version number */ 8039027Sbosticunsigned long str_numstr; /* # of strings in the file */ 8139027Sbosticunsigned long str_longlen; /* length of longest string */ 8239027Sbosticunsigned long str_shortlen; /* length of shortest string */ 8339071Sbostic#define STR_RANDOM 0x1 /* randomized pointers */ 8439071Sbostic#define STR_ORDERED 0x2 /* ordered pointers */ 8539071Sbostic#define STR_ROTATED 0x4 /* rot-13'd text */ 8639071Sbosticunsigned long str_flags; /* bit field for flags */ 8739027Sbosticchar str_delim; /* delimiting character */ 8847462Scael.Ed 8947462Scael.Pp 9039082SbosticAll fields are written in network byte order. 9147462Scael.Pp 9239011SbosticThe purpose of 9347462Scael.Nm unstr 9439011Sbosticis to undo the work of 9547462Scael.Nm strfile . 9639032SbosticIt prints out the strings contained in the file 9747462Scael.Ar source_file 9839032Sbosticin the order that they are listed in 9939032Sbosticthe header file 10047462Scael.Ar source_file Ns Pa .dat 10139032Sbosticto standard output. 10239027SbosticIt is possible to create sorted versions of input files by using 10347462Scael.Fl o 10439027Sbosticwhen 10547462Scael.Nm strfile 10639027Sbosticis run and then using 10747462Scael.Nm unstr 10839011Sbosticto dump them out in the table order. 10947462Scael.Sh SEE ALSO 11047462Scael.Xr byteorder 3 , 11147462Scael.Xr fortune 6 11247462Scael.Sh FILES 11347462Scael.Bl -tag -width strfile.out -compact 11447462Scael.It Pa strfile.out 11547462Scaeldefault output file. 11647462Scael.El 11747462Scael.Sh HISTORY 11847462ScaelThe 11962854Selan.Nm strfile 12062854Selanutility first appeared in 4.4BSD. 121