simplified gcm registration in cryptodev.
[gnutls.git] / src / libopts / alias.c
blob18a2fd6e1eee51fdce4c4ed9cd8d3e432deb77f7
2 /**
3 * \file alias.c
5 * Time-stamp: "2012-02-12 09:41:42 bkorb"
7 * Automated Options Paged Usage module.
9 * This routine will forward an option alias to the correct option code.
11 * This file is part of AutoOpts, a companion to AutoGen.
12 * AutoOpts is free software.
13 * AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
15 * AutoOpts is available under any one of two licenses. The license
16 * in use must be one of these two and the choice is under the control
17 * of the user of the license.
19 * The GNU Lesser General Public License, version 3 or later
20 * See the files "COPYING.lgplv3" and "COPYING.gplv3"
22 * The Modified Berkeley Software Distribution License
23 * See the file "COPYING.mbsd"
25 * These files have the following md5sums:
27 * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3
28 * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3
29 * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd
32 /*=export_func optionAlias
33 * private:
35 * what: relay an option to its alias
36 * arg: + tOptions* + pOpts + program options descriptor +
37 * arg: + tOptDesc* + pOptDesc + the descriptor for this arg +
38 * arg: + unsigned int + alias + the aliased-to option index +
39 * ret-type: int
41 * doc:
42 * Handle one option as if it had been specified as another. Exactly.
43 * Returns "-1" if the aliased-to option has appeared too many times.
44 =*/
45 int
46 optionAlias(tOptions * pOpts, tOptDesc * pOldOD, unsigned int alias)
48 tOptDesc * pOD;
50 if (pOpts == OPTPROC_EMIT_USAGE)
51 return 0;
53 pOD = pOpts->pOptDesc + alias;
54 if ((unsigned)pOpts->optCt <= alias) {
55 fwrite(zAliasRange, strlen (zAliasRange), 1, stderr);
56 exit(EXIT_FAILURE);
60 * Copy over the option instance flags
62 pOD->fOptState &= OPTST_PERSISTENT_MASK;
63 pOD->fOptState |= (pOldOD->fOptState & ~OPTST_PERSISTENT_MASK);
64 pOD->optArg.argString = pOldOD->optArg.argString;
67 * Keep track of count only for DEFINED (command line) options.
68 * IF we have too many, build up an error message and bail.
70 if ( (pOD->fOptState & OPTST_DEFINED)
71 && (++pOD->optOccCt > pOD->optMaxCt) ) {
73 if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
74 char const * pzEqv =
75 (pOD->optEquivIndex != NO_EQUIVALENT) ? zEquiv : zNil;
77 fputs(zErrOnly, stderr);
79 if (pOD->optMaxCt > 1)
80 fprintf(stderr, zAtMost, pOD->optMaxCt, pOD->pz_Name, pzEqv);
81 else
82 fprintf(stderr, zOnlyOne, pOD->pz_Name, pzEqv);
85 return -1;
89 * Clear the state bits and counters
91 pOldOD->fOptState &= OPTST_PERSISTENT_MASK;
92 pOldOD->optOccCt = 0;
95 * If there is a procedure to call, call it
97 if (pOD->pOptProc != NULL)
98 (*pOD->pOptProc)(pOpts, pOD);
99 return 0;
103 * Local Variables:
104 * mode: C
105 * c-file-style: "stroustrup"
106 * indent-tabs-mode: nil
107 * End:
108 * end of autoopts/alias.c */