summaryrefslogtreecommitdiff
path: root/autoopts/tpl/optcode.tlib
blob: 9f519aecf94371885137474d7ddc58db0545f9ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
[= autogen5 template

# Time-stamp:      "2012-08-11 08:31:28 bkorb"
#
##  This file is part of AutoOpts, a companion to AutoGen.
##  AutoOpts is free software.
##  AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved
##
##  AutoOpts is available under any one of two licenses.  The license
##  in use must be one of these two and the choice is under the control
##  of the user of the license.
##
##   The GNU Lesser General Public License, version 3 or later
##      See the files "COPYING.lgplv3" and "COPYING.gplv3"
##
##   The Modified Berkeley Software Distribution License
##      See the file "COPYING.mbsd"
##
##  These files have the following md5sums:
##
##  43b91e8ca915626ed3818ffb1b71248b COPYING.gplv3
##  06a1a2e4760c90ea5e1dad8dfaac4d39 COPYING.lgplv3
##  66a5cedaf62c4b2637025f049f9b826f COPYING.mbsd

=][=

;;;
;;;  Compute the usage line.  It is complex because we are trying to
;;;  encode as much information as we can and still be comprehensible.
;;;
;;;  The rules are:  If any options have a "value" attribute, then
;;;  there are flags allowed, so include "-<flag>" on the usage line.
;;;  If the program has the "long-opts" attribute set, then we must
;;;  have "<option-name>" or "--<name>" on the line, depending on
;;;  whether or not there are flag options.  If any options take
;;;  arguments, then append "[<val>]" to the flag description and
;;;  "[{=| }<val>]" to the option-name/name descriptions.  We will not
;;;  worry about being correct if every option has a required argument.
;;;  Finally, if there are no minimum occurrence counts (i.e. all
;;;  options are optional), then we put square brackets around the
;;;  syntax.
;;;
;;;  Compute the option arguments
;;;
(define tmp-val "")
(if (exist? "flag.arg-type")
    (set! tmp-val "[{=| }<val>]"))

(define usage-line (string-append "USAGE:  %s "

  ;; If at least one option has a minimum occurrence count
  ;; we use curly brackets around the option syntax.
  ;;
  (if (not (exist? "flag.min")) "[ " "{ ")

  (if (exist? "flag.value")
      (string-append "-<flag>"
         (if (exist? "flag.arg-type") " [<val>]" "")
         (if (exist? "long-opts") " | " "") )
      (if (not (exist? "long-opts"))
         (string-append "<option-name>" tmp-val) "" )  )

  (if (exist? "long-opts")
      (string-append "--<name>" tmp-val) "" )

  (if (not (exist? "flag.min")) " ]..." " }...")
) )

(if (exist? "argument")
  (set! usage-line (string-append usage-line

    ;; the USAGE line plus the program name plus the argument goes
    ;; past 80 columns, then break the line, else separate with space
    ;;
    (if (< 80 (+ (string-length usage-line)
          (len "argument")
          (string-length prog-name) ))
        " \\\n\t\t"
        " "
    )

    (get "argument")
  ))
)

(define usage-text (string-append prog-name
        (if (exist? "package")
            (string-append " (" (get "package") ")")
            "" )
        " - " (get "prog-title")
        (if (exist? "version")
            (string-append " - Ver. " (get "version"))
            "" )
        "\n" usage-line "\n"
))

=][= # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # =][=

INCLUDE "optmain.tlib"

=][=

IF (or (= "shell-process"  (get "main.main-type"))
       (= "shell-parser"   (get "main.main-type"))
       (exist? "main.code")) =]
#define [= (set! make-test-main #t) main-guard =] 1[=
ENDIF
=]
#ifndef __doxygen__
#define OPTION_CODE_COMPILE 1
#include "[= (define lib-externs "") header-file=]"[=

IF (== (get "main.main-type" "") "for-each")

=]
#include <sys/types.h>
#include <sys/stat.h>

#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>[=

ELSE

