Annotation of embedaddon/ntp/sntp/libopts/boolean.c, revision 1.1

1.1     ! misho       1: 
        !             2: /**
        !             3:  * \file boolean.c
        !             4:  *
        !             5:  * Time-stamp:      "2010-07-10 11:02:10 bkorb"
        !             6:  *
        !             7:  *   Automated Options Paged Usage module.
        !             8:  *
        !             9:  *  This routine will run run-on options through a pager so the
        !            10:  *  user may examine, print or edit them at their leisure.
        !            11:  *
        !            12:  *  This file is part of AutoOpts, a companion to AutoGen.
        !            13:  *  AutoOpts is free software.
        !            14:  *  AutoOpts is Copyright (c) 1992-2011 by Bruce Korb - all rights reserved
        !            15:  *
        !            16:  *  AutoOpts is available under any one of two licenses.  The license
        !            17:  *  in use must be one of these two and the choice is under the control
        !            18:  *  of the user of the license.
        !            19:  *
        !            20:  *   The GNU Lesser General Public License, version 3 or later
        !            21:  *      See the files "COPYING.lgplv3" and "COPYING.gplv3"
        !            22:  *
        !            23:  *   The Modified Berkeley Software Distribution License
        !            24:  *      See the file "COPYING.mbsd"
        !            25:  *
        !            26:  *  These files have the following md5sums:
        !            27:  *
        !            28:  *  43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3
        !            29:  *  06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3
        !            30:  *  66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
        !            31:  */
        !            32: 
        !            33: /*=export_func  optionBooleanVal
        !            34:  * private:
        !            35:  *
        !            36:  * what:  Decipher a boolean value
        !            37:  * arg:   + tOptions* + pOpts    + program options descriptor +
        !            38:  * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
        !            39:  *
        !            40:  * doc:
        !            41:  *  Decipher a true or false value for a boolean valued option argument.
        !            42:  *  The value is true, unless it starts with 'n' or 'f' or "#f" or
        !            43:  *  it is an empty string or it is a number that evaluates to zero.
        !            44: =*/
        !            45: void
        !            46: optionBooleanVal( tOptions* pOpts, tOptDesc* pOD )
        !            47: {
        !            48:     char* pz;
        !            49:     ag_bool  res = AG_TRUE;
        !            50: 
        !            51:     if ((pOD->fOptState & OPTST_RESET) != 0)
        !            52:         return;
        !            53: 
        !            54:     if (pOD->optArg.argString == NULL) {
        !            55:         pOD->optArg.argBool = AG_FALSE;
        !            56:         return;
        !            57:     }
        !            58: 
        !            59:     switch (*(pOD->optArg.argString)) {
        !            60:     case '0':
        !            61:     {
        !            62:         long  val = strtol( pOD->optArg.argString, &pz, 0 );
        !            63:         if ((val != 0) || (*pz != NUL))
        !            64:             break;
        !            65:         /* FALLTHROUGH */
        !            66:     }
        !            67:     case 'N':
        !            68:     case 'n':
        !            69:     case 'F':
        !            70:     case 'f':
        !            71:     case NUL:
        !            72:         res = AG_FALSE;
        !            73:         break;
        !            74:     case '#':
        !            75:         if (pOD->optArg.argString[1] != 'f')
        !            76:             break;
        !            77:         res = AG_FALSE;
        !            78:     }
        !            79: 
        !            80:     if (pOD->fOptState & OPTST_ALLOC_ARG) {
        !            81:         AGFREE(pOD->optArg.argString);
        !            82:         pOD->fOptState &= ~OPTST_ALLOC_ARG;
        !            83:     }
        !            84:     pOD->optArg.argBool = res;
        !            85: }
        !            86: /*
        !            87:  * Local Variables:
        !            88:  * mode: C
        !            89:  * c-file-style: "stroustrup"
        !            90:  * indent-tabs-mode: nil
        !            91:  * End:
        !            92:  * end of autoopts/boolean.c */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>