Untitled.gif

CUG CD-ROM Vols. 380-399


(CUG 380)JMODEM: File Transfer Protocol

JMODEM, by Richard B. Johnson (Beverly, Massacusetts), is the definitive version of this innovative file transfer protocol. Johnson wrote and distributed the first version JMODEM protocol in 1989. Although originally written totally in assembler, he has since rewritten it in C and made the source freely available. His hope is that it will "make it easier for software developers throughout the world to use this very useful protocol".

The CUG distribution includes a pre-built JMODEM MS-DOS executable that can be used as-is. Much care has been taken to insure that it behaves well as externally shelled communications protocol driver. As such, you may simply add it to your existing upload/download protocol menu in Procomm, Telix, Commo, and other terminal programs. JMODEM also provides detailed installation instructions for BBS use.

Developers of their own communications programs can also integrate JMODEM support. JMODEM requires as little as 79K RAM to run and can be built without any floating-point support libraries. The current version runs only on MS-DOS and has been successfully built with Microsoft C and Borland Turbo C.

You might ask, why does the world need another file transfer protocol? In short, JMODEM provides more intelligent block sizing, data compression, and CRC support. Many of the older protocols, such as XMODEM and YMODEM variants, were designed when 1200 baud was state-of-the-art. As such, they use fairly small block sizes which typically range from 128 to 1024 bytes in length. After each block gets transmitted, the older protocols require an immediate acknowledgement before any more data will be sent. The acknowledgement overhead and block size limitations together slow transmission down up to 25% less than its maximum throughput.

JMODEM avoids the block size and acknowledgement logjam by allowing block sizes to increase to 8,192 bytes in length. JMODEM starts out the block size at 512 bytes in length. With each successively correct transmission, it doubles the block size to 1,024, 2,048, 4,096, and finally 8,192 bytes. Similarly, each successively incorrect transmission causes it to halve the previous block size. Block sizes as small as 64 bytes allow transmission even in a high-noise environment.

JMODEM remains one of the few file transfer protocols with built-in data compression. Specifically, JMODEM will provide Run-Length Encoding (RLE) on blocks in which an efficiency can be obtained. In pre-compressed data scenarios, such as transmission of ZIP-ed files, JMODEM automatically disables its compression. Realistically, RLE can significantly help out older 2400 baud (v.22bis) modems on uncompressed data. However, RLE cannot beat modern hardware implemented compression protocols such as Microcom Networking Protocol (MNP 5) and the CCITT v.42bis LZW compression. MNP 5 typically achieves 2:1 compression and v.42bis achieves 4:1 compression.

Last, JMODEM provides a 16-bit Cyclic Redundancy Check (CRC) for further protection against transmission errors. Older protocols, such as XMODEM, often rely on Checksums to guard against accidental transmission errors. Some protocols, such as ZMODEM, offer even higher protection via 32-bit CRCs. However, the 16-bit CRC means that only about 1 in 2^132 errors will go undetected.

(CUG 381)JPEG: Highly portable graphics compression

JPEG Software, by Thomas G. Lane (The Independent JPEG Group), is a complete JPEG image compression and decompression system. JPEG (pronounced "jay-peg") is a standardized compression method for full-color and gray-scale images. JPEG originated from a desire to efficiently handle photographic images. The source of the image can be any sort of computer captured or generated medium, such as 35mm film scanners, video capture boards, or fractal landscapes.

The JPEG Software distribution source code is written entirely in C. You can compile it on many platforms including IBM compatibles, Amiga, Macintosh, Atari ST, DEC VAX/VMS, Cray Y/MP, and most Unix platforms. Supported Unix platforms include, but are not limited to, Apollo, HP-UX, SGI Indigo, and SUN Sparcstation. The make system even includes a utility to convert the ANSI-style C code back to older K&R-style.

JPEG differs considerably from file formats such as PCX, GIF, and TIFF which must reproduce 100% of the original image data. Rather, JPEG is said to be "lossy" in that that the output image is not necessarily identical to the input image. Applications requiring exact correspondence between input and output bits, such as engineering blueprints, are thus inappropriate for JPEG. However, on typical photographic images, JPEG delivers very good compression levels without visible change. Additionally, amazingly high compression is possible if you can tolerate a low-quality image. You can trade off image quality against file size by adjusting the compressor's "quality" setting.

By default, the JPEG Software distribution builds a command-line driven translator. The currently supported image file formats are: PPM (PBMPLUS color format), PGM (PBMPLUS gray-scale format), GIF, Targa, and RLE (Utah Raster Toolkit format). RLE is supported only if the URT library is available. The compression program "cjpeg" recognizes the input image format automatically, with the exception of some Targa-format files. Of course for the decompression program "djpeg", you have to tell it what file format to generate. The only JPEG file format currently supported is the JFIF format. Support for the TIFF 6.0 JPEG format will probably be added at some future date.

You may incorporate any or all of the JPEG Software source code into your own applications. The only restriction is that you must include a small notice stating: "This software is based in part on the work of the Independent JPEG Group".