=]
#include <sys/types.h>

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>[=

 (if (exist? "flag.arg-range")
     (emit "\n#include <errno.h>"))

 (if (and (exist? "resettable") (exist? "flag.open-file"))
     (emit "
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>" )) =][=

ENDIF

=]

#ifdef  __cplusplus
extern "C" {
#endif
extern FILE * option_usage_fp;

/* TRANSLATORS: choose the translation for option names wisely because you
                cannot ever change your mind. */[=

IF (not (exist? "copyright"))

=]
#define zCopyright      NULL
#define zLicenseDescrip NULL[=
ELSE  =][=
  (define cright-owner (get "copyright.owner" (get "copyright.author")))
  =][=
  CASE (get "copyright.type") =][=
    = note       =][=
      (set! tmp-text (get  "copyright.text"))
      (define ext-text tmp-text)            =][=

    ~~* .       =][=
      (define ext-text
         (license-description (get "copyright.type")
            prog-name "" cright-owner ) )

      (set! tmp-text
         (license-info (get "copyright.type")
            prog-name "" cright-owner (get "copyright.date") ) )
                =][=

    *           =][=
      (set! tmp-text (sprintf
              "Copyright (C) %s %s, all rights reserved"
              (get "copyright.date") cright-owner  ))
      (define ext-text tmp-text)            =][=

  ESAC          =][=

(set! tmp-text (string-append version-text "\n" tmp-text))
(string-append "\n#define zCopyright      ("
    (string-table-add-ref opt-strs tmp-text)
    ")\n#define zLicenseDescrip ("

    (if (= tmp-text ext-text)
        "zCopyright"
        (begin
           (set! ext-text (string-append (shell (string-append
             "${CLexe} --fill -I0 -W75 <<_EOF_\n" ext-text "\n_EOF_" )) "\n" ))

           (string-table-add-ref opt-strs ext-text)
    )   )
    ")\n" )              =][=

ENDIF "copyright"        =][=

   (define usage-proc (get "usage"))
   (if (< 1 (string-length usage-proc))
     (emit (string-append "\nextern tUsageProc " usage-proc ";"))
     (set! usage-proc "optionUsage")
   )

=]
[= INVOKE join-or-expand   join-type = "include" =]
#ifndef NULL
#  define NULL 0
#endif

/*
 *  [= prog-name =] option static const strings
 */[=
 (out-resume "home-list") \=][=

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # =][=

FOR flag "\n"           =][=
  (define flag-index (for-index)) =][=
  INVOKE emit-opt-strs  =][=

  (if (exist? "lib-name") (begin
      (set! lib-opt-ptr (string->c-name! (string-append
                        (get "lib-name") "_" (get "name") "_optDesc_p")))
      (set! lib-externs (string-append lib-externs
                        (sprintf "tOptDesc * const %-16s = optDesc + %d;\n"
                                 lib-opt-ptr (for-index) )  ))
  )   )                 =][=

ENDFOR flag             =][=

INVOKE help-strs        =][=
INVOKE decl-callbacks   =][=

IF (exist? "version")   =][=

  IF (exist? "version-proc") =]
#define VER_PROC        [= (get "version-proc") =][=
  ELIF (. make-test-main) =]
#ifdef [=(. main-guard) =]
# define VER_PROC       optionVersionStderr
#else
# define VER_PROC       optionPrintVersion
#endif /* [=(. main-guard)=] */[=
  ELSE                  =]
#define VER_PROC        optionPrintVersion[=
  ENDIF  make-test-main =][=

ENDIF  there is a version

=]
[= INVOKE emit-option-desc-table =]
[= (. lib-externs) =]
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *  Define the [= (. prog-name) =] Option Environment
 */
#define zPROGNAME       ([= (string-table-add-ref opt-strs pname-up)   =])
#define zUsageTitle     ([=
 (define homerc-ct   0)
 (define homerc-txt "")
 (string-table-add-ref opt-strs usage-text) =])
