kk@amdcad.UUCP (Krishnakumar K.) (07/03/86)
I am posting in net.sources.mac some Unix utilities and a C printing
program I wrote for the Aztec C Shell. The three programs are:
cpr: C printing program, that print programs (or any text file) with line
numbers, a main page header (which includes the name of the file
and the date printed), with subsequent small page header for the
following pages (which includes the name of the file and the page
number).
It also has the options of 1) printing reserved words in bold,
2) printing a variable cross reference table as the end of the file,
3) print only selected lines (from line# to line#) and 4) accepts
tabs which can be reset to the desired value (default 4).
Lines longer than the page width are wrapped around to the
next line. This added extra line is accounted for but it does
not get a linenumber. The program will fit the same number of
lines on each page, no matter how many wrap around. This avoids
one page with wrap around lines to run off the end of the sheet.
USAGE: cpr [-tvb] [tab] file1 [-l] [start end] file2 ... fileN
[t] reset tab value to [tab], default = 4
[b] don't bold reserved words
[v] print variable cross reference table
[l] start at line [start], end at line [end]
use \"d\" to default to begining or end
wc: Word Count. Same as the Unix function 'wc'. Counts the number of
characters, words and lines in the listed text files. If more than
one file is specified, a total is listed at the end.
USAGE: wc [-lwc] filename ...
page: Page a file. Similar to the Unix function 'page'. Allows a
text file to be listed one page at a time. Hitting return
shows the next page.
The [-f] option cause the output not to wrap long lines
around to the next line. [start] and [end] can be given to
start and end the listing at the specified lines
USAGE: page [-f] filename [start] [end]\n"
-------------------------------------------------------------------------
All of the programs are in seperate files, but if you run the
makefile, it will create one file 'main', which contians the code
for all 3 programs. Command programs (see below) are created to call
the main module, which then appropriately call the correct internal
module. This was done to save Library space that would have been used
for each program, and instead is only used once. (This does save quite
a bit of space, and allows you to add your own utilities, without
the overhead).
The source in net.sources.mac contiains a total of 5 files and need
to be seperate and saved seperately, so the makefile can then be run.
The files are:
main.c
cpr.c
wc.c
page.c
makefile
The 3 command programs are quite simple and are:
( These are each seperate files )
main cpr $*
main wc $*
main page $*
Put the result of the compilation, 'main' in a bin directory along with
the three command files.
This allow you to call the programs as if it was a seperate program.
Help for any of these programs can be obtain be just type the programs
name.
Please let me know if you have any questions
Thomas Carstensen
AMD - Sunnyvale, CA