Read the full-length review!

(CUG 382)GZIP: Highly portable file compression

GZIP, by Jean-loup Gailly (Rueil-Malmaison, France), is a general-purpose archiving and compression utility. Rather than introducing yet another compression file format, GZIP seeks to unite the existing myriad compression methods. Specifically, GZIP will automatically detect and uncompress files created by Phil Katz PKZIP and compatible zip methods. It also handles Unix derived "pack" (Huffman encoding) and "compress" (LZW) files.

GZIP v1.0.7 (released 3/18/93) supports many platforms including MS-DOS, OS/2, Atari, Amiga, and DEC VAX/VMS. GZIP works well with most Unix workstations including those compatible with NeXT, MIPS, SGI Indigo, and Sun Sparcstations. On the MS-DOS platform, GZIP only guarantees to work with Microsoft C 5.0 (or later) and Borland Turbo C 2.0 (or later). By default, GZIP builds for the MS-DOS Compact memory model. An additional compilation flag allows for Large memory model. Other memory model variations might possibly as well, though only Small model is specifically disclaimed.

GZIP uses the well-known Lempel-Ziv encoding method as published in the "IEEE Transactions on Information Theory" (1977). As such, it avoids the patented algorithms that prevail in many implementations. Typical text, such as English or C source code, reduces in size about 60-70%. Files which are already signficantly compressed, such as GIF graphics and VOC audio files, undergo far less reduction. The algorithm itself is implemented entirely in C -- with one exception. The routines that do the performance critical longest string matching have been rewritten in platform-specific assembly language.

GZIP is licensed under the GNU General Public Software License. This means that if you plan on incorporating source code from GZIP in your own product, you must make source code readily available. However, you are still free to distribute the unmodified version of GZIP and bundle files archived with it.

(CUG 383)VGL: 256-color VGA Graphics Library

The VGL graphics library, by Mark Morley (Victoria, B.C., Canada), is a complete graphics library for use with VGA mode 13H. As you may recall, when IBM first introduced the VGA in 1987, the revolutionary 320x200 resolution with 256 colors (mode 13H) was one of its biggest improvements over the EGA. As was typical of IBM PC hardware, the VGA did not include any programming tools. Freeware programming tools, such as the VGL graphics library, help fill the void for DOS programmers. The VGL graphics library includes routines for drawing on virtual screens, drawing sprites, doing fast blits, animating the palette, drawing bitmapped fonts, loading GIF images, drawing lines, trapping keypresses, and even mouse handling. Fig 1. shows animated sprites in the form of bouncing balls. VGL version 2.0, released on 5/93, is now available as volue #386 in the CUG Library.

Above all, the VGL graphics library is *FAST*. Animation appeared quite smooth even with my pokey old 386-20Mhz CPU. Morely maximizes speed by writing about 1/3rd of the package in hand-optimized assembly language. The core routines even appear in separate versions for 80286 and 80386 CPUs. The 80386 version takes advantage of 32-bit registers, such as EAX, and their instruction extensions. With its speed of animation, VGL graphics makes a great starting base for game programming.

VGL includes 22 fonts for serious work and fun work. For serious applications, Helvetica (from 13 to 29 points) and Times Roman (12 or 14 points) look great. For fun applications, there are cartoon, comics, stencil, art deco, and other fonts. VGL renders fonts in regular, underlined, boldface, italics, and shadowed attributes as desired. Of course, the font displays are fast too.

(CUG 384)Ghostscript: a postscript previewer

Ghostscript, by L. Peter Deutsch of Aladdin Enterprises (Menlo Park, CA), consists of an Adobe Postscript(TM) compatible interpreter, fonts, and utilities. The interpreter is composed of c functions which implement the graphics capabilities that appear as primitive operations in the PostScript language. Ghostscript interprets your Postscript files and can print to a variety of displays, printers, and graphics file formats. Ghostscript version 2.6.1 is now available as CUG volume #387.

For example, you can view the Postcript files on EGA, VGA, and many SuperVGAs. You can print the files to an HP LaserJet (LJ), LJ+, LJ IIp, LJ III, DeskJet (color or mono), PaintJet, IBM ProPrinter, Epson, and other printers. Ghostscript will write out to mono or 256-color GIF files as well as mono, 16-color, or 256-color PC Paintbrush (.PCX) files.

Ghostscript will work on any PC with EGA (or better) graphics and MS-DOS 3.1 (or later). You may also build Ghostscript as a Windows 3.0 or 3.1 application. Ghostscript runs on most Unix systems including Sun SPARCstations, SCO Unix, DECStation and VAX Ultrix, SGI Iris Indigo, Sequent, and more. The CUG Library edition of Ghostscript includes pre-built versions for MS-Windows and DOS only. The DOS version must be built with a DOS Extender such as DOS/4GW by Rational Systems, Inc.

