91erm@bigbird.cc.williams.edu (06/05/89)
While all this talk about fortune is in the air ... Does anyone have a good description of the format used by fortune data files ? I haven't source access, so I can't just go look, but I'd like to be able to add/delete my own messages which should be doable once I know the file format. Thanks for any help. Evan R. Moore Academic Computing Group Williams College 91erm@bigbird.cc.williams.edu 'Live Fast, Die Young, Leave a Good Lookin' Corpse'
diomidis@ecrcvax.UUCP (Diomidis Spinellis) (06/06/89)
In article <19854@adm.BRL.MIL> 91erm@bigbird.cc.williams.edu writes: >[...] >Does anyone have a good description of the format used by >fortune data files ? I haven't source access, so I can't >just go look, but I'd like to be able to add/delete my own messages >which should be doable once I know the file format. The complete fortune program was mailed in comp.sources.games about two years ago. It was an improved version over the one distributed with 4.3 BSD and included more fortunes and documentation for the commands used to build the fortune database. For some reason it does not seem to be included in the freely distributed files of the 4.3 BSD Tahoe release. The fortune database can exist in two forms: The strfile(5)* form consists of a list of fortunes separated by lines starting with %%. Furthermore different classes of strings are divided by %-. This is used to divide the ``scene'' from the obscene fortunes if your system supports them. A program called strfile(8)* takes the original file and creates a file containing a header describing the lengths of the strings, a list of offsets and some flags, followed by the list of null character separated strings. This is the file that appears as fortunes.dat. A program that reverses this transformation, called unstr(8)*, also exists. (*) Manual pages for strfile(5) strfile(8) and unstr(8) appeared in the comp.sources.games release of fortune, but I have not seen them on any other system. The simplest way I can think of, to add a fortune would be to: - Get strfile and unstr from your friendly comp.sources.games archive. - unstr fortunes (this reads fortunes.dat and produces fortunes) - Edit fortunes. Put a non-obscene fortune before the %- delimiter, an obscene one after it. - strfile -r fortunes Alternatively you could try to write your own program to add fortunes to the file or use an editor that can edit non-text files. The functional description of the current fortune header is as follows (note that this is not the same as the general description of the file produced by strfile and that I have only verified it on a 4.3 BSD system): struct fortune_header { long file_end; /* Offset to the end of the file */ unsigned longest; /* The length of the longest fortune */ unsigned shortest; /* The length of the shortest fortune */ long scenes_end; /* Offset to the end of the non-obscene fortunes */ long curr_scene; /* Offset to the last non-obscene fortune printed */ long cur_obscene; /* Offset to the last obscene fortune printed */ int flags; /* flags & 1 means randomized flags & 2 means sorted */ }; Following the header are the fortunes, each terminated with a 0 byte. In the 4.3 BSD implementation first come the non-obscene fortunes, followed by the obscene. -- Diomidis Spinellis European Computer-Industry Research Centre Arabellastrasse 17, D-8000 Muenchen 81, West Germany +49 (89) 92699199 USA: diomidis%ecrcvax.uucp@pyramid.pyramid.com ...!pyramid!ecrcvax!diomidis Europe: diomidis@ecrcvax.uucp ...!unido!ecrcvax!diomidis
alex@xicom.UUCP (Alex Laney) (06/14/89)
In article <736@ecrcvax.UUCP>, diomidis@ecrcvax.UUCP (Diomidis Spinellis) writes: > ... For some reason it does not seem to be > included in the freely distributed files of the 4.3 BSD Tahoe release. ^^^^^^^^^^^^^ Is this release called "Tahoe", referring to the Intel 320 "Tahoe" series of computers? Is this a standard release that I can get from MtXinu, for example? <Maybe this can go in the FAQ posting> -- Alex Laney, Xicom Technologies Corp., Ottawa, Canada (613) 728-9099 uunet!mitel!sce!xicom!alex (NOT alex@xicom) Fax: (613) 728-1134 "You save time, increase the amount of work done and it is easy."