Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fortune(6)

STRFILE(8)  —  MAINTENANCE COMMANDS

NAME

strfile, unstr − create a random access file for storing strings

SYNOPSIS

strfile [ − ] [ −svcC ] [ −oir ] sourcefile [ datafile ] unstr [ −o ] datafile[.dat] [ outfile ]

DESCRIPTION

strfile is designed to take a file which contains a set of strings and create a data file which contains those strings, along with a seek pointer table to the beginning of each.  This allows random access of the strings. 

The source file contains strings separated by lines starting with “%%” or “%−” Anything following these starting characters on the line will be ignored, so comments can be placed on these lines.  A “%%” simply separates strings; a “%−” separates not only strings but sections.  A file can have up to four sections, i.e. , up to three delimiters.  This can be used in a program-defined way. 

The data file, if not specified on the command line, is named sourcefile.out, and contains a header, which describes the contents of the data file, the seek pointers to the beginning of each string, and the strings themselves, terminated by null bytes. 

The format of the header is:

# defineMAXDELIMS3
 # defineSTR_RANDOM0x1
# defineSTR_ORDERED0x2
 typedef struct {
unsigned longstr_numstr;/∗ # of strings in the file ∗/
unsigned longstr_longlen;/∗ length of longest string ∗/
unsigned longstr_shortlen;/∗ length of shortest string ∗/
longstr_delims[MAXDELIMS];/∗ delimiter markings ∗/
off_tstr_dpos[MAXDELIMS];/∗ delimiter positions ∗/
shortstr_flags;/∗ bit field for flags ∗/
} STRFILE;

The values in str_delims are the indices of the first string which follow each “%−” in the file.  The field str_flags fill have the bit STR_RANDOM set if the −r flag was specified, or STR_ORDERED if the −o flag was specified. 

The options are:

− Give a usage summary. 

−s Run silently; don’t give the summary of data at the end. 

−v Verbose (default). 

−o Order the strings in alphabetical order.  The strings will be stored in the same order in the data file as they were in the source, but the seek pointer table will be sorted in alphabetical order of the strings the point to.  Any initial non-alphanumeric characters are ignored.  This sets the STR_ORDERED bit in the str_flags field of the header. 

−i Ignore case when ordering. 

−r Randomize the order of the seek pointers in the table.  The strings will be stored in the same order in the data file as they were in the source, but the seek pointer table will be randomized.  This sets the STR_RANDOM bit in the str_flags field of the header. 

−cC Change the delimiting character from “%” to “C”, making the delimiting lines start with “CC” or “C−”.

The purpose of unstr is to undo the work of strfile .  It primarily exists as an emergency backup in case you accidentally delete your source file, but still have your data file around.  It reads data files and creates a corresponding output file.  If you don’t want “%” as your delimiting character, you can use the −cC option to change it. 

unstr will normally print out the strings in the order they are in the data file.  If you give it the −o option, it will print them out in the header order, which could be different if the file was randomized or ordered when created.  Using this, you can created sorted versions of your input file by using −o when you run strfile, and then using unstr −o to dump them out in the table order. 

SEE ALSO

fortune(6)

Amiga Unix  —  Last change: 31 Apr, 1987

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026