Ghostscript includes many useful postscript fonts. Most fonts are derivatives of the public domain Hershey and MIT X11 distribution. These fonts include Avante-Garde, Bookman, Courier, Helvetica, New Century Schoolbook, Palatino, Times-Roman, Zapf Chancery, and many more.

Ghostscript is licensed under the GNU General Public Software License. This means that if you plan on incorporating source code from Ghostscript in your own product, you must make source code readily available. However, you are still free to distribute the unmodified version of Ghostscript and bundle files archived with it.

(CUG 385)BCC+ TSR, DOSThread, and Coroutine classes

From John English, at the University of Brighton (England), comes a trilogy of highly useful class libraries for Borland C++. The TSR class presents a framework for writing memory-resident DOS programs (TSRs). The DOSThread class presents a framework for writing DOS applications consisting of multiple "threads" in a self-contained preemptive multitasker. The Coroutine class presents a cooperative non-premptive framework for sharing the CPU. Version 1.00 (March 1993) of all three BCC+ class libraries is now available in a single CUG library volume #389.

(CUG 385A)TSR class for Borland C++

After more than a decade of MS-DOS, resident programs remain as tricky as ever to design and implement properly. If anything, writing TSRs becomes more complex with every new version of MS-DOS, Windows, and other environments. The TSR class helps make development of resident programs an attainable goal for Borland C++ programs. Applications developed with TSR class require an 80286 (or better) and DOS version 3.1 (or later) on the target machine. Building them requires Borland C++ version 3.0 (or later).

TSRs produced using this class can be woken up by a specific key (the "hotkey") or after a specified number of timer ticks (the "timeslice") or a combination of both. You must supply a function "main" in your application class to be invoked whenever the TSR is woken up. The member function "run" makes the TSR resident. The member function "loaded" tells whether an instance is already resident. The member function "unload" can then remove it. A foreground copy can also communicate with a resident copy using the functions "request" and "respond". Each TSR must be given a unique name up to 32 characters long.

(CUG 385b)DOSThread class for Borland C++

MS-DOS remains a single-threaded operating system, even with today's most advanced version. Many of the functions in its published interrupt API are non-reentrant. However, the DOSThread class lets you create multithreaded DOS applications with ease. Like the aforementioned TSR class, the DOSThread class requires a "main" function which gets invoked by the member function "run".

Once started, each thread runs in a single timer tick (55 ms) interval before being preempted by the scheduler. Intervals can be set for any integral number of ticks by the "timeslice" member function. Alternately, scheduling can be disabled thus providing non-preemptive multitasking. Threads can put themselves to sleep with the "wait" member function, yield control with the "pause" member function, and kill any thread with the "terminate" member function. The extra classes DOSMonitor and DOSMonitorQueue provide monitor classes for intertask communication. A "monitor" contains data structures which can be accessed by several threads.

(CUG 385C)Coroutine class for Borland C++

The Coroutine class is similar to the DOSThread class except that it is always a cooperative multitasker. The Coroutine class has some elements in common with the TSR and DOSThread classes. Once again, the Coroutine class requires a "main" function which gets invoked by the member function "run". Since coroutines are non-preemptive by definition, the other member function needed is "pause" to yield control. Synchronization is unnecessary because corutines never interrupt eachother.

(CUG 386) Thomson-Davis Editor

The Thomson-Davis Editor, as provided by Frank Davis (Tifton, GA), is a multi-file/multi-window binary and text file editor written for IBM PCs and close compatibles. Thomson-Davis Editor (TDE) works well with batch files, binary files, text files, and various computer language source code files. TDE can handle any size of file and any number of windows that fit in conventional DOS memory. Davis' most recent improvement is support for regular-expressions in searching text and selecting files for editing. TDE version 3.0 (June 1993) is now available as CUG library volume #391.

The TDE compiles under Microsoft C versions 5.1 through 7.0 as well as QuickC version 2.5. TDE also supports Borland C version 3.1. The same makefile can be used with either Microsoft nmake or Borland make utilities. Assembly language portions will build with Microsoft MASM 5.1 through 6.0, Quick Assembler, or Borland Turbo Assembler. The CUG library distribution also includes a complete compiled and linked TDE.EXE.

TDE includes more than 800K of C source code plus two small modules in Assembler (totalling 26k). The TDE source code itself is remarkably well documented. Each function includes a detailed header describing parameters and purpose of the function. Best of all, TDE provides an incredible amount of detail in bibliographic references to algorithms employed. For example, the sort.c module provides precise references to all of C.A.R. Hoare's original work on QuickSort (1961) plus embellishments by Knuth and Sedgewick. Overall, the references remain current and even include information accurately reflecting changes in MS-DOS 6.0.

Since the TDE has been officially released into the public domain, you may use and distribute it freely. There is no copyright, no fee for use, no licensing, or no registration. This editor is not user supported, corporate sponsored, or government subsidized - it is sustained and maintained solely by Frank Davis.

(CUG 387)C/C++ Lost Algorithms