[=
FOR homerc              =][=
  (set! tmp-text (get "homerc"))
  (if (> (string-length tmp-text)) (begin
      (set! homerc-ct  (+ 1 homerc-ct))
      (set! homerc-txt (string-append homerc-txt
            "\n    " (string-table-add-ref opt-strs tmp-text) "," ))
  )   )                 =][=
ENDFOR homerc           =][=
IF (> homerc-ct 0)     \=]
#define zRcName         ([=
 (set! tmp-text (if (exist? "rcfile") (get "rcfile")
       (string-append "." pname-down "rc") ))
 (string-table-add-ref opt-strs tmp-text) =])
static char const * const apzHomeList[=
  (sprintf "[%u] = {%s\n    NULL };" (+ 1 homerc-ct) homerc-txt) =][=

ELSE                    \=]
#define zRcName         NULL
#define apzHomeList     NULL[=
ENDIF                   =]
#define zBugsAddr       ([=
(out-push-new)         \=]
s/@[a-z]*{\([^{@}]*\)}/``\1''/g
s=@<prog-name>@=[= prog-name =]=g
/^@\(end *\)*example/d
s/^@item *$/\
/[=

(define patch-text-sed
  (sprintf "sed %s <<\\_EODetail_ | ${CLexe} --fill -I0 -W75\n"
    (raw-shell-str (out-pop #t)) ) )

(define patch-text (lambda (t-name)
  (set! tmp-text (string-append "\n"

  (shell (string-append
    patch-text-sed
    (get t-name)
    "\n_EODetail_" ))
  "\n" )) ))

(if (exist? "copyright.eaddr")
    (string-table-add-ref opt-strs (get "copyright.eaddr"))
    (if (exist? "eaddr")
        (string-table-add-ref opt-strs (get "eaddr"))
        "NULL"
)   )                   =])
#define zExplain        ([=

(if (or (exist? "explain") (== (get "main.main-type") "for-each"))
    (begin
      (if (exist? "explain")
          (patch-text "explain")
          (set! tmp-text "")  )

      (if (== (get "main.main-type") "for-each")
          (set! tmp-text (string-append tmp-text
"\nIf no arguments are provided, input arguments are read from stdin,
one per line; blank and '#'-prefixed lines are comments.
'stdin' may not be a terminal (tty).\n" ))  )

      (string-table-add-ref opt-strs tmp-text)
    )
    "NULL"
)                       =])
#define zDetail         ([=

(if (exist? "detail")
    (begin
      (patch-text "detail")
      (string-table-add-ref opt-strs tmp-text)
    )
    "NULL"
)                       =])
#define zFullVersion    ([=

(if (exist? "version")
    (string-table-add-ref opt-strs version-text)
    "NULL")             =])[=
(tpl-file-line extract-fmt)
=][=

   IF (. omit-nls-code) =]
#define OPTPROC_BASE OPTPROC_NONE
#define translate_option_strings NULL
[= ELSE  =]
#if defined(ENABLE_NLS)
# define OPTPROC_BASE OPTPROC_TRANSLATE[=
CASE   no-xlate             =][=
!E                          =][=
= opt-cfg                   =] | OPTPROC_NXLAT_OPT_CFG[=
= opt                       =] | OPTPROC_NXLAT_OPT[=
*                           =][= (error "invalid value for 'no-xlate'") =][=
ESAC   no-xlate             =]
  static tOptionXlateProc translate_option_strings;
#else
# define OPTPROC_BASE OPTPROC_NONE
# define translate_option_strings NULL
#endif /* ENABLE_NLS */
[= ENDIF no-nls             =][=
   IF (exist? "resettable") =]
static optArgBucket_t const original_[=(. pname-down)=]_defaults[ [=
(. UP-prefix) =]OPTION_CT ] = {
[= (shell (string-append
      "sed '$s@},@} @' <<\\_EOF_" default-text "\n_EOF_\n")) =]
};
static void * const original_[=(. pname-down)=]_cookies[ [=
(. UP-prefix) =]OPTION_CT ] = {
[=
 (shell (string-append "${CLexe} -I4 -S, <<\\_EOF_\n" default-cookie "_EOF_"))
=]
};
[= ENDIF resettable=]
[= INVOKE usage-text usage-type = full  \=]
[= INVOKE usage-text usage-type = short  =]
#endif /* not defined __doxygen__ */
[= INVOKE emit-option-callbacks          =]
/**
 * The directory containing the data associated with [= prog-name =].
 */
