+/*
+ * These procedures manage the source files examined by sdb,
+ * providing access to lines by number and utilities for printing
+ * and scrolling. One file is kept open by these routines, and
+ * line index tables are maintained for all files which have been
+ * ``current'' at any time so far. This makes line access trivial,
+ * since the location of each line in the files is known,
+ * although we get ``burned'' if the file is changed.
+ * SHOULD WATCH THE MODTIME OF FILES AND REINDEX IF IT CHANGES.
+ */
+
+/*
+ * Structure for files which have been ``indexed''.
+ * Contains a pointer to the file name, a pointer to an
+ * array of seek pointers for the lines in the file,
+ * and a next link in a chain of these for all files we have indexed,
+ * The currently open file is cinfo->; the chain of active files is finfo.
+ */
+struct finfo {
+ char *name; /* name of this file w/o common pfx */
+ off_t *lines; /* array of seek pointers */
+/* line i stretches from lines[i-1] to lines[i] - 1, if first line is 1 */
+ int nlines; /* number of lines in file */
+/* lines array actually has nlines+1 elements, so last line is bracketed */
+ struct finfo *next; /* link in chain of known files */
+} *finfo, *cfile;
+FILE *FIO; /* current open file (only 1 now) */
+char fibuf[BUFSIZ];
+/*
+ * We use stdio when first reading the file, but thereafter
+ * use our own routines, because we want to be able
+ * to read backwards efficiently and avoid a tell() system
+ * call on each line. Fseekpt remebers where we are in the current
+ * file.
+ */
+off_t fseekpt;
+
+/*
+ * Make ``name'' the current source file, if it isn't already.
+ * If we have never seen this file before, then we create a finfo
+ * structure for it indexing the lines (this requires reading the
+ * entire file and building an index, but is well worth it since
+ * we otherwise have to brute force search the files all the time.)
+ */