Changes To Manual for lc_handle_type

Changes to "Manual for lc_handle_type" between 2014-11-24 20:10:47 and 2014-11-24 20:11:51

            1  +<H2>NAME</H2>
            2  +lc_handle_type - Convert string representation of a value to its correct type
            3  +<P>
            4  +<A NAME="lbAC">&nbsp;</A>
            5  +<H2>SYNOPSIS</H2>
            6  +<B>#include &lt;<A HREF="artifact/7c61a9805e664fde7943807af8d5e164e7cebdb6">libconfig.h</A>&gt;</B>
            7  +<P>
            8  +<B>int lc_handle_type(lc_var_type_t </B><I>type</I><B>, const char *</B><I>value</I><B>, void *</B><I>data</I><B>);</B>
            9  +<P>
           10  +<A NAME="lbAD">&nbsp;</A>
           11  +<H2>DESCRIPTION</H2>
           12  +<B><A HREF="wiki/Manual for lc_handle_type">lc_handle_type</A></B>(3)
           13  +converts the string
           14  +<I>value</I>
           15  +to the correct type specified by the 
           16  +<I>type </I>
           17  +parameter.  The result is stored in the memory region passed as
           18  +<I>data</I>,
           19  +which should be of the correct type.  For possible values for
           20  +<I>type</I>
           21  +and the corresponding
           22  +<I>data</I>
           23  +type, see the
           24  +<B><A HREF="wiki/Manual for lc_register_var">lc_register_var</A></B>(3)
           25  +man page.
           26  +<P>
           27  +<A NAME="lbAE">&nbsp;</A>
           28  +<H2>RETURN VALUE</H2>
           29  +On success 0 is returned, otherwise -1 is returned.  The memory pointed to by
           30  +<I>data</I>
           31  +may be altered in either case.
           32  +<P>
           33  +<A NAME="lbAF">&nbsp;</A>
           34  +<H2>EXAMPLE</H2>
           35  +<PRE>
           36  +#include &lt;<A HREF="artifact/7c61a9805e664fde7943807af8d5e164e7cebdb6">libconfig.h</A>&gt;
           37  +#include &lt;<A HREF="file:/usr/include/stdlib.h">stdlib.h</A>&gt;
           38  +#include &lt;<A HREF="file:/usr/include/stdio.h">stdio.h</A>&gt;
           39  +int callback_size(const char *shortvar, const char *var,
           40  +                  const char *arguments, const char *value,
           41  +                  lc_flags_t flags, void *extra) {
           42  +        size_t size;
           43  +        int lc_ht_ret;
           44  +        if (value == NULL) {
           45  +                lc_seterrstr(&quot;You must specify an argument to \
           46  +                              Size.&quot;);
           47  +                return(LC_CBRET_ERROR);
           48  +        }
           49  +        lc_ht_ret = lc_handle_type(LC_VAR_SIZE_SIZE_T, value, &amp;size);
           50  +        if (lc_ht_ret != 0) {
           51  +                lc_seterrstr(&quot;Invalid size specified.&quot;);
           52  +                return(LC_CBRET_ERROR);
           53  +        }
           54  +        printf(&quot;Size: %lu\n&quot;, (unsigned long) size);
           55  +        return(LC_CBRET_OKAY);
           56  +}
           57  +int main(int argc, char **argv) {
           58  +        int lc_rc_ret, lc_p_ret;
           59  +        lc_rc_ret = lc_register_callback(&quot;Size&quot;, 0, LC_VAR_SIZE_SIZE_T,
           60  +                                         callback_size, NULL);
           61  +        if (lc_rc_ret != 0) {
           62  +                fprintf(stderr, &quot;Error registering callback.\n&quot;);
           63  +                return(EXIT_FAILURE);
           64  +        }
           65  +        lc_p_ret = lc_process(argc, argv, &quot;example&quot;, LC_CONF_APACHE,
           66  +                              NULL);
           67  +        lc_cleanup();
           68  +        if (lc_p_ret != 0) {
           69  +                fprintf(stderr, &quot;Error processing configuration: \
           70  +                        %s\n&quot;, lc_geterrstr());
           71  +                return(EXIT_FAILURE);
           72  +        }
           73  +        return(EXIT_SUCCESS);
           74  +}
           75  +</PRE>
           76  +<P>
           77  +<P>
           78  +<A NAME="lbAG">&nbsp;</A>
           79  +<H2>SEE ALSO</H2>
           80  +<B><A HREF="wiki/Manual">libconfig</A></B>(3),
           81  +<B><A HREF="wiki/Manual for lc_register_var">lc_register_var</A></B>(3),
           82  +<B><A HREF="wiki/Manual for lc_register_callback">lc_register_callback</A></B>(3),
           83  +<B><A HREF="wiki/Manual for lc_geterrno">lc_geterrno</A></B>(3),
           84  +<B><A HREF="wiki/Manual for lc_geterrstr">lc_geterrstr</A></B>(3),
           85  +<B><A HREF="wiki/Manual for lc_seterrstr">lc_seterrstr</A></B>(3),
           86  +<B><A HREF="wiki/Manual for lc_process">lc_process</A></B>(3),
           87  +<B><A HREF="wiki/Manual for lc_process_file">lc_process_file</A></B>(3),
           88  +<B><A HREF="wiki/Manual for lc_cleanup">lc_cleanup</A></B>(3)
           89  +<P>