<H2>NAME</H2>
lc_register_var - Register a variable for automatic processing.
<P>
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>#include &lt;<A
<P>
<B>int lc_register_var(const char lc_var_type_t void char
<P>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The
<B><A HREF="wiki/Manual for
function registers a variable for automatic processing.
The
<I>var</I>
parameter specifies the variable name for processing.  This name can exist in a configuration file, an environment variable, or on the command line.
The
<I>opt</I>
parameter specifies the single letter short option that can be specified on the command line to change the value of the variable specified by the
<I>data</I>
parameter.  A value of '&nbsp;' can be specified for no short option.
<P>
The
<I>type</I>
parameter is of type
<I>lc_var_type_t</I>
which specifies the type of the
<I>data</I>
parameter.
Valid values for
<I>type</I>
are:
<DL COMPACT>
<DT>LC_VAR_STRING<DD>
For a string type variable.  The data passed should be of type &quot;char **&quot;.  The data will be set to a region of memory that has been allocated with malloc() and can be released be free()'d.
<DT>LC_VAR_LONG_LONG<DD>
For a &quot;long long&quot; integer type variable.  The data passed should be of type &quot;long long *&quot;.
<DT>LC_VAR_LONG<DD>
For a &quot;long&quot; integer type variable.  The data passed should be of type &quot;long *&quot;.
<DT>LC_VAR_INT<DD>
For a &quot;int&quot; integer type variable.  The data passed should be of type &quot;int *&quot;.
<DT>LC_VAR_SHORT<DD>
For a &quot;short&quot; integer type variable.  The data passed should be of type &quot;short *&quot;.
<DT>LC_VAR_FLOAT<DD>
For a &quot;float&quot; floating point type variable.  The data passed should be of type &quot;float *&quot;.
<DT>LC_VAR_DOUBLE<DD>
For a &quot;double&quot; floating point type variable.  The data passed should be of type &quot;double *&quot;.
<DT>LC_VAR_BOOL<DD>
For a boolean type variable.  The data passed should be of type &quot;int *&quot;.  When a true value is specified the variable is set to 1.  When a false value is specified the variable is set to 0.  Any other value sets the variable to -1.  Valid true values are: enable, true, yes, on, y, and 1.  Valid false values are: disable, false, off, no, n, and 0.
<DT>LC_VAR_FILENAME<DD>
Not implemented.
<DT>LC_VAR_DIRECTORY<DD>
Not implemented.
<DT>LC_VAR_SIZE_LONG_LONG<DD>
For a &quot;long long&quot; integer type that can have size modifiers, such as 'G' or gigabytes, 'M' for megabytes, 'K' for kilobytes.  The data passed should be of type &quot;long long *&quot;.
<DT>LC_VAR_SIZE_LONG<DD>
For a &quot;long&quot; integer type that can have size modifiers, such as 'G' or gigabytes, 'M' for megabytes, 'K' for kilobytes.  The data passed should be of type &quot;long *&quot;.
<DT>LC_VAR_SIZE_INT<DD>
For a &quot;int&quot; integer type that can have size modifiers, such as 'G' or gigabytes, 'M' for megabytes, 'K' for kilobytes.  The data passed should be of type &quot;int *&quot;.
<DT>LC_VAR_SIZE_SHORT<DD>
For a &quot;short&quot; integer type that can have size modifiers, such as 'G' or gigabytes, 'M' for megabytes, 'K' for kilobytes.  The data passed should be of type &quot;short *&quot;.
<DT>LC_VAR_SIZE_SIZE_T<DD>
For a &quot;size_t&quot; data type that can have size modifiers, such as 'G' or gigabytes, 'M' for megabytes, 'K' for kilobytes.  The data passed should be of type &quot;size_t *&quot;.
<DT>LC_VAR_TIME<DD>
Not implemented.
<DT>LC_VAR_DATE<DD>
Not implemented.
<DT>LC_VAR_BOOL_BY_EXISTANCE<DD>
This type of variable takes no arguments, it is set to true (1) by its existance in a configuration file, environment variable, or on the command line.  If it is not specified, the value of the data passed is not changed.  The data passed should be of type &quot;int *&quot;.
<DT>LC_VAR_CIDR<DD>
This type of variable accepts a CIDR format netmask and IP.  This is not yet implemented. (XXX)
<DT>LC_VAR_IP<DD>
This type of variable accepts an IP address in decimal-dot format.  The value is stored in a uint32_t in network byte order.
<DT>LC_VAR_HOSTNAME<DD>
This type of variable accepts an address in hostname format.  The value is stored in a uint32_t in network byte order.
<DT>LC_VAR_ADDR<DD>
This type of variable accepts an address in either hostname or decimal-dot format.  The value is stored in a uint32_t in network byte order.
<P>
</DL>
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
On success 0 is returned, otherwise -1 is returned.
<P>
<A NAME="lbAF">&nbsp;</A>
<H2>EXAMPLE</H2>
<PRE>
#include &lt;<A
#include &lt;<A
#include &lt;<A
int main(int argc, char **argv) {
        int lc_p_ret, lc_rv_ret;
        char *filename = NULL;
        long int counter = -1;
        lc_rv_ret = lc_register_var(&quot;Begin&quot;, LC_VAR_LONG,
                                    &amp;counter, 'c');
        if (lc_rv_ret != 0) {
                fprintf(stderr, &quot;Error registering variable: %i.\n&quot;,
                        lc_geterrno());
                return(EXIT_FAILURE);
        }
        lc_rv_ret = lc_register_var(&quot;File&quot;, LC_VAR_STRING,
                                    &amp;filename, 'f');
        if (lc_rv_ret != 0) {
                fprintf(stderr, &quot;Error registering variable: %i.\n&quot;,
                        lc_geterrno());
                return(EXIT_FAILURE);
        }
        lc_p_ret = lc_process(argc, argv, &quot;example&quot;, LC_CONF_APACHE,
                              NULL);
        lc_cleanup();
        if (lc_p_ret != 0) {
                fprintf(stderr, &quot;Error processing configuration: \
                        %s\n&quot;, lc_geterrstr());
                return(EXIT_FAILURE);
        }
        if (filename != NULL) {
                printf(&quot;File specified was: %s\n&quot;, filename);
        } else {
                printf(&quot;No filename specified.\n&quot;);
        }
        if (counter != -1) {
                printf(&quot;Counter was specified as: %ld\n&quot;, counter);
        } else {
                printf(&quot;Counter was not specified.\n&quot;);
        }
        return(EXIT_SUCCESS);
}
</PRE>
<P>
<A NAME="lbAG">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A
<B><A HREF="wiki/Manual for
<B><A HREF="wiki/Manual for
<B><A HREF="wiki/Manual for
<B><A HREF="wiki/Manual for
<B><A HREF="wiki/Manual for
<B><A HREF="wiki/Manual for
<B><A HREF="wiki/Manual for
<B><A HREF="wiki/Manual for
<P>