The C/C++ Lost Algorithms, by John Tal (Rochester, MI), releases handy implementations of textbook classic algorithms into the public domain. These algorithms are implemented twice (once in C and again in C++) and focus primarily on Link Lists, Binary Trees, Stacks, Fifo Queues, Heaps (Priority Queues). He places secondary importances on algorithms for Shell Sort, File Merging, Multi-tasking and processing scheduling, Virtual Memory Management, File-based process communication, Graph/Network Job Management, and Data Encryption. The algorithms (as released in Fall 1992) are immediately available under a single volume distribution as CUG #393.

Tal expresses concern that many of the worlds best and most efficient algorithms have been carelessly disregarded in the wake of faster computers with more memory. He points out that it will ALWAYS make sense to make the best use of any computing resource.

The C/C++ Lost Algorithms have been tested on a variety of platforms including both DOS, OS/2, and Unix workstations. Each algorithm set includes complete documentation in the form of a Unix-style "man" page. The C++ implementation include general porting notes and Borland Turbo C++ .PRJ makefiles. As an added bonus, Tal also includes implementations of Unix utilities binsrch (binary search on flat file), cat, db (dump bytes), split, tail, and wc (word count).

(CUG 388)Anthony's Tools

Anthony C. Howe (Waterloo, Ontario) presents his award-winning Editor, Make, Grep, and Stdscr Curses tools. Anthony's Tools have won the International Obfuscated C Code Contest (IOCCC) for Best Utility in 1990, 1992, and 1993 respectively. For those who are unfamiliar, the IOCCC competition pits C programmers against each other to see who can produce the most unreadable and obscure code that compiles and runs. Fortunately, he has included both the obfuscated and readable source versions of each utility. Both versions of all tools have been listed as public domain, except for the readable version of Anthony's Editor which remains freeware. All of Anthony's Tools are available on a the CUG volume #392.

Anthony's Editor appears in both its obfuscated 1991 award-winning form and its readable July 1993 version. Both versions will compile and run on PCs and Unix workstations. The 1993 version of Anthony's Editor (AE) can be configured for modal (vi-style) or modeless (EMACS-style) user interface. The configuration file also presents the key mapping for each internal command. Thus, you can customize AE to your preferences or support any conceivable terminal. AE can edit arbitrarily long lines of text and assumes tabstops every eight characters. AE includes cut, copy, and paste operations with blocks of text. The same buffer is also used for a single-level undo command. The AE macro facility allows one keystroke to feed other keystrokes into the buffer and execute them. AE does not provide any searching or replacing operations.

Anthony's Make provides most of the functionality required of "make" utilities under POSIX.2 draft standard 11.2. Indeed, the judges were so impressed as to jokingly recommend lobbying the IEEE for an obfuscated POSIX subcommittee. Anthony's Make (AM) has been tested with GCC under SunOs, Sozobon C on Atari ST, Borland Turbo C on PCs, and Interactive UNIX System V/386 release 3.2. On the PC, the AM executable is less than 18K in size! AM supports many of the constructs you've come to expect in makefiles including macros, multiple targets and dependencies, comments, and more.

Anthony's Grep provides most of the POSIX.2 functionality for "grep" utilities. Anthony's Grep (AG) can be built on the same platforms as AM plus WatCom C for the PC. AG supports a Useful subset of POSIX.2 Extended Regular Expressions (ERE). It has a recursive ERE parser/compiler that generates an NFA railroad. AG uses lazy NFA to DFA evaluation to improve performance speed. AG is both useful and useable for a variety of applications.

Anthony's Stdscr Curses is the only tool which is limited to PC platforms. Anthony calls it quick and dirty because it assumes that only stdscr is used and therefore goes directly to BIOS rather than waiting for a refresh(). Unlike the other modules, Stdscr Curses doesn't include formal documentation so a working knowledge of Unix curses is essential.

(CUG 389)VGA FontLib, MakeFont and DXF viewer

Joseph V. Gagliano (Austin, TX) submits a pair of utilities developing MS-DOS applications with VGA graphics fonts and a standalone DXF (AutoCAD vector) viewer. FontLib is a set of 13 functions for rendering fonts on EGA and VGA displays with a minimum of resolution of at least 640x350 (see Fig.1 ). MakeFont is an editor for producing and editing your own font files. CDXF views 2-D AutoCAD compatible vector files and is not a development tool. All three are marketed as shareware and require seperate registration with the author after an evaluation period. The latest versions of all three (released 09/16/93) are immediately available as CUG #396.

FontLib comes with Small model library built with Microsoft QuickC v2.5. FontLib currently does not claim compatability with any other compilers. Registration of FontLib for $25 includes the full library source code for the Microsoft compilers, unlimited technical support, and low-cost upgrades. Registration also grants you royalty-free use of the library functions. For an additional $10, you receive source code to MakeFont as well.

FontLib characters can be renderend in normal or boldface, in different colors, vertically or horizontally, and with shadowing effects. You can embed style rendering changes in a string using escape codes to make color and shadowing changes within the context of a single string display call. The baker's dozen of functions appears below:

