Cover V03, I03
Article
Listing 1
Listing 2
Sidebar 1

may94.tar


Sidebar: About the File Browser

The file browser (pager.c, included in the electronic code distribution for this issue) was originally developed to allow users to immediately look at reports generated from Oracle DB. The Oracle developers requested that the browser include a means to mark and bound a portion of the report, then download only that portion or all of the report. The browser had to serve users with dumb terminals with attached printers as well as users who were using a proprietarty terminal emulation with a proprietary 7-bit file transfer. Eventually, the mix included users with commercial terminal emulations, and the browser utility was adapted to support all of these variations. As written, the browser can be used to view any text file, or even text files with embedded printer commands, as long as the text contains no high ASCII. The section of code that reads in the file can be modified to include high ASCII if your network supports 8 bits, and terminals can handle this.

What Does It Do?

The design specs for the browser were never formally written, but can basically be described as follows:

1. Work with a proprietary terminal emulation which can transfer files via terminal control command rather than keyboard control.

2. Also work with dumb terminals and commercial PC terminal emulations to allow printer logging and/or file capture.

3. Maintain files as read-only so users could not modify the contents of a file while online.

4. Incorporate a very simple user interface.

5. Allow users to specify all or a portion of the document to download.

6. Browse only text files or text files with embedded printer control commands which contain no characters > 127d.

7. Browse files with up to 210 columns on an 80-column terminal using left/right shift.

8. Provide useful information to the user, such as current line and column, how many lines to download, and approximate number of printed pages, as well as warning of lines > 80 columns so the user can program the printer to use small font; incorporate built-in help screens from which users can print-screen, etc.

9. Include string search and find next.

10. Set MAX size of text report files at 1Mb.

File Transfer Protocols

The program was later enhanced to support file downloads using Kermit protocol. In the source code, all references to the original proprietary terminal emulation have been removed. While this version only supports Kermit, by studying the Kermit download code, you could implement other protocols similarly. I recommend using the terminal emulation from Columbia University called MS-DOS Kermit. Kermit v3.13 can receive packets up to 9024 bytes long. The counterpart on the UNIX host is C-Kermit v5A(189). Both of these were released in 1993. You can ftp them from kermit.columbia.edu (128.59.39.2). Since my network has a 7-bit limitation, I can't use X/Y/modem protocols. I haven't tried the rz/sz Zmodem code; I've heard that this can also work with 7-bit networks, but that possibility doesn't seem to be well advertised and the copyright may not allow me to use Zmodem. In any case, I currently do not have a requirement to support Zmodem.

To allow pager to use Kermit protocol for downloads, uncomment the #define CKERMIT in the code below.

Terminal Independence

The code contains a rather long switch(key) statement which checks for the key the user pressed while viewing the browse screen. In many cases, multiple keys can activate the same function. For example the, "j", <space>, and NextPg keys all clear the screen and display the next screen's worth of information. Some terminals may not have all the keys that are checked for, or the label on a particular key may not actually describe the obvious function. In such cases, you will have to adjust the help() function to suit your local terminal support environment. You'll find extended comments regarding this problem just before the switch(key) statement.

File Size Limitation

Originally, the Oracle developers indicated that files to be browsed would never be greater than 1Mb. Accordingly, I designed this piece to just read the file into memory. Sure enough, after a while, some of the reports started growing into the multimegabyte size. But this is still rare. It may be that the user runs out of memory before a very large file is completely loaded. With my SCO 3.2 2.2, I've successfully used pager with a file larger than 4Mb. Because pager performs a good deal of checking on the file to be browsed, long files take a few moments to load.