#ifndef  PKGDATADIR
# define PKGDATADIR ""
#endif

/**
 * Information about the person or institution that packaged [= prog-name =]
 * for the current distribution.
 */
#ifndef  WITH_PACKAGER
# define [=(. pname)=]_packager_info NULL
#else
static char const [=(. pname)=]_packager_info[] =
    "Packaged by " WITH_PACKAGER

# ifdef WITH_PACKAGER_VERSION
        " ("WITH_PACKAGER_VERSION")"
# endif

# ifdef WITH_PACKAGER_BUG_REPORTS
    "\nReport [=(. pname)=] bugs to " WITH_PACKAGER_BUG_REPORTS
# endif
    "\n";
#endif
#ifndef __doxygen__
[=
 (out-suspend  "home-list") =][=
 (emit-string-table opt-strs) =][=
 (out-resume   "home-list") =][=
 (out-pop      #t)
=]
#endif /* __doxygen__ */
/**
 * The option definitions for [= prog-name =].  The one structure that
 * binds them all.
 */
tOptions [=(. pname)=]Options = {
    OPTIONS_STRUCT_VERSION,
    0, NULL,                    /* original argc + argv    */
    ( OPTPROC_BASE[=                IF (not (exist? "allow-errors"))     =]
    + OPTPROC_ERRSTOP[=    ENDIF=][=IF      (exist? "flag.value")        =]
    + OPTPROC_SHORTOPT[=   ENDIF=][=IF      (exist? "long-opts")         =]
    + OPTPROC_LONGOPT[=    ENDIF=][=IF (not (exist? "flag.min"))         =]
    + OPTPROC_NO_REQ_OPT[= ENDIF=][=IF      (exist? "flag.disable")      =]
    + OPTPROC_NEGATIONS[=  ENDIF=][=IF (>=   number-opt-index 0)         =]
    + OPTPROC_NUM_OPT[=    ENDIF=][=IF      (exist? "environrc")         =]
    + OPTPROC_ENVIRON[=    ENDIF=][=IF (not (exist? "argument"))         =]
    + OPTPROC_NO_ARGS[=           ELIF (not (==* (get "argument") "[" )) =]
    + OPTPROC_ARGS_REQ[=   ENDIF=][=IF      (exist? "reorder-args")      =]
    + OPTPROC_REORDER[=    ENDIF=][=IF      (exist? "gnu-usage")         =]
    + OPTPROC_GNUUSAGE[=   ENDIF=][=IF      (exist? "no-misuse-usage")   =]
    + OPTPROC_MISUSE[=     ENDIF=][=IF      (exist? "vendor-opt")        =]
    + OPTPROC_VENDOR_OPT[= ENDIF=] ),
    0, NULL,                    /* current option index, current option */
    NULL,         NULL,         zPROGNAME,
    zRcName,      zCopyright,   zLicenseDescrip,
    zFullVersion, apzHomeList,  zUsageTitle,
    zExplain,     zDetail,      optDesc,
    zBugsAddr,                  /* address to send bugs to */
    NULL, NULL,                 /* extensions/saved state  */
    [= (. usage-proc)       =], /* usage procedure */
    translate_option_strings,   /* translation procedure */
    /*
     *  Indexes to special options
     */
    { [= (if (exist? "no-libopts") "NO_EQUIVALENT"
             (string-append INDEX-pfx "MORE_HELP"))
       =], /* more-help option index */
      [=IF (and (exist? "homerc") (not (exist? "disable-save")))
             =][= (. INDEX-pfx) =]SAVE_OPTS[=
        ELSE =]NO_EQUIVALENT[=
        ENDIF=], /* save option index */
      [= (if (>= number-opt-index 0) number-opt-index "NO_EQUIVALENT")
        =], /* '-#' option index */
      [= (if (>= default-opt-index 0) default-opt-index "NO_EQUIVALENT")
        =] /* index of default opt */
    },
    [= (. option-ct) =] /* full option count */, [=
       (count "flag")=] /* user option count */,
    [= (. pname) =]_full_usage, [= (. pname) =]_short_usage,
[= IF (exist? "resettable") \=]
    original_[=(. pname-down)=]_defaults, original_[=(. pname-down)=]_cookies,
[= ELSE \=]
    NULL, NULL,
[= ENDIF \=]
    PKGDATADIR, [=(. pname)=]_packager_info
};
[=

FOR lib-name

=]
tOptDesc* [= (string->c-name! (get "lib-name")) =]_optDesc_p = NULL;[=

ENDFOR                      =][=

INVOKE emit-nls-code

=]
#ifdef  __cplusplus
}
#endif[= #

