3 #include "../src/paths.h"
7 * Print a quotation from Zippy the Pinhead.
8 * Qux <Kaufman-David@Yale> March 6, 1986
14 #define YOW_FILE "yow.lines"
24 if (argc
> 2 && !strcmp (argv
[1], "-f"))
25 strcpy (file
, argv
[2]);
28 sprintf (file
, "%s%s", PATH_EXEC
, YOW_FILE
);
30 sprintf (file
, "%s/%s", PATH_EXEC
, YOW_FILE
);
33 if ((fp
= fopen(file
, "r")) == NULL
) {
38 /* initialize random seed */
39 srand((int) (getpid() + time((long *) 0)));
55 /* Get length of file, go to a random place in it */
57 if (fseek(fp
, 0, 2) == -1) {
63 offset
= rand() % len
;
64 if (fseek(fp
, offset
, 0) == -1) {
69 /* Read until SEP, read next line, print it.
70 (Note that we will never print anything before the first seperator.)
71 If we hit EOF looking for the first SEP, just recurse. */
72 while ((c
= getc(fp
)) != SEP
)
78 /* Skip leading whitespace, then read in a quotation.
79 If we hit EOF before we find a non-whitespace char, recurse. */
80 while (isspace(c
= getc(fp
)))
87 while ((c
= getc(fp
)) != SEP
&& c
!= EOF
) {
91 /* Yow! Is this quotation too long yet? */