Function Name                   Purpose
--------------------            ---------------------------
 regfont();                     Load the font for immediate use
 draw_letter()                  Display a single character
 draw_letter_bold();            As above, in boldface
 letter();                      Display entire string
 letter_bold();                 As above, in boldface
 letter_w();                    Display string using window coords
 letter_bold_w();               As above, in boldface
 letter_column();               Display string as vertical column
 letter_column_bold();          As above, in boldface
 letter_column_w();             With window coords
 letter_column_bold_w();        And in boldface
 freefont();                    Unload the font
 set_shadow_color();            Use this color for shadowing effect
 set_font_color();              Use this color for base colors

The CUG distribution includes four font files: 8x5, 13x8, 20x12, and 20x20 characters. Fig. 2 shows MakeFont editing the letter "V" in the 20x20 font. The font file format is plain ASCII and is well-documented in the 20 page reference manual on disk. FontLib and Makefont works only with monospaced raster font files.

As mentioned earlier, CDXF currently does not have any source code availability. Fig. 3 shows a 2-D AutoCAD DXF file rendered by CDXF. CDXF requires a $25 registration for the first copy and $5 for every copy thereafter.

(CUG 390)ACTLIB: Another C Tools LIB

Marc Stern of S.A. Philips Industrial and Telecommunication Systems (Brussels, Belgium) presents Another C Tools Library (ACTLIB) for MS-DOS developers. ACTLIB contains tricks and algorithms that will be very helpful for novice MS-DOS C programmers. There's also some things for advanced C programmers as well. These low-level disk and keyboard functions answer many frequently asked questions. The string and date function library should work on a broader base of platforms. ACTLIB v1.4 (released 05/27/93) is immediately available as CUG #398.

ACTLIB has been compiled and tested using Borland C 3.1 and Microsoft C 7.0. The only assembly language file is one that supplies a function to return the CPU type. No makefiles are included with the library. The TOOLS.LIB library provides the low-level functions specific to MS-DOS, including:

The STRINGS.LIB library provides 28 source files of functions to simplify common string handling tasks. These functions perform complex operations such as regular expression handling via recursion, string mathematical expression evaluation (e.g. "1 + 2 * 3 /4"), and multiple substring replacement. Simpler functions perform BASIC-like "left", "right", and "mid" string extractions. Functions such as these can help out nearly any application.

The DATE.LIB library provides functions to validate dates, perform simple date arithmetic, and answer the question "What day of the week is it?".

(CUG 391)C/C++ Exploration Tools

C/C++ Exploration Tools, by Juergen Mueller (Kornwestheim, Germany), includes both his C Function Tree Generator (CFT) and the C Structure Tree Generator (CST). CFT and CST analyse the C/C++ source code of applications of any size with multiple files. CFT and CST are useful to explore new, unknown software and to support re-use, maintenance and re-engineering. By preprocessing, scanning, and analysing the program source code, these programs generate the function call hierarchy (CFT) and the data structure/class (CST) relations. Both programs can handle C and C++ code, CFT can additionally analyse assembler code. The C Exploration Tools v2.12 as MS-DOS executables (released 07/03/93) are immediately available as CUG volume #391.

An important feature is the database generation which allows the recalling of informations without reprocessing the source. This database can again be read from CFT and CST to produce different outputs or to add new files to the database. The database format is dBASE compatible. Special recall programs called CFTN and CSTN allow fast searching for items in the database. These programs can be used within any environment, for example from inside editors like BRIEF, QEDIT or MicroEMACS (DOS and Windows version), to provide a full software project management system with access to all functions and data types with just a keystroke. This feature makes a comfortable "hypertext source code browser and locator" system out of the editor.

The documentation is supplied in ASCII and includes 63 pages of reference material. The manual is in plain English and should be accessible to even novice C programmers even though advanced techniques are discussed.

The C Exploration Tools are shareware and require registration with the author if you decide to use them beyone the 30 day evaluation period. The registration price is $46 U.S. or 60 DM for a single copy. Generous site license discounts with prices as low as $15 are appropriate for corporate use or educational institutions. Registered users automatically receive Protected Mode versions of the tools optimized for 80386 and the latest versions of everything. Source code for the C Exploration Tools itself is not available.

(CUG 392)GNU Indent: beautifies your C code

GNU Indent, from Joseph Arceneaux (San Francisco, CA), becomes the newest installment of high quality tools from GNU project. The Indent program changes the appearance of a C program by inserting or deleting whitespace. The Indent program can be used to make code easier to read. It can also convert from one style of writing C to another. Indent understands a substantial amount about the syntax of C, but it also attempts to cope with incomplete and misformed syntax. Indent can replace the original source .C file and retain a backup copy or else write its output to a new .C file. GNU Indent v1.8 (released 06/16/93) is immediately available as CUG volume #392.

