Although in this assignment you will not build nor render any scene, it will get you started on using CLI. You need to copy all the files in
~cs4391/clito one of your directories. The files are:
cli.h - Header file of CLI cli.c - C code file of CLI makefile - Makefile to build the library and test program testcli.c - Test program example.cli - Example input fileYou can compile everything by typing
make. When you run
the test program testcli you will see a prompt:
testcli>You can then type in commands it understands at that prompt. For example,
? lists all the commands; add takes
two integer parameters and adds them together; repeat
takes an integer parameter n and a word, then prints out
the word n-times; and finally read takes a
file name and executes every command in that file as if they were
typed in.
The main function in a program using CLI usually looks
like the following:
START_CLI("testcli", "cli")
Here "testcli" becomes the prompt string, and
"cli" becomes the data file extension.
COMMAND("add num1 num2") {
float a, b;
get_real(&a);
get_real(&b);
printf("%g + %g = %g\n", a, b, a + b);
}
Here "add num1 num2" is the command description. The
first word is the command name. The rest of them are dummy names
for command parameters. When CLI gets a matching input, it executes
code in the definition block. get_real is a CLI
function that parses a parameter on the command line and saves it in
a float variable. You can see uses of other CLI routines in the
test program.
A typical use of a command is to get the necessary parameters, then
invoke an application defined function in the place of the
printf; the application define function may be in some
other file(s) that will be linked in during the make
process.
END_CLI("Pardon?", "Bye-bye.")
Here "Pardon?" becomes the error prompt string, and
"Bye-bye." becomes the log-out confirmation string.
;'' after any of the START_CLI,
COMMAND, or END_CLI block.
matrix that takes 16 float parameters and
saves them in a 4 by 4 matrix in row order. Let's call the matrix
M.
vector that takes 3 float parameters and
saves them in a 4 by 1 column vector (the last value in the vector is
always set to 1.0). Let's call the vector
V. The program prints out the result of M
multiplies V.
vector commands
(with possibly different values) and calculate multiplication results
against the set matrix. It should also allow reseting the matrix with
new sets of values.
Hints: Use input data files to help testing your program. Use an ANSI C compiler, for example in the College of Computing:
/usr/local/lang/acc - on SunOS 4 machines /opt/SUNWspro/bin/cc - on Solaris 2 machines /usr/bin/cc - on SGI IRIX machinesYou don't have to use the SGI machines to finish this project, but it's a good idea to test your program on them (because your friendly TA will grade your project on those machines, and any compilation error or core-dumping behavior can drive him really mad ;-).
shar *.c *.h makefile | elm -s "proj0" cs4391@cc.gatech.eduThe programs
shar and elm are in the
/usr/local/bin directory.
Note that you are not allowed to
modify the CLI library files; and the cs4391 email
address is only for turning in your project files (mails to that
account are saved automatically for grading).