SYNOPSIS#include "cgi.h"
char *cgivar(cp, n, which, valp)
CGI *cp;
int n, which;
char ***valp;
DESCRIPTION
The cgivar()
function is used to iterate all the CGI
variables, one at a time. The which
parameter indicates which
lists to iterate through; it has the same values as in
getcgi()
. The n
parameter indicates which variable in
the indicated lists to get, starting with 0 for the first variable.
*valp
will be set to the string list of values for the
variable. cgivar()
returns the name of the requested variable,
or CHARPN
if the value of n
is out of range; this
indicates the end of the list.
The variable lists indicated by which
are iterated in order
of precedence, from highest to lowest. Note that some variables could
appear more than once, if they occur in multiple lists.
The returned string list and variable name are associated with the
CGI
object and freed when it is closed.
EXAMPLE#include "cgi.h"
CGI *cp;
...
{
char **vals, *name;
int i;
printf("State variables:\n");
for (i = 0; (name = cgivar(cp, i, CGI_STATE, &vals)) != CHARPN; i++) {
printf("%s = ", name);
for ( ; **vals; vals++) printf(" %s", *vals);
printf("\n");
}
}
CAVEATS
Same as for getcgi()
. Changes to the CGI variables
(e.g. putcgi()
) can affect a given variable's index and/or values.
SEE ALSOgetcgi()