There are several common styles of C code, including the GNU style, the Kernighan & Ritchie style, and the original Berkeley style. A style may be selected with a single "background" option, which specifies a set of values for all other options. However, explicitly specified options always override options implied by a background option. Thus, you can create hybrid styles or a new coding style uniquely your own by combining the many option settings.

Option settings include many things that programmers regularly spar about, such as:

Each option can be specified in short form or long form. For example, the short form option "-ncdb" can be entered as

"--no-comment-delimiters-on-blank-lines".

GNU Indent supports MS-DOS, OS/2, VAX VMS, and most versions of Unix. For Unix versions, it includes the popular GNU auto-configuration utility which customizes the Makefile to meet the needs of your system. The CUG Library distribution includes source code only.

(CUG 393)LL, GIFSave, and Cordic++

As you might have guessed from the introduction, this volume is something of a C potpourri. George Matas (University of Surrey, U.K.) presents his "LL" for a generic double-linked list library with examples. Sverre H. Huseby (Oslo, Norway) contributes "GIFSave" to save bitmaps in this popular image file format. Last, "Cordic++" by Timothy M. Farnum (Rochester, NY) builds on Michael Bertrand's C implementation of fast trigonometric functions. Altogether, three very useful and specialized tools for common C problems. The entire set fits on just one diskette. This diskette is immediately available as CUG volume #401.

(CUG 393A)LL: Doubly-linked list handler library

LL is a double-linked list handler library with more than four dozen operator functions. Variables of any type can be stored in an LL list. Individual elements of a list may be of different types. Any depth of lists of lists can be created. An instance of a list is created using either ConsLL(), ConsCopyLL() or ConsPtrLL() functions. Its best to call one of these functions at the point of declaration of a list variable. The result of one of the constructor functions must be assigned to a given list instance before passing it to any other function in the LL library.

ConsLL() creates an empty list. ConsCopyLL(src) creates a new copy of an existing list. ConsPtrLL(src) creates a list of pointers to elements stored in list 'src'. DestLL(list) destroys a list, ie. deletes all elements and frees all memory allocated for 'list'. It should be called at the point where 'list' goes out of scope.

LL has been tested only on SUN Sparcstations and DEC Ultrix machines. In these environments, it works with both the native "cc" compiler as well as GNU C ("gcc"). The CUG Library distribution includes source only.

(CUG 393B)GIFSave: Save bitmaps in .GIF format

The GIFSAVE library makes it possible to save GIF-images from your own graphic-producing C-programs. GIFSAVE creates simple GIF-files following the GIF87a standard. Interlaced images can not be created, and there should only be one image per file. GIFSAVE has been released as Public Domain source code with no restrictions on its usage.

GIFSAVE consists of four functions, all decleared in GIFSAVE.H:

The functions should be called in the listed order for each GIF-file. One file must be closed before a new one can be created. To use these functions, you must create a callback function that will do what is needed to get the pixel values for each point in the image.

GIFSAVE includes a makefile for use with Borland C/C++. Huseby claims he has taken care to insure that all byte-order sensitive operations are handled in platform independent method. This means the source code should work without modification on non-MS-DOS platforms.

The Graphics Interchange Format(c) is the Copyright property of CompuServe Incorporated. GIF(tm) is a Service Mark property of CompuServe Incorporated.

(CUG 393C)CORDIC++: Fast trig function class library

The Coordinate Rotational Digital Computer (CORDIC) was an early device implementing fast integer sine and cosine calculations. By favoring integer operations over floating point, it represents a classic computing tradeoff of speed vs. precision. Although first documented by Jack E. Volder in 1959, most CUG readers may remember Michael Bertrand's C implementation in C Users Journal Vol. 10, No. 11 (November 1992). Farnum presents his own reimplementation of Bertrand's code this time as a full C++ class.

According to Farnum, the most notable change for C++ is encapsulating the variables which were global in the C version. As static member variables of "cordic" class they become protected from accidental modification by routines unaware of them. Moving these variables inside a class structure makes it necessary to develop interface routines, and also requires that a decision be made about how the class will be used. Farnum decided to predefine one member of the cordic class, "cord", to access the member functions which compute the integer sine and cosine. Other instances of class cordic can be created and will work as well as the predefined instance, but there is little advantage to this in the current implementation.

One implementation possibility left open to other readers is providing the ability to instantiate the class with different levels of accuracy. This would be done by using different bases for the CORDIC algorithm. Farnum decided against that alternative because the complexity of implementation and its use seemed to go against the straightforwardness which is the main advantage of the CORDIC algorithm.

(CUG 394)C++SIM: Discrete Simulations

The C++SIM discrete event process based simulation package provides Simula-style class libraries. C++SIM is a newly released package from M.C. Little and D. McCue at the Department of Computing Science in the University of Newcastle upon Tyne (England). The same distribution also includes the SIMSET linked list manipulation facilities. According to MacLennan (1983), Simula was the first computer language to incorporate the ideas of a "class" and "object" constructs in 1967. SIM++ currently claims usability only on Unix workstations, such as SUN Sparcs. C++SIM version 1.0 (released 06/15/92) is now available as CUG volume #394.