// = = = = = = = = = = = = = = = = = = = = = = = = = = = = =][=

DEFINE emit-nls-code

=][= IF (. omit-nls-code) =][= RETURN =][= ENDIF

=]
#if ENABLE_NLS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <autoopts/usage-txt.h>

static char* AO_gettext(char const* pz);
static void  coerce_it(void** s);

/**
 * AutoGen specific wrapper function for gettext.
 * It relies on the macro _() to convert from English to the target
 * language, then strdup-duplicates the result string.
 *
 * @param[in] pz the input text used as a lookup key.
 * @returns the translated text (if there is one),
 *   or the original text (if not).
 */
static char *
AO_gettext(char const* pz)
{
    char* pzRes;
    if (pz == NULL)
        return NULL;
    pzRes = _(pz);
    if (pzRes == pz)
        return pzRes;
    pzRes = strdup(pzRes);
    if (pzRes == NULL) {
        fputs(_("No memory for duping translated strings\n"), stderr);
        exit([=(. nomem-exit-code)=]);
    }
    return pzRes;
}

static void coerce_it(void** s) { *s = AO_gettext(*s);
}

/**
 * Translate all the translatable strings in the [=(. pname)=]Options
 * structure defined above.  This is done only once.
 */
static void
translate_option_strings(void)
{
    tOptions * const pOpt = &[=(. pname)=]Options;

    /*
     *  Guard against re-translation.  It won't work.  The strings will have
     *  been changed by the first pass through this code.  One shot only.
     */
    if (option_usage_text.field_ct != 0) {
        /*
         *  Do the translations.  The first pointer follows the field count
         *  field.  The field count field is the size of a pointer.
         */
        tOptDesc * pOD = pOpt->pOptDesc;
        char **    ppz = (char**)(void*)&(option_usage_text);
        int        ix  = option_usage_text.field_ct;

        do {
            ppz++;
            *ppz = AO_gettext(*ppz);
        } while (--ix > 0);
[=
  FOR field IN pzCopyright pzCopyNotice pzFullVersion pzUsageTitle pzExplain
               pzDetail    pzPackager   =]
        coerce_it((void*)&(pOpt->[= field =]));[=
  ENDFOR                        =][=

  IF (exist? "full-usage")      =]
        coerce_it((void*)&(pOpt->pzFullUsage));[=
  ENDIF                         =][=

  IF (exist? "short-usage")     =]
        coerce_it((void*)&(pOpt->pzShortUsage));[=
  ENDIF                         =]
        option_usage_text.field_ct = 0;

        for (ix = pOpt->optCt; ix > 0; ix--, pOD++)
            coerce_it((void*)&(pOD->pzText));
    }

    if ((pOpt->fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) {
        tOptDesc * pOD = pOpt->pOptDesc;
        int        ix;

        for (ix = pOpt->optCt; ix > 0; ix--, pOD++) {[=

  FOR field IN pz_Name pz_DisableName pz_DisablePfx  =][=

    (sprintf "\n            coerce_it((void*)&(pOD->%1$s));"
             (get "field"))     =][=

  ENDFOR                        =]
        }
        /* prevent re-translation */
        [= (. pname)
        =]Options.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT;
    }
}

#endif /* ENABLE_NLS */
[=

ENDDEF emit-nls-code

=][=

DEFINE emit-option-desc-table

=]
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
 *  Define the [= prog-name =] Option Descriptions.
 * This is an array of [=(. UP-prefix)=]OPTION_CT entries, one for each
 * option that the [= prog-name =] program responds to.
 */
static tOptDesc optDesc[[=
(define default-text   "")
(define default-cookie "")
UP-prefix
=]OPTION_CT] = {[=

FOR flag "\n"           =][=
  (define flag-index (for-index)) =][=

  INVOKE emit-opt-desc  =][=

ENDFOR flag

=][=

IF (exist? "resettable")

=]

  {  /* entry idx, value */ [=
        (set! default-text (string-append default-text
               "\n    { NULL }, /* resettable */" ))
        (set! default-cookie (string-append default-cookie "NULL\n" ))
        INDEX-pfx =]RESET_OPTION, [= (. VALUE-pfx) =]RESET_OPTION,
     /* equiv idx value  */ NO_EQUIVALENT, [= (. VALUE-pfx) =]RESET_OPTION,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ RESET_FLAGS, 0,
     /* last opt argumnt */ { NULL },
     /* arg list/cookie  */ NULL,
     /* must/cannot opts */ NULL,  NULL,
     /* option proc      */ optionResetOpt,
     /* desc, NAME, name */ RESET_DESC, NULL, RESET_name,
     /* disablement strs */ NULL, NULL },[=

ENDIF

=][=

IF (exist? "version")   =]

  {  /* entry idx, value */ [=
        (set! default-text (string-append default-text
               "\n    { NULL }, /* version */" ))
        (set! default-cookie (string-append default-cookie "NULL\n" ))
         INDEX-pfx =]VERSION, [= (. VALUE-pfx) =]VERSION,
     /* equiv idx value  */ NO_EQUIVALENT, [= (. VALUE-pfx) =]VERSION,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ VER_FLAGS, 0,
     /* last opt argumnt */ { NULL },
     /* arg list/cookie  */ NULL,
     /* must/cannot opts */ NULL, NULL,
     /* option proc      */ VER_PROC,
     /* desc, NAME, name */ VER_DESC, NULL, VER_name,
     /* disablement strs */ NULL, NULL },

[=

ENDIF =]

  {  /* entry idx, value */ [=
        (set! default-text (string-append default-text
               "\n    { NULL }, /* help */" ))
        (set! default-cookie (string-append default-cookie "NULL\n" ))
        INDEX-pfx =]HELP, [= (. VALUE-pfx) =]HELP,
     /* equiv idx value  */ NO_EQUIVALENT, [= (. VALUE-pfx) =]HELP,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
     /* last opt argumnt */ { NULL },
     /* arg list/cookie  */ NULL,
     /* must/cannot opts */ NULL, NULL,
     /* option proc      */ doUsageOpt,
     /* desc, NAME, name */ HELP_DESC, NULL, HELP_name,
     /* disablement strs */ NULL, NULL }[=

IF (not (exist? "no-libopts"))          =],

  {  /* entry idx, value */ [=
        (set! default-text (string-append default-text
               "\n    { NULL }, /* more-help */" ))
        (set! default-cookie (string-append default-cookie "NULL\n" ))
        INDEX-pfx =]MORE_HELP, [= (. VALUE-pfx) =]MORE_HELP,
     /* equiv idx value  */ NO_EQUIVALENT, [= (. VALUE-pfx) =]MORE_HELP,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ MORE_HELP_FLAGS, 0,
     /* last opt argumnt */ { NULL },
     /* arg list/cookie  */ NULL,
     /* must/cannot opts */ NULL,  NULL,
     /* option proc      */ optionPagedUsage,
     /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name,
     /* disablement strs */ NULL, NULL }[=

ENDIF not have no-libopts               =][=

IF (exist? "usage-opt")                 =],

  {  /* entry idx, value */ [=
        (set! default-text (string-append default-text
               "\n    { NULL }, /* usage-opt */" ))
        (set! default-cookie (string-append default-cookie "NULL\n" ))
        INDEX-pfx =]USAGE, [= (. VALUE-pfx) =]USAGE,
     /* equiv idx value  */ NO_EQUIVALENT, [= (. VALUE-pfx) =]USAGE,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
     /* last opt argumnt */ { NULL },
     /* arg list/cookie  */ NULL,
     /* must/cannot opts */ NULL,  NULL,
     /* option proc      */ doUsageOpt,
     /* desc, NAME, name */ USAGE_DESC, NULL, USAGE_name,
     /* disablement strs */ NULL, NULL }[=

ENDIF have usage-opt                    =][=

IF (exist? "homerc")                    =][=
   IF (not (exist? "disable-save"))     =],

  {  /* entry idx, value */ [=
        (set! default-text (string-append default-text
               "\n    { NULL }, /* save-opts */" ))
        (set! default-cookie (string-append default-cookie "NULL\n" ))
        INDEX-pfx =]SAVE_OPTS, [=
           (if (not (exist? "disable-save"))
               (string-append VALUE-pfx "SAVE_OPTS")
               "0") =],
     /* equiv idx value  */ NO_EQUIVALENT, [= (. VALUE-pfx) =]SAVE_OPTS,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, 1, 0,
     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
                          | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
     /* last opt argumnt */ { NULL },
     /* arg list/cookie  */ NULL,
     /* must/cannot opts */ NULL,  NULL,
     /* option proc      */ NULL,
     /* desc, NAME, name */ SAVE_OPTS_DESC, NULL, SAVE_OPTS_name,
     /* disablement strs */ NULL, NULL }[=

   ENDIF disable-save does not exist     =],

  {  /* entry idx, value */ [=
        (set! default-text (string-append default-text
               "\n    { NULL }, /* load-opts */" ))
        (set! default-cookie (string-append default-cookie "NULL\n" ))
        INDEX-pfx =]LOAD_OPTS, [=
           (if (not (exist? "disable-load"))
               (string-append VALUE-pfx "LOAD_OPTS")
               "0") =],
     /* equiv idx value  */ NO_EQUIVALENT, [= (. VALUE-pfx) =]LOAD_OPTS,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, NOLIMIT, 0,
     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
			  | OPTST_DISABLE_IMM[=
    (if (exist? "disable-load") "| OPTST_NO_COMMAND") =], 0,
     /* last opt argumnt */ { NULL },
     /* arg list/cookie  */ NULL,
     /* must/cannot opts */ NULL, NULL,
     /* option proc      */ optionLoadOpt,
     /* desc, NAME, name */ [=
    (if (exist? "disable-load") "NULL, NULL, NULL"
         "LOAD_OPTS_DESC, LOAD_OPTS_NAME, LOAD_OPTS_name")=],
     /* disablement strs */ [=
    (if (exist? "disable-load") "NULL, NULL"
         "NO_LOAD_OPTS_name, LOAD_OPTS_pfx")=] }[=

ENDIF have homerc                       =][=

IF (exist? "vendor-opt")                =],

  {  /* entry idx, value */ [=
        (set! default-text (string-append default-text
               "\n    { NULL }, /* vendor-opt */" ))
        (set! default-cookie (string-append default-cookie "NULL\n" ))
        INDEX-pfx =]VENDOR_OPT, [= (. VALUE-pfx) =]VENDOR_OPT,
     /* equiv idx value  */ NO_EQUIVALENT, [= (. VALUE-pfx) =]VENDOR_OPT,
     /* equivalenced to  */ NO_EQUIVALENT,
     /* min, max, act ct */ 0, NOLIMIT, 0,
     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
                          | OPTST_IMM | OPTST_TWICE, 0, /* both directions */
     /* last opt argumnt */ { NULL },
     /* arg list/cookie  */ NULL,
     /* must/cannot opts */ NULL,  NULL,
     /* option proc      */ optionVendorOption,
     /* desc, NAME, name */ VEND_DESC, NULL, VEND_name,
     /* disablement strs */ NULL, NULL }[=

ENDIF have vendor-opt                   =]
};
[=

ENDDEF emit-option-desc-table

/*
 * Local Variables:
 * mode: C
 * c-file-style: "stroustrup"
 * indent-tabs-mode: nil
 * End:
 * opthead.tpl ends here */    \=]