cmdform, prmsetup, filename, funcname, prmset - Parameter setup routines

SYNOPSIS

#include <uif.h>
#include <terrno.h>

int cmdform(argc, argv, form, def, dir)
int argc;
char **argv;
int form;
char *def;
char **dir;

char *filename(i)
int i;

char *funcname()

int prmset(param, value)
char *param;
char *value;

DESCRIPTION

The functions described here are related to TeraScan command parameter processing setup. The command line form of any TeraScan command is

command param1=value1 param2=value2 ... file1 file2 ...

Besides command name, there are only two things found on the command line: parameters followed by files. Parameters are simply named inputs to commands. If parameters are not (or are incorrectly) entered on the command line, users can be prompted for them by name.

Each command is assumed to have one of the following forms, based on what files it expects to find on on the command line. These forms are defined in include/uif.h.

FORM_00	0 files in		0 files out
FORM_10	1 file  in		0 files out
FORM_01	0 files in		1 file  out
FORM_11	1 file  in		1 file  out
FORM_0M	0 files in		many files out
FORM_M0	many files in	0 files out
FORM_M1	many files in	1 file  out
FORM_MM	many files in	many files out

For example, a command that modifies a dataset in place will probably have form FORM_10 or FORM_M0.

Some commands allow a directory name to be used in place of a list of output files. Such commands must be capable of generating output pathnames from input file names (FORM_MM) or from input data (FORM_0M).

Note: Form refers only to what a command expects to see on the command line. A command with form FORM_00, FORM_10, or FORM_M0 could conceivably generate output files; e.g. like the UNIX C compiler. Also, commands can ask for files as parameters.

cmdform is the basic setup routine for parameter processing. It determines what is on the command line using arguments argc and argv from main(argc, argv). cmdform prompts users for files not (or incorrectly) entered on the command line based on form. Input files are tested for existence. def is the default response to use when prompting users for file names. dir is used only when form is either FORM_0M or FORM_MM. dir is set to NULL if the output file is not a directory. Otherwise dir points to the directory name on return.

Applications access the names of files set up by cmdform using the filename function. filename returns a pointer to the ith filename, where i is 0-relative.

funcname returns a pointer to the function name, namely argv[0].

prmset is used to define new parameters with values, or to change values of existing parameters. It is very rarely needed.

RETURN VALUES

cmdform returns the number of files entered if successful. Otherwise it returns -1 and sets terrno to the appropriate error code.

filename returns a pointer to the ith filename, or NULL if i is out of range, or if cmdform was not called first.

funcname returns a pointer to the function name, or NULL if cmdform was not called first.

prmset returns 0 if successful. Otherwise, it returns -1 and sets terrno to the appropriate error code.

ERRORS

The following error codes are defined in include/uif.h:

Signal occurred during input

Unexpected end of input

Parameter setup routine not called

FILES

include/uif.h, include/terrno.h, lib/libuif.a

SEE ALSO

inpstr, outpstr prmint, prmstr, prmyn, sigsetup uif(7)

NOTES

None.


Last Update: $Date: 1999/05/10 20:56:28 $