C++SIM uses inheritance throughout the design to an even greater extent than already provided by Simula. This allows adding mew functionality without affecting the overall system structure. Thus, inheritance provides for a more flexible and expandable simulation package. Specifically, C++SIM supports the following classes: Process, ProcessList, ProcessIterator, ProcessCons, Random, Element & Head, thread, lwp_thread, an gnu_thread.

C++SIM includes a paper describing its design and implementation and examples of how to use it. The paper describes the class hierarchy itself as well as how to further refine the simulation package.

The simulation package requires a threads package and currently only works with either the Sun lightweight process library or the included GNU thread package. The thread library is the only system-specific code, so porting the remainder to other Unix workstations should be easy. C++SIM compiles with Cfront 2.1 and Cfront 3.0.1 and GNU g++ 2.3.3

The C++SIM license grants permission to use, copy, modify and distribute the program for evaluation, teaching and/or research purposes only and without fee. The University of Newcastle upon Tyne copyright and permission notice must appear on all copies and supporting documentation, and similar conditions are imposed on any individual or organization to whom the program is distributed.

(CUG 395) Input-Edit, SORTLIST AVL, and Typing Tutor

This volume combines three relatively small but powerful archives on a single diskette. Chris Thewalt (University of California at Berkeley, Civil Engineering) presents his interactive line editor library. Walter Karas (Cary, NC) contributes his implementation of the classic binary search tree with AVL balancing. Last, Christopher Sawtell (Linwood, Christchurch, New Zealand) releases his Typing Tutor for use with Curses. All three are immediately available as CUG volume #395.

(CUG 395A)Input-Edit

Input-Edit, also known as getline, provides an easy method to greatly increase the functionality of programs which read input a line at a time. Interactive programs that read input line by line can now provide line editing and history functionality to the end-user that runs the program. As far as the programmer is concerned, the program only asks for the next line of input. However, until the user presses the [RETURN] key they can use emacs-style line editing commands and can traverse the history of lines previously typed.

Other packages, such as GNU's readline, have greater capability but are also substantially larger. Input-edit is small (1200 source lines) and quite portable because it uses neither stdio nor any termcap features. For example, it only uses \b to backspace and \007 to ring the bell on errors. Since it cannot edit multiple lines it scrolls long lines left and right on the same line.

Input edit uses K&R C and can run on any Unix system (BSD, SYSV or POSIX), AIX, XENIX, MS-DOS with MSC, Borland Turbo C, or djgpp, OS/2 with gcc (EMX), and DEC VAX-11 VMS. Porting the package to new systems consists mainly of maintaining the function to read a character when it is typed without echoing it.

(CUG 395B)SORTLIST AVL

SORTLIST implements a "sorted list" data structure library in ANSI C. This library is appropriate whenever all elements of the sorted list have the following characteristics:

  1. All elements are of a single fixed size.
  2. Each element is associated with a unique key value.
  3. The set of key values has a well-defined "less than, greater than" relation.

Symbol tables and dictionary applications are excellent candidates for the sorted list data structure. This implementation of a sorted list data structure employs an AVL tree. AVL trees were invented by Adelson-Velskii and Landis in 1962. Specifically, Karas draws on algorithms presented by Horowitz and Sahni in Fundamentals of Data Structures (Computer Science Press). The add, find, and delete operations on an AVL tree have worst-case O(log n) time complexity. SORTLIST version 1.1 (released 8/25/93) is now available on CUG volume #395.

(CUG 395C) Typing Tutor

The Typing Tutor for use with Curses is a marvel of compactness. Since it builds on the substantial functionality of the Unix curses library, the Typing Tutor consists of just 250 source lines. The learning scenario is simple, yet easily customizable to fit any lesson plan. The screen is broken into two windows. The top window contains the "lesson" which is the text you will be typing from. The bottom window contains the results of your (presumably) touch typing. Everytime a character in the bottom window fails to match the original in the top window, it is flagged by changing the screen attribute to flashing. Although Sawtell does not specify compatability for Typing Tutor, he expects it to run on any Unix system with a curses package available.

(CUG 396) NNUTILS: Neural Network

NNUTILS, by Gregory Stevens (Rochester, NY), is a public domain package meant to help you to start programming neural networks in C. It is a tutorial about how to program neural networks where source code is your textbook. Stevens' intensely documented source code contains everything you need to implement several kinds of net architectures. NNUTILS gives you a series of simple implementations to let you see how they work step by step. NNUTILS version 1.01 (released 08/02/93) is immediately available as CUG #396.

Each subdirectory contains a different example with six standard C source files and a main program with a name similar to that of the directory. The source is written ANSI compliant C and developed primarily under Borland C++ 3.1. Accordingly, the CUG distribution includes DOS executables and project files for each implementation. Because the code is ANSI compliant, all of the examples work with GNU C under UNIX. Building executables with GNU C is simple enough that no makefiles are included.

Briefly, here's a summary of problem sets included with NNUTILS:

NNTEST1A network with one input node and one output node.
NNTEST2A network using the "logistic" activation function (as opposed to linear).
NNXORA network implementation of the famous Exclusive Or problem.
NNSIM1A generic feed-forward network with backpropagation.
NNWHEREA 5x5 retina is presented with shapes it must classify correctly.
NNWHAT A continuation of above where shapes can assume any position.
NNEVOLVEA feed-forward, back-propagation supervised net.
NNSIM2Simulates a competitive learning network with a Hebbian learning algorithm.
NNRECUR1A recurrent net with back-propagation, a kind of supervised learning called Self-Correlating, where the input patterns serve as their own output patterns.

(CUG 397) International Obfuscated C Code Contest 1984-1993

Landon Noll (Sunnyvale, CA) submits a decade of source code from the International Obfuscated C Code Contest (IOCCC). This contest has long been a favorite of many CUJ readers. The entire IOCCC archive from 1984-1993 is now available as a two diskette set from CUG Library. Obfuscation implies purposefully obscuring and confusing a situation. Why obfuscate C code? The official IOCCC rules state it succinctly:

Recently, Bob van der Poel reviewed Don Libes' book entitled Obfuscated C and Other Mysteries (see C Users Journal, Vol. 11, No. 10, October 1993, pp. 131-132). The diskette for this book includes IOCCC entries from 1984-1991. Libes has produced special reports about the IOCCC several times in the CUJ. Please see the following back issues for more detail:

Libes, Don. "Don't Put This on Your Resume'", C Users Journal, May 1991, p. 89.

Libes, Don. "The Far Side of C", C Users Journal, May 1990, p. 125.

Libes, Don. "The International Obfuscated C Code Contest", C Users Journal, July 1989, p. 93.

The CUG Library volume #397 contains the full IOCCC archive including two additional years not included in the Libes book.

In addition to dozens and dozens of obfuscated C programs, the archive includes complete rules and guidelines so you can submit your own entries into next years contest. Some of the obfuscated programs are quite useful, including scaled-down versions of make, grep, and editors.

(CUG 398)ASxxxx Cross Assembler - Part 3

Cross assemblers continue to play an important role in the CUG Library. A cross assembler reads assembly language source code for a non-native CPU and writes object code that can be linked and downloaded to the target machine for execution. Developers of embedded systems are the most frequent users of cross assemblers. This month, Alan R. Baldwin (Kent State University, Ohio), adds his third cross assembler to the CUG Library's repetoire. ASxxx Part 3 provides a complete Motorola 68HC08 development system. ASxxx Part 3 version 1.50 (released 8/9/93) is immediately available as CUG volume #398.

The CUG distribution of ASxxx Part 3 includes MS-DOS executables for the ASxxx Cross Assembler and Linker. However, if you want to recompile the Cross Assembler or Linker, you'll also need ASxxx Part 1 (CUG #292). ASxxx Part 2 contains cross assembler source files for the 6816 CPU. The ASxxxx family of cross assemblers can be built on DEC machines running DECUS C in the TSX+ environment or PDOS C v5.4b under RT-11. ASxxxx has been built with Borland C++ v3.1 under MS-DOS and includes a project (.PRJ) file. Although only these implementations have been specifically tested, Baldwin claims many other K&R C compilers may work as well.

ASxxx Part 3 includes a comprehensive 80-page manual covering functionality provided by all three existing ASxxxx cross assemblers and linkers. The documentation lays out the exact specifications of syntax for symbols, labels, assembler directives, and expressions in detail. The manual includes appendices with instruction set highlights and supported syntax for Motorola 6800, 6801, 6804, 6805, 68HC08, 6809, 6811 6816, Intel 8080 and 8085, and Zilog Z80 and HD64180 CPUs.

The ASxxxx assembler falls short of full macro implementation, but does include a host of important features such as: if/then/else, #include files, radix support from binary to hexadecimal, and a full complement of C-language operators for expressions. The ASxxxx linker goes beyond conventional loaders by resolving intermodule symbols, combining code into segments, relocating absolute symbols and base addresses, and producing either Intel HEX or Motorola S19 output files.

(CUG 399)MINED: Multi-Platform Editor

MINED, by Thomas Wolff (Freie Universitt Berlin, Institut fr Informatik, Germany), is a modeless full-screen text editor. MINED was originally written for MINIX and now works with most Unix platforms as well as MS-DOS, and DEC VAX-11/VMS. It works best at editing small files (50K or less) and can edit many files simultaneously. Unlike other editors which have separate command modes and input modes, MINED uses a modeless design for ease of use. It also includes a powerful regular expressions for both searching and replacing text. MINED Version 3 (released 08/04/93) is immediately available as CUG volume #399.



This page maintained by Victor R. Volkman
Last updated on 3/16/96