Fixed build with HWASan
[platform/upstream/autogen.git] / doc / autogen.info-1
1 This is autogen.info, produced by makeinfo version 6.5 from
2 autogen.texi.
3
4 This manual is for GNU AutoGen version 5.18, updated August 2018.
5
6    Copyright (C) 1992-2018 by Bruce Korb.
7
8      Permission is granted to copy, distribute and/or modify this
9      document under the terms of the GNU Free Documentation License,
10      Version 1.2 or any later version published by the Free Software
11      Foundation; with no Invariant Sections, no Front-Cover Texts, and
12      no Back-Cover Texts.
13 INFO-DIR-SECTION GNU programming tools
14 START-INFO-DIR-ENTRY
15 * AutoGen: (autogen).         The Automated Program Generator
16 END-INFO-DIR-ENTRY
17
18    This file documents GNU AutoGen Version 5.18.
19
20    AutoGen copyright (C) 1992-2018 Bruce Korb AutoOpts copyright (C)
21 1992-2018 Bruce Korb snprintfv copyright (C) 1999-2000 Gary V. Vaughan
22
23    AutoGen is free software: you can redistribute it and/or modify it
24 under the terms of the GNU General Public License as published by the
25 Free Software Foundation, either version 3 of the License, or (at your
26 option) any later version.
27
28    AutoGen is distributed in the hope that it will be useful, but
29 WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
31 Public License for more details.
32
33    You should have received a copy of the GNU General Public License
34 along with this program.  If not, see <http://www.gnu.org/licenses/>.
35
36 \1f
37 File: autogen.info,  Node: Top,  Next: Introduction,  Up: (dir)
38
39 The Automated Program Generator
40 *******************************
41
42 This file documents AutoGen version 5.18.  It is a tool designed for
43 generating program files that contain repetitive text with varied
44 substitutions.  This document is very long because it is intended as a
45 reference document.  For a quick start example, *Note Example Usage::.
46
47    The AutoGen distribution includes the basic generator engine and
48 several add-on libraries and programs.  Of the most general interest
49 would be Automated Option processing, *Note AutoOpts::, which also
50 includes stand-alone support for configuration file parsing, *Note
51 Features::.  *Note Add-on packages for AutoGen: Add-Ons, section for
52 additional programs and libraries associated with AutoGen.
53
54    This edition documents version 5.18, August 2018.
55
56 * Menu:
57
58 * Introduction::         AutoGen's Purpose
59 * Definitions File::     AutoGen Definitions File
60 * Template File::        AutoGen Template
61 * Augmenting AutoGen::   Augmenting AutoGen Features
62 * autogen Invocation::   Invoking AutoGen
63 * Installation::         Configuring and Installing
64 * AutoOpts::             Automated Option Processing
65 * Add-Ons::              Add-on packages for AutoGen
66 * Future::               Some ideas for the future.
67 * Copying This Manual::  Copying This Manual
68 * Concept Index::        General index
69 * Function Index::       Function index
70
71 \1f
72 File: autogen.info,  Node: Introduction,  Next: Definitions File,  Up: Top
73
74 1 Introduction
75 **************
76
77 AutoGen is a tool designed for generating program files that contain
78 repetitive text with varied substitutions.  Its goal is to simplify the
79 maintenance of programs that contain large amounts of repetitious text.
80 This is especially valuable if there are several blocks of such text
81 that must be kept synchronized in parallel tables.
82
83    An obvious example is the problem of maintaining the code required
84 for processing program options and configuration settings.  Processing
85 options requires a minimum of four different constructs be kept in
86 proper order in different places in your program.  You need at least:
87
88   1. The flag character in the flag string,
89   2. code to process the flag when it is encountered,
90   3. a global state variable or two, and
91   4. a line in the usage text.
92
93 You will need more things besides this if you choose to implement long
94 option names, configuration (rc/ini) file processing, environment
95 variable settings and keep all the documentation for these up to date.
96 This can be done mechanically; with the proper templates and this
97 program.  In fact, it has already been done and AutoGen itself uses it
98 *Note AutoOpts::.  For a simple example of Automated Option processing,
99 *Note Quick Start::.  For a full list of the Automated Option features,
100 *Note Features::.  Be forewarned, though, the feature list is
101 ridiculously extensive.
102
103 * Menu:
104
105 * Generalities::         The Purpose of AutoGen
106 * Example Usage::        A Simple Example
107 * csh/zsh caveat::       csh/zsh caveat
108 * Testimonial::          A User's Perspective
109
110 \1f
111 File: autogen.info,  Node: Generalities,  Next: Example Usage,  Up: Introduction
112
113 1.1 The Purpose of AutoGen
114 ==========================
115
116 The idea of this program is to have a text file, a template if you will,
117 that contains the general text of the desired output file.  That file
118 includes substitution expressions and sections of text that are
119 replicated under the control of separate definition files.
120
121    AutoGen was designed with the following features:
122
123   1. The definitions are completely separate from the template.  By
124      completely isolating the definitions from the template it greatly
125      increases the flexibility of the template implementation.  A
126      secondary goal is that a template user only needs to specify those
127      data that are necessary to describe his application of a template.
128
129   2. Each datum in the definitions is named.  Thus, the definitions can
130      be rearranged, augmented and become obsolete without it being
131      necessary to go back and clean up older definition files.  Reduce
132      incompatibilities!
133
134   3. Every definition name defines an array of values, even when there
135      is only one entry.  These arrays of values are used to control the
136      replication of sections of the template.
137
138   4. There are named collections of definitions.  They form a nested
139      hierarchy.  Associated values are collected and associated with a
140      group name.  These associated data are used collectively in sets of
141      substitutions.
142
143   5. The template has special markers to indicate where substitutions
144      are required, much like the '${VAR}' construct in a shell 'here
145      doc'.  These markers are not fixed strings.  They are specified at
146      the start of each template.  Template designers know best what fits
147      into their syntax and can avoid marker conflicts.
148
149      We did this because it is burdensome and difficult to avoid
150      conflicts using either M4 tokenization or C preprocessor
151      substitution rules.  It also makes it easier to specify expressions
152      that transform the value.  Of course, our expressions are less
153      cryptic than the shell methods.
154
155   6. These same markers are used, in conjunction with enclosed keywords,
156      to indicate sections of text that are to be skipped and for
157      sections of text that are to be repeated.  This is a major
158      improvement over using C preprocessing macros.  With the C
159      preprocessor, you have no way of selecting output text because it
160      is an unvarying, mechanical substitution process.
161
162   7. Finally, we supply methods for carefully controlling the output.
163      Sometimes, it is just simply easier and clearer to compute some
164      text or a value in one context when its application needs to be
165      later.  So, functions are available for saving text or values for
166      later use.
167
168 \1f
169 File: autogen.info,  Node: Example Usage,  Next: csh/zsh caveat,  Prev: Generalities,  Up: Introduction
170
171 1.2 A Simple Example
172 ====================
173
174 This is just one simple example that shows a few basic features.  If you
175 are interested, you also may run "make check" with the 'VERBOSE'
176 environment variable set and see a number of other examples in the
177 'agen5/test' directory.
178
179    Assume you have an enumeration of names and you wish to associate
180 some string with each name.  Assume also, for the sake of this example,
181 that it is either too complex or too large to maintain easily by hand.
182 We will start by writing an abbreviated version of what the result is
183 supposed to be.  We will use that to construct our output templates.
184
185 In a header file, 'list.h', you define the enumeration and the global
186 array containing the associated strings:
187
188      typedef enum {
189              IDX_ALPHA,
190              IDX_BETA,
191              IDX_OMEGA }  list_enum;
192
193      extern char const* az_name_list[ 3 ];
194
195 Then you also have 'list.c' that defines the actual strings:
196
197      #include "list.h"
198      char const* az_name_list[] = {
199              "some alpha stuff",
200              "more beta stuff",
201              "final omega stuff" };
202
203 First, we will define the information that is unique for each
204 enumeration name/string pair.  This would be placed in a file named,
205 'list.def', for example.
206
207      autogen definitions list;
208      list = { list_element = alpha;
209               list_info    = "some alpha stuff"; };
210      list = { list_info    = "more beta stuff";
211               list_element = beta; };
212      list = { list_element = omega;
213               list_info    = "final omega stuff"; };
214
215    The 'autogen definitions list;' entry defines the file as an AutoGen
216 definition file that uses a template named 'list'.  That is followed by
217 three 'list' entries that define the associations between the
218 enumeration names and the strings.  The order of the differently named
219 elements inside of list is unimportant.  They are reversed inside of the
220 'beta' entry and the output is unaffected.
221
222    Now, to actually create the output, we need a template or two that
223 can be expanded into the files you want.  In this program, we use a
224 single template that is capable of multiple output files.  The
225 definitions above refer to a 'list' template, so it would normally be
226 named, 'list.tpl'.
227
228    It looks something like this.  (For a full description, *Note
229 Template File::.)
230
231      [+ AutoGen5 template h c +]
232      [+ CASE (suffix) +][+
233         ==  h  +]
234      typedef enum {[+
235         FOR list "," +]
236              IDX_[+ (string-upcase! (get "list_element")) +][+
237         ENDFOR list +] }  list_enum;
238
239      extern char const* az_name_list[ [+ (count "list") +] ];
240      [+
241
242         ==  c  +]
243      #include "list.h"
244      char const* az_name_list[] = {[+
245        FOR list "," +]
246              "[+list_info+]"[+
247        ENDFOR list +] };[+
248
249      ESAC +]
250
251    The '[+ AutoGen5 template h c +]' text tells AutoGen that this is an
252 AutoGen version 5 template file; that it is to be processed twice; that
253 the start macro marker is '[+'; and the end marker is '+]'.  The
254 template will be processed first with a suffix value of 'h' and then
255 with 'c'.  Normally, the suffix values are appended to the 'base-name'
256 to create the output file name.
257
258    The '[+ == h +]' and '[+ == c +]' 'CASE' selection clauses select
259 different text for the two different passes.  In this example, the
260 output is nearly disjoint and could have been put in two separate
261 templates.  However, sometimes there are common sections and this is
262 just an example.
263
264    The '[+FOR list "," +]' and '[+ ENDFOR list +]' clauses delimit a
265 block of text that will be repeated for every definition of 'list'.
266 Inside of that block, the definition name-value pairs that are members
267 of each 'list' are available for substitutions.
268
269    The remainder of the macros are expressions.  Some of these contain
270 special expression functions that are dependent on AutoGen named values;
271 others are simply Scheme expressions, the result of which will be
272 inserted into the output text.  Other expressions are names of AutoGen
273 values.  These values will be inserted into the output text.  For
274 example, '[+list_info+]' will result in the value associated with the
275 name 'list_info' being inserted between the double quotes and
276 '(string-upcase! (get "list_element"))' will first "get" the value
277 associated with the name 'list_element', then change the case of all the
278 letters to upper case.  The result will be inserted into the output
279 document.
280
281    If you have compiled AutoGen, you can copy out the template and
282 definitions as described above and run 'autogen list.def'.  This will
283 produce exactly the hypothesized desired output.
284
285    One more point, too.  Lets say you decided it was too much trouble to
286 figure out how to use AutoGen, so you created this enumeration and
287 string list with thousands of entries.  Now, requirements have changed
288 and it has become necessary to map a string containing the enumeration
289 name into the enumeration number.  With AutoGen, you just alter the
290 template to emit the table of names.  It will be guaranteed to be in the
291 correct order, missing none of the entries.  If you want to do that by
292 hand, well, good luck.
293
294 \1f
295 File: autogen.info,  Node: csh/zsh caveat,  Next: Testimonial,  Prev: Example Usage,  Up: Introduction
296
297 1.3 csh/zsh caveat
298 ==================
299
300 AutoGen tries to use your normal shell so that you can supply shell code
301 in a manner you are accustomed to using.  If, however, you use csh or
302 zsh, you cannot do this.  Csh is sufficiently difficult to program that
303 it is unsupported.  Zsh, though largely programmable, also has some
304 anomalies that make it incompatible with AutoGen usage.  Therefore, when
305 invoking AutoGen from these environments, you must be certain to set the
306 SHELL environment variable to a Bourne-derived shell, e.g., sh, ksh or
307 bash.
308
309    Any shell you choose for your own scripts need to follow these basic
310 requirements:
311
312   1. It handles 'trap ":" $sig' without output to standard out.  This is
313      done when the server shell is first started.  If your shell does
314      not handle this, then it may be able to by loading functions from
315      its start up files.
316   2. At the beginning of each scriptlet, the command '\\cd $PWD' is
317      inserted.  This ensures that 'cd' is not aliased to something
318      peculiar and each scriptlet starts life in the execution directory.
319   3. At the end of each scriptlet, the command 'echo mumble' is
320      appended.  The program you use as a shell must emit the single
321      argument 'mumble' on a line by itself.
322
323 \1f
324 File: autogen.info,  Node: Testimonial,  Prev: csh/zsh caveat,  Up: Introduction
325
326 1.4 A User's Perspective
327 ========================
328
329 Alexandre wrote:
330 >
331 > I'd appreciate opinions from others about advantages/disadvantages of
332 > each of these macro packages.
333
334    I am using AutoGen in my pet project, and find one of its best points
335 to be that it separates the operational data from the implementation.
336
337    Indulge me for a few paragraphs, and all will be revealed: In the
338 manual, Bruce cites the example of maintaining command line flags inside
339 the source code; traditionally spreading usage information, flag names,
340 letters and processing across several functions (if not files).
341 Investing the time in writing a sort of boiler plate (a template in
342 AutoGen terminology) pays by moving all of the option details (usage,
343 flags names etc.)  into a well structured table (a definition file if
344 you will), so that adding a new command line option becomes a simple
345 matter of adding a set of details to the table.
346
347    So far so good!  Of course, now that there is a template, writing all
348 of that tedious optargs processing and usage functions is no longer an
349 issue.  Creating a table of the options needed for the new project and
350 running AutoGen generates all of the option processing code in C
351 automatically from just the tabular data.  AutoGen in fact already ships
352 with such a template...  AutoOpts.
353
354    One final consequence of the good separation in the design of AutoGen
355 is that it is retargetable to a greater extent.  The
356 egcs/gcc/fixinc/inclhack.def can equally be used (with different
357 templates) to create a shell script (inclhack.sh) or a c program
358 (fixincl.c).
359
360    This is just the tip of the iceberg.  AutoGen is far more powerful
361 than these examples might indicate, and has many other varied uses.  I
362 am certain Bruce or I could supply you with many and varied examples,
363 and I would heartily recommend that you try it for your project and see
364 for yourself how it compares to m4.
365
366    As an aside, I would be interested to see whether someone might be
367 persuaded to rationalise autoconf with AutoGen in place of m4...  Ben,
368 are you listening?  autoconf-3.0!  'kay?  =)O|
369
370 Sincerely,
371         Gary V. Vaughan
372
373 \1f
374 File: autogen.info,  Node: Definitions File,  Next: Template File,  Prev: Introduction,  Up: Top
375
376 2 Definitions File
377 ******************
378
379 This chapter describes the syntax and semantics of the AutoGen
380 definition file.  In order to instantiate a template, you normally must
381 provide a definitions file that identifies itself and contains some
382 value definitions.  Consequently, we keep it very simple.  For
383 "advanced" users, there are preprocessing directives, sparse arrays,
384 named indexes and comments that may be used as well.
385
386    The definitions file is used to associate values with names.  Every
387 value is implicitly an array of values, even if there is only one value.
388 Values may be either simple strings or compound collections of
389 name-value pairs.  An array may not contain both simple and compound
390 members.  Fundamentally, it is as simple as:
391
392      prog-name = "autogen";
393      flag = {
394          name      = templ_dirs;
395          value     = L;
396          descrip   = "Template search directory list";
397      };
398
399    For purposes of commenting and controlling the processing of the
400 definitions, C-style comments and most C preprocessing directives are
401 honored.  The major exception is that the '#if' directive is ignored,
402 along with all following text through the matching '#endif' directive.
403 The C preprocessor is not actually invoked, so C macro substitution is
404 *not* performed.
405
406 * Menu:
407
408 * Identification::        The Identification Definition
409 * Definitions::           Named Definitions
410 * Index Assignments::     Assigning an Index to a Definition
411 * Dynamic Text::          Dynamic Text
412 * Directives::            Controlling What Gets Processed
413 * Predefines::            Pre-defined Names
414 * Comments::              Commenting Your Definitions
415 * Example::               What it all looks like.
416 * Full Syntax::           Finite State Machine Grammar
417 * Alternate Definition::  Alternate Definition Forms
418
419 \1f
420 File: autogen.info,  Node: Identification,  Next: Definitions,  Up: Definitions File
421
422 2.1 The Identification Definition
423 =================================
424
425 The first definition in this file is used to identify it as a AutoGen
426 file.  It consists of the two keywords, 'autogen' and 'definitions'
427 followed by the default template name and a terminating semi-colon
428 (';').  That is:
429
430              AutoGen Definitions TEMPLATE-NAME;
431
432 Note that, other than the name TEMPLATE-NAME, the words 'AutoGen' and
433 'Definitions' are searched for without case sensitivity.  Most lookups
434 in this program are case insensitive.
435
436 Also, if the input contains more identification definitions, they will
437 be ignored.  This is done so that you may include (*note Directives::)
438 other definition files without an identification conflict.
439
440 AutoGen uses the name of the template to find the corresponding template
441 file.  It searches for the file in the following way, stopping when it
442 finds the file:
443
444   1. It tries to open './TEMPLATE-NAME'.  If it fails,
445   2. it tries './TEMPLATE-NAME.tpl'.
446   3. It searches for either of these files in the directories listed in
447      the templ-dirs command line option.
448
449    If AutoGen fails to find the template file in one of these places, it
450 prints an error message and exits.
451
452 \1f
453 File: autogen.info,  Node: Definitions,  Next: Index Assignments,  Prev: Identification,  Up: Definitions File
454
455 2.2 Named Definitions
456 =====================
457
458 A name is a sequence of characters beginning with an alphabetic
459 character ('a' through 'z') followed by zero or more alpha-numeric
460 characters and/or separator characters: hyphen ('-'), underscore ('_')
461 or carat ('^').  Names are case insensitive.
462
463    Any name may have multiple values associated with it.  Every name may
464 be considered a sparse array of one or more elements.  If there is more
465 than one value, the values my be accessed by indexing the value with
466 '[index]' or by iterating over them using the FOR (*note FOR::) AutoGen
467 macro on it, as described in the next chapter.  Sparse arrays are
468 specified by specifying an index when defining an entry (*note Assigning
469 an Index to a Definition: Index Assignments.).
470
471    There are two kinds of definitions, 'simple' and 'compound'.  They
472 are defined thus (*note Full Syntax::):
473
474      compound_name '=' '{' definition-list '}' ';'
475
476      simple-name[2] '=' string ';'
477
478      no^text^name ';'
479
480 'simple-name' has the third index (index number 2) defined here.
481 'No^text^name' is a simple definition with a shorthand empty string
482 value.  The string values for definitions may be specified in any of
483 several formation rules.
484
485 * Menu:
486
487 * def-list::                 Definition List
488 * double-quote-string::      Double Quote String
489 * single-quote-string::      Single Quote String
490 * simple-string::            An Unquoted String
491 * shell-generated::          Shell Output String
492 * scheme-generated::         Scheme Result String
493 * here-string::              A Here String
494 * concat-string::            Concatenated Strings
495
496 \1f
497 File: autogen.info,  Node: def-list,  Next: double-quote-string,  Up: Definitions
498
499 2.2.1 Definition List
500 ---------------------
501
502 'definition-list' is a list of definitions that may or may not contain
503 nested compound definitions.  Any such definitions may *only* be
504 expanded within a 'FOR' block iterating over the containing compound
505 definition.  *Note FOR::.
506
507    Here is, again, the example definitions from the previous chapter,
508 with three additional name value pairs.  Two with an empty value
509 assigned (FIRST and LAST), and a "global" GROUP_NAME.
510
511      autogen definitions list;
512      group_name = example;
513      list = { list_element = alpha;  first;
514               list_info    = "some alpha stuff"; };
515      list = { list_info    = "more beta stuff";
516               list_element = beta; };
517      list = { list_element = omega;  last;
518               list_info    = "final omega stuff"; };
519
520 \1f
521 File: autogen.info,  Node: double-quote-string,  Next: single-quote-string,  Prev: def-list,  Up: Definitions
522
523 2.2.2 Double Quote String
524 -------------------------
525
526 The string follows the C-style escaping, using the backslash to quote
527 (escape) the following character(s).  Certain letters are translated to
528 various control codes (e.g.  '\n', '\f', '\t', etc.).  'x' introduces a
529 two character hex code.  '0' (the digit zero) introduces a one to three
530 character octal code (note: an octal byte followed by a digit must be
531 represented with three octal digits, thus: '"\0001"' yielding a NUL byte
532 followed by the ASCII digit 1).  Any other character following the
533 backslash escape is simply inserted, without error, into the string
534 being formed.
535
536    Like ANSI "C", a series of these strings, possibly intermixed with
537 single quote strings, will be concatenated together.
538
539 \1f
540 File: autogen.info,  Node: single-quote-string,  Next: simple-string,  Prev: double-quote-string,  Up: Definitions
541
542 2.2.3 Single Quote String
543 -------------------------
544
545 This is similar to the shell single-quote string.  However, escapes '\'
546 are honored before another escape, single quotes ''' and hash characters
547 '#'.  This latter is done specifically to disambiguate lines starting
548 with a hash character inside of a quoted string.  In other words,
549
550      fumble = '
551      #endif
552      ';
553
554    could be misinterpreted by the definitions scanner, whereas this
555 would not:
556
557      fumble = '
558      \#endif
559      ';
560
561
562    As with the double quote string, a series of these, even intermixed
563 with double quote strings, will be concatenated together.
564
565 \1f
566 File: autogen.info,  Node: simple-string,  Next: shell-generated,  Prev: single-quote-string,  Up: Definitions
567
568 2.2.4 An Unquoted String
569 ------------------------
570
571 A simple string that does not contain white space may be left unquoted.
572 The string must not contain any of the characters special to the
573 definition text (i.e., '"', '#', ''', '(', ')', ',', ';', '<', '=', '>',
574 '[', ']', '`', '{', or '}').  This list is subject to change, but it
575 will never contain underscore ('_'), period ('.'), slash ('/'), colon
576 (':'), hyphen ('-') or backslash ('\\').  Basically, if the string looks
577 like it is a normal DOS or UNIX file or variable name, and it is not one
578 of two keywords ('autogen' or 'definitions') then it is OK to not quote
579 it, otherwise you should.
580
581 \1f
582 File: autogen.info,  Node: shell-generated,  Next: scheme-generated,  Prev: simple-string,  Up: Definitions
583
584 2.2.5 Shell Output String
585 -------------------------
586
587 This is assembled according to the same rules as the double quote
588 string, except that there is no concatenation of strings and the
589 resulting string is written to a shell server process.  The definition
590 takes on the value of the output string.
591
592    NB The text is interpreted by a server shell.  There may be left over
593 state from previous server shell processing.  This scriptlet may also
594 leave state for subsequent processing.  However, a 'cd' to the original
595 directory is always issued before the new command is issued.
596
597 \1f
598 File: autogen.info,  Node: scheme-generated,  Next: here-string,  Prev: shell-generated,  Up: Definitions
599
600 2.2.6 Scheme Result String
601 --------------------------
602
603 A scheme result string must begin with an open parenthesis '('.  The
604 scheme expression will be evaluated by Guile and the value will be the
605 result.  The AutoGen expression functions are *dis*abled at this stage,
606 so do not use them.
607
608 \1f
609 File: autogen.info,  Node: here-string,  Next: concat-string,  Prev: scheme-generated,  Up: Definitions
610
611 2.2.7 A Here String
612 -------------------
613
614 A 'here string' is formed in much the same way as a shell here doc.  It
615 is denoted with two less than characters('<<') and, optionally, a
616 hyphen.  This is followed by optional horizontal white space and an
617 ending marker-identifier.  This marker must follow the syntax rules for
618 identifiers.  Unlike the shell version, however, you must not quote this
619 marker.
620
621    The resulting string will start with the first character on the next
622 line and continue up to but not including the newline that precedes the
623 line that begins with the marker token.  The characters are copied
624 directly into the result string.  Mostly.
625
626    If a hyphen follows the less than characters, then leading tabs will
627 be stripped and the terminating marker will be recognized even if
628 preceded by tabs.  Also, if the first character on the line (after
629 removing tabs) is a backslash and the next character is a tab or space,
630 then the backslash will be removed as well.  No other kind of processing
631 is done on this string.
632
633    Here are three examples:
634      str1 = <<-  STR_END
635              $quotes = " ' `
636              STR_END;
637
638      str2 = <<   STR_END
639              $quotes = " ' `
640              STR_END;
641      STR_END;
642
643      str3 = <<-  STR_END
644              \  $quotes = " ' `
645              STR_END;
646    The first string contains no new line characters.  The first
647 character is the dollar sign, the last the back quote.
648
649    The second string contains one new line character.  The first
650 character is the tab character preceding the dollar sign.  The last
651 character is the semicolon after the 'STR_END'.  That 'STR_END' does not
652 end the string because it is not at the beginning of the line.  In the
653 preceding case, the leading tab was stripped.
654
655    The third string is almost identical to the first, except that the
656 first character is a tab.  That is, it exactly matches the first line of
657 the second string.
658
659 \1f
660 File: autogen.info,  Node: concat-string,  Prev: here-string,  Up: Definitions
661
662 2.2.8 Concatenated Strings
663 --------------------------
664
665 If single or double quote characters are used, then you also have the
666 option, a la ANSI-C syntax, of implicitly concatenating a series of them
667 together, with intervening white space ignored.
668
669    NB You *cannot* use directives to alter the string content.  That is,
670
671      str = "fumble"
672      #ifdef LATER
673            "stumble"
674      #endif
675            ;
676
677 will result in a syntax error.  The preprocessing directives are not
678 carried out by the C preprocessor.  However,
679
680      str = '"fumble\n"
681      #ifdef LATER
682      "     stumble\n"
683      #endif
684      ';
685
686 *Will* work.  It will enclose the '#ifdef LATER' and '#endif' in the
687 string.  But it may also wreak havoc with the definition processing
688 directives.  The hash characters in the first column should be
689 disambiguated with an escape '\' or join them with previous lines:
690 '"fumble\n#ifdef LATER...'.
691
692 \1f
693 File: autogen.info,  Node: Index Assignments,  Next: Dynamic Text,  Prev: Definitions,  Up: Definitions File
694
695 2.3 Assigning an Index to a Definition
696 ======================================
697
698 In AutoGen, every name is implicitly an array of values.  When assigning
699 values, they are usually implicitly assigned to the next highest slot.
700 They can also be specified explicitly:
701
702      mumble[9] = stumble;
703      mumble[0] = grumble;
704
705 If, subsequently, you assign a value to 'mumble' without an index, its
706 index will be '10', not '1'.  If indexes are specified, they must not
707 cause conflicts.
708
709    '#define'-d names may also be used for index values.  This is
710 equivalent to the above:
711
712      #define FIRST 0
713      #define LAST  9
714      mumble[LAST]  = stumble;
715      mumble[FIRST] = grumble;
716
717    All values in a range do *not* have to be filled in.  If you leave
718 gaps, then you will have a sparse array.  This is fine (*note FOR::).
719 You have your choice of iterating over all the defined values, or
720 iterating over a range of slots.  This:
721
722      [+ FOR mumble +][+ ENDFOR +]
723
724 iterates over all and only the defined entries, whereas this:
725
726      [+ FOR mumble (for-by 1) +][+ ENDFOR +]
727
728 will iterate over all 10 "slots".  Your template will likely have to
729 contain something like this:
730
731      [+ IF (exist? (sprintf "mumble[%d]" (for-index))) +]
732
733 or else "mumble" will have to be a compound value that, say, always
734 contains a "grumble" value:
735
736      [+ IF (exist? "grumble") +]
737
738 \1f
739 File: autogen.info,  Node: Dynamic Text,  Next: Directives,  Prev: Index Assignments,  Up: Definitions File
740
741 2.4 Dynamic Text
742 ================
743
744 There are several methods for including dynamic content inside a
745 definitions file.  Three of them are mentioned above (*note
746 shell-generated:: and *note scheme-generated::) in the discussion of
747 string formation rules.  Another method uses the '#shell' processing
748 directive.  It will be discussed in the next section (*note
749 Directives::).  Guile/Scheme may also be used to yield to create
750 definitions.
751
752    When the Scheme expression is preceded by a backslash and single
753 quote, then the expression is expected to be an alist of names and
754 values that will be used to create AutoGen definitions.
755
756 This method can be be used as follows:
757
758      \'( (name  (value-expression))
759          (name2 (another-expr))  )
760
761 This is entirely equivalent to:
762
763      name  = (value-expression);
764      name2 = (another-expr);
765
766 Under the covers, the expression gets handed off to a Guile function
767 named 'alist->autogen-def' in an expression that looks like this:
768
769      (alist->autogen-def
770          ( (name (value-expression))  (name2 (another-expr)) ) )
771
772 \1f
773 File: autogen.info,  Node: Directives,  Next: Predefines,  Prev: Dynamic Text,  Up: Definitions File
774
775 2.5 Controlling What Gets Processed
776 ===================================
777
778 Definition processing directives can *only* be processed if the '#'
779 character is the first character on a line.  Also, if you want a '#' as
780 the first character of a line in one of your string assignments, you
781 should either escape it by preceding it with a backslash '\', or by
782 embedding it in the string as in '"\n#"'.
783
784    All of the normal C preprocessing directives are recognized, though
785 several are ignored.  There is also an additional '#shell' - '#endshell'
786 pair.  Another minor difference is that AutoGen directives must have the
787 hash character ('#') in column 1.  Unrecognized directives produce an
788 error.
789
790    The final tweak is that '#!' is treated as a comment line.  Using
791 this feature, you can use: '#! /usr/local/bin/autogen' as the first line
792 of a definitions file, set the mode to executable and "run" the
793 definitions file as if it were a direct invocation of AutoGen.  This was
794 done for its hack value.
795
796    The AutoGen recognized directives are:
797 '#assert'
798      This directive is processed, but only if the expression begins with
799      either a back quote ('`') or an open parenthesis ('(').  Text
800      within the back quotes are handed off to the shell for processing
801      and parenthesized text is handed off to Guile.  Multiple line
802      expressions must be joined with backslashes.
803
804      If the 'shell-script' or 'scheme-expr' do not yield 'true' valued
805      results, autogen will be aborted.  If '<anything else>' or nothing
806      at all is provided, then this directive is ignored.
807
808      The result is 'false' (and fails) if the result is empty, the
809      number zero, or a string that starts with the letters 'n' or 'f'
810      ("no" or "false").
811
812 '#define'
813      Will add the name to the define list as if it were a DEFINE program
814      argument.  Its value will be the first non-whitespace token
815      following the name.  Quotes are *not* processed.
816
817      After the definitions file has been processed, any remaining
818      entries in the define list will be added to the environment.
819
820 '#elif'
821      Marks a transition in the #if directive.  Error when out of
822      context.  #if blocks are always ignored.
823
824 '#else'
825      This must follow an '#if', '#ifdef' or '#ifndef'.  If it follows
826      the '#if', then it will be ignored.  Otherwise, it will change the
827      processing state to the reverse of what it was.
828
829 '#endif'
830      This must follow an '#if', '#ifdef' or '#ifndef'.  In all cases,
831      this will resume normal processing of text.
832
833 '#endmac'
834      Marks the end of the #macdef directive.  Error when out of context.
835
836 '#endshell'
837      Marks the end of the #shell directive.  Error when out of context.
838
839 '#error'
840      This directive will cause AutoGen to stop processing and exit with
841      a status of EXIT_FAILURE.
842
843 '#ident'
844      Ignored directive.
845
846 '#if'
847      '#if' expressions are not analyzed.  *Everything* from here to the
848      matching '#endif' is skipped.
849
850 '#ifdef'
851      The definitions that follow, up to the matching '#endif' will be
852      processed only if there is a corresponding '-Dname' command line
853      option or if a '#define' of that name has been previously
854      encountered.
855
856 '#ifndef'
857      The definitions that follow, up to the matching '#endif' will be
858      processed only if the named value has *not* been defined.
859
860 '#include'
861      This directive will insert definitions from another file into the
862      current collection.  If the file name is adorned with double quotes
863      or angle brackets (as in a C program), then the include is ignored.
864
865 '#let'
866      Ignored directive.
867
868 '#line'
869      Alters the current line number and/or file name.  You may wish to
870      use this directive if you extract definition source from other
871      files.  'getdefs' uses this mechanism so AutoGen will report the
872      correct file and approximate line number of any errors found in
873      extracted definitions.
874
875 '#macdef'
876      This is a new AT&T research preprocessing directive.  Basically, it
877      is a multi-line #define that may include other preprocessing
878      directives.  Text between this line and a #endmac directive are
879      ignored.
880
881 '#option'
882      This directive will pass the option name and associated text to the
883      AutoOpts optionLoadLine routine (*note libopts-optionLoadLine::).
884      The option text may span multiple lines by continuing them with a
885      backslash.  The backslash/newline pair will be replaced with two
886      space characters.  This directive may be used to set a search path
887      for locating template files For example, this:
888
889           #option templ-dirs $ENVVAR/dirname
890      will direct autogen to use the 'ENVVAR' environment variable to
891      find a directory named 'dirname' that (may) contain templates.
892      Since these directories are searched in most recently supplied
893      first order, search directories supplied in this way will be
894      searched before any supplied on the command line.
895
896 '#pragma'
897      Ignored directive.
898
899 '#shell'
900      Invokes '$SHELL' or '/bin/sh' on a script that should generate
901      AutoGen definitions.  It does this using the same server process
902      that handles the back-quoted '`' text.  The block of text handed to
903      the shell is terminated with the #endshell directive.
904
905      *CAUTION* let not your '$SHELL' be 'csh'.
906
907 '#undef'
908      Will remove any entries from the define list that match the undef
909      name pattern.
910
911 \1f
912 File: autogen.info,  Node: Predefines,  Next: Comments,  Prev: Directives,  Up: Definitions File
913
914 2.6 Pre-defined Names
915 =====================
916
917 When AutoGen starts, it tries to determine several names from the
918 operating environment and put them into environment variables for use in
919 both '#ifdef' tests in the definitions files and in shell scripts with
920 environment variable tests.  '__autogen__' is always defined.  For other
921 names, AutoGen will first try to use the POSIX version of the
922 'sysinfo(2)' system call.  Failing that, it will try for the POSIX
923 'uname(2)' call.  If neither is available, then only "'__autogen__'"
924 will be inserted into the environment.  In all cases, the associated
925 names are converted to lower case, surrounded by doubled underscores and
926 non-symbol characters are replaced with underscores.
927
928    With Solaris on a sparc platform, 'sysinfo(2)' is available.  The
929 following strings are used:
930
931    * 'SI_SYSNAME' (e.g., "__sunos__")
932    * 'SI_HOSTNAME' (e.g., "__ellen__")
933    * 'SI_ARCHITECTURE' (e.g., "__sparc__")
934    * 'SI_HW_PROVIDER' (e.g., "__sun_microsystems__")
935    * 'SI_PLATFORM' (e.g., "__sun_ultra_5_10__")
936    * 'SI_MACHINE' (e.g., "__sun4u__")
937
938    For Linux and other operating systems that only support the
939 'uname(2)' call, AutoGen will use these values:
940
941    * 'sysname' (e.g., "__linux__")
942    * 'machine' (e.g., "__i586__")
943    * 'nodename' (e.g., "__bach__")
944
945    By testing these pre-defines in my definitions, you can select pieces
946 of the definitions without resorting to writing shell scripts that parse
947 the output of 'uname(1)'.  You can also segregate real C code from
948 autogen definitions by testing for "'__autogen__'".
949
950      #ifdef __bach__
951        location = home;
952      #else
953        location = work;
954      #endif
955
956 \1f
957 File: autogen.info,  Node: Comments,  Next: Example,  Prev: Predefines,  Up: Definitions File
958
959 2.7 Commenting Your Definitions
960 ===============================
961
962 The definitions file may contain C and C++ style comments.
963
964      /*
965       *  This is a comment.  It continues for several lines and closes
966       *  when the characters '*' and '/' appear together.
967       */
968      // this comment is a single line comment
969
970 \1f
971 File: autogen.info,  Node: Example,  Next: Full Syntax,  Prev: Comments,  Up: Definitions File
972
973 2.8 What it all looks like.
974 ===========================
975
976 This is an extended example:
977
978      autogen definitions 'template-name';
979      /*
980       *  This is a comment that describes what these
981       *  definitions are all about.
982       */
983      global = "value for a global text definition.";
984
985      /*
986       *  Include a standard set of definitions
987       */
988      #include standards.def
989
990      a_block = {
991          a_field;
992          a_subblock = {
993              sub_name  = first;
994              sub_field = "sub value.";
995          };
996
997      #ifdef FEATURE
998          a_subblock = {
999              sub_name  = second;
1000          };
1001      #endif
1002
1003      };
1004
1005 \1f
1006 File: autogen.info,  Node: Full Syntax,  Next: Alternate Definition,  Prev: Example,  Up: Definitions File
1007
1008 2.9 Finite State Machine Grammar
1009 ================================
1010
1011 The preprocessing directives and comments are not part of the grammar.
1012 They are handled by the scanner/lexer.  The following was extracted
1013 directly from the generated defParse-fsm.c source file.  The "EVT:" is
1014 the token seen, the "STATE:" is the current state and the entries in
1015 this table describe the next state and the action to take.  Invalid
1016 transitions were removed from the table.
1017
1018      dp_trans_table[ DP_STATE_CT ][ DP_EVENT_CT ] = {
1019
1020        /* STATE 0:  DP_ST_INIT */
1021        { { DP_ST_NEED_DEF, NULL },                       /* EVT:  AUTOGEN */
1022          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DEFINITIONS */
1023          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  End-Of-File */
1024          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  VAR_NAME */
1025          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  OTHER_NAME */
1026          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  STRING */
1027          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  HERE_STRING */
1028          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DELETE_ENT */
1029          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  NUMBER */
1030          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  ; */
1031          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  = */
1032          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  , */
1033          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  { */
1034          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  } */
1035          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  [ */
1036          { DP_ST_INVALID, dp_do_invalid }                /* EVT:  ] */
1037
1038        /* STATE 1:  DP_ST_NEED_DEF */
1039        { { DP_ST_INVALID, dp_do_invalid },               /* EVT:  AUTOGEN */
1040          { DP_ST_NEED_TPL, NULL },                       /* EVT:  DEFINITIONS */
1041          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  End-Of-File */
1042          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  VAR_NAME */
1043          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  OTHER_NAME */
1044          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  STRING */
1045          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  HERE_STRING */
1046          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DELETE_ENT */
1047          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  NUMBER */
1048          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  ; */
1049          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  = */
1050          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  , */
1051          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  { */
1052          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  } */
1053          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  [ */
1054          { DP_ST_INVALID, dp_do_invalid }                /* EVT:  ] */
1055
1056        /* STATE 2:  DP_ST_NEED_TPL */
1057        { { DP_ST_INVALID, dp_do_invalid },               /* EVT:  AUTOGEN */
1058          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DEFINITIONS */
1059          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  End-Of-File */
1060          { DP_ST_NEED_SEMI, dp_do_tpl_name },            /* EVT:  VAR_NAME */
1061          { DP_ST_NEED_SEMI, dp_do_tpl_name },            /* EVT:  OTHER_NAME */
1062          { DP_ST_NEED_SEMI, dp_do_tpl_name },            /* EVT:  STRING */
1063          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  HERE_STRING */
1064          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DELETE_ENT */
1065          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  NUMBER */
1066          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  ; */
1067          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  = */
1068          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  , */
1069          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  { */
1070          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  } */
1071          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  [ */
1072          { DP_ST_INVALID, dp_do_invalid }                /* EVT:  ] */
1073
1074        /* STATE 3:  DP_ST_NEED_SEMI */
1075        { { DP_ST_INVALID, dp_do_invalid },               /* EVT:  AUTOGEN */
1076          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DEFINITIONS */
1077          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  End-Of-File */
1078          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  VAR_NAME */
1079          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  OTHER_NAME */
1080          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  STRING */
1081          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  HERE_STRING */
1082          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DELETE_ENT */
1083          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  NUMBER */
1084          { DP_ST_NEED_NAME, NULL },                      /* EVT:  ; */
1085          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  = */
1086          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  , */
1087          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  { */
1088          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  } */
1089          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  [ */
1090          { DP_ST_INVALID, dp_do_invalid }                /* EVT:  ] */
1091
1092        /* STATE 4:  DP_ST_NEED_NAME */
1093        { { DP_ST_NEED_DEF, NULL },                       /* EVT:  AUTOGEN */
1094          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DEFINITIONS */
1095          { DP_ST_DONE, dp_do_need_name_end },            /* EVT:  End-Of-File */
1096          { DP_ST_HAVE_NAME, dp_do_need_name_var_name },  /* EVT:  VAR_NAME */
1097          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  OTHER_NAME */
1098          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  STRING */
1099          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  HERE_STRING */
1100          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DELETE_ENT */
1101          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  NUMBER */
1102          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  ; */
1103          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  = */
1104          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  , */
1105          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  { */
1106          { DP_ST_HAVE_VALUE, dp_do_end_block },          /* EVT:  } */
1107          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  [ */
1108          { DP_ST_INVALID, dp_do_invalid }                /* EVT:  ] */
1109
1110        /* STATE 5:  DP_ST_HAVE_NAME */
1111        { { DP_ST_INVALID, dp_do_invalid },               /* EVT:  AUTOGEN */
1112          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DEFINITIONS */
1113          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  End-Of-File */
1114          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  VAR_NAME */
1115          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  OTHER_NAME */
1116          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  STRING */
1117          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  HERE_STRING */
1118          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DELETE_ENT */
1119          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  NUMBER */
1120          { DP_ST_NEED_NAME, dp_do_empty_val },           /* EVT:  ; */
1121          { DP_ST_NEED_VALUE, dp_do_have_name_lit_eq },   /* EVT:  = */
1122          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  , */
1123          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  { */
1124          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  } */
1125          { DP_ST_NEED_IDX, NULL },                       /* EVT:  [ */
1126          { DP_ST_INVALID, dp_do_invalid }                /* EVT:  ] */
1127
1128        /* STATE 6:  DP_ST_NEED_VALUE */
1129        { { DP_ST_INVALID, dp_do_invalid },               /* EVT:  AUTOGEN */
1130          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DEFINITIONS */
1131          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  End-Of-File */
1132          { DP_ST_HAVE_VALUE, dp_do_str_value },          /* EVT:  VAR_NAME */
1133          { DP_ST_HAVE_VALUE, dp_do_str_value },          /* EVT:  OTHER_NAME */
1134          { DP_ST_HAVE_VALUE, dp_do_str_value },          /* EVT:  STRING */
1135          { DP_ST_HAVE_VALUE, dp_do_str_value },          /* EVT:  HERE_STRING */
1136          { DP_ST_NEED_NAME, dp_do_need_value_delete_ent }, /* EVT:  DELETE_ENT */
1137          { DP_ST_HAVE_VALUE, dp_do_str_value },          /* EVT:  NUMBER */
1138          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  ; */
1139          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  = */
1140          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  , */
1141          { DP_ST_NEED_NAME, dp_do_start_block },         /* EVT:  { */
1142          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  } */
1143          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  [ */
1144          { DP_ST_INVALID, dp_do_invalid }                /* EVT:  ] */
1145
1146        /* STATE 7:  DP_ST_NEED_IDX */
1147        { { DP_ST_INVALID, dp_do_invalid },               /* EVT:  AUTOGEN */
1148          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DEFINITIONS */
1149          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  End-Of-File */
1150          { DP_ST_NEED_CBKT, dp_do_indexed_name },        /* EVT:  VAR_NAME */
1151          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  OTHER_NAME */
1152          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  STRING */
1153          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  HERE_STRING */
1154          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DELETE_ENT */
1155          { DP_ST_NEED_CBKT, dp_do_indexed_name },        /* EVT:  NUMBER */
1156          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  ; */
1157          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  = */
1158          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  , */
1159          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  { */
1160          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  } */
1161          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  [ */
1162          { DP_ST_INVALID, dp_do_invalid }                /* EVT:  ] */
1163
1164        /* STATE 8:  DP_ST_NEED_CBKT */
1165        { { DP_ST_INVALID, dp_do_invalid },               /* EVT:  AUTOGEN */
1166          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DEFINITIONS */
1167          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  End-Of-File */
1168          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  VAR_NAME */
1169          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  OTHER_NAME */
1170          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  STRING */
1171          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  HERE_STRING */
1172          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DELETE_ENT */
1173          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  NUMBER */
1174          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  ; */
1175          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  = */
1176          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  , */
1177          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  { */
1178          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  } */
1179          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  [ */
1180          { DP_ST_INDX_NAME, NULL }                       /* EVT:  ] */
1181
1182        /* STATE 9:  DP_ST_INDX_NAME */
1183        { { DP_ST_INVALID, dp_do_invalid },               /* EVT:  AUTOGEN */
1184          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DEFINITIONS */
1185          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  End-Of-File */
1186          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  VAR_NAME */
1187          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  OTHER_NAME */
1188          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  STRING */
1189          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  HERE_STRING */
1190          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DELETE_ENT */
1191          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  NUMBER */
1192          { DP_ST_NEED_NAME, dp_do_empty_val },           /* EVT:  ; */
1193          { DP_ST_NEED_VALUE, NULL },                     /* EVT:  = */
1194          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  , */
1195          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  { */
1196          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  } */
1197          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  [ */
1198          { DP_ST_INVALID, dp_do_invalid }                /* EVT:  ] */
1199
1200        /* STATE 10:  DP_ST_HAVE_VALUE */
1201        { { DP_ST_INVALID, dp_do_invalid },               /* EVT:  AUTOGEN */
1202          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DEFINITIONS */
1203          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  End-Of-File */
1204          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  VAR_NAME */
1205          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  OTHER_NAME */
1206          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  STRING */
1207          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  HERE_STRING */
1208          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  DELETE_ENT */
1209          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  NUMBER */
1210          { DP_ST_NEED_NAME, NULL },                      /* EVT:  ; */
1211          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  = */
1212          { DP_ST_NEED_VALUE, dp_do_next_val },           /* EVT:  , */
1213          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  { */
1214          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  } */
1215          { DP_ST_INVALID, dp_do_invalid },               /* EVT:  [ */
1216          { DP_ST_INVALID, dp_do_invalid }                /* EVT:  ] */
1217
1218 \1f
1219 File: autogen.info,  Node: Alternate Definition,  Prev: Full Syntax,  Up: Definitions File
1220
1221 2.10 Alternate Definition Forms
1222 ===============================
1223
1224 There are several methods for supplying data values for templates.
1225
1226 'no definitions'
1227      It is entirely possible to write a template that does not depend
1228      upon external definitions.  Such a template would likely have an
1229      unvarying output, but be convenient nonetheless because of an
1230      external library of either AutoGen or Scheme functions, or both.
1231      This can be accommodated by providing the '--override-tpl' and
1232      '--no-definitions' options on the command line.  *Note autogen
1233      Invocation::.
1234
1235 'CGI'
1236      AutoGen behaves as a CGI server if the definitions input is from
1237      stdin and the environment variable 'REQUEST_METHOD' is defined and
1238      set to either "GET" or "POST", *Note AutoGen CGI::.  Obviously, all
1239      the values are constrained to strings because there is no way to
1240      represent nested values.
1241
1242 'XML'
1243      AutoGen comes with a program named, 'xml2ag'.  Its output can
1244      either be redirected to a file for later use, or the program can be
1245      used as an AutoGen wrapper.  *Note xml2ag Invocation::.
1246
1247      The introductory template example (*note Example Usage::) can be
1248      rewritten in XML as follows:
1249
1250           <EXAMPLE  template="list.tpl">
1251           <LIST list_element="alpha"
1252                 list_info="some alpha stuff"/>
1253           <LIST list_info="more beta stuff"
1254                 list_element="beta"/>
1255           <LIST list_element="omega"
1256                 list_info="final omega stuff"/>
1257           </EXAMPLE>
1258
1259      A more XML-normal form might look like this:
1260           <EXAMPLE  template="list.tpl">
1261           <LIST list_element="alpha">some alpha stuff</LIST>
1262           <LIST list_element="beta" >more beta stuff</LIST>
1263           <LIST list_element="omega">final omega stuff</LIST>
1264           </EXAMPLE>
1265      but you would have to change the template 'list-info' references
1266      into 'text' references.
1267
1268 'standard AutoGen definitions'
1269      Of course.  :-)
1270
1271 \1f
1272 File: autogen.info,  Node: Template File,  Next: Augmenting AutoGen,  Prev: Definitions File,  Up: Top
1273
1274 3 Template File
1275 ***************
1276
1277 The AutoGen template file defines the content of the output text.  It is
1278 composed of two parts.  The first part consists of a pseudo macro
1279 invocation and commentary.  It is followed by the template proper.
1280
1281    This pseudo macro is special.  It is used to identify the file as a
1282 AutoGen template file, fixing the starting and ending marks for the
1283 macro invocations in the rest of the file, specifying the list of
1284 suffixes to be generated by the template and, optionally, the shell to
1285 use for processing shell commands embedded in the template.
1286
1287    AutoGen-ing a file consists of copying text from the template to the
1288 output file until a start macro marker is found.  The text from the
1289 start marker to the end marker constitutes the macro text.  AutoGen
1290 macros may cause sections of the template to be skipped or processed
1291 several times.  The process continues until the end of the template is
1292 reached.  The process is repeated once for each suffix specified in the
1293 pseudo macro.
1294
1295    This chapter describes the format of the AutoGen template macros and
1296 the usage of the AutoGen native macros.  Users may augment these by
1297 defining their own macros, *Note DEFINE::.
1298
1299 * Menu:
1300
1301 * pseudo macro::       Format of the Pseudo Macro
1302 * naming values::      Naming a value
1303 * expression syntax::  Macro Expression Syntax
1304 * AutoGen Functions::  AutoGen Scheme Functions
1305 * Common Functions::   Common Scheme Functions
1306 * native macros::      AutoGen Native Macros
1307 * output controls::    Redirecting Output
1308
1309 \1f
1310 File: autogen.info,  Node: pseudo macro,  Next: naming values,  Up: Template File
1311
1312 3.1 Format of the Pseudo Macro
1313 ==============================
1314
1315 The pseudo macro is used to tell AutoGen how to process a template.  It
1316 tells autogen:
1317
1318   1. The start macro marker.  It consists of punctuation characters used
1319      to demarcate the start of a macro.  It may be up to seven
1320      characters long and must be the first non-whitespace characters in
1321      the file.
1322
1323      It is generally a good idea to use some sort of opening bracket in
1324      the starting macro and closing bracket in the ending macro (e.g.
1325      '{', '(', '[', or even '<' in the starting macro).  It helps both
1326      visually and with editors capable of finding a balancing
1327      parenthesis.
1328
1329   2. That start marker must be immediately followed by the identifier
1330      strings "AutoGen5" and then "template", though capitalization is
1331      not important.
1332
1333 The next several components may be intermingled:
1334
1335   3. Zero, one or more suffix specifications tell AutoGen how many times
1336      to process the template file.  No suffix specifications mean that
1337      it is to be processed once and that the generated text is to be
1338      written to 'stdout'.  The current suffix for each pass can be
1339      determined with the '(suffix)' scheme function (*note SCM
1340      suffix::).
1341
1342      The suffix specification consists of a sequence of POSIX compliant
1343      file name characters and, optionally, an equal sign and a file name
1344      formatting specification.  That specification may be either an
1345      ordinary sequence of file name characters with zero, one or two
1346      "%s" formatting sequences in it, or else it may be a Scheme
1347      expression that, when evaluated, produces such a string.  The
1348      Scheme result may not be empty.  The two string arguments allowed
1349      for that string are the base name of the definition file, and the
1350      current suffix (that being the text to the left of the equal sign).
1351      (Note: "POSIX compliant file name characters" consist of
1352      alphanumerics plus the period ('.'), hyphen ('-') and underscore
1353      ('_') characters.)
1354
1355      If the suffix begins with one of these three latter characters and
1356      a formatting string is not specified, then that character is
1357      presumed to be the suffix separator.  Otherwise, without a
1358      specified format string, a single period will separate the suffix
1359      from the base name in constructing the output file name.
1360
1361   4. Shell specification: to specify that the template was written
1362      expecting a particular shell to run the shell commands.  By
1363      default, the shell used is the autoconf-ed 'CONFIG_SHELL'.  This
1364      will usually be '/bin/sh'.  The shell is specified by a hash mark
1365      ('#') followed by an exclamation mark ('!') followed by a full-path
1366      file name (e.g.  '/usr/xpg4/bin/sh' on Solaris):
1367           [= Autogen5 Template c
1368           #!/usr/xpg4/bin/sh
1369           =]
1370
1371   5. Comments: blank lines, lines starting with a hash mark ('#') and
1372      not specifying a shell, and edit mode markers (text between pairs
1373      of '-*-' strings) are all treated as comments.
1374
1375   6. Some scheme expressions may be inserted in order to make
1376      configuration changes before template processing begins.  before
1377      template processing begins means that there is no current output
1378      file, no current suffix and, basically, none of the AutoGen
1379      specific functions (*note AutoGen Functions::) may be invoked.
1380
1381      The scheme expression can also be used, for example, to save a
1382      pre-existing output file for later text extraction (*note SCM
1383      extract::).
1384
1385           (shellf "mv -f %1$s.c %1$s.sav" (base-name))
1386
1387 After these must come the end macro marker:
1388
1389   6. The punctuation characters used to demarcate the end of a macro.
1390      Like the start marker, it must consist of seven or fewer
1391      punctuation characters.
1392
1393    The ending macro marker has a few constraints on its content.  Some
1394 of them are just advisory, though.  There is no special check for
1395 advisory restrictions.
1396
1397    * It must not begin with a POSIX file name character (hyphen '-',
1398      underscore '_' or period '.'), the backslash ('\') or open
1399      parenthesis ('(').  These are used to identify a suffix
1400      specification, indicate Scheme code and trim white space.
1401
1402    * If it begins with an equal sign, then it must be separated from any
1403      suffix specification by white space.
1404
1405    * The closing marker may not begin with an open parenthesis, as that
1406      is used to enclose a scheme expression.
1407
1408    * It cannot begin with a backslash, as that is used to indicate white
1409      space trimming after the end macro mark.  If, in the body of the
1410      template, you put the backslash character ('\') before the end
1411      macro mark, then any white space characters after the mark and
1412      through the newline character are trimmed.
1413
1414    * It is also helpful to avoid using the comment marker ('#').  It
1415      might be seen as a comment within the pseudo macro.
1416
1417    * You should avoid using any of the quote characters double, single
1418      or back-quote.  It won't confuse AutoGen, but it might well confuse
1419      you and/or your editor.
1420
1421    As an example, assume we want to use '[+' and '+]' as the start and
1422 end macro markers, and we wish to produce a '.c' and a '.h' file, then
1423 the pseudo macro might look something like this:
1424
1425      [+ AutoGen5 template -*- Mode: emacs-mode-of-choice -*-
1426      h=chk-%s.h
1427      c
1428      # make sure we don't use csh:
1429      (setenv "SHELL" "/bin/sh")  +]
1430
1431    The template proper starts after the pseudo-macro.  The starting
1432 character is either the first non-whitespace character or the first
1433 character after the newline that follows the end macro marker.
1434
1435 \1f
1436 File: autogen.info,  Node: naming values,  Next: expression syntax,  Prev: pseudo macro,  Up: Template File
1437
1438 3.2 Naming a value
1439 ==================
1440
1441 When an AutoGen value is specified in a template, it is specified by
1442 name.  The name may be a simple name, or a compound name of several
1443 components.  Since each named value in AutoGen is implicitly an array of
1444 one or more values, each component may have an index associated with it.
1445
1446 It looks like this:
1447
1448      comp-name-1 . comp-name-2 [ 2 ]
1449
1450    Note that if there are multiple components to a name, each component
1451 name is separated by a dot ('.').  Indexes follow a component name,
1452 enclosed in square brackets ('[' and ']').  The index may be either an
1453 integer or an integer-valued define name.  The first component of the
1454 name is searched for in the current definition level.  If not found,
1455 higher levels will be searched until either a value is found, or there
1456 are no more definition levels.  Subsequent components of the name must
1457 be found within the context of the newly-current definition level.
1458 Also, if the named value is prefixed by a dot ('.'), then the value
1459 search is started in the current context only.  Backtracking into other
1460 definition levels is prevented.
1461
1462    If someone rewrites this, I'll incorporate it.  :-)
1463
1464 \1f
1465 File: autogen.info,  Node: expression syntax,  Next: AutoGen Functions,  Prev: naming values,  Up: Template File
1466
1467 3.3 Macro Expression Syntax
1468 ===========================
1469
1470 AutoGen has two types of expressions: full expressions and basic ones.
1471 A full AutoGen expression can appear by itself, or as the argument to
1472 certain AutoGen built-in macros: CASE, IF, ELIF, INCLUDE, INVOKE
1473 (explicit invocation, *note INVOKE::), and WHILE. If it appears by
1474 itself, the result is inserted into the output.  If it is an argument to
1475 one of these macros, the macro code will act on it sensibly.
1476
1477    You are constrained to basic expressions only when passing arguments
1478 to user defined macros, *Note DEFINE::.
1479
1480    The syntax of a full AutoGen expression is:
1481
1482      [[ <apply-code> ] <value-name> ] [ <basic-expr-1> [ <basic-expr-2> ]]
1483
1484    How the expression is evaluated depends upon the presence or absence
1485 of the apply code and value name.  The "value name" is the name of an
1486 AutoGen defined value, or not.  If it does not name such a value, the
1487 expression result is generally the empty string.  All expressions must
1488 contain either a VALUE-NAME or a BASIC-EXPR.
1489
1490 * Menu:
1491
1492 * apply code::           Apply Code
1493 * basic expression::     Basic Expression
1494
1495 \1f
1496 File: autogen.info,  Node: apply code,  Next: basic expression,  Up: expression syntax
1497
1498 3.3.1 Apply Code
1499 ----------------
1500
1501 The "apply code" selected determines the method of evaluating the
1502 expression.  There are five apply codes, including the non-use of an
1503 apply code.
1504
1505 'no apply code'
1506      This is the most common expression type.  Expressions of this sort
1507      come in three flavors:
1508
1509      '<value-name>'
1510           The result is the value of VALUE-NAME, if defined.  Otherwise
1511           it is the empty string.
1512
1513      '<basic-expr>'
1514           The result of the basic expression is the result of the full
1515           expression, *Note basic expression::.
1516
1517      '<value-name> <basic-expr>'
1518           If there is a defined value for VALUE-NAME, then the
1519           BASIC-EXPR is evaluated.  Otherwise, the result is the empty
1520           string.
1521
1522 '% <value-name> <basic-expr>'
1523      If VALUE-NAME is defined, use BASIC-EXPR as a format string for
1524      sprintf.  Then, if the BASIC-EXPR is either a back-quoted string or
1525      a parenthesized expression, then hand the result to the appropriate
1526      interpreter for further evaluation.  Otherwise, for single and
1527      double quote strings, the result is the result of the sprintf
1528      operation.  Naturally, if VALUE-NAME is not defined, the result is
1529      the empty string.
1530
1531      For example, assume that 'fumble' had the string value, 'stumble':
1532           [+ % fumble `printf '%%x\\n' $%s` +]
1533      This would cause the shell to evaluate "'printf '%x\n' $stumble'".
1534      Assuming that the shell variable 'stumble' had a numeric value, the
1535      expression result would be that number, in hex.  Note the need for
1536      doubled percent characters and backslashes.
1537
1538 '? <value-name> <basic-expr-1> <basic-expr-2>'
1539      Two BASIC-EXPR-s are required.  If the VALUE-NAME is defined, then
1540      the first BASIC-EXPR-1 is evaluated, otherwise BASIC-EXPR-2 is.
1541
1542 '- <value-name> <basic-expr>'
1543      Evaluate BASIC-EXPR only if VALUE-NAME is not defined.
1544
1545 '?% <value-name> <basic-expr-1> <basic-expr-2>'
1546      This combines the functions of '?' and '%'.  If VALUE-NAME is
1547      defined, it behaves exactly like '%', above, using BASIC-EXPR-1.
1548      If not defined, then BASIC-EXPR-2 is evaluated.
1549
1550      For example, assume again that 'fumble' had the string value,
1551      'stumble':
1552           [+ ?% fumble `cat $%s` `pwd` +]
1553      This would cause the shell to evaluate "'cat $stumble'".  If
1554      'fumble' were not defined, then the result would be the name of our
1555      current directory.
1556
1557 \1f
1558 File: autogen.info,  Node: basic expression,  Prev: apply code,  Up: expression syntax
1559
1560 3.3.2 Basic Expression
1561 ----------------------
1562
1563 A basic expression can have one of the following forms:
1564
1565 ''STRING''
1566      A single quoted string.  Backslashes can be used to protect single
1567      quotes ('''), hash characters ('#'), or backslashes ('\') in the
1568      string.  All other characters of STRING are output as-is when the
1569      single quoted string is evaluated.  Backslashes are processed
1570      before the hash character for consistency with the definition
1571      syntax.  It is needed there to avoid preprocessing conflicts.
1572
1573 '"STRING"'
1574      A double quoted string.  This is a cooked text string as in C,
1575      except that they are not concatenated with adjacent strings.
1576      Evaluating "'STRING'" will output STRING with all backslash
1577      sequences interpreted.
1578
1579 '`STRING`'
1580      A back quoted string.  When this expression is evaluated, STRING is
1581      first interpreted as a cooked string (as in '"STRING"') and
1582      evaluated as a shell expression by the AutoGen server shell.  This
1583      expression is replaced by the 'stdout' output of the shell.
1584
1585 '(STRING)'
1586      A parenthesized expression.  It will be passed to the Guile
1587      interpreter for evaluation and replaced by the resulting value.  If
1588      there is a Scheme error in this expression, Guile 1.4 and Guile 1.6
1589      will report the template line number where the error occurs.  Guile
1590      1.7 has lost this capability.
1591
1592      Guile has the capability of creating and manipulating variables
1593      that can be referenced later on in the template processing.  If you
1594      define such a variable, it is invisible to AutoGen.  To reference
1595      its value, you must use a Guile expression.  For example,
1596           [+ (define my-var "some-string-value") +]
1597      can have that string inserted later, but only as in:
1598           [+ (. my-var) +]
1599
1600      Additionally, other than in the '%' and '?%' expressions, the Guile
1601      expressions may be introduced with the Guile comment character
1602      (';') and you may put a series of Guile expressions within a single
1603      macro.  They will be implicitly evaluated as if they were arguments
1604      to the '(begin ...)' expression.  The result will be the result of
1605      the last Guile expression evaluated.
1606
1607 \1f
1608 File: autogen.info,  Node: AutoGen Functions,  Next: Common Functions,  Prev: expression syntax,  Up: Template File
1609
1610 3.4 AutoGen Scheme Functions
1611 ============================
1612
1613 AutoGen uses Guile to interpret Scheme expressions within AutoGen
1614 macros.  All of the normal Guile functions are available, plus several
1615 extensions (*note Common Functions::) have been added to augment the
1616 repertoire of string manipulation functions and manage the state of
1617 AutoGen processing.
1618
1619    This section describes those functions that are specific to AutoGen.
1620 Please take note that these AutoGen specific functions are not loaded
1621 and thus not made available until after the command line options have
1622 been processed and the AutoGen definitions have been loaded.  They may,
1623 of course, be used in Scheme functions that get defined at those times,
1624 but they cannot be invoked.
1625
1626 * Menu:
1627
1628 * SCM ag-fprintf::         'ag-fprintf' - format to autogen stream
1629 * SCM ag-function?::       'ag-function?' - test for function
1630 * SCM base-name::          'base-name' - base output name
1631 * SCM chdir::              'chdir' - Change current directory
1632 * SCM count::              'count' - definition count
1633 * SCM def-file::           'def-file' - definitions file name
1634 * SCM def-file-line::      'def-file-line' - get a definition file+line number
1635 * SCM dne::                'dne' - "Do Not Edit" warning
1636 * SCM emit::               'emit' - emit the text for each argument
1637 * SCM emit-string-table::  'emit-string-table' - output a string table
1638 * SCM error::              'error' - display message and exit
1639 * SCM exist?::             'exist?' - test for value name
1640 * SCM find-file::          'find-file' - locate a file in the search path
1641 * SCM first-for?::         'first-for?' - detect first iteration
1642 * SCM for-by::             'for-by' - set iteration step
1643 * SCM for-from::           'for-from' - set initial index
1644 * SCM for-index::          'for-index' - get current loop index
1645 * SCM for-sep::            'for-sep' - set loop separation string
1646 * SCM for-to::             'for-to' - set ending index
1647 * SCM found-for?::         'found-for?' - is current index in list?
1648 * SCM get::                'get' - get named value
1649 * SCM get-c-name::         'get-c-name' - get named value, mapped to C name syntax
1650 * SCM get-down-name::      'get-down-name' - get lower cased named value, mapped to C name syntax
1651 * SCM get-up-name::        'get-up-name' - get upper cased named value, mapped to C name syntax
1652 * SCM high-lim::           'high-lim' - get highest value index
1653 * SCM insert-file::        'insert-file' - insert the contents of a (list of) files.
1654 * SCM insert-suspended::   'insert-suspended' - insert a named suspension in current output
1655 * SCM last-for?::          'last-for?' - detect last iteration
1656 * SCM len::                'len' - get count of values
1657 * SCM low-lim::            'low-lim' - get lowest value index
1658 * SCM make-header-guard::  'make-header-guard' - make self-inclusion guard
1659 * SCM make-tmp-dir::       'make-tmp-dir' - create a temporary directory
1660 * SCM match-value?::       'match-value?' - test for matching value
1661 * SCM max-file-time::      'max-file-time' - get the maximum input file modification time
1662 * SCM mk-gettextable::     'mk-gettextable' - print a string in a gettext-able format
1663 * SCM out-delete::         'out-delete' - delete current output file
1664 * SCM out-depth::          'out-depth' - output file stack depth
1665 * SCM out-emit-suspended:: 'out-emit-suspended' - emit the text of suspended output
1666 * SCM out-line::           'out-line' - output file line number
1667 * SCM out-move::           'out-move' - change name of output file
1668 * SCM out-name::           'out-name' - current output file name
1669 * SCM out-pop::            'out-pop' - close current output file
1670 * SCM out-push-add::       'out-push-add' - append output to file
1671 * SCM out-push-new::       'out-push-new' - purge and create output file
1672 * SCM out-resume::         'out-resume' - resume suspended output file
1673 * SCM out-suspend::        'out-suspend' - suspend current output file
1674 * SCM out-switch::         'out-switch' - close and create new output
1675 * SCM output-file-next-line:: 'output-file-next-line' - print the file name and next line number
1676 * SCM set-option::         'set-option' - Set a command line option
1677 * SCM set-writable::       'set-writable' - Make the output file be writable
1678 * SCM stack::              'stack' - make list of AutoGen values
1679 * SCM stack-join::         'stack-join' - stack values then join them
1680 * SCM suffix::             'suffix' - get the current suffix
1681 * SCM tpl-file::           'tpl-file' - get the template file name
1682 * SCM tpl-file-line::      'tpl-file-line' - get the template file+line number
1683 * SCM tpl-file-next-line:: 'tpl-file-next-line' - get the template file plus next line number
1684 * SCM warn::               'warn' - display warning message and continue
1685 * SCM autogen-version::     'autogen-version' - "5.18.16"
1686 * SCM c-file-line-fmt::     format file info as, "'#line nn "file"'"
1687
1688 \1f
1689 File: autogen.info,  Node: SCM ag-fprintf,  Next: SCM ag-function?,  Up: AutoGen Functions
1690
1691 3.4.1 'ag-fprintf' - format to autogen stream
1692 ---------------------------------------------
1693
1694 Usage: (ag-fprintf ag-diversion format [ format-arg ...  ])
1695 Format a string using arguments from the alist.  Write to a specified
1696 AutoGen diversion.  That may be either a specified suspended output
1697 stream (*note SCM out-suspend::) or an index into the output stack
1698 (*note SCM out-push-new::).  '(ag-fprintf 0 ...)' is equivalent to
1699 '(emit (sprintf ...))', and '(ag-fprintf 1 ...)' sends output to the
1700 most recently suspended output stream.
1701
1702    Arguments:
1703 ag-diversion - AutoGen diversion name or number
1704 format - formatting string
1705 format-arg - Optional - list of arguments to formatting string
1706
1707 \1f
1708 File: autogen.info,  Node: SCM ag-function?,  Next: SCM base-name,  Prev: SCM ag-fprintf,  Up: AutoGen Functions
1709
1710 3.4.2 'ag-function?' - test for function
1711 ----------------------------------------
1712
1713 Usage: (ag-function?  ag-name)
1714 return SCM_BOOL_T if a specified name is a user-defined AutoGen macro,
1715 otherwise return SCM_BOOL_F.
1716
1717    Arguments:
1718 ag-name - name of AutoGen macro
1719
1720 \1f
1721 File: autogen.info,  Node: SCM base-name,  Next: SCM chdir,  Prev: SCM ag-function?,  Up: AutoGen Functions
1722
1723 3.4.3 'base-name' - base output name
1724 ------------------------------------
1725
1726 Usage: (base-name)
1727 Returns a string containing the base name of the output file(s).
1728 Generally, this is also the base name of the definitions file.
1729
1730    This Scheme function takes no arguments.
1731
1732 \1f
1733 File: autogen.info,  Node: SCM chdir,  Next: SCM count,  Prev: SCM base-name,  Up: AutoGen Functions
1734
1735 3.4.4 'chdir' - Change current directory
1736 ----------------------------------------
1737
1738 Usage: (chdir dir)
1739 Sets the current directory for AutoGen.  Shell commands will run from
1740 this directory as well.  This is a wrapper around the Guile native
1741 function.  It returns its directory name argument and fails the program
1742 on failure.
1743
1744    Arguments:
1745 dir - new directory name
1746
1747 \1f
1748 File: autogen.info,  Node: SCM count,  Next: SCM def-file,  Prev: SCM chdir,  Up: AutoGen Functions
1749
1750 3.4.5 'count' - definition count
1751 --------------------------------
1752
1753 Usage: (count ag-name)
1754 Count the number of entries for a definition.  The input argument must
1755 be a string containing the name of the AutoGen values to be counted.  If
1756 there is no value associated with the name, the result is an SCM
1757 immediate integer value of zero.
1758
1759    Arguments:
1760 ag-name - name of AutoGen value
1761
1762 \1f
1763 File: autogen.info,  Node: SCM def-file,  Next: SCM def-file-line,  Prev: SCM count,  Up: AutoGen Functions
1764
1765 3.4.6 'def-file' - definitions file name
1766 ----------------------------------------
1767
1768 Usage: (def-file)
1769 Get the name of the definitions file.  Returns the name of the source
1770 file containing the AutoGen definitions.
1771
1772    This Scheme function takes no arguments.
1773
1774 \1f
1775 File: autogen.info,  Node: SCM def-file-line,  Next: SCM dne,  Prev: SCM def-file,  Up: AutoGen Functions
1776
1777 3.4.7 'def-file-line' - get a definition file+line number
1778 ---------------------------------------------------------
1779
1780 Usage: (def-file-line ag-name [ msg-fmt ])
1781 Returns the file and line number of a AutoGen defined value, using
1782 either the default format, "from %s line %d", or else the format you
1783 supply.  For example, if you want to insert a "C" language file-line
1784 directive, you would supply the format "# %2$d \"%1$s\"", but that is
1785 also already supplied with the scheme variable *Note SCM
1786 c-file-line-fmt::.  You may use it thus:
1787
1788      (def-file-line "ag-def-name" c-file-line-fmt)
1789
1790    It is also safe to use the formatting string, "%2$d".  AutoGen uses
1791 an argument vector version of printf: *Note snprintfv::.
1792
1793    Arguments:
1794 ag-name - name of AutoGen value
1795 msg-fmt - Optional - formatting for line message
1796
1797 \1f
1798 File: autogen.info,  Node: SCM dne,  Next: SCM emit,  Prev: SCM def-file-line,  Up: AutoGen Functions
1799
1800 3.4.8 'dne' - "Do Not Edit" warning
1801 -----------------------------------
1802
1803 Usage: (dne prefix [ first_prefix ] [ optpfx ])
1804 Generate a "DO NOT EDIT" or "EDIT WITH CARE" warning string.  Which
1805 depends on whether or not the '--writable' command line option was set.
1806
1807    The first argument may be an option: '-D' or '-d', causing the second
1808 and (potentially) third arguments to be interpreted as the first and
1809 second arguments.  The only useful option is '-D':
1810
1811 '-D'
1812      will add date, timestamp and version information.
1813 '-d'
1814      is ignored, but still accepted for compatibility with older
1815      versions of the "dne" function where emitting the date was the
1816      default.
1817
1818    If one of these options is specified, then the "prefix" and "first"
1819 arguments are obtained from the following arguments.  The presence (or
1820 absence) of this option can be overridden with the environment variable,
1821 'AUTOGEN_DNE_DATE'.  The date is disabled if the value is empty or
1822 starts with one of the characters, '0nNfF' - zero or the first letter of
1823 "no" or "false".
1824
1825    The 'prefix' argument is a per-line string prefix.  The optional
1826 second argument is a prefix for the first line only and, in read-only
1827 mode, activates editor hints.
1828
1829      -*- buffer-read-only: t -*- vi: set ro:
1830
1831 The warning string also includes information about the template used to
1832 construct the file and the definitions used in its instantiation.
1833
1834    Arguments:
1835 prefix - string for starting each output line
1836 first_prefix - Optional - for the first output line
1837 optpfx - Optional - shifted prefix
1838
1839 \1f
1840 File: autogen.info,  Node: SCM emit,  Next: SCM emit-string-table,  Prev: SCM dne,  Up: AutoGen Functions
1841
1842 3.4.9 'emit' - emit the text for each argument
1843 ----------------------------------------------
1844
1845 Usage: (emit alist ...)
1846 Walk the tree of arguments, displaying the values of displayable SCM
1847 types.  EXCEPTION: if the first argument is a number, then that number
1848 is used to index the output stack.  "0" is the default, the current
1849 output.
1850
1851    Arguments:
1852 alist - list of arguments to stringify and emit
1853
1854 \1f
1855 File: autogen.info,  Node: SCM emit-string-table,  Next: SCM error,  Prev: SCM emit,  Up: AutoGen Functions
1856
1857 3.4.10 'emit-string-table' - output a string table
1858 --------------------------------------------------
1859
1860 Usage: (emit-string-table st-name)
1861 Emit into the current output stream a 'static char const' array named
1862 'st-name' that will have 'NUL' bytes between each inserted string.
1863
1864    Arguments:
1865 st-name - the name of the array of characters
1866
1867 \1f
1868 File: autogen.info,  Node: SCM error,  Next: SCM exist?,  Prev: SCM emit-string-table,  Up: AutoGen Functions
1869
1870 3.4.11 'error' - display message and exit
1871 -----------------------------------------
1872
1873 Usage: (error message)
1874 The argument is a string that printed out as part of an error message.
1875 The message is formed from the formatting string:
1876
1877      DEFINITIONS ERROR in %s line %d for %s:  %s\n
1878
1879    The first three arguments to this format are provided by the routine
1880 and are: The name of the template file, the line within the template
1881 where the error was found, and the current output file name.
1882
1883    After displaying the message, the current output file is removed and
1884 autogen exits with the EXIT_FAILURE error code.  IF, however, the
1885 argument begins with the number 0 (zero), or the string is the empty
1886 string, then processing continues with the next suffix.
1887
1888    Arguments:
1889 message - message to display before exiting
1890
1891 \1f
1892 File: autogen.info,  Node: SCM exist?,  Next: SCM find-file,  Prev: SCM error,  Up: AutoGen Functions
1893
1894 3.4.12 'exist?' - test for value name
1895 -------------------------------------
1896
1897 Usage: (exist?  ag-name)
1898 return SCM_BOOL_T iff a specified name has an AutoGen value.  The name
1899 may include indexes and/or member names.  All but the last member name
1900 must be an aggregate definition.  For example:
1901      (exist? "foo[3].bar.baz")
1902    will yield true if all of the following is true:
1903 There is a member value of either group or string type named 'baz' for
1904 some group value 'bar' that is a member of the 'foo' group with index
1905 '3'.  There may be multiple entries of 'bar' within 'foo', only one
1906 needs to contain a value for 'baz'.
1907
1908    Arguments:
1909 ag-name - name of AutoGen value
1910
1911 \1f
1912 File: autogen.info,  Node: SCM find-file,  Next: SCM first-for?,  Prev: SCM exist?,  Up: AutoGen Functions
1913
1914 3.4.13 'find-file' - locate a file in the search path
1915 -----------------------------------------------------
1916
1917 Usage: (find-file file-name [ suffix ])
1918 AutoGen has a search path that it uses to locate template and definition
1919 files.  This function will search the same list for 'file-name', both
1920 with and without the '.suffix', if provided.
1921
1922    Arguments:
1923 file-name - name of file with text
1924 suffix - Optional - file suffix to try, too
1925
1926 \1f
1927 File: autogen.info,  Node: SCM first-for?,  Next: SCM for-by,  Prev: SCM find-file,  Up: AutoGen Functions
1928
1929 3.4.14 'first-for?' - detect first iteration
1930 --------------------------------------------
1931
1932 Usage: (first-for?  [ for_var ])
1933 Returns 'SCM_BOOL_T' if the named FOR loop (or, if not named, the
1934 current innermost loop) is on the first pass through the data.  Outside
1935 of any 'FOR' loop, it returns 'SCM_UNDEFINED', *note FOR::.
1936
1937    Arguments:
1938 for_var - Optional - which for loop
1939
1940 \1f
1941 File: autogen.info,  Node: SCM for-by,  Next: SCM for-from,  Prev: SCM first-for?,  Up: AutoGen Functions
1942
1943 3.4.15 'for-by' - set iteration step
1944 ------------------------------------
1945
1946 Usage: (for-by by)
1947 This function records the "step by" information for an AutoGen FOR
1948 function.  Outside of the FOR macro itself, this function will emit an
1949 error.  *Note FOR::.
1950
1951    Arguments:
1952 by - the iteration increment for the AutoGen FOR macro
1953
1954 \1f
1955 File: autogen.info,  Node: SCM for-from,  Next: SCM for-index,  Prev: SCM for-by,  Up: AutoGen Functions
1956
1957 3.4.16 'for-from' - set initial index
1958 -------------------------------------
1959
1960 Usage: (for-from from)
1961 This function records the initial index information for an AutoGen FOR
1962 function.  Outside of the FOR macro itself, this function will emit an
1963 error.  *Note FOR::.
1964
1965    Arguments:
1966 from - the initial index for the AutoGen FOR macro
1967
1968 \1f
1969 File: autogen.info,  Node: SCM for-index,  Next: SCM for-sep,  Prev: SCM for-from,  Up: AutoGen Functions
1970
1971 3.4.17 'for-index' - get current loop index
1972 -------------------------------------------
1973
1974 Usage: (for-index [ for_var ])
1975 Returns the current index for the named 'FOR' loop.  If not named, then
1976 the index for the innermost loop.  Outside of any FOR loop, it returns
1977 'SCM_UNDEFINED', *Note FOR::.
1978
1979    Arguments:
1980 for_var - Optional - which for loop
1981
1982 \1f
1983 File: autogen.info,  Node: SCM for-sep,  Next: SCM for-to,  Prev: SCM for-index,  Up: AutoGen Functions
1984
1985 3.4.18 'for-sep' - set loop separation string
1986 ---------------------------------------------
1987
1988 Usage: (for-sep separator)
1989 This function records the separation string that is to be inserted
1990 between each iteration of an AutoGen FOR function.  This is often
1991 nothing more than a comma.  Outside of the FOR macro itself, this
1992 function will emit an error.
1993
1994    Arguments:
1995 separator - the text to insert between the output of each FOR iteration
1996
1997 \1f
1998 File: autogen.info,  Node: SCM for-to,  Next: SCM found-for?,  Prev: SCM for-sep,  Up: AutoGen Functions
1999
2000 3.4.19 'for-to' - set ending index
2001 ----------------------------------
2002
2003 Usage: (for-to to)
2004 This function records the terminating value information for an AutoGen
2005 FOR function.  Outside of the FOR macro itself, this function will emit
2006 an error.  *Note FOR::.
2007
2008    Arguments:
2009 to - the final index for the AutoGen FOR macro
2010
2011 \1f
2012 File: autogen.info,  Node: SCM found-for?,  Next: SCM get,  Prev: SCM for-to,  Up: AutoGen Functions
2013
2014 3.4.20 'found-for?' - is current index in list?
2015 -----------------------------------------------
2016
2017 Usage: (found-for?  [ for_var ])
2018 Returns SCM_BOOL_T if the currently indexed value is present, otherwise
2019 SCM_BOOL_F. Outside of any FOR loop, it returns SCM_UNDEFINED. *Note
2020 FOR::.
2021
2022    Arguments:
2023 for_var - Optional - which for loop
2024
2025 \1f
2026 File: autogen.info,  Node: SCM get,  Next: SCM get-c-name,  Prev: SCM found-for?,  Up: AutoGen Functions
2027
2028 3.4.21 'get' - get named value
2029 ------------------------------
2030
2031 Usage: (get ag-name [ alt-val ])
2032 Get the first string value associated with the name.  It will either
2033 return the associated string value (if the name resolves), the alternate
2034 value (if one is provided), or else the empty string.
2035
2036    Arguments:
2037 ag-name - name of AutoGen value
2038 alt-val - Optional - value if not present
2039
2040 \1f
2041 File: autogen.info,  Node: SCM get-c-name,  Next: SCM get-down-name,  Prev: SCM get,  Up: AutoGen Functions
2042
2043 3.4.22 'get-c-name' - get named value, mapped to C name syntax
2044 --------------------------------------------------------------
2045
2046 Usage: (get-c-name ag-name)
2047 Get the first string value associated with the name.  It will either
2048 return the associated string value (if the name resolves), the alternate
2049 value (if one is provided), or else the empty string.  The result is
2050 passed through "string->c-name!".
2051
2052    Arguments:
2053 ag-name - name of AutoGen value
2054
2055 \1f
2056 File: autogen.info,  Node: SCM get-down-name,  Next: SCM get-up-name,  Prev: SCM get-c-name,  Up: AutoGen Functions
2057
2058 3.4.23 'get-down-name' - get lower cased named value, mapped to C name syntax
2059 -----------------------------------------------------------------------------
2060
2061 Usage: (get-down-name ag-name)
2062 Get the first string value associated with the name.  It will either
2063 return the associated string value (if the name resolves), the alternate
2064 value (if one is provided), or else the empty string.  The result is
2065 passed through "string->c-name!"  and "string->down-case!".
2066
2067    Arguments:
2068 ag-name - name of AutoGen value
2069
2070 \1f
2071 File: autogen.info,  Node: SCM get-up-name,  Next: SCM high-lim,  Prev: SCM get-down-name,  Up: AutoGen Functions
2072
2073 3.4.24 'get-up-name' - get upper cased named value, mapped to C name syntax
2074 ---------------------------------------------------------------------------
2075
2076 Usage: (get-up-name ag-name)
2077 Get the first string value associated with the name.  It will either
2078 return the associated string value (if the name resolves), the alternate
2079 value (if one is provided), or else the empty string.  The result is
2080 passed through "string->c-name!"  and "string->up-case!".
2081
2082    Arguments:
2083 ag-name - name of AutoGen value
2084
2085 \1f
2086 File: autogen.info,  Node: SCM high-lim,  Next: SCM insert-file,  Prev: SCM get-up-name,  Up: AutoGen Functions
2087
2088 3.4.25 'high-lim' - get highest value index
2089 -------------------------------------------
2090
2091 Usage: (high-lim ag-name)
2092 Returns the highest index associated with an array of definitions.  This
2093 is generally, but not necessarily, one less than the 'count' value.
2094 (The indexes may be specified, rendering a non-zero based or sparse
2095 array of values.)
2096
2097    This is very useful for specifying the size of a zero-based array of
2098 values where not all values are present.  For example:
2099
2100      tMyStruct myVals[ [+ (+ 1 (high-lim "my-val-list")) +] ];
2101
2102    Arguments:
2103 ag-name - name of AutoGen value
2104
2105 \1f
2106 File: autogen.info,  Node: SCM insert-file,  Next: SCM insert-suspended,  Prev: SCM high-lim,  Up: AutoGen Functions
2107
2108 3.4.26 'insert-file' - insert the contents of a (list of) files.
2109 ----------------------------------------------------------------
2110
2111 Usage: (insert-file alist ...)
2112 Insert the contents of one or more files.
2113
2114    Arguments:
2115 alist - list of files to emit
2116
2117 \1f
2118 File: autogen.info,  Node: SCM insert-suspended,  Next: SCM last-for?,  Prev: SCM insert-file,  Up: AutoGen Functions
2119
2120 3.4.27 'insert-suspended' - insert a named suspension in current output
2121 -----------------------------------------------------------------------
2122
2123 Usage: (insert-suspended susp-name)
2124 Emit into the current output the output suspended under a given
2125 diversion name.
2126
2127    Arguments:
2128 susp-name - the name of the suspended output
2129
2130 \1f
2131 File: autogen.info,  Node: SCM last-for?,  Next: SCM len,  Prev: SCM insert-suspended,  Up: AutoGen Functions
2132
2133 3.4.28 'last-for?' - detect last iteration
2134 ------------------------------------------
2135
2136 Usage: (last-for?  [ for_var ])
2137 Returns SCM_BOOL_T if the named FOR loop (or, if not named, the current
2138 innermost loop) is on the last pass through the data.  Outside of any
2139 FOR loop, it returns SCM_UNDEFINED. *Note FOR::.
2140
2141    Arguments:
2142 for_var - Optional - which for loop
2143
2144 \1f
2145 File: autogen.info,  Node: SCM len,  Next: SCM low-lim,  Prev: SCM last-for?,  Up: AutoGen Functions
2146
2147 3.4.29 'len' - get count of values
2148 ----------------------------------
2149
2150 Usage: (len ag-name)
2151 If the named object is a group definition, then "len" is the same as
2152 "count".  Otherwise, if it is one or more text definitions, then it is
2153 the sum of their string lengths.  If it is a single text definition,
2154 then it is equivalent to '(string-length (get "ag-name"))'.
2155
2156    Arguments:
2157 ag-name - name of AutoGen value
2158
2159 \1f
2160 File: autogen.info,  Node: SCM low-lim,  Next: SCM make-header-guard,  Prev: SCM len,  Up: AutoGen Functions
2161
2162 3.4.30 'low-lim' - get lowest value index
2163 -----------------------------------------
2164
2165 Usage: (low-lim ag-name)
2166 Returns the lowest index associated with an array of definitions.
2167
2168    Arguments:
2169 ag-name - name of AutoGen value
2170
2171 \1f
2172 File: autogen.info,  Node: SCM make-header-guard,  Next: SCM make-tmp-dir,  Prev: SCM low-lim,  Up: AutoGen Functions
2173
2174 3.4.31 'make-header-guard' - make self-inclusion guard
2175 ------------------------------------------------------
2176
2177 Usage: (make-header-guard name)
2178 This function will create a '#ifndef'/'#define' sequence for protecting
2179 a header from multiple evaluation.  It will also set the Scheme variable
2180 'header-file' to the name of the file being protected and it will set
2181 'header-guard' to the name of the '#define' being used to protect it.
2182 It is expected that this will be used as follows:
2183      [+ (make-header-guard "group_name") +]
2184      ...
2185      #endif /* [+ (. header-guard) +] */
2186
2187      #include "[+ (. header-file)  +]"
2188 The '#define' name is composed as follows:
2189
2190   1. The first element is the string argument and a separating
2191      underscore.
2192   2. That is followed by the name of the header file with illegal
2193      characters mapped to underscores.
2194   3. The end of the name is always, "'_GUARD'".
2195   4. Finally, the entire string is mapped to upper case.
2196
2197    The final '#define' name is stored in an SCM symbol named
2198 'header-guard'.  Consequently, the concluding '#endif' for the file
2199 should read something like:
2200
2201      #endif /* [+ (. header-guard) +] */
2202
2203    The name of the header file (the current output file) is also stored
2204 in an SCM symbol, 'header-file'.  Therefore, if you are also generating
2205 a C file that uses the previously generated header file, you can put
2206 this into that generated file:
2207
2208      #include "[+ (. header-file) +]"
2209
2210    Obviously, if you are going to produce more than one header file from
2211 a particular template, you will need to be careful how these SCM symbols
2212 get handled.
2213
2214    Arguments:
2215 name - header group name
2216
2217 \1f
2218 File: autogen.info,  Node: SCM make-tmp-dir,  Next: SCM match-value?,  Prev: SCM make-header-guard,  Up: AutoGen Functions
2219
2220 3.4.32 'make-tmp-dir' - create a temporary directory
2221 ----------------------------------------------------
2222
2223 Usage: (make-tmp-dir)
2224 Create a directory that will be cleaned up upon exit.
2225
2226    This Scheme function takes no arguments.
2227
2228 \1f
2229 File: autogen.info,  Node: SCM match-value?,  Next: SCM max-file-time,  Prev: SCM make-tmp-dir,  Up: AutoGen Functions
2230
2231 3.4.33 'match-value?' - test for matching value
2232 -----------------------------------------------
2233
2234 Usage: (match-value?  op ag-name test-str)
2235 This function answers the question, "Is there an AutoGen value named
2236 'ag-name' with a value that matches the pattern 'test-str' using the
2237 match function 'op'?"  Return SCM_BOOL_T iff at least one occurrence of
2238 the specified name has such a value.  The operator can be any function
2239 that takes two string arguments and yields a boolean.  It is expected
2240 that you will use one of the string matching functions provided by
2241 AutoGen.
2242 The value name must follow the same rules as the 'ag-name' argument for
2243 'exist?' (*note SCM exist?::).
2244
2245    Arguments:
2246 op - boolean result operator
2247 ag-name - name of AutoGen value
2248 test-str - string to test against
2249
2250 \1f
2251 File: autogen.info,  Node: SCM max-file-time,  Next: SCM mk-gettextable,  Prev: SCM match-value?,  Up: AutoGen Functions
2252
2253 3.4.34 'max-file-time' - get the maximum input file modification time
2254 ---------------------------------------------------------------------
2255
2256 Usage: (max-file-time)
2257 returns the time stamp of the most recently modified sourc file as the
2258 number of seconds since the epoch.  If any input is dynamic (a shell
2259 command), then it will be the current time.
2260
2261    This Scheme function takes no arguments.
2262
2263 \1f
2264 File: autogen.info,  Node: SCM mk-gettextable,  Next: SCM out-delete,  Prev: SCM max-file-time,  Up: AutoGen Functions
2265
2266 3.4.35 'mk-gettextable' - print a string in a gettext-able format
2267 -----------------------------------------------------------------
2268
2269 Usage: (mk-gettextable string)
2270 Returns SCM_UNDEFINED. The input text string is printed to the current
2271 output as one puts() call per paragraph.
2272
2273    Arguments:
2274 string - a multi-paragraph string
2275
2276 \1f
2277 File: autogen.info,  Node: SCM out-delete,  Next: SCM out-depth,  Prev: SCM mk-gettextable,  Up: AutoGen Functions
2278
2279 3.4.36 'out-delete' - delete current output file
2280 ------------------------------------------------
2281
2282 Usage: (out-delete)
2283 Remove the current output file.  Cease processing the template for the
2284 current suffix.  It is an error if there are 'push'-ed output files.
2285 Use the '(error "0")' scheme function instead.  *Note output controls::.
2286
2287    This Scheme function takes no arguments.
2288
2289 \1f
2290 File: autogen.info,  Node: SCM out-depth,  Next: SCM out-emit-suspended,  Prev: SCM out-delete,  Up: AutoGen Functions
2291
2292 3.4.37 'out-depth' - output file stack depth
2293 --------------------------------------------
2294
2295 Usage: (out-depth)
2296 Returns the depth of the output file stack.  *Note output controls::.
2297
2298    This Scheme function takes no arguments.
2299
2300 \1f
2301 File: autogen.info,  Node: SCM out-emit-suspended,  Next: SCM out-line,  Prev: SCM out-depth,  Up: AutoGen Functions
2302
2303 3.4.38 'out-emit-suspended' - emit the text of suspended output
2304 ---------------------------------------------------------------
2305
2306 Usage: (out-emit-suspended susp_nm)
2307 This function is equivalent to '(begin (out-resume <name>) (out-pop
2308 #t))'
2309
2310    Arguments:
2311 susp_nm - A name tag of suspended output
2312
2313 \1f
2314 File: autogen.info,  Node: SCM out-line,  Next: SCM out-move,  Prev: SCM out-emit-suspended,  Up: AutoGen Functions
2315
2316 3.4.39 'out-line' - output file line number
2317 -------------------------------------------
2318
2319 Usage: (out-line)
2320 Returns the current line number of the output file.  It rewinds and
2321 reads the file to count newlines.
2322
2323    This Scheme function takes no arguments.
2324
2325 \1f
2326 File: autogen.info,  Node: SCM out-move,  Next: SCM out-name,  Prev: SCM out-line,  Up: AutoGen Functions
2327
2328 3.4.40 'out-move' - change name of output file
2329 ----------------------------------------------
2330
2331 Usage: (out-move new-name)
2332 Rename current output file.  *Note output controls::.  Please note:
2333 changing the name will not save a temporary file from being deleted.  It
2334 may, however, be used on the root output file.
2335
2336    Arguments:
2337 new-name - new name for the current output file
2338
2339 \1f
2340 File: autogen.info,  Node: SCM out-name,  Next: SCM out-pop,  Prev: SCM out-move,  Up: AutoGen Functions
2341
2342 3.4.41 'out-name' - current output file name
2343 --------------------------------------------
2344
2345 Usage: (out-name)
2346 Returns the name of the current output file.  If the current file is a
2347 temporary, unnamed file, then it will scan up the chain until a real
2348 output file name is found.  *Note output controls::.
2349
2350    This Scheme function takes no arguments.
2351
2352 \1f
2353 File: autogen.info,  Node: SCM out-pop,  Next: SCM out-push-add,  Prev: SCM out-name,  Up: AutoGen Functions
2354
2355 3.4.42 'out-pop' - close current output file
2356 --------------------------------------------
2357
2358 Usage: (out-pop [ disp ])
2359 If there has been a 'push' on the output, then close that file and go
2360 back to the previously open file.  It is an error if there has not been
2361 a 'push'.  *Note output controls::.
2362
2363    If there is no argument, no further action is taken.  Otherwise, the
2364 argument should be '#t' and the contents of the file are returned by the
2365 function.
2366
2367    Arguments:
2368 disp - Optional - return contents of the file
2369
2370 \1f
2371 File: autogen.info,  Node: SCM out-push-add,  Next: SCM out-push-new,  Prev: SCM out-pop,  Up: AutoGen Functions
2372
2373 3.4.43 'out-push-add' - append output to file
2374 ---------------------------------------------
2375
2376 Usage: (out-push-add file-name)
2377 Identical to 'push-new', except the contents are *not* purged, but
2378 appended to.  *Note output controls::.
2379
2380    Arguments:
2381 file-name - name of the file to append text to
2382
2383 \1f
2384 File: autogen.info,  Node: SCM out-push-new,  Next: SCM out-resume,  Prev: SCM out-push-add,  Up: AutoGen Functions
2385
2386 3.4.44 'out-push-new' - purge and create output file
2387 ----------------------------------------------------
2388
2389 Usage: (out-push-new [ file-name ])
2390 Leave the current output file open, but purge and create a new file that
2391 will remain open until a 'pop' 'delete' or 'switch' closes it.  The file
2392 name is optional and, if omitted, the output will be sent to a temporary
2393 file that will be deleted when it is closed.  *Note output controls::.
2394
2395    Arguments:
2396 file-name - Optional - name of the file to create
2397
2398 \1f
2399 File: autogen.info,  Node: SCM out-resume,  Next: SCM out-suspend,  Prev: SCM out-push-new,  Up: AutoGen Functions
2400
2401 3.4.45 'out-resume' - resume suspended output file
2402 --------------------------------------------------
2403
2404 Usage: (out-resume susp_nm)
2405 If there has been a suspended output, then make that output descriptor
2406 current again.  That output must have been suspended with the same tag
2407 name given to this routine as its argument.
2408
2409    Arguments:
2410 susp_nm - A name tag for reactivating
2411
2412 \1f
2413 File: autogen.info,  Node: SCM out-suspend,  Next: SCM out-switch,  Prev: SCM out-resume,  Up: AutoGen Functions
2414
2415 3.4.46 'out-suspend' - suspend current output file
2416 --------------------------------------------------
2417
2418 Usage: (out-suspend suspName)
2419 If there has been a 'push' on the output, then set aside the output
2420 descriptor for later reactiviation with '(out-resume "xxx")'.  The tag
2421 name need not reflect the name of the output file.  In fact, the output
2422 file may be an anonymous temporary file.  You may also change the tag
2423 every time you suspend output to a file, because the tag names are
2424 forgotten as soon as the file has been "resumed".
2425
2426    Arguments:
2427 suspName - A name tag for reactivating
2428
2429 \1f
2430 File: autogen.info,  Node: SCM out-switch,  Next: SCM output-file-next-line,  Prev: SCM out-suspend,  Up: AutoGen Functions
2431
2432 3.4.47 'out-switch' - close and create new output
2433 -------------------------------------------------
2434
2435 Usage: (out-switch file-name)
2436 Switch output files - close current file and make the current file
2437 pointer refer to the new file.  This is equivalent to 'out-pop' followed
2438 by 'out-push-new', except that you may not pop the base level output
2439 file, but you may 'switch' it.  *Note output controls::.
2440
2441    Arguments:
2442 file-name - name of the file to create
2443
2444 \1f
2445 File: autogen.info,  Node: SCM output-file-next-line,  Next: SCM set-option,  Prev: SCM out-switch,  Up: AutoGen Functions
2446
2447 3.4.48 'output-file-next-line' - print the file name and next line number
2448 -------------------------------------------------------------------------
2449
2450 Usage: (output-file-next-line [ line_off ] [ alt_fmt ])
2451 Returns a string with the current output file name and line number.  The
2452 default format is: # <line+1> "<output-file-name>" The argument may be
2453 either a number indicating an offset from the current output line number
2454 or an alternate formatting string.  If both are provided, then the first
2455 must be a numeric offset.
2456
2457    Be careful that you are directing output to the final output file.
2458 Otherwise, you will get the file name and line number of the temporary
2459 file.  That won't be what you want.
2460
2461    Arguments:
2462 line_off - Optional - offset to line number
2463 alt_fmt - Optional - alternate format string
2464
2465 \1f
2466 File: autogen.info,  Node: SCM set-option,  Next: SCM set-writable,  Prev: SCM output-file-next-line,  Up: AutoGen Functions
2467
2468 3.4.49 'set-option' - Set a command line option
2469 -----------------------------------------------
2470
2471 Usage: (set-option opt)
2472 The text argument must be an option name followed by any needed option
2473 argument.  Returns SCM_UNDEFINED.
2474
2475    Arguments:
2476 opt - AutoGen option name + its argument
2477
2478 \1f
2479 File: autogen.info,  Node: SCM set-writable,  Next: SCM stack,  Prev: SCM set-option,  Up: AutoGen Functions
2480
2481 3.4.50 'set-writable' - Make the output file be writable
2482 --------------------------------------------------------
2483
2484 Usage: (set-writable [ set?  ])
2485 This function will set the current output file to be writable (or not).
2486 This is only effective if neither the '--writable' nor '--not-writable'
2487 have been specified.  This state is reset when the current suffix's
2488 output is complete.
2489
2490    Arguments:
2491 set?  - Optional - boolean arg, false to make output non-writable
2492
2493 \1f
2494 File: autogen.info,  Node: SCM stack,  Next: SCM stack-join,  Prev: SCM set-writable,  Up: AutoGen Functions
2495
2496 3.4.51 'stack' - make list of AutoGen values
2497 --------------------------------------------
2498
2499 Usage: (stack ag-name)
2500 Create a scheme list of all the strings that are associated with a name.
2501 They must all be text values or we choke.
2502
2503    Arguments:
2504 ag-name - AutoGen value name
2505
2506 \1f
2507 File: autogen.info,  Node: SCM stack-join,  Next: SCM suffix,  Prev: SCM stack,  Up: AutoGen Functions
2508
2509 3.4.52 'stack-join' - stack values then join them
2510 -------------------------------------------------
2511
2512 Usage: (stack-join join ag-name)
2513 This function will collect all the values named 'ag-name' (see the *note
2514 stack function: SCM stack.) and join them separated by the 'join' string
2515 (see the *note join function: SCM join.).
2516
2517    Arguments:
2518 join - string between each element
2519 ag-name - name of autogen values to stack
2520
2521 \1f
2522 File: autogen.info,  Node: SCM suffix,  Next: SCM tpl-file,  Prev: SCM stack-join,  Up: AutoGen Functions
2523
2524 3.4.53 'suffix' - get the current suffix
2525 ----------------------------------------
2526
2527 Usage: (suffix)
2528 Returns the current active suffix (*note pseudo macro::).
2529
2530    This Scheme function takes no arguments.
2531
2532 \1f
2533 File: autogen.info,  Node: SCM tpl-file,  Next: SCM tpl-file-line,  Prev: SCM suffix,  Up: AutoGen Functions
2534
2535 3.4.54 'tpl-file' - get the template file name
2536 ----------------------------------------------
2537
2538 Usage: (tpl-file [ full_path ])
2539 Returns the name of the current template file.  If '#t' is passed in as
2540 an argument, then the template file is hunted for in the template search
2541 path.  Otherwise, just the unadorned name.
2542
2543    Arguments:
2544 full_path - Optional - include full path to file
2545
2546 \1f
2547 File: autogen.info,  Node: SCM tpl-file-line,  Next: SCM tpl-file-next-line,  Prev: SCM tpl-file,  Up: AutoGen Functions
2548
2549 3.4.55 'tpl-file-line' - get the template file+line number
2550 ----------------------------------------------------------
2551
2552 Usage: (tpl-file-line [ msg-fmt ])
2553 Returns the file and line number of the current template macro using
2554 either the default format, "from %s line %d", or else the format you
2555 supply.  For example, if you want to insert a "C" language file-line
2556 directive, you would supply the format "# %2$d \"%1$s\"", but that is
2557 also already supplied with the scheme variable *Note SCM
2558 c-file-line-fmt::.  You may use it thus:
2559      (tpl-file-line c-file-line-fmt)
2560
2561    It is also safe to use the formatting string, "%2$d".  AutoGen uses
2562 an argument vector version of printf: *Note snprintfv::, and it does not
2563 need to know the types of each argument in order to skip forward to the
2564 second argument.
2565
2566    Arguments:
2567 msg-fmt - Optional - formatting for line message
2568
2569 \1f
2570 File: autogen.info,  Node: SCM tpl-file-next-line,  Next: SCM warn,  Prev: SCM tpl-file-line,  Up: AutoGen Functions
2571
2572 3.4.56 'tpl-file-next-line' - get the template file plus next line number
2573 -------------------------------------------------------------------------
2574
2575 Usage: (tpl-file-next-line [ msg-fmt ])
2576 This is almost the same as *Note SCM tpl-file-line::, except that the
2577 line referenced is the next line, per C compiler conventions, and
2578 consequently defaults to the format: # <line-no+1> "<file-name>"
2579
2580    Arguments:
2581 msg-fmt - Optional - formatting for line message
2582
2583 \1f
2584 File: autogen.info,  Node: SCM warn,  Next: SCM autogen-version,  Prev: SCM tpl-file-next-line,  Up: AutoGen Functions
2585
2586 3.4.57 'warn' - display warning message and continue
2587 ----------------------------------------------------
2588
2589 Usage: (warn message)
2590 The argument is a string that printed out to stderr.  The message is
2591 formed from the formatting string:
2592
2593      WARNING:  %s\n
2594
2595    The template processing resumes after printing the message.
2596
2597    Arguments:
2598 message - message to display
2599
2600 \1f
2601 File: autogen.info,  Node: SCM autogen-version,  Next: SCM c-file-line-fmt,  Prev: SCM warn,  Up: AutoGen Functions
2602
2603 3.4.58 'autogen-version' - autogen version number
2604 -------------------------------------------------
2605
2606 This is a symbol defining the current AutoGen version number string.  It
2607 was first defined in AutoGen-5.2.14.  It is currently "5.18.16".
2608
2609 \1f
2610 File: autogen.info,  Node: SCM c-file-line-fmt,  Prev: SCM autogen-version,  Up: AutoGen Functions
2611
2612 3.4.59 format file info as, "'#line nn "file"'"
2613 -----------------------------------------------
2614
2615 This is a symbol that can easily be used with the functions *Note SCM
2616 tpl-file-line::, and *Note SCM def-file-line::.  These will emit C
2617 program '#line' directives pointing to template and definitions text,
2618 respectively.
2619
2620 \1f
2621 File: autogen.info,  Node: Common Functions,  Next: native macros,  Prev: AutoGen Functions,  Up: Template File
2622
2623 3.5 Common Scheme Functions
2624 ===========================
2625
2626 This section describes a number of general purpose functions that make
2627 the kind of string processing that AutoGen does a little easier.  Unlike
2628 the AutoGen specific functions (*note AutoGen Functions::), these
2629 functions are available for direct use during definition load time.  The
2630 equality test (*note SCM =::) is "overloaded" to do string equivalence
2631 comparisons.  If you are looking for inequality, the Scheme/Lisp way of
2632 spelling that is, "(not (= ...))".
2633
2634 * Menu:
2635
2636 * SCM agpl::               'agpl' - GNU Affero General Public License
2637 * SCM bsd::                'bsd' - BSD Public License
2638 * SCM c-string::           'c-string' - emit string for ANSI C
2639 * SCM error-source-line::  'error-source-line' - display of file & line
2640 * SCM extract::            'extract' - extract text from another file
2641 * SCM format-arg-count::   'format-arg-count' - count the args to a format
2642 * SCM fprintf::            'fprintf' - format to a file
2643 * SCM gperf::              'gperf' - perform a perfect hash function
2644 * SCM gperf-code::         'gperf-code' - emit the source of the generated gperf program
2645 * SCM gpl::                'gpl' - GNU General Public License
2646 * SCM hide-email::         'hide-email' - convert eaddr to javascript
2647 * SCM html-escape-encode:: 'html-escape-encode' - encode html special characters
2648 * SCM in?::                'in?' - test for string in list
2649 * SCM join::               'join' - join string list with separator
2650 * SCM kr-string::          'kr-string' - emit string for K&R C
2651 * SCM lgpl::               'lgpl' - GNU Library General Public License
2652 * SCM license::            'license' - an arbitrary license
2653 * SCM license-description:: 'license-description' - Emit a license description
2654 * SCM license-full::       'license-full' - Emit the licensing information and description
2655 * SCM license-info::       'license-info' - Emit the licensing information and copyright years
2656 * SCM license-name::       'license-name' - Emit the name of the license
2657 * SCM make-gperf::         'make-gperf' - build a perfect hash function program
2658 * SCM makefile-script::    'makefile-script' - create makefile script
2659 * SCM max::                'max' - maximum value in list
2660 * SCM min::                'min' - minimum value in list
2661 * SCM prefix::             'prefix' - prefix lines with a string
2662 * SCM printf::             'printf' - format to stdout
2663 * SCM raw-shell-str::      'raw-shell-str' - single quote shell string
2664 * SCM shell::              'shell' - invoke a shell script
2665 * SCM shell-str::          'shell-str' - double quote shell string
2666 * SCM shellf::             'shellf' - format a string, run shell
2667 * SCM sprintf::            'sprintf' - format a string
2668 * SCM string-capitalize::  'string-capitalize' - capitalize a new string
2669 * SCM string-capitalize!:: 'string-capitalize!' - capitalize a string
2670 * SCM *=*::                'string-contains-eqv?' - caseless substring
2671 * SCM *==*::               'string-contains?' - substring match
2672 * SCM string-downcase::    'string-downcase' - lower case a new string
2673 * SCM string-downcase!::   'string-downcase!' - make a string be lower case
2674 * SCM *~::                 'string-end-eqv-match?' - caseless regex ending
2675 * SCM *~~::                'string-end-match?' - regex match end
2676 * SCM *=::                 'string-ends-eqv?' - caseless string ending
2677 * SCM *==::                'string-ends-with?' - string ending
2678 * SCM ==::                 'string-equals?' - string matching
2679 * SCM ~::                  'string-eqv-match?' - caseless regex match
2680 * SCM =::                  'string-eqv?' - caseless match
2681 * SCM *~*::                'string-has-eqv-match?' - caseless regex contains
2682 * SCM *~~*::               'string-has-match?' - contained regex match
2683 * SCM ~~::                 'string-match?' - regex match
2684 * SCM ~*::                 'string-start-eqv-match?' - caseless regex start
2685 * SCM ~~*::                'string-start-match?' - regex match start
2686 * SCM =*::                 'string-starts-eqv?' - caseless string start
2687 * SCM ==*::                'string-starts-with?' - string starting
2688 * SCM string-substitute::  'string-substitute' - multiple global replacements
2689 * SCM string-table-add::   'string-table-add' - Add an entry to a string table
2690 * SCM string-table-add-ref:: 'string-table-add-ref' - Add an entry to a string table, get reference
2691 * SCM string-table-new::   'string-table-new' - create a string table
2692 * SCM string-table-size::  'string-table-size' - print the current size of a string table
2693 * SCM string->c-name!::    'string->c-name!' - map non-name chars to underscore
2694 * SCM string->camelcase::  'string->camelcase' - make a string be CamelCase
2695 * SCM string-tr::          'string-tr' - convert characters with new result
2696 * SCM string-tr!::         'string-tr!' - convert characters
2697 * SCM string-upcase::      'string-upcase' - upper case a new string
2698 * SCM string-upcase!::     'string-upcase!' - make a string be upper case
2699 * SCM sub-shell-str::      'sub-shell-str' - back quoted (sub-)shell string
2700 * SCM sum::                'sum' - sum of values in list
2701 * SCM time-string->number:: 'time-string->number' - duration string to seconds
2702 * SCM version-compare::    'version-compare' - compare two version numbers
2703
2704 \1f
2705 File: autogen.info,  Node: SCM agpl,  Next: SCM bsd,  Up: Common Functions
2706
2707 3.5.1 'agpl' - GNU Affero General Public License
2708 ------------------------------------------------
2709
2710 Usage: (agpl prog-name prefix)
2711 Emit a string that contains the GNU Affero General Public License.  This
2712 function is now deprecated.  Please *Note SCM license-description::.
2713
2714    Arguments:
2715 prog-name - name of the program under the GPL
2716 prefix - String for starting each output line
2717
2718 \1f
2719 File: autogen.info,  Node: SCM bsd,  Next: SCM c-string,  Prev: SCM agpl,  Up: Common Functions
2720
2721 3.5.2 'bsd' - BSD Public License
2722 --------------------------------
2723
2724 Usage: (bsd prog_name owner prefix)
2725 Emit a string that contains the Free BSD Public License.  This function
2726 is now deprecated.  Please *Note SCM license-description::.
2727
2728    Arguments:
2729 prog_name - name of the program under the BSD
2730 owner - Grantor of the BSD License
2731 prefix - String for starting each output line
2732
2733 \1f
2734 File: autogen.info,  Node: SCM c-string,  Next: SCM error-source-line,  Prev: SCM bsd,  Up: Common Functions
2735
2736 3.5.3 'c-string' - emit string for ANSI C
2737 -----------------------------------------
2738
2739 Usage: (c-string string)
2740 Reform a string so that, when printed, the C compiler will be able to
2741 compile the data and construct a string that contains exactly what the
2742 current string contains.  Many non-printing characters are replaced with
2743 escape sequences.  Newlines are replaced with a backslash, an 'n', a
2744 closing quote, a newline, seven spaces and another re-opening quote.
2745 The compiler will implicitly concatenate them.  The reader will see line
2746 breaks.
2747
2748    A K&R compiler will choke.  Use 'kr-string' for that compiler.
2749
2750    Arguments:
2751 string - string to reformat
2752
2753 \1f
2754 File: autogen.info,  Node: SCM error-source-line,  Next: SCM extract,  Prev: SCM c-string,  Up: Common Functions
2755
2756 3.5.4 'error-source-line' - display of file & line
2757 --------------------------------------------------
2758
2759 Usage: (error-source-line)
2760 This function is only invoked just before Guile displays an error
2761 message.  It displays the file name and line number that triggered the
2762 evaluation error.  You should not need to invoke this routine directly.
2763 Guile will do it automatically.
2764
2765    This Scheme function takes no arguments.
2766
2767 \1f
2768 File: autogen.info,  Node: SCM extract,  Next: SCM format-arg-count,  Prev: SCM error-source-line,  Up: Common Functions
2769
2770 3.5.5 'extract' - extract text from another file
2771 ------------------------------------------------
2772
2773 Usage: (extract file-name marker-fmt [ caveat ] [ default ])
2774 This function is used to help construct output files that may contain
2775 text that is carried from one version of the output to the next.
2776
2777    The first two arguments are required, the second are optional:
2778
2779    * The 'file-name' argument is used to name the file that contains the
2780      demarcated text.
2781    * The 'marker-fmt' is a formatting string that is used to construct
2782      the starting and ending demarcation strings.  The sprintf function
2783      is given the 'marker-fmt' with two arguments.  The first is either
2784      "START" or "END". The second is either "DO NOT CHANGE THIS COMMENT"
2785      or the optional 'caveat' argument.
2786    * 'caveat' is presumed to be absent if it is the empty string ('""').
2787      If absent, "DO NOT CHANGE THIS COMMENT" is used as the second
2788      string argument to the 'marker-fmt'.
2789    * When a 'default' argument is supplied and no pre-existing text is
2790      found, then this text will be inserted between the START and END
2791      markers.
2792
2793 The resulting strings are presumed to be unique within the subject file.
2794 As a simplified example:
2795
2796      [+ (extract "fname" "// %s - SOMETHING - %s" ""
2797      "example default") +]
2798 will result in the following text being inserted into the output:
2799
2800      // START - SOMETHING - DO NOT CHANGE THIS COMMENT
2801      example default
2802      // END   - SOMETHING - DO NOT CHANGE THIS COMMENT
2803
2804 The "'example default'" string can then be carried forward to the next
2805 generation of the output, *provided* the output is not named "'fname'"
2806 and the old output is renamed to "'fname'" before AutoGen-eration
2807 begins.
2808
2809 *NB:*
2810      You can set aside previously generated source files inside the
2811      pseudo macro with a Guile/scheme function, extract the text you
2812      want to keep with this extract function.  Just remember you should
2813      delete it at the end, too.  Here is an example from my Finite State
2814      Machine generator:
2815
2816           [+ AutoGen5 Template  -*- Mode: text -*-
2817           h=%s-fsm.h   c=%s-fsm.c
2818           (shellf
2819           "test -f %1$s-fsm.h && mv -f %1$s-fsm.h .fsm.head
2820           test -f %1$s-fsm.c && mv -f %1$s-fsm.c .fsm.code" (base-name))
2821           +]
2822
2823      This code will move the two previously produced output files to
2824      files named ".fsm.head" and ".fsm.code".  At the end of the 'c'
2825      output processing, I delete them.
2826
2827 *also NB:*
2828      This function presumes that the output file ought to be editable so
2829      that the code between the 'START' and 'END' marks can be edited by
2830      the template user.  Consequently, when the '(extract ...)' function
2831      is invoked, if the 'writable' option has not been specified, then
2832      it will be set at that point.  If this is not the desired behavior,
2833      the '--not-writable' command line option will override this.  Also,
2834      you may use the guile function '(chmod "file" mode-value)' to
2835      override whatever AutoGen is using for the result mode.
2836
2837    Arguments:
2838 file-name - name of file with text
2839 marker-fmt - format for marker text
2840 caveat - Optional - warn about changing marker
2841 default - Optional - default initial text
2842
2843 \1f
2844 File: autogen.info,  Node: SCM format-arg-count,  Next: SCM fprintf,  Prev: SCM extract,  Up: Common Functions
2845
2846 3.5.6 'format-arg-count' - count the args to a format
2847 -----------------------------------------------------
2848
2849 Usage: (format-arg-count format)
2850 Sometimes, it is useful to simply be able to figure out how many
2851 arguments are required by a format string.  For example, if you are
2852 extracting a format string for the purpose of generating a macro to
2853 invoke a printf-like function, you can run the formatting string through
2854 this function to determine how many arguments to provide for in the
2855 macro.  e.g.  for this extraction text:
2856
2857       /*=fumble bumble
2858        * fmt: 'stumble %s: %d\n'
2859       =*/
2860
2861 You may wish to generate a macro:
2862
2863       #define BUMBLE(a1,a2) printf_like(something,(a1),(a2))
2864
2865 You can do this by knowing that the format needs two arguments.
2866
2867    Arguments:
2868 format - formatting string
2869
2870 \1f
2871 File: autogen.info,  Node: SCM fprintf,  Next: SCM gperf,  Prev: SCM format-arg-count,  Up: Common Functions
2872
2873 3.5.7 'fprintf' - format to a file
2874 ----------------------------------
2875
2876 Usage: (fprintf port format [ format-arg ...  ])
2877 Format a string using arguments from the alist.  Write to a specified
2878 port.  The result will NOT appear in your output.  Use this to print
2879 information messages to a template user.
2880
2881    Arguments:
2882 port - Guile-scheme output port
2883 format - formatting string
2884 format-arg - Optional - list of arguments to formatting string
2885
2886 \1f
2887 File: autogen.info,  Node: SCM gperf,  Next: SCM gperf-code,  Prev: SCM fprintf,  Up: Common Functions
2888
2889 3.5.8 'gperf' - perform a perfect hash function
2890 -----------------------------------------------
2891
2892 Usage: (gperf name str)
2893 Perform the perfect hash on the input string.  This is only useful if
2894 you have previously created a gperf program with the 'make-gperf'
2895 function *Note SCM make-gperf::.  The 'name' you supply here must match
2896 the name used to create the program and the string to hash must be one
2897 of the strings supplied in the 'make-gperf' string list.  The result
2898 will be a perfect hash index.
2899
2900    See the documentation for 'gperf(1GNU)' for more details.
2901
2902    Arguments:
2903 name - name of hash list
2904 str - string to hash
2905
2906 \1f
2907 File: autogen.info,  Node: SCM gperf-code,  Next: SCM gpl,  Prev: SCM gperf,  Up: Common Functions
2908
2909 3.5.9 'gperf-code' - emit the source of the generated gperf program
2910 -------------------------------------------------------------------
2911
2912 Usage: (gperf-code st-name)
2913 Returns the contents of the emitted code, suitable for inclusion in
2914 another program.  The interface contains the following elements:
2915
2916 'struct <st-name>_index'
2917      containg the fields: '{char const * name, int const id; };'
2918
2919 '<st-name>_hash()'
2920      This is the hashing function with local only scope (static).
2921
2922 '<st-name>_find()'
2923      This is the searching and validation function.  The first argument
2924      is the string to look up, the second is its length.  It returns a
2925      pointer to the corresponding '<st-name>_index' entry.
2926
2927    Use this in your template as follows where "<st-name>" was set to be
2928 "'lookup'":
2929
2930      [+ (make-gperf "lookup" (join "\n" (stack "name_list")))
2931      (gperf-code "lookup") +]
2932      void my_fun(char * str) {
2933      struct lookup_index * li = lookup_find(str, strlen(str));
2934      if (li != NULL) printf("%s yields %d\n", str, li->idx);
2935
2936    Arguments:
2937 st-name - the name of the gperf hash list
2938
2939 \1f
2940 File: autogen.info,  Node: SCM gpl,  Next: SCM hide-email,  Prev: SCM gperf-code,  Up: Common Functions
2941
2942 3.5.10 'gpl' - GNU General Public License
2943 -----------------------------------------
2944
2945 Usage: (gpl prog-name prefix)
2946 Emit a string that contains the GNU General Public License.  This
2947 function is now deprecated.  Please *Note SCM license-description::.
2948
2949    Arguments:
2950 prog-name - name of the program under the GPL
2951 prefix - String for starting each output line
2952
2953 \1f
2954 File: autogen.info,  Node: SCM hide-email,  Next: SCM html-escape-encode,  Prev: SCM gpl,  Up: Common Functions
2955
2956 3.5.11 'hide-email' - convert eaddr to javascript
2957 -------------------------------------------------
2958
2959 Usage: (hide-email display eaddr)
2960 Hides an email address as a java scriptlett.  The 'mailto:' tag and the
2961 email address are coded bytes rather than plain text.  They are also
2962 broken up.
2963
2964    Arguments:
2965 display - display text
2966 eaddr - email address
2967
2968 \1f
2969 File: autogen.info,  Node: SCM html-escape-encode,  Next: SCM in?,  Prev: SCM hide-email,  Up: Common Functions
2970
2971 3.5.12 'html-escape-encode' - encode html special characters
2972 ------------------------------------------------------------
2973
2974 Usage: (html-escape-encode str)
2975 This function will replace replace the characters ''&'', ''<'' and ''>''
2976 characters with the HTML/XML escape-encoded strings ('"&amp;"',
2977 '"&lt;"', and '"&gt;"', respectively).
2978
2979    Arguments:
2980 str - string to make substitutions in
2981
2982 \1f
2983 File: autogen.info,  Node: SCM in?,  Next: SCM join,  Prev: SCM html-escape-encode,  Up: Common Functions
2984
2985 3.5.13 'in?' - test for string in list
2986 --------------------------------------
2987
2988 Usage: (in?  test-string string-list ...)
2989 Return SCM_BOOL_T if the first argument string is found in one of the
2990 entries in the second (list-of-strings) argument.
2991
2992    Arguments:
2993 test-string - string to look for
2994 string-list - list of strings to check
2995
2996 \1f
2997 File: autogen.info,  Node: SCM join,  Next: SCM kr-string,  Prev: SCM in?,  Up: Common Functions
2998
2999 3.5.14 'join' - join string list with separator
3000 -----------------------------------------------
3001
3002 Usage: (join separator list ...)
3003 With the first argument as the separator string, joins together an
3004 a-list of strings into one long string.  The list may contain nested
3005 lists, partly because you cannot always control that.
3006
3007    Arguments:
3008 separator - string to insert between entries
3009 list - list of strings to join
3010
3011 \1f
3012 File: autogen.info,  Node: SCM kr-string,  Next: SCM lgpl,  Prev: SCM join,  Up: Common Functions
3013
3014 3.5.15 'kr-string' - emit string for K&R C
3015 ------------------------------------------
3016
3017 Usage: (kr-string string)
3018 Reform a string so that, when printed, a K&R C compiler will be able to
3019 compile the data and construct a string that contains exactly what the
3020 current string contains.  Many non-printing characters are replaced with
3021 escape sequences.  New-lines are replaced with a backslash-n-backslash
3022 and newline sequence,
3023
3024    Arguments:
3025 string - string to reformat
3026
3027 \1f
3028 File: autogen.info,  Node: SCM lgpl,  Next: SCM license,  Prev: SCM kr-string,  Up: Common Functions
3029
3030 3.5.16 'lgpl' - GNU Library General Public License
3031 --------------------------------------------------
3032
3033 Usage: (lgpl prog_name owner prefix)
3034 Emit a string that contains the GNU Library General Public License.
3035 This function is now deprecated.  Please *Note SCM
3036 license-description::.
3037
3038    Arguments:
3039 prog_name - name of the program under the LGPL
3040 owner - Grantor of the LGPL
3041 prefix - String for starting each output line
3042
3043 \1f
3044 File: autogen.info,  Node: SCM license,  Next: SCM license-description,  Prev: SCM lgpl,  Up: Common Functions
3045
3046 3.5.17 'license' - an arbitrary license
3047 ---------------------------------------
3048
3049 Usage: (license lic_name prog_name owner prefix)
3050 Emit a string that contains the named license.  This function is now
3051 deprecated.  Please *Note SCM license-description::.
3052
3053    Arguments:
3054 lic_name - file name of the license
3055 prog_name - name of the licensed program or library
3056 owner - Grantor of the License
3057 prefix - String for starting each output line
3058
3059 \1f
3060 File: autogen.info,  Node: SCM license-description,  Next: SCM license-full,  Prev: SCM license,  Up: Common Functions
3061
3062 3.5.18 'license-description' - Emit a license description
3063 ---------------------------------------------------------
3064
3065 Usage: (license-description license prog-name prefix [ owner ])
3066 Emit a string that contains a detailed license description, with
3067 substitutions for program name, copyright holder and a per-line prefix.
3068 This is the text typically used as part of a source file header.  For
3069 more details, *Note the license-full command: SCM license-full.
3070
3071    Arguments:
3072 license - name of license type
3073 prog-name - name of the program under the GPL
3074 prefix - String for starting each output line
3075 owner - Optional - owner of the program
3076
3077 \1f
3078 File: autogen.info,  Node: SCM license-full,  Next: SCM license-info,  Prev: SCM license-description,  Up: Common Functions
3079
3080 3.5.19 'license-full' - Emit the licensing information and description
3081 ----------------------------------------------------------------------
3082
3083 Usage: (license-full license prog-name prefix [ owner ] [ years ])
3084 Emit all the text that 'license-info' and 'license-description' would
3085 emit (*note 'license-info': SCM license-info, and *note
3086 'license-description': SCM license-description.), with all the same
3087 substitutions.
3088
3089    All of these depend upon the existence of a license file named after
3090 the 'license' argument with a '.lic' suffix.  That file should contain
3091 three blocks of text, each separated by two or more consecutive newline
3092 characters (at least one completely blank line).
3093
3094    The first section describes copyright attribution and the name of the
3095 usage licence.  For GNU software, this should be the text that is to be
3096 displayed with the program version.  Four text markers can be replaced:
3097 <PFX>, <program>, <years> and <owner>.
3098
3099    The second section is a short description of the terms of the
3100 license.  This is typically the kind of text that gets displayed in the
3101 header of source files.  Only the <PFX>, <owner> and <program> markers
3102 are substituted.
3103
3104    The third section is strictly the name of the license.  No marker
3105 substitutions are performed.
3106
3107      <PFX>Copyright (C) <years> <owner>, all rights reserved.
3108      <PFX>
3109      <PFX>This is free software. It is licensed for use,
3110      <PFX>modification and redistribution under the terms
3111      <PFX>of the GNU General Public License, version 3 or later
3112      <PFX>    <http://gnu.org/licenses/gpl.html>
3113
3114      <PFX><program> is free software: you can redistribute it
3115      <PFX>and/or modify it under the terms of the GNU General
3116      <PFX>Public License as published by the Free Software ...
3117
3118      the GNU General Public License, version 3 or later
3119
3120    Arguments:
3121 license - name of license type
3122 prog-name - name of the program under the GPL
3123 prefix - String for starting each output line
3124 owner - Optional - owner of the program
3125 years - Optional - copyright years
3126
3127 \1f
3128 File: autogen.info,  Node: SCM license-info,  Next: SCM license-name,  Prev: SCM license-full,  Up: Common Functions
3129
3130 3.5.20 'license-info' - Emit the licensing information and copyright years
3131 --------------------------------------------------------------------------
3132
3133 Usage: (license-info license prog-name prefix [ owner ] [ years ])
3134 Emit a string that contains the licensing description, with some
3135 substitutions for program name, copyright holder, a list of years when
3136 the source was modified, and a per-line prefix.  This text typically
3137 includes a brief license description and is often printed out when a
3138 program starts running or as part of the '--version' output.  For more
3139 details, *Note the license-full command: SCM license-full.
3140
3141    Arguments:
3142 license - name of license type
3143 prog-name - name of the program under the GPL
3144 prefix - String for starting each output line
3145 owner - Optional - owner of the program
3146 years - Optional - copyright years
3147
3148 \1f
3149 File: autogen.info,  Node: SCM license-name,  Next: SCM make-gperf,  Prev: SCM license-info,  Up: Common Functions
3150
3151 3.5.21 'license-name' - Emit the name of the license
3152 ----------------------------------------------------
3153
3154 Usage: (license-name license)
3155 Emit a string that contains the full name of the license.
3156
3157    Arguments:
3158 license - name of license type
3159
3160 \1f
3161 File: autogen.info,  Node: SCM make-gperf,  Next: SCM makefile-script,  Prev: SCM license-name,  Up: Common Functions
3162
3163 3.5.22 'make-gperf' - build a perfect hash function program
3164 -----------------------------------------------------------
3165
3166 Usage: (make-gperf name strings ...)
3167 Build a program to perform perfect hashes of a known list of input
3168 strings.  This function produces no output, but prepares a program
3169 named, 'gperf_<name>' for use by the gperf function *Note SCM gperf::.
3170
3171    This program will be obliterated as AutoGen exits.  However, you may
3172 incorporate the generated hashing function into your C program with
3173 commands something like the following:
3174
3175      [+ (shellf "sed '/^int main(/,$d;/^#line/d' ${gpdir}/%s.c"
3176      name ) +]
3177
3178    where 'name' matches the name provided to this 'make-perf' function.
3179 'gpdir' is the variable used to store the name of the temporary
3180 directory used to stash all the files.
3181
3182    Arguments:
3183 name - name of hash list
3184 strings - list of strings to hash
3185
3186 \1f
3187 File: autogen.info,  Node: SCM makefile-script,  Next: SCM max,  Prev: SCM make-gperf,  Up: Common Functions
3188
3189 3.5.23 'makefile-script' - create makefile script
3190 -------------------------------------------------
3191
3192 Usage: (makefile-script text)
3193 This function will take ordinary shell script text and reformat it so
3194 that it will work properly inside of a makefile shell script.  Not every
3195 shell construct can be supported; the intent is to have most ordinary
3196 scripts work without much, if any, alteration.
3197
3198    The following transformations are performed on the source text:
3199
3200   1. Trailing whitespace on each line is stripped.
3201
3202   2. Except for the last line, the string, " ; \\" is appended to the
3203      end of every line that does not end with certain special characters
3204      or keywords.  Note that this will mutilate multi-line quoted
3205      strings, but 'make' renders it impossible to use multi-line
3206      constructs anyway.
3207
3208   3. If the line ends with a backslash, it is left alone.
3209
3210   4. If the line ends with a semi-colon, conjunction operator, pipe
3211      (vertical bar) or one of the keywords "then", "else" or "in", then
3212      a space and a backslash is added, but no semi-colon.
3213
3214   5. The dollar sign character is doubled, unless it immediately
3215      precedes an opening parenthesis or the single character make macros
3216      '*', '<', '@', '?'  or '%'.  Other single character make macros
3217      that do not have enclosing parentheses will fail.  For shell usage
3218      of the "$@", "$?"  and "$*" macros, you must enclose them with
3219      curly braces, e.g., "${?}".  The ksh construct '$(<command>)' will
3220      not work.  Though some 'make's accept '${var}' constructs, this
3221      function will assume it is for shell interpretation and double the
3222      dollar character.  You must use '$(var)' for all 'make'
3223      substitutions.
3224
3225   6. Double dollar signs are replaced by four before the next character
3226      is examined.
3227
3228   7. Every line is prefixed with a tab, unless the first line already
3229      starts with a tab.
3230
3231   8. The newline character on the last line, if present, is suppressed.
3232
3233   9. Blank lines are stripped.
3234
3235   10. Lines starting with "@ifdef", "@ifndef", "@else" and "@endif" are
3236      presumed to be autoconf "sed" expression tags.  These lines will be
3237      emitted as-is, with no tab prefix and no line splicing backslash.
3238      These lines can then be processed at configure time with
3239      'AC_CONFIG_FILES' sed expressions, similar to:
3240
3241           sed "/^@ifdef foo/d;/^@endif foo/d;/^@ifndef foo/,/^@endif foo/d"
3242
3243 This function is intended to be used approximately as follows:
3244
3245      $(TARGET) : $(DEPENDENCIES)
3246      <+ (out-push-new) +>
3247      ....mostly arbitrary shell script text....
3248      <+ (makefile-script (out-pop #t)) +>
3249
3250    Arguments:
3251 text - the text of the script
3252
3253 \1f
3254 File: autogen.info,  Node: SCM max,  Next: SCM min,  Prev: SCM makefile-script,  Up: Common Functions
3255
3256 3.5.24 'max' - maximum value in list
3257 ------------------------------------
3258
3259 Usage: (max list ...)
3260 Return the maximum value in the list
3261
3262    Arguments:
3263 list - list of values.  Strings are converted to numbers
3264
3265 \1f
3266 File: autogen.info,  Node: SCM min,  Next: SCM prefix,  Prev: SCM max,  Up: Common Functions
3267
3268 3.5.25 'min' - minimum value in list
3269 ------------------------------------
3270
3271 Usage: (min list ...)
3272 Return the minimum value in the list
3273
3274    Arguments:
3275 list - list of values.  Strings are converted to numbers
3276
3277 \1f
3278 File: autogen.info,  Node: SCM prefix,  Next: SCM printf,  Prev: SCM min,  Up: Common Functions
3279
3280 3.5.26 'prefix' - prefix lines with a string
3281 --------------------------------------------
3282
3283 Usage: (prefix prefix text)
3284 Prefix every line in the second string with the first string.  This
3285 includes empty lines.  Trailing white space will be removed so if the
3286 prefix is all horizontal white space, then it will be removed from
3287 otherwise blank lines.  Also, if the last character is a newline, then
3288 *two* prefixes will be inserted into the result text.
3289
3290    For example, if the first string is "# " and the second contains:
3291      "two\nlines\n"
3292 The result string will contain:
3293      # two
3294      # lines
3295      #
3296
3297    The last line will be incomplete: no newline and no space after the
3298 hash character, either.
3299
3300    Arguments:
3301 prefix - string to insert at start of each line
3302 text - multi-line block of text
3303
3304 \1f
3305 File: autogen.info,  Node: SCM printf,  Next: SCM raw-shell-str,  Prev: SCM prefix,  Up: Common Functions
3306
3307 3.5.27 'printf' - format to stdout
3308 ----------------------------------
3309
3310 Usage: (printf format [ format-arg ...  ])
3311 Format a string using arguments from the alist.  Write to the standard
3312 out port.  The result will NOT appear in your output.  Use this to print
3313 information messages to a template user.  Use "(sprintf ...)"  to add
3314 text to your document.
3315
3316    Arguments:
3317 format - formatting string
3318 format-arg - Optional - list of arguments to formatting string
3319
3320 \1f
3321 File: autogen.info,  Node: SCM raw-shell-str,  Next: SCM shell,  Prev: SCM printf,  Up: Common Functions
3322
3323 3.5.28 'raw-shell-str' - single quote shell string
3324 --------------------------------------------------
3325
3326 Usage: (raw-shell-str string)
3327 Convert the text of the string into a singly quoted string that a normal
3328 shell will process into the original string.  (It will not do macro
3329 expansion later, either.)  Contained single quotes become tripled, with
3330 the middle quote escaped with a backslash.  Normal shells will
3331 reconstitute the original string.
3332
3333    *Notice*: some shells will not correctly handle unusual non-printing
3334 characters.  This routine works for most reasonably conventional ASCII
3335 strings.
3336
3337    Arguments:
3338 string - string to transform
3339
3340 \1f
3341 File: autogen.info,  Node: SCM shell,  Next: SCM shell-str,  Prev: SCM raw-shell-str,  Up: Common Functions
3342
3343 3.5.29 'shell' - invoke a shell script
3344 --------------------------------------
3345
3346 Usage: (shell command ...)
3347 Generate a string by writing the value to a server shell and reading the
3348 output back in.  The template programmer is responsible for ensuring
3349 that it completes within 10 seconds.  If it does not, the server will be
3350 killed, the output tossed and a new server started.
3351
3352    Please note: This is the same server process used by the '#shell'
3353 definitions directive and backquoted '`' definitions.  There may be left
3354 over state from previous shell expressions and the '`' processing in the
3355 declarations.  However, a 'cd' to the original directory is always
3356 issued before the new command is issued.
3357
3358    Also note: When initializing, autogen will set the environment
3359 variable "AGexe" to the full path of the autogen executable.
3360
3361    Arguments:
3362 command - shell command - the result is from stdout
3363
3364 \1f
3365 File: autogen.info,  Node: SCM shell-str,  Next: SCM shellf,  Prev: SCM shell,  Up: Common Functions
3366
3367 3.5.30 'shell-str' - double quote shell string
3368 ----------------------------------------------
3369
3370 Usage: (shell-str string)
3371 Convert the text of the string into a double quoted string that a normal
3372 shell will process into the original string, almost.  It will add the
3373 escape character '\\' before two special characters to accomplish this:
3374 the backslash '\\' and double quote '"'.
3375
3376    *Notice*: some shells will not correctly handle unusual non-printing
3377 characters.  This routine works for most reasonably conventional ASCII
3378 strings.
3379
3380    *WARNING*:
3381 This function omits the extra backslash in front of a backslash,
3382 however, if it is followed by either a backquote or a dollar sign.  It
3383 must do this because otherwise it would be impossible to protect the
3384 dollar sign or backquote from shell evaluation.  Consequently, it is not
3385 possible to render the strings "\\$" or "\\'".  The lesser of two evils.
3386
3387    All others characters are copied directly into the output.
3388
3389    The 'sub-shell-str' variation of this routine behaves identically,
3390 except that the extra backslash is omitted in front of '"' instead of
3391 '`'.  You have to think about it.  I'm open to suggestions.
3392
3393    Meanwhile, the best way to document is with a detailed output
3394 example.  If the backslashes make it through the text processing
3395 correctly, below you will see what happens with three example strings.
3396 The first example string contains a list of quoted 'foo's, the second is
3397 the same with a single backslash before the quote characters and the
3398 last is with two backslash escapes.  Below each is the result of the
3399 'raw-shell-str', 'shell-str' and 'sub-shell-str' functions.
3400
3401      foo[0]           ''foo'' 'foo' "foo" `foo` $foo
3402      raw-shell-str -> \'\''foo'\'\'' '\''foo'\'' "foo" `foo` $foo'
3403      shell-str     -> "''foo'' 'foo' \"foo\" `foo` $foo"
3404      sub-shell-str -> `''foo'' 'foo' "foo" \`foo\` $foo`
3405
3406      foo[1]           \'bar\' \"bar\" \`bar\` \$bar
3407      raw-shell-str -> '\'\''bar\'\'' \"bar\" \`bar\` \$bar'
3408      shell-str     -> "\\'bar\\' \\\"bar\\\" \`bar\` \$bar"
3409      sub-shell-str -> `\\'bar\\' \"bar\" \\\`bar\\\` \$bar`
3410
3411      foo[2]           \\'BAZ\\' \\"BAZ\\" \\`BAZ\\` \\$BAZ
3412      raw-shell-str -> '\\'\''BAZ\\'\'' \\"BAZ\\" \\`BAZ\\` \\$BAZ'
3413      shell-str     -> "\\\\'BAZ\\\\' \\\\\"BAZ\\\\\" \\\`BAZ\\\` \\\$BAZ"
3414      sub-shell-str -> `\\\\'BAZ\\\\' \\\"BAZ\\\" \\\\\`BAZ\\\\\` \\\$BAZ`
3415
3416    There should be four, three, five and three backslashes for the four
3417 examples on the last line, respectively.  The next to last line should
3418 have four, five, three and three backslashes.  If this was not
3419 accurately reproduced, take a look at the agen5/test/shell.test test.
3420 Notice the backslashes in front of the dollar signs.  It goes from zero
3421 to one to three for the "cooked" string examples.
3422
3423    Arguments:
3424 string - string to transform
3425
3426 \1f
3427 File: autogen.info,  Node: SCM shellf,  Next: SCM sprintf,  Prev: SCM shell-str,  Up: Common Functions
3428
3429 3.5.31 'shellf' - format a string, run shell
3430 --------------------------------------------
3431
3432 Usage: (shellf format [ format-arg ...  ])
3433 Format a string using arguments from the alist, then send the result to
3434 the shell for interpretation.
3435
3436    Arguments:
3437 format - formatting string
3438 format-arg - Optional - list of arguments to formatting string
3439
3440 \1f
3441 File: autogen.info,  Node: SCM sprintf,  Next: SCM string-capitalize,  Prev: SCM shellf,  Up: Common Functions
3442
3443 3.5.32 'sprintf' - format a string
3444 ----------------------------------
3445
3446 Usage: (sprintf format [ format-arg ...  ])
3447 Format a string using arguments from the alist.
3448
3449    Arguments:
3450 format - formatting string
3451 format-arg - Optional - list of arguments to formatting string
3452
3453 \1f
3454 File: autogen.info,  Node: SCM string-capitalize,  Next: SCM string-capitalize!,  Prev: SCM sprintf,  Up: Common Functions
3455
3456 3.5.33 'string-capitalize' - capitalize a new string
3457 ----------------------------------------------------
3458
3459 Usage: (string-capitalize str)
3460 Create a new SCM string containing the same text as the original, only
3461 all the first letter of each word is upper cased and all other letters
3462 are made lower case.
3463
3464    Arguments:
3465 str - input string
3466
3467 \1f
3468 File: autogen.info,  Node: SCM string-capitalize!,  Next: SCM *=*,  Prev: SCM string-capitalize,  Up: Common Functions
3469
3470 3.5.34 'string-capitalize!' - capitalize a string
3471 -------------------------------------------------
3472
3473 Usage: (string-capitalize!  str)
3474 capitalize all the words in an SCM string.
3475
3476    Arguments:
3477 str - input/output string
3478
3479 \1f
3480 File: autogen.info,  Node: SCM *=*,  Next: SCM *==*,  Prev: SCM string-capitalize!,  Up: Common Functions
3481
3482 3.5.35 'string-contains-eqv?' - caseless substring
3483 --------------------------------------------------
3484
3485 Usage: (*=* text match)
3486 string-contains-eqv?: Test to see if a string contains an equivalent
3487 string.  'equivalent' means the strings match, but without regard to
3488 character case and certain characters are considered 'equivalent'.
3489 Viz., '-', '_' and '^' are equivalent.
3490
3491    Arguments:
3492 text - text to test for pattern
3493 match - pattern/substring to search for
3494
3495 \1f
3496 File: autogen.info,  Node: SCM *==*,  Next: SCM string-downcase,  Prev: SCM *=*,  Up: Common Functions
3497
3498 3.5.36 'string-contains?' - substring match
3499 -------------------------------------------
3500
3501 Usage: (*==* text match)
3502 string-contains?: Test to see if a string contains a substring.
3503 "strstr(3)" will find an address.
3504
3505    Arguments:
3506 text - text to test for pattern
3507 match - pattern/substring to search for
3508
3509 \1f
3510 File: autogen.info,  Node: SCM string-downcase,  Next: SCM string-downcase!,  Prev: SCM *==*,  Up: Common Functions
3511
3512 3.5.37 'string-downcase' - lower case a new string
3513 --------------------------------------------------
3514
3515 Usage: (string-downcase str)
3516 Create a new SCM string containing the same text as the original, only
3517 all the upper case letters are changed to lower case.
3518
3519    Arguments:
3520 str - input string
3521
3522 \1f
3523 File: autogen.info,  Node: SCM string-downcase!,  Next: SCM *~,  Prev: SCM string-downcase,  Up: Common Functions
3524
3525 3.5.38 'string-downcase!' - make a string be lower case
3526 -------------------------------------------------------
3527
3528 Usage: (string-downcase!  str)
3529 Change to lower case all the characters in an SCM string.
3530
3531    Arguments:
3532 str - input/output string
3533
3534 \1f
3535 File: autogen.info,  Node: SCM *~,  Next: SCM *~~,  Prev: SCM string-downcase!,  Up: Common Functions
3536
3537 3.5.39 'string-end-eqv-match?' - caseless regex ending
3538 ------------------------------------------------------
3539
3540 Usage: (*~ text match)
3541 string-end-eqv-match?: Test to see if a string ends with a pattern.
3542 Case is not significant.
3543
3544    Arguments:
3545 text - text to test for pattern
3546 match - pattern/substring to search for
3547
3548 \1f
3549 File: autogen.info,  Node: SCM *~~,  Next: SCM *=,  Prev: SCM *~,  Up: Common Functions
3550
3551 3.5.40 'string-end-match?' - regex match end
3552 --------------------------------------------
3553
3554 Usage: (*~~ text match)
3555 string-end-match?: Test to see if a string ends with a pattern.  Case is
3556 significant.
3557
3558    Arguments:
3559 text - text to test for pattern
3560 match - pattern/substring to search for
3561
3562 \1f
3563 File: autogen.info,  Node: SCM *=,  Next: SCM *==,  Prev: SCM *~~,  Up: Common Functions
3564
3565 3.5.41 'string-ends-eqv?' - caseless string ending
3566 --------------------------------------------------
3567
3568 Usage: (*= text match)
3569 string-ends-eqv?: Test to see if a string ends with an equivalent
3570 string.
3571
3572    Arguments:
3573 text - text to test for pattern
3574 match - pattern/substring to search for
3575
3576 \1f
3577 File: autogen.info,  Node: SCM *==,  Next: SCM ==,  Prev: SCM *=,  Up: Common Functions
3578
3579 3.5.42 'string-ends-with?' - string ending
3580 ------------------------------------------
3581
3582 Usage: (*== text match)
3583 string-ends-with?: Test to see if a string ends with a substring.
3584 strcmp(3) returns zero for comparing the string ends.
3585
3586    Arguments:
3587 text - text to test for pattern
3588 match - pattern/substring to search for
3589
3590 \1f
3591 File: autogen.info,  Node: SCM ==,  Next: SCM ~,  Prev: SCM *==,  Up: Common Functions
3592
3593 3.5.43 'string-equals?' - string matching
3594 -----------------------------------------
3595
3596 Usage: (== text match)
3597 string-equals?: Test to see if two strings exactly match.
3598
3599    Arguments:
3600 text - text to test for pattern
3601 match - pattern/substring to search for
3602
3603 \1f
3604 File: autogen.info,  Node: SCM ~,  Next: SCM =,  Prev: SCM ==,  Up: Common Functions
3605
3606 3.5.44 'string-eqv-match?' - caseless regex match
3607 -------------------------------------------------
3608
3609 Usage: (~ text match)
3610 string-eqv-match?: Test to see if a string fully matches a pattern.
3611 Case is not significant, but any character equivalences must be
3612 expressed in your regular expression.
3613
3614    Arguments:
3615 text - text to test for pattern
3616 match - pattern/substring to search for
3617
3618 \1f
3619 File: autogen.info,  Node: SCM =,  Next: SCM *~*,  Prev: SCM ~,  Up: Common Functions
3620
3621 3.5.45 'string-eqv?' - caseless match
3622 -------------------------------------
3623
3624 Usage: (= text match)
3625 string-eqv?: Test to see if two strings are equivalent.  'equivalent'
3626 means the strings match, but without regard to character case and
3627 certain characters are considered 'equivalent'.  Viz., '-', '_' and '^'
3628 are equivalent.  If the arguments are not strings, then the result of
3629 the numeric comparison is returned.
3630
3631    This is an overloaded operation.  If the arguments are both numbers,
3632 then the query is passed through to 'scm_num_eq_p()', otherwise the
3633 result depends on the SCMs being strictly equal.
3634
3635    Arguments:
3636 text - text to test for pattern
3637 match - pattern/substring to search for
3638
3639 \1f
3640 File: autogen.info,  Node: SCM *~*,  Next: SCM *~~*,  Prev: SCM =,  Up: Common Functions
3641
3642 3.5.46 'string-has-eqv-match?' - caseless regex contains
3643 --------------------------------------------------------
3644
3645 Usage: (*~* text match)
3646 string-has-eqv-match?: Test to see if a string contains a pattern.  Case
3647 is not significant.
3648
3649    Arguments:
3650 text - text to test for pattern
3651 match - pattern/substring to search for
3652
3653 \1f
3654 File: autogen.info,  Node: SCM *~~*,  Next: SCM ~~,  Prev: SCM *~*,  Up: Common Functions
3655
3656 3.5.47 'string-has-match?' - contained regex match
3657 --------------------------------------------------
3658
3659 Usage: (*~~* text match)
3660 string-has-match?: Test to see if a string contains a pattern.  Case is
3661 significant.
3662
3663    Arguments:
3664 text - text to test for pattern
3665 match - pattern/substring to search for
3666
3667 \1f
3668 File: autogen.info,  Node: SCM ~~,  Next: SCM ~*,  Prev: SCM *~~*,  Up: Common Functions
3669
3670 3.5.48 'string-match?' - regex match
3671 ------------------------------------
3672
3673 Usage: (~~ text match)
3674 string-match?: Test to see if a string fully matches a pattern.  Case is
3675 significant.
3676
3677    Arguments:
3678 text - text to test for pattern
3679 match - pattern/substring to search for
3680
3681 \1f
3682 File: autogen.info,  Node: SCM ~*,  Next: SCM ~~*,  Prev: SCM ~~,  Up: Common Functions
3683
3684 3.5.49 'string-start-eqv-match?' - caseless regex start
3685 -------------------------------------------------------
3686
3687 Usage: (~* text match)
3688 string-start-eqv-match?: Test to see if a string starts with a pattern.
3689 Case is not significant.
3690
3691    Arguments:
3692 text - text to test for pattern
3693 match - pattern/substring to search for
3694
3695 \1f
3696 File: autogen.info,  Node: SCM ~~*,  Next: SCM =*,  Prev: SCM ~*,  Up: Common Functions
3697
3698 3.5.50 'string-start-match?' - regex match start
3699 ------------------------------------------------
3700
3701 Usage: (~~* text match)
3702 string-start-match?: Test to see if a string starts with a pattern.
3703 Case is significant.
3704
3705    Arguments:
3706 text - text to test for pattern
3707 match - pattern/substring to search for
3708
3709 \1f
3710 File: autogen.info,  Node: SCM =*,  Next: SCM ==*,  Prev: SCM ~~*,  Up: Common Functions
3711
3712 3.5.51 'string-starts-eqv?' - caseless string start
3713 ---------------------------------------------------
3714
3715 Usage: (=* text match)
3716 string-starts-eqv?: Test to see if a string starts with an equivalent
3717 string.
3718
3719    Arguments:
3720 text - text to test for pattern
3721 match - pattern/substring to search for
3722
3723 \1f
3724 File: autogen.info,  Node: SCM ==*,  Next: SCM string-substitute,  Prev: SCM =*,  Up: Common Functions
3725
3726 3.5.52 'string-starts-with?' - string starting
3727 ----------------------------------------------
3728
3729 Usage: (==* text match)
3730 string-starts-with?: Test to see if a string starts with a substring.
3731
3732    Arguments:
3733 text - text to test for pattern
3734 match - pattern/substring to search for
3735
3736 \1f
3737 File: autogen.info,  Node: SCM string-substitute,  Next: SCM string-table-add,  Prev: SCM ==*,  Up: Common Functions
3738
3739 3.5.53 'string-substitute' - multiple global replacements
3740 ---------------------------------------------------------
3741
3742 Usage: (string-substitute source match repl)
3743 'match' and 'repl' may be either a single string or a list of strings.
3744 Either way, they must have the same structure and number of elements.
3745 For example, to replace all amphersands, less than and greater than
3746 characters, do something like this:
3747
3748      (string-substitute source
3749      (list "&"     "<"    ">")
3750      (list "&amp;" "&lt;" "&gt;"))
3751
3752    Arguments:
3753 source - string to transform
3754 match - substring or substring list to be replaced
3755 repl - replacement strings or substrings
3756
3757 \1f
3758 File: autogen.info,  Node: SCM string-table-add,  Next: SCM string-table-add-ref,  Prev: SCM string-substitute,  Up: Common Functions
3759
3760 3.5.54 'string-table-add' - Add an entry to a string table
3761 ----------------------------------------------------------
3762
3763 Usage: (string-table-add st-name str-val)
3764 Check for a duplicate string and, if none, then insert a new string into
3765 the string table.  In all cases, returns the character index of the
3766 beginning of the string in the table.
3767
3768    The returned index can be used in expressions like:
3769      string_array + <returned-value>
3770 that will yield the address of the first byte of the inserted string.
3771 See the 'strtable.test' AutoGen test for a usage example.
3772
3773    Arguments:
3774 st-name - the name of the array of characters
3775 str-val - the (possibly) new value to add
3776
3777 \1f
3778 File: autogen.info,  Node: SCM string-table-add-ref,  Next: SCM string-table-new,  Prev: SCM string-table-add,  Up: Common Functions
3779
3780 3.5.55 'string-table-add-ref' - Add an entry to a string table, get reference
3781 -----------------------------------------------------------------------------
3782
3783 Usage: (string-table-add-ref st-name str-val)
3784 Identical to string-table-add, except the value returned is the string
3785 "st-name" '+' and the index returned by string-table-add.
3786
3787    Arguments:
3788 st-name - the name of the array of characters
3789 str-val - the (possibly) new value to add
3790
3791 \1f
3792 File: autogen.info,  Node: SCM string-table-new,  Next: SCM string-table-size,  Prev: SCM string-table-add-ref,  Up: Common Functions
3793
3794 3.5.56 'string-table-new' - create a string table
3795 -------------------------------------------------
3796
3797 Usage: (string-table-new st-name)
3798 This function will create an array of characters.  The companion
3799 functions, (*Note SCM string-table-add::, *Note SCM
3800 string-table-add-ref::, and *note SCM emit-string-table::) will insert
3801 text and emit the populated table.
3802
3803    With these functions, it should be much easier to construct
3804 structures containing string offsets instead of string pointers.  That
3805 can be very useful when transmitting, storing or sharing data with
3806 different address spaces.
3807
3808 Here is a brief example copied from the strtable.test test:
3809
3810      [+ (string-table-new "scribble")
3811         (out-push-new) ;; redirect output to temporary
3812         (define ct 1)  +][+
3813
3814      FOR str IN that was the week that was +][+
3815        (set! ct (+ ct 1))
3816      +]
3817          [+ (string-table-add-ref "scribble" (get "str")) +],[+
3818      ENDFOR  +]
3819      [+ (out-suspend "main")
3820         (emit-string-table "scribble")
3821         (ag-fprintf 0 "\nchar const *ap[%d] = {" ct)
3822         (out-resume "main")
3823         (out-pop #t) ;; now dump out the redirected output +]
3824          NULL };
3825
3826 Some explanation:
3827
3828 I added the '(out-push-new)' because the string table text is diverted
3829 into an output stream named, "scribble" and I want to have the string
3830 table emitted before the string table references.  The string table
3831 references are also emitted inside the 'FOR' loop.  So, when the loop is
3832 done, the current output is suspended under the name, "main" and the
3833 "scribble" table is then emitted into the primary output.
3834 ('emit-string-table' inserts its output directly into the current output
3835 stream.  It does not need to be the last function in an AutoGen macro
3836 block.)  Next I 'ag-fprintf' the array-of-pointer declaration directly
3837 into the current output.  Finally I restore the "main" output stream and
3838 '(out-pop #t)'-it into the main output stream.
3839
3840    Here is the result.  Note that duplicate strings are not repeated in
3841 the string table:
3842
3843      static char const scribble[18] =
3844          "that\0" "was\0"  "the\0"  "week\0";
3845
3846      char const *ap[7] = {
3847          scribble+0,
3848          scribble+5,
3849          scribble+9,
3850          scribble+13,
3851          scribble+0,
3852          scribble+5,
3853          NULL };
3854
3855    These functions use the global name space 'stt-*' in addition to the
3856 function names.
3857
3858    If you utilize this in your programming, it is recommended that you
3859 prevent printf format usage warnings with the GCC option
3860 '-Wno-format-contains-nul'
3861
3862    Arguments:
3863 st-name - the name of the array of characters
3864
3865 \1f
3866 File: autogen.info,  Node: SCM string-table-size,  Next: SCM string->c-name!,  Prev: SCM string-table-new,  Up: Common Functions
3867
3868 3.5.57 'string-table-size' - print the current size of a string table
3869 ---------------------------------------------------------------------
3870
3871 Usage: (string-table-size st-name)
3872 Returns the current byte count of the string table.
3873
3874    Arguments:
3875 st-name - the name of the array of characters
3876
3877 \1f
3878 File: autogen.info,  Node: SCM string->c-name!,  Next: SCM string->camelcase,  Prev: SCM string-table-size,  Up: Common Functions
3879
3880 3.5.58 'string->c-name!' - map non-name chars to underscore
3881 -----------------------------------------------------------
3882
3883 Usage: (string->c-name!  str)
3884 Change all the graphic characters that are invalid in a C name token
3885 into underscores.  Whitespace characters are ignored.  Any other
3886 character type (i.e.  non-graphic and non-white) will cause a failure.
3887
3888    Arguments:
3889 str - input/output string
3890
3891 \1f
3892 File: autogen.info,  Node: SCM string->camelcase,  Next: SCM string-tr,  Prev: SCM string->c-name!,  Up: Common Functions
3893
3894 3.5.59 'string->camelcase' - make a string be CamelCase
3895 -------------------------------------------------------
3896
3897 Usage: (string->camelcase str)
3898 Capitalize the first letter of each block of letters and numbers, and
3899 stripping out characters that are not alphanumerics.  For example,
3900 "alpha-beta0gamma" becomes "AlphaBeta0gamma".
3901
3902    Arguments:
3903 str - input/output string
3904
3905 \1f
3906 File: autogen.info,  Node: SCM string-tr,  Next: SCM string-tr!,  Prev: SCM string->camelcase,  Up: Common Functions
3907
3908 3.5.60 'string-tr' - convert characters with new result
3909 -------------------------------------------------------
3910
3911 Usage: (string-tr source match translation)
3912 This is identical to 'string-tr!', except that it does not over-write
3913 the previous value.
3914
3915    Arguments:
3916 source - string to transform
3917 match - characters to be converted
3918 translation - conversion list
3919
3920 \1f
3921 File: autogen.info,  Node: SCM string-tr!,  Next: SCM string-upcase,  Prev: SCM string-tr,  Up: Common Functions
3922
3923 3.5.61 'string-tr!' - convert characters
3924 ----------------------------------------
3925
3926 Usage: (string-tr!  source match translation)
3927 This is the same as the 'tr(1)' program, except the string to transform
3928 is the first argument.  The second and third arguments are used to
3929 construct mapping arrays for the transformation of the first argument.
3930
3931    It is too bad this little program has so many different and
3932 incompatible implementations!
3933
3934    Arguments:
3935 source - string to transform
3936 match - characters to be converted
3937 translation - conversion list
3938
3939 \1f
3940 File: autogen.info,  Node: SCM string-upcase,  Next: SCM string-upcase!,  Prev: SCM string-tr!,  Up: Common Functions
3941
3942 3.5.62 'string-upcase' - upper case a new string
3943 ------------------------------------------------
3944
3945 Usage: (string-upcase str)
3946 Create a new SCM string containing the same text as the original, only
3947 all the lower case letters are changed to upper case.
3948
3949    Arguments:
3950 str - input string
3951
3952 \1f
3953 File: autogen.info,  Node: SCM string-upcase!,  Next: SCM sub-shell-str,  Prev: SCM string-upcase,  Up: Common Functions
3954
3955 3.5.63 'string-upcase!' - make a string be upper case
3956 -----------------------------------------------------
3957
3958 Usage: (string-upcase!  str)
3959 Change to upper case all the characters in an SCM string.
3960
3961    Arguments:
3962 str - input/output string
3963
3964 \1f
3965 File: autogen.info,  Node: SCM sub-shell-str,  Next: SCM sum,  Prev: SCM string-upcase!,  Up: Common Functions
3966
3967 3.5.64 'sub-shell-str' - back quoted (sub-)shell string
3968 -------------------------------------------------------
3969
3970 Usage: (sub-shell-str string)
3971 This function is substantially identical to 'shell-str', except that the
3972 quoting character is '`' and the "leave the escape alone" character is
3973 '"'.
3974
3975    Arguments:
3976 string - string to transform
3977
3978 \1f
3979 File: autogen.info,  Node: SCM sum,  Next: SCM time-string->number,  Prev: SCM sub-shell-str,  Up: Common Functions
3980
3981 3.5.65 'sum' - sum of values in list
3982 ------------------------------------
3983
3984 Usage: (sum list ...)
3985 Compute the sum of the list of expressions.
3986
3987    Arguments:
3988 list - list of values.  Strings are converted to numbers
3989
3990 \1f
3991 File: autogen.info,  Node: SCM time-string->number,  Next: SCM version-compare,  Prev: SCM sum,  Up: Common Functions
3992
3993 3.5.66 'time-string->number' - duration string to seconds
3994 ---------------------------------------------------------
3995
3996 Usage: (time-string->number time_spec)
3997 Convert the argument string to a time period in seconds.  The string may
3998 use multiple parts consisting of days, hours minutes and seconds.  These
3999 are indicated with a suffix of 'd', 'h', 'm' and 's' respectively.
4000 Hours, minutes and seconds may also be represented with 'HH:MM:SS' or,
4001 without hours, as 'MM:SS'.
4002
4003    Arguments:
4004 time_spec - string to parse
4005
4006 \1f
4007 File: autogen.info,  Node: SCM version-compare,  Prev: SCM time-string->number,  Up: Common Functions
4008
4009 3.5.67 'version-compare' - compare two version numbers
4010 ------------------------------------------------------
4011
4012 Usage: (version-compare op v1 v2)
4013 Converts v1 and v2 strings into 64 bit values and returns the result of
4014 running 'op' on those values.  It assumes that the version is a 1 to 4
4015 part dot-separated series of numbers.  Suffixes like, "5pre4" or
4016 "5-pre4" will be interpreted as two numbers.  The first number ("5" in
4017 this case) will be decremented and the number after the "pre" will be
4018 added to 0xC000.  (Unless your platform is unable to support 64 bit
4019 integer arithmetic.  Then it will be added to 0xC0.)  Consequently,
4020 these yield true:
4021      (version-compare > "5.8.5"       "5.8.5-pre4")
4022      (version-compare > "5.8.5-pre10" "5.8.5-pre4")
4023
4024    Arguments:
4025 op - comparison operator
4026 v1 - first version
4027 v2 - compared-to version
4028
4029 \1f
4030 File: autogen.info,  Node: native macros,  Next: output controls,  Prev: Common Functions,  Up: Template File
4031
4032 3.6 AutoGen Native Macros
4033 =========================
4034
4035 This section describes the various AutoGen natively defined macros.
4036 Unlike the Scheme functions, some of these macros are "block macros"
4037 with a scope that extends through a terminating macro.  Block macros
4038 must not overlap.  That is to say, a block macro started within the
4039 scope of an encompassing block macro must have its matching end macro
4040 appear before the encompassing block macro is either ended or
4041 subdivided.
4042
4043    The block macros are these:
4044
4045 'CASE'
4046      This macro has scope through the 'ESAC' macro.  The scope is
4047      subdivided by 'SELECT' macros.  You must have at least one 'SELECT'
4048      macro.
4049
4050 'DEFINE'
4051      This macro has scope through the 'ENDDEF' macro.  The defined user
4052      macro can never be a block macro.  This macro is extracted from the
4053      template before the template is processed.  Consequently, you
4054      cannot select a definition based on context.  You can, however,
4055      place them all at the end of the file.
4056
4057 'FOR'
4058      This macro has scope through the 'ENDFOR' macro.
4059
4060 'IF'
4061      This macro has scope through the 'ENDIF' macro.  The scope may be
4062      subdivided by 'ELIF' and 'ELSE' macros.  Obviously, there may be
4063      only one 'ELSE' macro and it must be the last of these
4064      subdivisions.
4065
4066 'INCLUDE'
4067      This macro has the scope of the included file.  It is a block macro
4068      in the sense that the included file must not contain any incomplete
4069      block macros.
4070
4071 'WHILE'
4072      This macro has scope through the 'ENDWHILE' macro.
4073 * Menu:
4074
4075 * AGMacro syntax::   AutoGen Macro Syntax
4076 * BREAK::            BREAK - Leave a FOR or WHILE macro
4077 * CASE::             CASE - Select one of several template blocks
4078 * COMMENT::          COMMENT - A block of comment to be ignored
4079 * CONTINUE::         CONTINUE - Skip to end of a FOR or WHILE macro.
4080 * DEBUG::            DEBUG - Print debug message to trace output
4081 * DEFINE::           DEFINE - Define a user AutoGen macro
4082 * ELIF::             ELIF - Alternate Conditional Template Block
4083 * ELSE::             ELSE - Alternate Template Block
4084 * ENDDEF::           ENDDEF - Ends a macro definition.
4085 * ENDFOR::           ENDFOR - Terminates the 'FOR' function template block
4086 * ENDIF::            ENDIF - Terminate the 'IF' Template Block
4087 * ENDWHILE::         ENDWHILE - Terminate the 'WHILE' Template Block
4088 * ESAC::             ESAC - Terminate the 'CASE' Template Block
4089 * EXPR::             EXPR - Evaluate and emit an Expression
4090 * FOR::              FOR - Emit a template block multiple times
4091 * IF::               IF - Conditionally Emit a Template Block
4092 * INCLUDE::          INCLUDE - Read in and emit a template block
4093 * INVOKE::           INVOKE - Invoke a User Defined Macro
4094 * RETURN::           RETURN - Leave an INVOKE-d (DEFINE) macro
4095 * SELECT::           SELECT - Selection block for CASE function
4096 * UNKNOWN::          UNKNOWN - Either a user macro or a value name.
4097 * WHILE::            WHILE - Conditionally loop over a Template Block
4098 * shell command::    Inserting text from a shell script
4099 * guile command::    Inserting text from a scheme script
4100
4101 \1f
4102 File: autogen.info,  Node: AGMacro syntax,  Next: BREAK,  Up: native macros
4103
4104 3.6.1 AutoGen Macro Syntax
4105 --------------------------
4106
4107 The general syntax is:
4108
4109      [ { <native-macro-name> | <user-defined-name> } ] [ <arg> ... ]
4110
4111 The syntax for '<arg>' depends on the particular macro, but is generally
4112 a full expression (*note expression syntax::).  Here are the exceptions
4113 to that general rule:
4114
4115   1. 'INVOKE' macros, implicit or explicit, must be followed by a list
4116      of name/string value pairs.  The string values are simple
4117      expressions, as described above.
4118
4119      That is, the 'INVOKE' syntax is one of these two:
4120           <user-macro-name> [ <name> [ = <expression> ] ... ]
4121
4122           INVOKE <name-expression> [ <name> [ = <expression> ] ... ]
4123
4124   2. AutoGen FOR macros must be in one of three forms:
4125
4126           FOR <name> [ <separator-string> ]
4127
4128           FOR <name> (...Scheme expression list)
4129
4130           FOR <name> IN <string-entry> [ ... ]
4131      where:
4132      '<name>'
4133           must be a simple name.
4134      '<separator-string>'
4135           is inserted between copies of the enclosed block.  Do not try
4136           to use "IN" as your separator string.  It won't work.
4137      '<string-entry>'
4138           is an entry in a list of strings.  "'<name>'" is assigned each
4139           value from the "'IN'" list before expanding the 'FOR' block.
4140      '(...Scheme expression list)'
4141           is expected to contain one or more of the 'for-from',
4142           'for-to', 'for-by', and 'for-sep' functions.  (*Note FOR::,
4143           and *note AutoGen Functions::)
4144
4145      The first two forms iterate over the 'FOR' block if '<name>' is
4146      found in the AutoGen values.  The last form will create the AutoGen
4147      value named '<name>'.
4148
4149   3. AutoGen 'DEFINE' macros must be followed by a simple name.
4150      Anything after that is ignored.  Consequently, that "comment space"
4151      may be used to document any named values the macro expects to have
4152      set up as arguments.  *Note DEFINE::.
4153
4154   4. The AutoGen 'COMMENT', 'ELSE', 'ESAC' and the 'END*' macros take no
4155      arguments and ignore everything after the macro name (e.g.  see
4156      *note COMMENT::)
4157
4158 \1f
4159 File: autogen.info,  Node: BREAK,  Next: CASE,  Prev: AGMacro syntax,  Up: native macros
4160
4161 3.6.2 BREAK - Leave a FOR or WHILE macro
4162 ----------------------------------------
4163
4164 This will unwind the loop context and resume after ENDFOR/ENDWHILE. Note
4165 that unless this happens to be the last iteration anyway, the
4166 (last-for?)  function will never yield "#t".
4167
4168 \1f
4169 File: autogen.info,  Node: CASE,  Next: COMMENT,  Prev: BREAK,  Up: native macros
4170
4171 3.6.3 CASE - Select one of several template blocks
4172 --------------------------------------------------
4173
4174 The arguments are evaluated and converted to a string, if necessary.  A
4175 simple name will be interpreted as an AutoGen value name and its value
4176 will be used by the 'SELECT' macros (see the example below and the
4177 expression evaluation function, *note EXPR::).  The scope of the macro
4178 is up to the matching 'ESAC' macro.  Within the scope of a 'CASE', this
4179 string is matched against case selection macros.  There are sixteen
4180 match macros that are derived from four different ways matches may be
4181 performed, plus an "always true", "true if the AutoGen value was found",
4182 and "true if no AutoGen value was found" matches.  The codes for the
4183 nineteen match macros are formed as follows:
4184
4185   1. Must the match start matching from the beginning of the string?  If
4186      not, then the match macro code starts with an asterisk ('*').
4187   2. Must the match finish matching at the end of the string?  If not,
4188      then the match macro code ends with an asterisk ('*').
4189   3. Is the match a pattern match or a string comparison?  If a
4190      comparison, use an equal sign ('=').  If a pattern match, use a
4191      tilde ('~').
4192   4. Is the match case sensitive?  If alphabetic case is important,
4193      double the tilde or equal sign.
4194   5. Do you need a default match when none of the others match?  Use a
4195      single asterisk ('*').
4196   6. Do you need to distinguish between an empty string value and a
4197      value that was not found?  Use the non-existence test ('!E') before
4198      testing a full match against an empty string ('== ''').  There is
4199      also an existence test ('+E'), more for symmetry than for practical
4200      use.
4201
4202 For example:
4203
4204      [+ CASE <full-expression> +]
4205      [+ ~~*  "[Tt]est" +]reg exp must match at start, not at end
4206      [+ ==   "TeSt"    +]a full-string, case sensitive compare
4207      [+ =    "TEST"    +]a full-string, case insensitive compare
4208      [+ !E             +]not exists - matches if no AutoGen value found
4209      [+ ==   ""        +]expression yielded a zero-length string
4210      [+ +E             +]exists - matches if there is any value result
4211      [+ *              +]always match - no testing
4212      [+ ESAC +]
4213
4214    '<full-expression>' (*note expression syntax::) may be any
4215 expression, including the use of apply-codes and value-names.  If the
4216 expression yields a number, it is converted to a decimal string.
4217
4218    These case selection codes have also been implemented as Scheme
4219 expression functions using the same codes.  They are documented in this
4220 texi doc as "string-*?"  predicates (*note Common Functions::).
4221
4222 \1f
4223 File: autogen.info,  Node: COMMENT,  Next: CONTINUE,  Prev: CASE,  Up: native macros
4224
4225 3.6.4 COMMENT - A block of comment to be ignored
4226 ------------------------------------------------
4227
4228 This function can be specified by the user, but there will never be a
4229 situation where it will be invoked at emit time.  The macro is actually
4230 removed from the internal representation.
4231
4232    If the native macro name code is '#', then the entire macro function
4233 is treated as a comment and ignored.
4234
4235      [+ # say what you want, but no '+' before any ']' chars +]
4236
4237 \1f
4238 File: autogen.info,  Node: CONTINUE,  Next: DEBUG,  Prev: COMMENT,  Up: native macros
4239
4240 3.6.5 CONTINUE - Skip to end of a FOR or WHILE macro.
4241 -----------------------------------------------------
4242
4243 This will skip the remainder of the loop and start the next.
4244
4245 \1f
4246 File: autogen.info,  Node: DEBUG,  Next: DEFINE,  Prev: CONTINUE,  Up: native macros
4247
4248 3.6.6 DEBUG - Print debug message to trace output
4249 -------------------------------------------------
4250
4251 If the tracing level is at "debug-message" or above (*note autogen
4252 trace::), this macro prints a debug message to trace output.  This
4253 message is not evaluated.  This macro can also be used to set useful
4254 debugger breakpoints.  By inserting [+DEBUG n+] into your template, you
4255 can set a debugger breakpoint on the #n case element below (in the
4256 AutoGen source) and step through the processing of interesting parts of
4257 your template.
4258
4259    To be useful, you have to have access to the source tree where
4260 autogen was built and the template being processed.  The definitions are
4261 also helpful, but not crucial.  Please contact the author if you think
4262 you might actually want to use this.
4263
4264 \1f
4265 File: autogen.info,  Node: DEFINE,  Next: ELIF,  Prev: DEBUG,  Up: native macros
4266
4267 3.6.7 DEFINE - Define a user AutoGen macro
4268 ------------------------------------------
4269
4270 This function will define a new macro.  You must provide a name for the
4271 macro.  You do not specify any arguments, though the invocation may
4272 specify a set of name/value pairs that are to be active during the
4273 processing of the macro.
4274
4275      [+ define foo +]
4276      ... macro body with macro functions ...
4277      [+ enddef +]
4278      ... [+ foo bar='raw text' baz=<<text expression>> +]
4279
4280    Once the macro has been defined, this new macro can be invoked by
4281 specifying the macro name as the first token after the start macro
4282 marker.  Alternatively, you may make the invocation explicitly invoke a
4283 defined macro by specifying 'INVOKE' (*note INVOKE::) in the macro
4284 invocation.  If you do that, the macro name can be computed with an
4285 expression that gets evaluated every time the INVOKE macro is
4286 encountered.
4287
4288    Any remaining text in the macro invocation will be used to create new
4289 name/value pairs that only persist for the duration of the processing of
4290 the macro.  The expressions are evaluated the same way basic expressions
4291 are evaluated.  *Note expression syntax::.
4292
4293    The resulting definitions are handled much like regular definitions,
4294 except:
4295
4296   1. The values may not be compound.  That is, they may not contain
4297      nested name/value pairs.
4298   2. The bindings go away when the macro is complete.
4299   3. The name/value pairs are separated by whitespace instead of
4300      semi-colons.
4301   4. Sequences of strings are not concatenated.
4302
4303      *NB:* The macro is extracted from the template as the template is
4304      scanned.  You cannot conditionally define a macro by enclosing it
4305      in an 'IF'/'ENDIF' (*note IF::) macro pair.  If you need to
4306      dynamically select the format of a 'DEFINE'd macro, then put the
4307      flavors into separate template files that simply define macros.
4308      'INCLUDE' (*note INCLUDE::) the appropriate template when you have
4309      computed which you need.
4310
4311    Due to this, it is acceptable and even a good idea to place all the
4312 'DEFINE' macros at the end of the template.  That puts the main body of
4313 the template at the beginning of the file.
4314
4315 \1f
4316 File: autogen.info,  Node: ELIF,  Next: ELSE,  Prev: DEFINE,  Up: native macros
4317
4318 3.6.8 ELIF - Alternate Conditional Template Block
4319 -------------------------------------------------
4320
4321 This macro must only appear after an 'IF' function, and before any
4322 associated 'ELSE' or 'ENDIF' functions.  It denotes the start of an
4323 alternate template block for the 'IF' function.  Its expression argument
4324 is evaluated as are the arguments to 'IF'.  For a complete description
4325 *Note IF::.
4326
4327 \1f
4328 File: autogen.info,  Node: ELSE,  Next: ENDDEF,  Prev: ELIF,  Up: native macros
4329
4330 3.6.9 ELSE - Alternate Template Block
4331 -------------------------------------
4332
4333 This macro must only appear after an 'IF' function, and before the
4334 associated 'ENDIF' function.  It denotes the start of an alternate
4335 template block for the 'IF' function.  For a complete description *Note
4336 IF::.
4337
4338 \1f
4339 File: autogen.info,  Node: ENDDEF,  Next: ENDFOR,  Prev: ELSE,  Up: native macros
4340
4341 3.6.10 ENDDEF - Ends a macro definition.
4342 ----------------------------------------
4343
4344 This macro ends the 'DEFINE' function template block.  For a complete
4345 description *Note DEFINE::.
4346
4347 \1f
4348 File: autogen.info,  Node: ENDFOR,  Next: ENDIF,  Prev: ENDDEF,  Up: native macros
4349
4350 3.6.11 ENDFOR - Terminates the 'FOR' function template block
4351 ------------------------------------------------------------
4352
4353 This macro ends the 'FOR' function template block.  For a complete
4354 description *Note FOR::.
4355
4356 \1f
4357 File: autogen.info,  Node: ENDIF,  Next: ENDWHILE,  Prev: ENDFOR,  Up: native macros
4358
4359 3.6.12 ENDIF - Terminate the 'IF' Template Block
4360 ------------------------------------------------
4361
4362 This macro ends the 'IF' function template block.  For a complete
4363 description *Note IF::.
4364
4365 \1f
4366 File: autogen.info,  Node: ENDWHILE,  Next: ESAC,  Prev: ENDIF,  Up: native macros
4367
4368 3.6.13 ENDWHILE - Terminate the 'WHILE' Template Block
4369 ------------------------------------------------------
4370
4371 This macro ends the 'WHILE' function template block.  For a complete
4372 description *Note WHILE::.
4373
4374 \1f
4375 File: autogen.info,  Node: ESAC,  Next: EXPR,  Prev: ENDWHILE,  Up: native macros
4376
4377 3.6.14 ESAC - Terminate the 'CASE' Template Block
4378 -------------------------------------------------
4379
4380 This macro ends the 'CASE' function template block.  For a complete
4381 description, *Note CASE::.
4382
4383 \1f
4384 File: autogen.info,  Node: EXPR,  Next: FOR,  Prev: ESAC,  Up: native macros
4385
4386 3.6.15 EXPR - Evaluate and emit an Expression
4387 ---------------------------------------------
4388
4389 This macro does not have a name to cause it to be invoked explicitly,
4390 though if a macro starts with one of the apply codes or one of the
4391 simple expression markers, then an expression macro is inferred.  The
4392 result of the expression evaluation (*note expression syntax::) is
4393 written to the current output.
4394
4395 \1f
4396 File: autogen.info,  Node: FOR,  Next: IF,  Prev: EXPR,  Up: native macros
4397
4398 3.6.16 FOR - Emit a template block multiple times
4399 -------------------------------------------------
4400
4401 This macro has a slight variation on the standard syntax:
4402      FOR <value-name> [ <separator-string> ]
4403
4404      FOR <value-name> (...Scheme expression list)
4405
4406      FOR <value-name> IN "string" [ ... ]
4407
4408    Other than for the last form, the first macro argument must be the
4409 name of an AutoGen value.  If there is no value associated with the
4410 name, the 'FOR' template block is skipped entirely.  The scope of the
4411 'FOR' macro extends to the corresponding 'ENDFOR' macro.  The last form
4412 will create an array of string values named '<value-name>' that only
4413 exists within the context of this 'FOR' loop.  With this form, in order
4414 to use a 'separator-string', you must code it into the end of the
4415 template block using the '(last-for?)' predicate function (*note SCM
4416 last-for?::).
4417
4418    If there are any arguments after the 'value-name', the initial
4419 characters are used to determine the form.  If the first character is
4420 either a semi-colon (';') or an opening parenthesis ('('), then it is
4421 presumed to be a Scheme expression containing the FOR macro specific
4422 functions 'for-from', 'for-by', 'for-to', and/or 'for-sep'.  *Note
4423 AutoGen Functions::.  If it consists of an ''i'' an ''n'' and separated
4424 by white space from more text, then the 'FOR x IN' form is processed.
4425 Otherwise, the remaining text is presumed to be a string for inserting
4426 between each iteration of the loop.  This string will be emitted one
4427 time less than the number of iterations of the loop.  That is, it is
4428 emitted after each loop, excepting for the last iteration.
4429
4430    If the from/by/to functions are invoked, they will specify which
4431 copies of the named value are to be processed.  If there is no copy of
4432 the named value associated with a particular index, the 'FOR' template
4433 block will be instantiated anyway.  The template must use 'found-for?'
4434 (*note SCM found-for?::) or other methods for detecting missing
4435 definitions and emitting default text.  In this fashion, you can insert
4436 entries from a sparse or non-zero based array into a dense, zero based
4437 array.
4438
4439    *NB:* the 'for-from', 'for-to', 'for-by' and 'for-sep' functions are
4440 disabled outside of the context of the 'FOR' macro.  Likewise, the
4441 'first-for?', 'last-for?'  'for-index', and 'found-for?' functions are
4442 disabled outside of the range of a 'FOR' block.
4443
4444    *Also:* the '<value-name>' must be a single level name, not a
4445 compound name (*note naming values::).
4446
4447      [+FOR var (for-from 0) (for-to <number>) (for-sep ",") +]
4448      ... text with various substitutions ...[+
4449      ENDFOR var+]
4450
4451 this will repeat the '... text with various substitutions ...'
4452 <number>+1 times.  Each repetition, except for the last, will have a
4453 comma ',' after it.
4454
4455      [+FOR var ",\n" +]
4456      ... text with various substitutions ...[+
4457      ENDFOR var +]
4458
4459 This will do the same thing, but only for the index values of 'var' that
4460 have actually been defined.
4461
4462 \1f
4463 File: autogen.info,  Node: IF,  Next: INCLUDE,  Prev: FOR,  Up: native macros
4464
4465 3.6.17 IF - Conditionally Emit a Template Block
4466 -----------------------------------------------
4467
4468 Conditional block.  Its arguments are evaluated (*note EXPR::) and if
4469 the result is non-zero or a string with one or more bytes, then the
4470 condition is true and the text from that point until a matched 'ELIF',
4471 'ELSE' or 'ENDIF' is emitted.  'ELIF' introduces a conditional
4472 alternative if the 'IF' clause evaluated FALSE and 'ELSE' introduces an
4473 unconditional alternative.
4474
4475      [+IF <full-expression> +]
4476      emit things that are for the true condition[+
4477
4478      ELIF <full-expression-2> +]
4479      emit things that are true maybe[+
4480
4481      ELSE "This may be a comment" +]
4482      emit this if all but else fails[+
4483
4484      ENDIF "This may *also* be a comment" +]
4485
4486 '<full-expression>' may be any expression described in the 'EXPR'
4487 expression function, including the use of apply-codes and value-names.
4488 If the expression yields an empty string, it is interpreted as false.
4489
4490 \1f
4491 File: autogen.info,  Node: INCLUDE,  Next: INVOKE,  Prev: IF,  Up: native macros
4492
4493 3.6.18 INCLUDE - Read in and emit a template block
4494 --------------------------------------------------
4495
4496 The entire contents of the named file is inserted at this point.  The
4497 contents of the file are processed for macro expansion.  The arguments
4498 are eval-ed, so you may compute the name of the file to be included.
4499 The included file must not contain any incomplete function blocks.
4500 Function blocks are template text beginning with any of the macro
4501 functions 'CASE', 'DEFINE', 'FOR', 'IF' and 'WHILE'; extending through
4502 their respective terminating macro functions.
4503
4504 \1f
4505 File: autogen.info,  Node: INVOKE,  Next: RETURN,  Prev: INCLUDE,  Up: native macros
4506
4507 3.6.19 INVOKE - Invoke a User Defined Macro
4508 -------------------------------------------
4509
4510 User defined macros may be invoked explicitly or implicitly.  If you
4511 invoke one implicitly, the macro must begin with the name of the defined
4512 macro.  Consequently, this may *not* be a computed value.  If you
4513 explicitly invoke a user defined macro, the macro begins with the macro
4514 name 'INVOKE' followed by a basic expression that must yield a known
4515 user defined macro.  A macro name _must_ be found, or AutoGen will issue
4516 a diagnostic and exit.
4517
4518    Arguments are passed to the invoked macro by name.  The text
4519 following the macro name must consist of a series of names each of which
4520 is followed by an equal sign ('=') and a basic expression that yields a
4521 string.
4522
4523    The string values may contain template macros that are parsed the
4524 first time the macro is processed and evaluated again every time the
4525 macro is evaluated.
4526
4527 \1f
4528 File: autogen.info,  Node: RETURN,  Next: SELECT,  Prev: INVOKE,  Up: native macros
4529
4530 3.6.20 RETURN - Leave an INVOKE-d (DEFINE) macro
4531 ------------------------------------------------
4532
4533 This will unwind looping constructs inside of a DEFINE-d macro and
4534 return to the invocation point.  The output files and diversions are
4535 left alone.  This means it is unwise to start diversions in a DEFINEd
4536 macro and RETURN from it before you have handled the diversion.  Unless
4537 you are careful.  Here is some rope for you.  Please be careful using
4538 it.
4539
4540 \1f
4541 File: autogen.info,  Node: SELECT,  Next: UNKNOWN,  Prev: RETURN,  Up: native macros
4542
4543 3.6.21 SELECT - Selection block for CASE function
4544 -------------------------------------------------
4545
4546 This macro selects a block of text by matching an expression against the
4547 sample text expression evaluated in the 'CASE' macro.  *Note CASE::.
4548
4549    You do not specify a 'SELECT' macro with the word "select".  Instead,
4550 you must use one of the 19 match operators described in the 'CASE' macro
4551 description.
4552
4553 \1f
4554 File: autogen.info,  Node: UNKNOWN,  Next: WHILE,  Prev: SELECT,  Up: native macros
4555
4556 3.6.22 UNKNOWN - Either a user macro or a value name.
4557 -----------------------------------------------------
4558
4559 The macro text has started with a name not known to AutoGen.  If, at run
4560 time, it turns out to be the name of a defined macro, then that macro is
4561 invoked.  If it is not, then it is a conditional expression that is
4562 evaluated only if the name is defined at the time the macro is invoked.
4563
4564    You may not specify 'UNKNOWN' explicitly.
4565
4566 \1f
4567 File: autogen.info,  Node: WHILE,  Next: shell command,  Prev: UNKNOWN,  Up: native macros
4568
4569 3.6.23 WHILE - Conditionally loop over a Template Block
4570 -------------------------------------------------------
4571
4572 Conditionally repeated block.  Its arguments are evaluated (*note
4573 EXPR::) and as long as the result is non-zero or a string with one or
4574 more bytes, then the condition is true and the text from that point
4575 until a matched 'ENDWHILE' is emitted.
4576
4577      [+WHILE <full-expression> +]
4578      emit things that are for the true condition[+
4579
4580      ENDWHILE +]
4581
4582 '<full-expression>' may be any expression described in the 'EXPR'
4583 expression function, including the use of apply-codes and value-names.
4584 If the expression yields an empty string, it is interpreted as false.
4585
4586 \1f
4587 File: autogen.info,  Node: shell command,  Next: guile command,  Prev: WHILE,  Up: native macros
4588
4589 3.6.24 Inserting text from a shell script
4590 -----------------------------------------
4591
4592 If the text between the start and end macro markers starts with an
4593 opening curly brace (''{'') or is surrounded by back quotes (''`''),
4594 then the text is handed off to the server shell for evaluation.  The
4595 output to standard out is inserted into the document.  If the text
4596 starts with the curly brace, all the text is passed off as is to the
4597 shell.  If surrounded by back quotes, then the string is "cooked" before
4598 being handed off to the shell.
4599
4600 \1f
4601 File: autogen.info,  Node: guile command,  Prev: shell command,  Up: native macros
4602
4603 3.6.25 Inserting text from a scheme script
4604 ------------------------------------------
4605
4606 If the text between the start and end macro markers starts with a
4607 semi-colon or an opening parenthesis, all the text is handed off to the
4608 Guile/scheme processor.  If the last result is text or a number, it is
4609 added (as text) to the output document.
4610
4611 \1f
4612 File: autogen.info,  Node: output controls,  Prev: native macros,  Up: Template File
4613
4614 3.7 Redirecting Output
4615 ======================
4616
4617 AutoGen provides a means for redirecting the template output to
4618 different files or, in 'M4' parlance, to various diversions.  It is
4619 accomplished by providing a set of Scheme functions named 'out-*' (*note
4620 AutoGen Functions::).
4621
4622 'out-push-new (*note SCM out-push-new::)'
4623      This allows you to logically "push" output files onto a stack.  If
4624      you supply a string name, then a file by that name is created to
4625      hold the output.  If you do not supply a name, then the text is
4626      written to a scratch pad and retrieved by passing a '#t' argument
4627      to the 'out-pop' (*note SCM out-pop::) function.
4628
4629 'out-pop (*note SCM out-pop::)'
4630      This function closes the current output file and resumes output to
4631      the next one in the stack.  At least one output must have been
4632      pushed onto the output stack with the 'out-push-new' (*note SCM
4633      out-push-new::) function.  If '#t' is passed in as an argument,
4634      then the entire contents of the diversion (or file) is returned.
4635
4636 'out-suspend (*note SCM out-suspend::)'
4637      This function does not close the current output, but instead sets
4638      it aside for resumption by the given name with 'out-resume'.  The
4639      current output must have been pushed on the output queue with
4640      'out-push-new' (*note SCM out-push-new::).
4641
4642 'out-resume (*note SCM out-resume::)'
4643      This will put a named file descriptor back onto the top of stack so
4644      that it becomes the current output again.
4645
4646 'out-switch (*note SCM out-switch::)'
4647      This closes the current output and creates a new file, purging any
4648      preexisting one.  This is a shortcut for "pop" followed by "push",
4649      but this can also be done at the base level.
4650
4651 'out-move (*note SCM out-move::)'
4652      Renames the current output file without closing it.
4653
4654    There are also several functions for determining the output status.
4655 *Note AutoGen Functions::.
4656
4657 \1f
4658 File: autogen.info,  Node: Augmenting AutoGen,  Next: autogen Invocation,  Prev: Template File,  Up: Top
4659
4660 4 Augmenting AutoGen Features
4661 *****************************
4662
4663 AutoGen was designed to be simple to enhance.  You can do it by
4664 providing shell commands, Guile/Scheme macros or callout functions that
4665 can be invoked as a Guile macro.  Here is how you do these.
4666
4667 * Menu:
4668
4669 * shell commands::       Shell Output Commands
4670 * guile macros::         Guile Macros
4671 * guile callouts::       Guile Callout Functions
4672 * AutoGen macros::       AutoGen Macros
4673
4674 \1f
4675 File: autogen.info,  Node: shell commands,  Next: guile macros,  Up: Augmenting AutoGen
4676
4677 4.1 Shell Output Commands
4678 =========================
4679
4680 Shell commands are run inside of a server process.  This means that,
4681 unlike 'make', context is kept from one command to the next.
4682 Consequently, you can define a shell function in one place inside of
4683 your template and invoke it in another.  You may also store values in
4684 shell variables for later reference.  If you load functions from a file
4685 containing shell functions, they will remain until AutoGen exits.
4686
4687    If your shell script should determine that AutoGen should stop
4688 processing, the recommended method for stopping AutoGen is:
4689      die "some error text"
4690
4691 That is a shell function added by AutoGen.  It will send a SIGTERM to
4692 autogen and exit from the "persistent" shell.
4693
4694 \1f
4695 File: autogen.info,  Node: guile macros,  Next: guile callouts,  Prev: shell commands,  Up: Augmenting AutoGen
4696
4697 4.2 Guile Macros
4698 ================
4699
4700 Guile also maintains context from one command to the next.  This means
4701 you may define functions and variables in one place and reference them
4702 elsewhere.  If your Scheme script should determine that AutoGen should
4703 stop processing, the recommended method for stopping AutoGen is:
4704      (error "some error text")
4705
4706 \1f
4707 File: autogen.info,  Node: guile callouts,  Next: AutoGen macros,  Prev: guile macros,  Up: Augmenting AutoGen
4708
4709 4.3 Guile Callout Functions
4710 ===========================
4711
4712 Callout functions must be registered with Guile to work.  This can be
4713 accomplished either by putting your routines into a shared library that
4714 contains a 'void scm_init(void)' routine that registers these routines,
4715 or by building them into AutoGen.
4716
4717    To build them into AutoGen, you must place your routines in the
4718 source directory and name the files 'exp*.c'.  You also must have a
4719 stylized comment that 'getdefs' can find that conforms to the following:
4720
4721      /*=gfunc <function-name>
4722       *
4723       *  what:    <short one-liner>
4724       *  general_use:
4725       *  string:  <invocation-name-string>
4726       *  exparg:  <name>, <description> [, ['optional'] [, 'list']]
4727       *  doc:     A long description telling people how to use
4728       *           this function.
4729      =*/
4730      SCM
4731      ag_scm_<function-name>( SCM arg_name[, ...] )
4732      { <code> }
4733
4734 'gfunc'
4735      You must have this exactly thus.
4736
4737 '<function-name>'
4738      This must follow C syntax for variable names
4739
4740 '<short one-liner>'
4741      This should be about a half a line long.  It is used as a
4742      subsection title in this document.
4743
4744 'general_use:'
4745      You must supply this unless you are an AutoGen maintainer and are
4746      writing a function that queries or modifies the state of AutoGen.
4747
4748 '<invocation-name-string>'
4749      Normally, the FUNCTION-NAME string will be transformed into a
4750      reasonable invocation name.  However, that is not always true.  If
4751      the result does not suit your needs, then supply an alternate
4752      string.
4753
4754 'exparg:'
4755      You must supply one for each argument to your function.  All
4756      optional arguments must be last.  The last of the optional
4757      arguments may be a list, if you choose.
4758
4759 'doc:'
4760      Please say something meaningful.
4761
4762 '[, ...]'
4763      Do not actually specify an ANSI ellipsis here.  You must provide
4764      for all the arguments you specified with EXPARG.
4765
4766    See the Guile documentation for more details.  More information is
4767 also available in a large comment at the beginning of the
4768 'agen5/snarf.tpl' template file.
4769
4770 \1f
4771 File: autogen.info,  Node: AutoGen macros,  Prev: guile callouts,  Up: Augmenting AutoGen
4772
4773 4.4 AutoGen Macros
4774 ==================
4775
4776 There are two kinds those you define yourself and AutoGen native.  The
4777 user-defined macros may be defined in your templates, *Note DEFINE::.
4778
4779    As for AutoGen native macros, do not add any.  It is easy to do, but
4780 I won't like it.  The basic functions needed to accomplish looping over
4781 and selecting blocks of text have proved to be sufficient over a period
4782 of several years.  New text transformations can be easily added via any
4783 of the AutoGen extension methods, as discussed above.
4784
4785 \1f
4786 File: autogen.info,  Node: autogen Invocation,  Next: Installation,  Prev: Augmenting AutoGen,  Up: Top
4787
4788 5 Invoking autogen
4789 ******************
4790
4791 AutoGen creates text files from templates using external definitions.
4792
4793    'AutoGen' is designed for generating program files that contain
4794 repetitive text with varied substitutions.  The goal is to simplify the
4795 maintenance of programs that contain large amounts of repetitious text.
4796 This is especially valuable if there are several blocks of such text
4797 that must be kept synchronized.
4798
4799    One common example is the problem of maintaining the code required
4800 for processing program options.  Processing options requires a minimum
4801 of four different constructs be kept in proper order in different places
4802 in your program.  You need at least: The flag character in the flag
4803 string, code to process the flag when it is encountered, a global state
4804 variable or two, and a line in the usage text.  You will need more
4805 things besides this if you choose to implement long option names,
4806 configuration file processing, environment variables and so on.
4807
4808    All of this can be done mechanically; with the proper templates and
4809 this program.
4810
4811    This chapter was generated by *AutoGen*, using the 'agtexi-cmd'
4812 template and the option descriptions for the 'autogen' program.  This
4813 software is released under the GNU General Public License, version 3 or
4814 later.
4815
4816 * Menu:
4817
4818 * autogen usage::                  autogen help/usage ('--help')
4819 * autogen input-select::           input-select options
4820 * autogen out-handling::           out-handling options
4821 * autogen debug-tpl::              debug-tpl options
4822 * autogen processing::             processing options
4823 * autogen dep-track::              dep-track options
4824 * autogen autoopts-opts::          autoopts-opts options
4825 * autogen config::                 presetting/configuring autogen
4826 * autogen exit status::            exit status
4827 * autogen Examples::               Examples
4828
4829 \1f
4830 File: autogen.info,  Node: autogen usage,  Next: autogen input-select,  Up: autogen Invocation
4831
4832 5.1 autogen help/usage ('--help')
4833 =================================
4834
4835 This is the automatically generated usage text for autogen.
4836
4837    The text printed is the same whether selected with the 'help' option
4838 ('--help') or the 'more-help' option ('--more-help').  'more-help' will
4839 print the usage text by passing it through a pager program.  'more-help'
4840 is disabled on platforms without a working 'fork(2)' function.  The
4841 'PAGER' environment variable is used to select the program, defaulting
4842 to 'more'.  Both will exit with a status code of 0.
4843
4844      autogen (GNU AutoGen) - The Automated Program Generator - Ver. 5.18.15.001
4845      Usage:  autogen [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ <def-file> ]
4846
4847      The following options select definitions, templates and scheme functions
4848      to use:
4849
4850        Flg Arg Option-Name    Description
4851         -L Str templ-dirs     Search for templates in DIR
4852                                      - may appear multiple times
4853         -T Str override-tpl   Use TPL-FILE for the template
4854                                      - may not be preset
4855            Str definitions    Read definitions from FILE
4856                                      - disabled as '--no-definitions'
4857                                      - enabled by default
4858                                      - may not be preset
4859            Str shell          name or path name of shell to use
4860         -m no  no-fmemopen    Do not use in-mem streams
4861            Str equate         characters considered equivalent
4862
4863      The following options modify how output is handled:
4864
4865        Flg Arg Option-Name    Description
4866         -b Str base-name      Specify NAME as the base name for output
4867                                      - may not be preset
4868            no  source-time    set mod times to latest source
4869                                      - disabled as '--no-source-time'
4870            no  writable       Allow output files to be writable
4871                                      - disabled as '--not-writable'
4872
4873      The following options are often useful while debugging new templates:
4874
4875        Flg Arg Option-Name    Description
4876            Num loop-limit     Limit on increment loops
4877                                      - is scalable with a suffix: k/K/m/M/g/G/t/T
4878                                      - it must lie in one of the ranges:
4879                                        -1 exactly, or
4880                                        1 to 16777216
4881         -t Num timeout        Limit server shell operations to SECONDS
4882                                      - it must be in the range:
4883                                        0 to 3600
4884            KWd trace          tracing level of detail
4885            Str trace-out      tracing output file or filter
4886            --- show-defs      This option has been disabled
4887            no  used-defines   Show the definitions used
4888                                      - may not be preset
4889         -C no  core           Leave a core dump on a failure exit
4890
4891      These options can be used to control what gets processed in the
4892      definitions files and template files:
4893
4894        Flg Arg Option-Name    Description
4895         -s Str skip-suffix    Skip the file with this SUFFIX
4896                                      - prohibits the option 'select-suffix'
4897                                      - may not be preset
4898                                      - may appear multiple times
4899         -o Str select-suffix  specify this output suffix
4900                                      - may not be preset
4901                                      - may appear multiple times
4902         -D Str define         name to add to definition list
4903                                      - may appear multiple times
4904         -U Str undefine       definition list removal pattern
4905                                      - an alternate for 'define'
4906
4907      This option is used to automate dependency tracking:
4908
4909        Flg Arg Option-Name    Description
4910         -M opt make-dep       emit make dependency file
4911                                      - may not be preset
4912                                      - may appear multiple times
4913
4914      help, version, option and error handling:
4915
4916        Flg Arg Option-Name    Description
4917            no  no-abort       Do not abort on errors
4918
4919      Version, usage and configuration options:
4920
4921        Flg Arg Option-Name    Description
4922         -R Str reset-option   reset an option's state
4923         -v opt version        output version information and exit
4924         -? no  help           display extended usage information and exit
4925         -! no  more-help      extended usage information passed thru pager
4926         -u no  usage          abbreviated usage to stdout
4927         -> opt save-opts      save the option state to a config file
4928         -< Str load-opts      load options from a config file
4929                                      - disabled as '--no-load-opts'
4930                                      - may appear multiple times
4931
4932      Options are specified by doubled hyphens and their name or by a single
4933      hyphen and the flag character.
4934      AutoGen creates text files from templates using external definitions.
4935
4936      The following option preset mechanisms are supported:
4937       - reading file $HOME
4938       - reading file ./.autogenrc
4939       - examining environment variables named AUTOGEN_*
4940
4941      The valid "trace" option keywords are:
4942        nothing       debug-message server-shell  templates     block-macros
4943        expressions   everything
4944        or an integer from 0 through 6
4945      AutoGen is a tool designed for generating program files that contain
4946      repetitive text with varied substitutions.
4947
4948      Please send bug reports to:  <autogen-users@lists.sourceforge.net>
4949
4950 \1f
4951 File: autogen.info,  Node: autogen input-select,  Next: autogen out-handling,  Prev: autogen usage,  Up: autogen Invocation
4952
4953 5.2 input-select options
4954 ========================
4955
4956 The following options select definitions, templates and scheme functions
4957 to use.
4958
4959 templ-dirs option (-L).
4960 -----------------------
4961
4962 This is the "search for templates in 'dir'" option.  This option takes a
4963 string argument 'DIR'.
4964
4965 This option has some usage constraints.  It:
4966    * may appear an unlimited number of times.
4967
4968    Add a directory to the list of directories 'autogen' searches when
4969 opening a template, either as the primary template or an included one.
4970 The last entry has the highest priority in the search list.  That is to
4971 say, they are searched in reverse order.
4972
4973 override-tpl option (-T).
4974 -------------------------
4975
4976 This is the "use 'tpl-file' for the template" option.  This option takes
4977 a string argument 'TPL-FILE'.
4978
4979 This option has some usage constraints.  It:
4980    * may not be preset with environment variables or configuration
4981      (rc/ini) files.
4982
4983    Definition files specify the standard template that is to be
4984 expanded.  This option will override that name and expand a different
4985 template.
4986
4987 definitions option.
4988 -------------------
4989
4990 This is the "read definitions from 'file'" option.  This option takes a
4991 string argument 'FILE'.
4992
4993 This option has some usage constraints.  It:
4994    * can be disabled with -no-definitions.
4995    * It is enabled by default.
4996    * may not be preset with environment variables or configuration
4997      (rc/ini) files.
4998
4999    Use this argument to specify the input definitions file with a
5000 command line option.  If you do not specify this option, then there must
5001 be a command line argument that specifies the file, even if only to
5002 specify stdin with a hyphen ('-').  Specify, '--no-definitions' when you
5003 wish to process a template without any active AutoGen definitions.
5004
5005 shell option.
5006 -------------
5007
5008 This is the "name or path name of shell to use" option.  This option
5009 takes a string argument 'shell'.
5010
5011 This option has some usage constraints.  It:
5012    * must be compiled in by defining 'SHELL_ENABLED' during the
5013      compilation.
5014
5015    By default, when AutoGen is built, the configuration is probed for a
5016 reasonable Bourne-like shell to use for shell script processing.  If a
5017 particular template needs an alternate shell, it must be specified with
5018 this option on the command line, with an environment variable ('SHELL')
5019 or in the configuration/initialization file.
5020
5021 no-fmemopen option (-m).
5022 ------------------------
5023
5024 This is the "do not use in-mem streams" option.  If the local C library
5025 supports "'fopencookie(3GNU)'", or "'funopen(3BSD)'" then AutoGen
5026 prefers to use in-memory stream buffer opens instead of anonymous files.
5027 This may lead to problems if there is a shortage of virtual memory.  If,
5028 for a particular application, you run out of memory, then specify this
5029 option.  This is unlikely in a modern 64-bit virtual memory environment.
5030
5031    On platforms without these functions, the option is accepted but
5032 ignored.  'fmemopen(POSIX)' is not adequate because its string buffer is
5033 not reallocatable.  'open_memstream(POSIX)' is also not adequate because
5034 the stream is only opened for output.  AutoGen needs a reallocatable
5035 buffer available for both reading and writing.
5036
5037 equate option.
5038 --------------
5039
5040 This is the "characters considered equivalent" option.  This option
5041 takes a string argument 'char-list'.  This option will alter the list of
5042 characters considered equivalent.  The default are the three characters,
5043 "_-^".  (The last is conventional on a Tandem/HP-NonStop, and I used to
5044 do a lot of work on Tandems.)
5045
5046 \1f
5047 File: autogen.info,  Node: autogen out-handling,  Next: autogen debug-tpl,  Prev: autogen input-select,  Up: autogen Invocation
5048
5049 5.3 out-handling options
5050 ========================
5051
5052 The following options modify how output is handled.
5053
5054 base-name option (-b).
5055 ----------------------
5056
5057 This is the "specify 'name' as the base name for output" option.  This
5058 option takes a string argument 'NAME'.
5059
5060 This option has some usage constraints.  It:
5061    * may not be preset with environment variables or configuration
5062      (rc/ini) files.
5063
5064    A template may specify the exact name of the output file.  Normally,
5065 it does not.  Instead, the name is composed of the base name of the
5066 definitions file with suffixes appended.  This option will override the
5067 base name derived from the definitions file name.  This is required if
5068 there is no definitions file and advisable if definitions are being read
5069 from stdin.  If the definitions are being read from standard in, the
5070 base name defaults to 'stdin'.  Any leading directory components in the
5071 name will be silently removed.  If you wish the output file to appear in
5072 a particular directory, it is recommended that you "cd" into that
5073 directory first, or use directory names in the format specification for
5074 the output suffix lists, *Note pseudo macro::.
5075
5076 source-time option.
5077 -------------------
5078
5079 This is the "set mod times to latest source" option.
5080
5081 This option has some usage constraints.  It:
5082    * can be disabled with -no-source-time.
5083
5084    If you stamp your output files with the 'DNE' macro output, then your
5085 output files will always be different, even if the content has not
5086 really changed.  If you use this option, then the modification time of
5087 the output files will change only if the input files change.  This will
5088 help reduce unneeded builds.
5089
5090 writable option.
5091 ----------------
5092
5093 This is the "allow output files to be writable" option.
5094
5095 This option has some usage constraints.  It:
5096    * can be disabled with -not-writable.
5097
5098    This option will leave output files writable.  Normally, output files
5099 are read-only.
5100
5101 \1f
5102 File: autogen.info,  Node: autogen debug-tpl,  Next: autogen processing,  Prev: autogen out-handling,  Up: autogen Invocation
5103
5104 5.4 debug-tpl options
5105 =====================
5106
5107 The following options are often useful while debugging new templates.
5108 They specify limits that prevent the template from taking overly long or
5109 producing more output than expected.
5110
5111 loop-limit option.
5112 ------------------
5113
5114 This is the "limit on increment loops" option.  This option takes a
5115 number argument 'lim'.  This option prevents runaway loops.  For
5116 example, if you accidentally specify, "FOR x (for-from 1) (for-to -1)
5117 (for-by 1)", it will take a long time to finish.  If you do have more
5118 than 256 entries in tables, you will need to specify a new limit with
5119 this option.
5120
5121 timeout option (-t).
5122 --------------------
5123
5124 This is the "limit server shell operations to 'seconds'" option.  This
5125 option takes a number argument 'SECONDS'.
5126
5127 This option has some usage constraints.  It:
5128    * must be compiled in by defining 'SHELL_ENABLED' during the
5129      compilation.
5130
5131    AutoGen works with a shell server process.  Most normal commands will
5132 complete in less than 10 seconds.  If, however, your commands need more
5133 time than this, use this option.
5134
5135    The valid range is 0 to 3600 seconds (1 hour).  Zero will disable the
5136 server time limit.
5137
5138 trace option.
5139 -------------
5140
5141 This is the "tracing level of detail" option.  This option takes a
5142 keyword argument 'level'.
5143
5144 This option has some usage constraints.  It:
5145    * This option takes a keyword as its argument.  The argument sets an
5146      enumeration value that can be tested by comparing the option value
5147      macro (OPT_VALUE_TRACE). The available keywords are:
5148               nothing       debug-message server-shell
5149               templates     block-macros  expressions
5150               everything
5151
5152      or their numeric equivalent.
5153
5154    This option will cause AutoGen to display a trace of its template
5155 processing.  There are six levels, each level including messages from
5156 the previous levels:
5157
5158 'nothing'
5159      Does no tracing at all (default)
5160
5161 'debug-message'
5162      Print messages from the "DEBUG" AutoGen macro (*note DEBUG::).
5163
5164 'server-shell'
5165      Traces all input and output to the server shell.  This includes a
5166      shell "independent" initialization script about 30 lines long.  Its
5167      output is discarded and not inserted into any template.
5168
5169 'templates'
5170      Traces the invocation of 'DEFINE'd macros and 'INCLUDE's
5171
5172 'block-macros'
5173      Traces all block macros.  The above, plus 'IF', 'FOR', 'CASE' and
5174      'WHILE'.
5175
5176 'expressions'
5177      Displays the results of expression evaluations.
5178
5179 'everything'
5180      Displays the invocation of every AutoGen macro, even 'TEXT' macros
5181      (i.e.  the text outside of macro quotes).  Additionally, if you
5182      rebuild the "expr.ini" file with debugging enabled, then all calls
5183      to AutoGen defined scheme functions will also get logged:
5184           cd ${top_builddir}/agen5
5185           DEBUG_ENABLED=true bash bootstrap.dir expr.ini
5186           make CFLAGS='-g -DDEBUG_ENABLED=1'
5187
5188      Be aware that you cannot rebuild this source in this way without
5189      first having installed the 'autogen' executable in your search
5190      path.  Because of this, "expr.ini" is in the distributed source
5191      list, and not in the dependencies.
5192
5193 trace-out option.
5194 -----------------
5195
5196 This is the "tracing output file or filter" option.  This option takes a
5197 string argument 'file'.  The output specified may be a file name, a file
5198 that is appended to, or, if the option argument begins with the 'pipe'
5199 operator ('|'), a command that will receive the tracing output as
5200 standard in.  For example, '--traceout='| less'' will run the trace
5201 output through the 'less' program.  Appending to a file is specified by
5202 preceding the file name with two greater-than characters ('>>').
5203
5204 show-defs option.
5205 -----------------
5206
5207 This is the "show the definition tree" option.
5208
5209 This option has some usage constraints.  It:
5210    * must be compiled in by defining 'DEBUG_ENABLED' during the
5211      compilation.
5212    * may not be preset with environment variables or configuration
5213      (rc/ini) files.
5214
5215    This will print out the complete definition tree before processing
5216 the template.
5217
5218 used-defines option.
5219 --------------------
5220
5221 This is the "show the definitions used" option.
5222
5223 This option has some usage constraints.  It:
5224    * may not be preset with environment variables or configuration
5225      (rc/ini) files.
5226
5227    This will print out the names of definition values searched for
5228 during the processing of the template, whether actually found or not.
5229 There may be other referenced definitions in a template in portions of
5230 the template not evaluated.  Some of the names listed may be computed
5231 names and others AutoGen macro arguments.  This is not a means for
5232 producing a definitive, all-encompassing list of all and only the values
5233 used from a definition file.  This is intended as an aid to template
5234 documentation only.
5235
5236 core option (-C).
5237 -----------------
5238
5239 This is the "leave a core dump on a failure exit" option.
5240
5241 This option has some usage constraints.  It:
5242    * must be compiled in by defining 'HAVE_SYS_RESOURCE_H' during the
5243      compilation.
5244
5245    Many systems default to a zero sized core limit.  If the system has
5246 the sys/resource.h header and if this option is supplied, then in the
5247 failure exit path, autogen will attempt to set the soft core limit to
5248 whatever the hard core limit is.  If that does not work, then an
5249 administrator must raise the hard core size limit.
5250
5251 \1f
5252 File: autogen.info,  Node: autogen processing,  Next: autogen dep-track,  Prev: autogen debug-tpl,  Up: autogen Invocation
5253
5254 5.5 processing options
5255 ======================
5256
5257 These options can be used to control what gets processed in the
5258 definitions files and template files.  They specify which outputs and
5259 parts of outputs to produce.
5260
5261 skip-suffix option (-s).
5262 ------------------------
5263
5264 This is the "skip the file with this 'suffix'" option.  This option
5265 takes a string argument 'SUFFIX'.
5266
5267 This option has some usage constraints.  It:
5268    * may appear an unlimited number of times.
5269    * may not be preset with environment variables or configuration
5270      (rc/ini) files.
5271    * must not appear in combination with any of the following options:
5272      select-suffix.
5273
5274    Occasionally, it may not be desirable to produce all of the output
5275 files specified in the template.  (For example, only the '.h' header
5276 file, but not the '.c' program text.)  To do this specify
5277 '--skip-suffix=c' on the command line.
5278
5279 select-suffix option (-o).
5280 --------------------------
5281
5282 This is the "specify this output suffix" option.  This option takes a
5283 string argument 'SUFFIX'.
5284
5285 This option has some usage constraints.  It:
5286    * may appear an unlimited number of times.
5287    * may not be preset with environment variables or configuration
5288      (rc/ini) files.
5289
5290    If you wish to override the suffix specifications in the template,
5291 you can use one or more copies of this option.  See the suffix
5292 specification in the *note pseudo macro:: section of the info doc.
5293
5294 define option (-D).
5295 -------------------
5296
5297 This is the "name to add to definition list" option.  This option takes
5298 a string argument 'value'.
5299
5300 This option has some usage constraints.  It:
5301    * may appear an unlimited number of times.
5302
5303    The AutoGen define names are used for the following purposes:
5304
5305   1. Sections of the AutoGen definitions may be enabled or disabled by
5306      using C-style #ifdef and #ifndef directives.
5307   2. When defining a value for a name, you may specify the index for a
5308      particular value.  That index may be a literal value, a define
5309      option or a value #define-d in the definitions themselves.
5310   3. The name of a file may be prefixed with '$NAME/'.  The '$NAME' part
5311      of the name string will be replaced with the define-d value for
5312      'NAME'.
5313   4. When AutoGen is finished loading the definitions, the defined
5314      values are exported to the environment with, 'putenv(3)'.  These
5315      values can then be used in shell scripts with '${NAME}' references
5316      and in templates with '(getenv "NAME")'.
5317   5. While processing a template, you may specify an index to retrieve a
5318      specific value.  That index may also be a define-d value.
5319
5320    It is entirely equivalent to place this name in the exported
5321 environment.  Internally, that is what AutoGen actually does with this
5322 option.
5323
5324 undefine option (-U).
5325 ---------------------
5326
5327 This is the "definition list removal pattern" option.  This option takes
5328 a string argument 'name-pat'.
5329
5330 This option has some usage constraints.  It:
5331    * may appear an unlimited number of times.
5332    * may not be preset with environment variables or configuration
5333      (rc/ini) files.
5334
5335    Similar to 'C', AutoGen uses '#ifdef/#ifndef' preprocessing
5336 directives.  This option will cause the matching names to be removed
5337 from the list of defined values.
5338
5339 \1f
5340 File: autogen.info,  Node: autogen dep-track,  Next: autogen autoopts-opts,  Prev: autogen processing,  Up: autogen Invocation
5341
5342 5.6 dep-track options
5343 =====================
5344
5345 This option is used to automate dependency tracking.
5346
5347 make-dep option (-M).
5348 ---------------------
5349
5350 This is the "emit make dependency file" option.  This option takes an
5351 optional string argument 'type'.
5352
5353 This option has some usage constraints.  It:
5354    * may appear an unlimited number of times.
5355    * may not be preset with environment variables or configuration
5356      (rc/ini) files.
5357
5358    This option behaves fairly closely to the way the '-M' series of
5359 options work with the gcc compiler, except that instead of just emitting
5360 the predecessor dependencies, this also emits the successor dependencies
5361 (output target files).  By default, the output dependency information
5362 will be placed in '<base-name>.d', but may also be specified with
5363 '-MF<file>'.  The time stamp on this file will be manipulated so that it
5364 will be one second older than the oldest primary output file.
5365
5366    The target in this dependency file will normally be the dependency
5367 file name, but may also be overridden with '-MT<targ-name>'.  AutoGen
5368 will not alter the contents of that file, but it may create it and it
5369 will adjust the modification time to match the start time.
5370
5371    *NB:* these second letters are part of the option argument, so '-MF
5372 <file>' must have the space character quoted or omitted, and '-M "F
5373 <file>"' is acceptable because the 'F' is part of the option argument.
5374
5375    '-M' may be followed by any of the letters M, F, P, T, Q, D, or G.
5376 However, only F, Q, T and P are meaningful.  All but F have somewhat
5377 different meanings.  '-MT<name>' is interpreted as meaning '<name>' is a
5378 sentinel file that will depend on all inputs (templates and definition
5379 files) and all the output files will depend on this sentinel file.  It
5380 is suitable for use as a real make target.  Q is treated identically to
5381 T, except dollar characters ('$') are doubled.  P causes a special clean
5382 (clobber) phoney rule to be inserted into the make file fragment.  An
5383 empty rule is always created for building the list of targets.
5384
5385    This is the recommended usage:
5386        -MFwhatever-you-like.dep -MTyour-sentinel-file -MP
5387    and then in your 'Makefile', make the 'autogen' rule:
5388        -include whatever-you-like.dep
5389        clean_targets += clean-your-sentinel-file
5390
5391        your-sentinel-file:
5392            autogen -MT$@ -MF$*.d .....
5393
5394        local-clean :
5395            rm -f $(clean_targets)
5396
5397    The modification time on the dependency file is adjusted to be one
5398 second before the earliest time stamp of any other output file.
5399 Consequently, it is suitable for use as the sentinel file testifying to
5400 the fact the program was successfully run.  ('-include' is the GNU make
5401 way of specifying "include it if it exists".  Your make must support
5402 that feature or your bootstrap process must create the file.)
5403
5404    All of this may also be specified using the 'DEPENDENCIES_OUTPUT' or
5405 'AUTOGEN_MAKE_DEP' environment variables.  If defined, dependency
5406 information will be output.  If defined with white space free text that
5407 is something other than 'true', 'false', 'yes', 'no', '0' or '1', then
5408 the string is taken to be an output file name.  If it contains a string
5409 of white space characters, the first token is as above and the second
5410 token is taken to be the target (sentinel) file as '-MT' in the
5411 paragraphs above.  'DEPENDENCIES_OUTPUT' will be ignored if there are
5412 multiple sequences of white space characters or if its contents are,
5413 specifically, 'false', 'no' or '0'.
5414
5415 \1f
5416 File: autogen.info,  Node: autogen autoopts-opts,  Next: autogen config,  Prev: autogen dep-track,  Up: autogen Invocation
5417
5418 5.7 autoopts-opts options
5419 =========================
5420
5421 help, version, option and error handling.
5422
5423 no-abort option.
5424 ----------------
5425
5426 This is the "do not abort on errors" option.  By default, 'AutoGen' will
5427 abort on an error leaving behind a core image.  That is sometimes
5428 inconvenient.  If present on the command line or in the environment,
5429 AutoGen will call 'exit(1)' instead of 'abort()'.
5430
5431 \1f
5432 File: autogen.info,  Node: autogen config,  Next: autogen exit status,  Prev: autogen autoopts-opts,  Up: autogen Invocation
5433
5434 5.8 presetting/configuring autogen
5435 ==================================
5436
5437 Any option that is not marked as not presettable may be preset by
5438 loading values from configuration ("rc" or "ini") files, and values from
5439 environment variables named 'AUTOGEN' and 'AUTOGEN_<OPTION_NAME>'.
5440 '<OPTION_NAME>' must be one of the options listed above in upper case
5441 and segmented with underscores.  The 'AUTOGEN' variable will be
5442 tokenized and parsed like the command line.  The remaining variables are
5443 tested for existence and their values are treated like option arguments.
5444
5445 'libopts' will search in 2 places for configuration files:
5446    * $HOME
5447    * $PWD
5448    The environment variables 'HOME', and 'PWD' are expanded and replaced
5449 when 'autogen' runs.  For any of these that are plain files, they are
5450 simply processed.  For any that are directories, then a file named
5451 '.autogenrc' is searched for within that directory and processed.
5452
5453    Configuration files may be in a wide variety of formats.  The basic
5454 format is an option name followed by a value (argument) on the same
5455 line.  Values may be separated from the option name with a colon, equal
5456 sign or simply white space.  Values may be continued across multiple
5457 lines by escaping the newline with a backslash.
5458
5459    Multiple programs may also share the same initialization file.
5460 Common options are collected at the top, followed by program specific
5461 segments.  The segments are separated by lines like:
5462      [AUTOGEN]
5463 or by
5464      <?program autogen>
5465 Do not mix these styles within one configuration file.
5466
5467    Compound values and carefully constructed string values may also be
5468 specified using XML syntax:
5469      <option-name>
5470         <sub-opt>...&lt;...&gt;...</sub-opt>
5471      </option-name>
5472 yielding an 'option-name.sub-opt' string value of
5473      "...<...>..."
5474    'AutoOpts' does not track suboptions.  You simply note that it is a
5475 hierarchicly valued option.  'AutoOpts' does provide a means for
5476 searching the associated name/value pair list (see: optionFindValue).
5477
5478    The command line options relating to configuration and/or usage help
5479 are:
5480
5481 version (-v)
5482 ------------
5483
5484 Print the program version to standard out, optionally with licensing
5485 information, then exit 0.  The optional argument specifies how much
5486 licensing detail to provide.  The default is to print just the version.
5487 The licensing information may be selected with an option argument.  Only
5488 the first letter of the argument is examined:
5489
5490 'version'
5491      Only print the version.  This is the default.
5492 'copyright'
5493      Name the copyright usage licensing terms.
5494 'verbose'
5495      Print the full copyright usage licensing terms.
5496
5497 usage (-u)
5498 ----------
5499
5500 Print abbreviated usage to standard out, then exit 0.
5501
5502 reset-option (-R)
5503 -----------------
5504
5505 Resets the specified option to the compiled-in initial state.  This will
5506 undo anything that may have been set by configuration files.  The option
5507 argument may be either the option flag character or its long name.
5508
5509 \1f
5510 File: autogen.info,  Node: autogen exit status,  Next: autogen Examples,  Prev: autogen config,  Up: autogen Invocation
5511
5512 5.9 autogen exit status
5513 =======================
5514
5515 One of the following exit values will be returned:
5516 '0 (EXIT_SUCCESS)'
5517      Successful program execution.
5518 '1 (EXIT_OPTION_ERROR)'
5519      The command options were misconfigured.
5520 '2 (EXIT_BAD_TEMPLATE)'
5521      An error was encountered processing the template.
5522 '3 (EXIT_BAD_DEFINITIONS)'
5523      The definitions could not be deciphered.
5524 '4 (EXIT_LOAD_ERROR)'
5525      An error was encountered during the load phase.
5526 '5 (EXIT_FS_ERROR)'
5527      a file system error stopped the program.
5528 '6 (EXIT_NO_MEM)'
5529      Insufficient memory to operate.
5530 '128 (EXIT_SIGNAL)'
5531      'autogen' exited due to catching a signal.  If your template
5532      includes string formatting, a number argument to a "%s" formatting
5533      element will trigger a segmentation fault.  Autogen will catch the
5534      seg fault signal and exit with 'AUTOGEN_EXIT_SIGNAL(5)'.
5535      Alternatively, AutoGen may have been interrupted with a 'kill(2)'
5536      signal.
5537
5538      Subtract 128 from the actual exit code to detect the signal number.
5539 '66 (EX_NOINPUT)'
5540      A specified configuration file could not be loaded.
5541 '70 (EX_SOFTWARE)'
5542      libopts had an internal operational error.  Please report it to
5543      autogen-users@lists.sourceforge.net.  Thank you.
5544
5545 \1f
5546 File: autogen.info,  Node: autogen Examples,  Prev: autogen exit status,  Up: autogen Invocation
5547
5548 5.10 autogen Examples
5549 =====================
5550
5551 Here is how the man page is produced:
5552      autogen -Tagman-cmd.tpl -MFman-dep -MTstamp-man opts.def
5553
5554    This command produced this man page from the AutoGen option
5555 definition file.  It overrides the template specified in 'opts.def'
5556 (normally 'options.tpl') and uses 'agman-cmd.tpl'.  It also sets the
5557 make file dependency output to 'man-dep' and the sentinel file (time
5558 stamp file) to 'man-stamp'.  The base of the file name is derived from
5559 the defined 'prog-name'.
5560
5561    The texi invocation document is produced via:
5562      autogen -Tagtexi-cmd.tpl -MFtexi-dep -MTtexi-stamp opts.def
5563
5564 \1f
5565 File: autogen.info,  Node: Installation,  Next: AutoOpts,  Prev: autogen Invocation,  Up: Top
5566
5567 6 Configuring and Installing
5568 ****************************
5569
5570 * Menu:
5571
5572 * configuring::    Configuring AutoGen
5573 * AutoGen CGI::    AutoGen as a CGI server
5574 * signal names::   Signal Names
5575 * installing::     Installing AutoGen
5576
5577 \1f
5578 File: autogen.info,  Node: configuring,  Next: AutoGen CGI,  Up: Installation
5579
5580 6.1 Configuring AutoGen
5581 =======================
5582
5583 AutoGen is configured and built using Libtool, Automake and Autoconf.
5584 Consequently, you can install it wherever you wish using the '--prefix'
5585 and other options.  To the various configuration options supplied by
5586 these tools, AutoGen adds a few of its own:
5587
5588 '--disable-shell'
5589      AutoGen is now capable of acting as a CGI forms server, *Note
5590      AutoGen CGI::.  As such, it will gather its definitions using
5591      either 'GET' or 'POST' methods.  All you need to do is have a
5592      template named 'cgi.tpl' handy or specify a different one with a
5593      command line option.
5594
5595      However, doing this without disabling the server shell brings
5596      considerable risk.  If you were to pass user input to a script that
5597      contained, say, the classic "'`rm -rf /`'", you might have a
5598      problem.  This configuration option will cause shell template
5599      commands to simply return the command string as the result.  No
5600      mistakes.  Much safer.  Strongly recommended.  The default is to
5601      have server shell scripting enabled.
5602
5603      Disabling the shell will have some build side effects, too.
5604
5605         * Many of the make check tests will fail, since they assume a
5606           working server shell.
5607         * The getdefs and columns programs are not built.  The options
5608           are distributed as definition files and they cannot be
5609           expanded with a shell-disabled AutoGen.
5610         * Similarly, the documentation cannot be regenerated because the
5611           documentation templates depend on subshell functionality.
5612
5613 '--enable-debug'
5614      Turning on AutoGen debugging enables very detailed inspection of
5615      the input definitions and monitoring shell script processing.
5616      These options are not particularly useful to anyone not directly
5617      involved in maintaining AutoGen.  If you do choose to enable
5618      AutoGen debugging, be aware that the usage page was generated
5619      without these options, so when the build process reaches the
5620      documentation rebuild, there will be a failure.  'cd' into the
5621      'agen5' build directory, 'make' the 'autogen.texi' file and all
5622      will be well thereafter.
5623
5624 '--with-regex-header'
5625 '--with-header-path'
5626 '--with-regex-lib'
5627      These three work together to specify how to compile with and link
5628      to a particular POSIX regular expression library.  The value for
5629      '--with-regex-header=value' must be the name of the relevant header
5630      file.  The AutoGen sources will attempt to include that source with
5631      a '#include <value>' C preprocessing statement.  The PATH from the
5632      '--with-header-path=path' will be added to 'CPPFLAGS' as '-Ipath'.
5633      The LIB-SPECS from '--with-regex-lib=lib-specs' will be added to
5634      'LDFLAGS' without any adornment.
5635
5636 \1f
5637 File: autogen.info,  Node: AutoGen CGI,  Next: signal names,  Prev: configuring,  Up: Installation
5638
5639 6.2 AutoGen as a CGI server
5640 ===========================
5641
5642 AutoGen is now capable of acting as a CGI forms server.  It behaves as a
5643 CGI server if the definitions input is from stdin and the environment
5644 variable 'REQUEST_METHOD' is defined and set to either "GET" or "POST".
5645 If set to anything else, AutoGen will exit with a failure message.  When
5646 set to one of those values, the CGI data will be converted to AutoGen
5647 definitions (*note Definitions File::) and the template named
5648 "'cgi.tpl'" will be processed.
5649
5650    This works by including the name of the real template to process in
5651 the form data and having the "'cgi.tpl'" template include that template
5652 for processing.  I do this for processing the form
5653 <http://autogen.sourceforge.net/conftest.html>.  The "'cgi.tpl'" looks
5654 approximately like this:
5655
5656      <? AutoGen5 Template ?>
5657      <?
5658      IF (not (exist? "template"))                       ?><?
5659        form-error                                       ?><?
5660
5661      ELIF (=* (get "template") "/")                     ?><?
5662        form-error                                       ?><?
5663
5664      ELIF (define tpl-file (string-append "cgi-tpl/"
5665                            (get "template")))
5666           (access? tpl-file R_OK)                       ?><?
5667        INCLUDE (. tpl-file)                             ?><?
5668
5669      ELIF (set! tpl-file (string-append tpl-file ".tpl"))
5670           (access? tpl-file R_OK)                       ?><?
5671        INCLUDE (. tpl-file)                             ?><?
5672
5673      ELSE                                               ?><?
5674        form-error                                       ?><?
5675      ENDIF                                              ?>
5676
5677 This forces the template to be found in the "'cgi-tpl/'" directory.
5678 Note also that there is no suffix specified in the pseudo macro (*note
5679 pseudo macro::).  That tells AutoGen to emit the output to 'stdout'.
5680
5681    The output is actually spooled until it is complete so that, in the
5682 case of an error, the output can be discarded and a proper error message
5683 can be written in its stead.
5684
5685    *Please also note* that it is advisable, _especially_ for network
5686 accessible machines, to configure AutoGen (*note configuring::) with
5687 shell processing disabled ('--disable-shell').  That will make it
5688 impossible for any referenced template to hand data to a subshell for
5689 interpretation.
5690
5691 \1f
5692 File: autogen.info,  Node: signal names,  Next: installing,  Prev: AutoGen CGI,  Up: Installation
5693
5694 6.3 Signal Names
5695 ================
5696
5697 When AutoGen is first built, it tries to use 'psignal(3)',
5698 'sys_siglist', 'strsigno(3)' and 'strsignal(3)' from the host operating
5699 system.  If your system does not supply these, the AutoGen distribution
5700 will.  However, it will use the distributed mapping and this mapping is
5701 unlikely to match what your system uses.  This can be fixed.  Once you
5702 have installed autogen, the mapping can be rebuilt on the host operating
5703 system.  To do so, you must perform the following steps:
5704
5705   1. Build and install AutoGen in a place where it will be found in your
5706      search path.
5707   2. 'cd ${top_srcdir}/compat'
5708   3. 'autogen strsignal.def'
5709   4. Verify the results by examining the 'strsignal.h' file produced.
5710   5. Re-build and re-install AutoGen.
5711
5712    If you have any problems or peculiarities that cause this process to
5713 fail on your platform, please send me copies of the header files
5714 containing the signal names and numbers, along with the full path names
5715 of these files.  I will endeavor to fix it.  There is a shell script
5716 inside of 'strsignal.def' that tries to hunt down the information.
5717
5718 \1f
5719 File: autogen.info,  Node: installing,  Prev: signal names,  Up: Installation
5720
5721 6.4 Installing AutoGen
5722 ======================
5723
5724 There are several files that get installed.  The number depend whether
5725 or not both shared and archive libraries are to be installed.  The
5726 following assumes that everything is installed relative to '$prefix'.
5727 You can, of course, use 'configure' to place these files where you wish.
5728
5729    *NB* AutoGen does not contain any compiled-in path names.  All
5730 support directories are located via option processing, the environment
5731 variable 'HOME' or finding the directory where the executable came from.
5732
5733    The installed files are:
5734
5735   1. The executables in 'bin' (autogen, getdefs and columns).
5736
5737   2. The AutoOpts link libraries as 'lib/libopts.*'.
5738
5739   3. An include file in 'include/options.h', needed for Automated Option
5740      Processing (see next chapter).
5741
5742   4. Several template files and a scheme script in 'share/autogen',
5743      needed for Automated Option Processing (*note AutoOpts::), parsing
5744      definitions written with scheme syntax (*note Dynamic Text::), the
5745      templates for producing documentation for your program (*note
5746      documentation attributes::), autoconf test macros, and AutoFSM.
5747
5748   5. Info-style help files as 'info/autogen.info*'.  These files
5749      document AutoGen, the option processing library AutoOpts, and
5750      several add-on components.
5751
5752   6. The three man pages for the three executables are installed in
5753      man/man1.
5754
5755    This program, library and supporting files can be installed with
5756 three commands:
5757
5758    * <src-dir>/configure [ <configure-options> ]
5759    * make
5760    * make install
5761
5762    However, you may wish to insert 'make check' before the 'make
5763 install' command.
5764
5765    If you do perform a 'make check' and there are any failures, you will
5766 find the results in '<module>/test/FAILURES'.  Needless to say, I would
5767 be interested in seeing the contents of those files and any associated
5768 messages.  If you choose to go on and analyze one of these failures, you
5769 will need to invoke the test scripts individually.  You may do so by
5770 specifying the test (or list of test) in the TESTS make variable, thus:
5771
5772      gmake TESTS=test-name.test check
5773
5774    I specify 'gmake' because most makes will not let you override
5775 internal definitions with command line arguments.  'gmake' does.
5776
5777    All of the AutoGen tests are written to honor the contents of the
5778 VERBOSE environment variable.  Normally, any commentary generated during
5779 a test run is discarded unless the VERBOSE environment variable is set.
5780 So, to see what is happening during the test, you might invoke the
5781 following with bash or ksh:
5782
5783      VERBOSE=1 gmake TESTS="for.test forcomma.test" check
5784
5785 Or equivalently with csh:
5786
5787      env VERBOSE=1 gmake TESTS="for.test forcomma.test" check
5788
5789 \1f
5790 File: autogen.info,  Node: AutoOpts,  Next: Add-Ons,  Prev: Installation,  Up: Top
5791
5792 7 Automated Option Processing
5793 *****************************
5794
5795 AutoOpts 42.1 is bundled with AutoGen.  It is a tool that virtually
5796 eliminates the hassle of processing options and keeping man pages, info
5797 docs and usage text up to date.  This package allows you to specify
5798 several program attributes, thousands of option types and many option
5799 attributes.  From this, it then produces all the code necessary to parse
5800 and handle the command line and configuration file options, and the
5801 documentation that should go with your program as well.
5802
5803    All the features notwithstanding, some applications simply have
5804 well-established command line interfaces.  Even still, those programs
5805 may use the configuration file parsing portion of the library.  See the
5806 "AutoOpts Features" and "Configuration File Format" sections.
5807
5808 * Menu:
5809
5810 * Features::            AutoOpts Features
5811 * Licensing::           AutoOpts Licensing
5812 * Caveats::             Developer and User Notes
5813 * Quick Start::         Quick Start
5814 * Option Definitions::  Option Definitions
5815 * AutoOpts API::        Programmatic Interface
5816 * Multi-Threading::     Multi-Threading
5817 * option descriptor::   Option Descriptor File
5818 * Using AutoOpts::      Using AutoOpts
5819 * Presetting Options::  Configuring your program
5820 * Config File Format::  Configuration File Format
5821 * shell options::       AutoOpts for Shell Scripts
5822 * AutoInfo::            Automated Info Docs
5823 * AutoMan pages::       Automated Man Pages
5824 * getopt_long::         Using getopt(3C)
5825 * i18n::                Internationalizing AutoOpts
5826 * Naming Conflicts::    Naming Conflicts
5827 * All Attribute Names:: All Attribute Names
5828 * Option Define Names:: Option Definition Name Index
5829
5830 \1f
5831 File: autogen.info,  Node: Features,  Next: Licensing,  Up: AutoOpts
5832
5833 7.1 AutoOpts Features
5834 =====================
5835
5836 AutoOpts supports option processing; option state saving; and program
5837 documentation with innumerable features.  Here, we list a few obvious
5838 ones and some important ones, but the full list is really defined by all
5839 the attributes defined in the *note Option Definitions:: section.
5840
5841   1. POSIX-compliant short (flag) option processing.
5842
5843   2. GNU-style long options processing.  Long options are recognized
5844      without case sensitivity, and they may be abbreviated.
5845
5846   3. Environment variable initializations, *Note environrc::.
5847
5848   4. Initialization from configuration files (aka RC or INI files), and
5849      saving the option state back into one, *Note loading rcfile::.
5850
5851   5. Config files may be partitioned.  One config file may be used by
5852      several programs by partitioning it with lines containing,
5853      '[PROGRAM_NAME]' or '<?program-name>', *Note loading rcfile::.
5854
5855   6. Config files may contain AutoOpts directives.  '<?auto-options
5856      [[option-text]]>' may be used to set 'AutoOpts' option processing
5857      options.  Viz., GNU usage layout versus 'AutoOpts' conventional
5858      layout, and 'misuse-usage' versus 'no-misuse-usage', *Note usage
5859      attributes::.
5860
5861   7. Options may be marked as 'dis-abled' with a disablement prefix.
5862      Such options may default to either an enabled or a disabled state.
5863      You may also provide an enablement prefix, too, e.g.,
5864      '--allow-mumble' and '--prevent-mumble' (*note Common
5865      Attributes::).
5866
5867   8. Verify that required options are present between the minimum and
5868      maximum number of times on the command line.  Verify that
5869      conflicting options do not appear together.  Verify that options
5870      requiring the presence of other options are, in fact, used in the
5871      presence of other options.  See *Note Common Attributes::, and
5872      *Note Option Conflict Attributes::.
5873
5874   9. There are several *note automatically supported options: automatic
5875      options.  They will have short flags if any options have option
5876      flags and the flags are not suppressed.  The associated flag may be
5877      altered or suppressed by specifying no value or an alternate
5878      character for 'xxx-value;' in the option definition file.  'xxx' is
5879      the name of the option below:
5880
5881      '--help'
5882      '--more-help'
5883           These are always available.  '--more-help' will pass the full
5884           usage text through a pager.
5885      '--usage'
5886           This is added to the option list if 'usage-opt' is specified.
5887           It yields the abbreviated usage to 'stdout'.
5888      '--version'
5889           This is added to the option list if 'version = xxx;' is
5890           specified.
5891      '--load-opts'
5892      '--save-opts'
5893           These are added to the option list if 'homerc' is specified.
5894           Mostly.  If, 'disable-save' is specified, then '--save-opts'
5895           is disabled.
5896
5897   10. Various forms of main procedures can be added to the output, *Note
5898      Generated main::.  There are four basic forms:
5899
5900        a. A program that processes the arguments and writes to standard
5901           out portable shell commands containing the digested options.
5902
5903        b. A program that will generate portable shell commands to parse
5904           the defined options.  The expectation is that this result will
5905           be copied into a shell script and used there.
5906
5907        c. A 'for-each' main that will invoke a named function once for
5908           either each non-option argument on the command line or, if
5909           there are none, then once for each non-blank, non-comment
5910           input line read from stdin.
5911
5912        d. A main procedure of your own design.  Its code can be supplied
5913           in the option description template or by incorporating another
5914           template.
5915
5916   11. There are several methods for handling option arguments.
5917         * nothing (*note OPT_ARG::) option argument strings are globally
5918           available.
5919         * user supplied (*note Option Argument Handling::)
5920         * stack option arguments (*note Option Argument Handling::)
5921         * integer numbers (*note arg-type number::)
5922         * true or false valued (*note arg-type boolean::)
5923         * enumerated list of names (*note arg-type keyword::)
5924         * an enumeration (membership) set (*note arg-type set
5925           membership::)
5926         * a list of name/value pairs (option 'subopts') (*note arg-type
5927           hierarchy::)
5928         * a time duration or a specific time and date
5929         * validated file name (*note arg-type file name::)
5930         * optional option argument (*note arg-optional::)
5931
5932   12. The generated usage text can be emitted in either AutoOpts
5933      standard format (maximizing the information about each option), or
5934      GNU-ish normal form.  The default form is selected by either
5935      specifying or not specifying the 'gnu-usage' attribute (*note
5936      information attributes::).  This can be overridden by the user
5937      himself with the 'AUTOOPTS_USAGE' environment variable.  If it
5938      exists and is set to the string 'gnu', it will force GNU-ish style
5939      format; if it is set to the string 'autoopts', it will force
5940      AutoOpts standard format; otherwise, it will have no effect.
5941
5942   13. The usage text and many other strings are stored in a single
5943      character array (*note string table functions: SCM
5944      string-table-new.).  This reduces fixup costs when loading the
5945      program or library.  The downside is that if GCC detects that any
5946      of these strings are used in a printf format, you may get the
5947      warning, 'embedded '\0' in format'.  To eliminate the warning, you
5948      must provide GCC with the '-Wno-format-contains-nul' option.
5949
5950   14. If you compile with 'ENABLE_NLS' defined and '_()' defined to a
5951      localization function (e.g.  'gettext(3GNU)'), then the option
5952      processing code will be localizable (*note i18n::).  Provided also
5953      that you do not define the 'no-xlate' attribute to _anything_
5954      (*note presentation attributes::).
5955
5956      You should also ensure that the 'ATTRIBUTE_FORMAT_ARG()' gets
5957      '#define'-ed to something useful.  There is an autoconf macro named
5958      'AG_COMPILE_FORMAT_ARG' in 'ag_macros.m4' that will set it
5959      appropriately for you.  If you do not do this, then translated
5960      formatting strings may trigger GCC compiler warnings.
5961
5962   15. Provides a callable routine to parse a text string as if it were
5963      from one of the rc/ini/config files, hereafter referred to as a
5964      configuration file.
5965
5966   16. By adding a 'doc' and 'arg-name' attributes to each option,
5967      AutoGen will also be able to produce a man page and the 'invoking'
5968      section of a texinfo document.
5969
5970   17. Intermingled option processing.  AutoOpts options may be
5971      intermingled with command line operands and options processed with
5972      other parsing techniques.  This is accomplished by setting the
5973      'allow-errors' (*note program attributes::) attribute.  When
5974      processing reaches a point where 'optionProcess' (*note
5975      libopts-optionProcess::) needs to be called again, the current
5976      option can be set with 'RESTART_OPT(n)' (*note RESTART_OPT::)
5977      before calling 'optionProcess'.
5978
5979      See: *Note library attributes::.
5980
5981   18. Library suppliers can specify command line options that their
5982      client programs will accept.  They specify option definitions that
5983      get '#include'-d into the client option definitions and they
5984      specify an "anchor" option that has a callback and must be invoked.
5985      That will give the library access to the option state for their
5986      options.
5987
5988   19. library options.  An AutoOpt-ed library may export its options for
5989      use in an AutoOpt-ed program.  This is done by providing an option
5990      definition file that client programs '#include' into their own
5991      option definitions.  See "AutoOpt-ed Library for AutoOpt-ed
5992      Program" (*note lib and program::) for more details.
5993
5994 \1f
5995 File: autogen.info,  Node: Licensing,  Next: Caveats,  Prev: Features,  Up: AutoOpts
5996
5997 7.2 AutoOpts Licensing
5998 ======================
5999
6000 When AutoGen is installed, the AutoOpts project is installed with it.
6001 AutoOpts includes various AutoGen templates and a pair of shared
6002 libraries.  These libraries may be used under the terms of version 3 of
6003 the GNU Lesser General Public License (LGPL).
6004
6005    One of these libraries ('libopts') is needed by programs that are
6006 built using AutoOpts generated code.  This library is available as a
6007 separate "tear-off" source tarball.  It is redistributable for use under
6008 either of two licenses: The above mentioned GNU Lesser General Public
6009 License, and the advertising-clause-free BSD license.  Both of these
6010 license terms are incorporated into appropriate COPYING files included
6011 with the 'libopts' source tarball.  This source may be incorporated into
6012 your package with the following simple commands:
6013
6014      rm -rf libopts libopts-*
6015      gunzip -c `autoopts-config libsrc` | \
6016         tar -xvf -
6017      mv libopts-*.*.* libopts
6018
6019    View the 'libopts/README' file for further integration information.
6020
6021 \1f
6022 File: autogen.info,  Node: Caveats,  Next: Quick Start,  Prev: Licensing,  Up: AutoOpts
6023
6024 7.3 Developer and User Notes
6025 ============================
6026
6027 The formatting of the usage message can be controlled with the use of
6028 the 'AUTOOPTS_USAGE' environment variable.  If it contains any of five
6029 possible comma separated values, it will affect 'libopts' behavior.  Any
6030 extraneous or conflicting data will cause its value to be ignored.
6031
6032    If the program attributes 'long-usage' and 'short-usage' have been
6033 specified (*note Usage and Version Info Display: usage attributes.),
6034 these strings are used for displaying full usage and abbreviated usage.
6035 "Full usage" is used when usage is requested, "abbreviated usage" when a
6036 usage error is detected.  If these strings are not provided, the usage
6037 text is computed.
6038
6039    The 'AUTOOPTS_USAGE' environment variable may be set to the comma
6040 and/or white space separated list of the following strings:
6041
6042 'compute'
6043      Ignore the provision of 'long-usage' and 'short-usage' attributes,
6044      and compute the usage strings.  This is useful, for example, if you
6045      wish to regenerate the basic form of these strings and either tweak
6046      them or translate them.  The methods used to compute the usage text
6047      are not suitable for translation.
6048
6049 'gnu'
6050      The format of the usage text will be displayed in GNU-normal form.
6051      The default display for '--version' will be to include a note on
6052      licensing terms.
6053
6054 'autoopts'
6055      The format of the extended usage will be in AutoOpts' native
6056      layout.  The default version display will be one line of text with
6057      the last token the version.  'gnu' and 'autoopts' conflict and may
6058      not be used together.
6059
6060 'no-misuse-usage'
6061      When an option error is made on the command line, the abbreviated
6062      usage text will be suppressed.  An error message and the method for
6063      getting full usage information will be displayed.
6064
6065 'misuse-usage'
6066      When an option error is made on the command line, the abbreviated
6067      usage text will be shown.  'misuse-usage' and 'no-misuse-usage'
6068      conflict and may not be used together.
6069
6070    'misuse-usage' and 'autoopts' are the defaults.  These defaults may
6071 be flipped to 'no-misuse-usage' and 'gnu' by specifying 'gnu-usage' and
6072 'no-misuse-usage' program attributes, respectively, in the option
6073 definition file.
6074
6075 Note for developers:
6076
6077    The templates used to implement AutoOpts depend heavily upon token
6078 pasting.  That mens that if you name an option, 'debug', for example,
6079 the generated header will expect to be able to emit '#define' macros
6080 such as this:
6081      #define DESC(n) (autogenOptions.pOptDesc[INDEX_OPT_## n])
6082    and expect 'DESC(DEBUG)' to expand correctly into
6083 '(autogenOptions.pOptDesc[INDEX_OPT_DEBUG])'.  If 'DEBUG' is '#defined'
6084 to something else, then that something else will be in the above
6085 expansion.
6086
6087    If you discover you are having strange problems like this, you may
6088 wish to use some variation of the 'guard-option-names' *Note program
6089 attributes::.
6090
6091 \1f
6092 File: autogen.info,  Node: Quick Start,  Next: Option Definitions,  Prev: Caveats,  Up: AutoOpts
6093
6094 7.4 Quick Start
6095 ===============
6096
6097 Since it is generally easier to start with a simple example than it is
6098 to look at the options that AutoGen uses itself, here is a very simple
6099 AutoOpts example.  You can copy this example out of the Info file and
6100 into a source file to try it.  You can then embellish it into what you
6101 really need.  For more extensive examples, you can also examine the help
6102 output and option definitions for the commands 'columns', 'getdefs' and
6103 'autogen' itself.
6104
6105    If you are looking for a more extensive example, you may search the
6106 autogen sources for files named '*opts.def'.  'xml2ag' is ridiculous and
6107 'autogen' is very lengthy, but 'columns' and 'getdefs' are not too
6108 difficult.  The 'sharutils' sources are fairly reasonable, too.
6109
6110 * Menu:
6111
6112 * quick ao problem::    Example option requirements
6113 * quick ao def::        Example option definitions
6114 * quick ao build::      Build the example options
6115 * quick ao help::       Example option help text
6116 * quick ao usage::      Using the example options
6117 * quick ao docs::       Example option documentation
6118
6119 \1f
6120 File: autogen.info,  Node: quick ao problem,  Next: quick ao def,  Up: Quick Start
6121
6122 7.4.1 Example option requirements
6123 ---------------------------------
6124
6125 For our simple example, assume you have a program named 'check' that
6126 takes two options:
6127
6128   1. A list of directories to check over for whatever it is 'check'
6129      does.  You want this option available as a POSIX-style flag option
6130      and a GNU long option.  You want to allow as many of these as the
6131      user wishes.
6132   2. An option to show or not show the definition tree being used.  Only
6133      one occurrence is to be allowed, specifying one or the other.
6134
6135 \1f
6136 File: autogen.info,  Node: quick ao def,  Next: quick ao build,  Prev: quick ao problem,  Up: Quick Start
6137
6138 7.4.2 Example option definitions
6139 --------------------------------
6140
6141 First, specify your program attributes and its options to AutoOpts, as
6142 with the following example.
6143
6144      AutoGen Definitions options;
6145      prog-name     = check;
6146      prog-title    = "Checkout Automated Options";
6147      long-opts;
6148      gnu-usage;    /* GNU style preferred to default */
6149
6150      main = { main-type = shell-process; };
6151
6152      flag = {
6153          name      = check-dirs;
6154          value     = L;        /* flag style option character */
6155          arg-type  = string;   /* option argument indication  */
6156          max       = NOLIMIT;  /* occurrence limit (none)     */
6157          stack-arg;            /* save opt args in a stack    */
6158          descrip   = "Checkout directory list";
6159          doc       = 'name of each directory that is to be "checked out".';
6160      };
6161
6162      flag = {
6163          name      = show_defs;
6164          descrip   = "Show the definition tree";
6165          disable   = dont;     /* mark as enable/disable type */
6166                                /* option.  Disable as `dont-' */
6167          doc       = 'disable, if you do not want to see the tree.';
6168      };
6169
6170 \1f
6171 File: autogen.info,  Node: quick ao build,  Next: quick ao help,  Prev: quick ao def,  Up: Quick Start
6172
6173 7.4.3 Build the example options
6174 -------------------------------
6175
6176 This program will produce a program that digests its options and writes
6177 the values as shell script code to stdout.  Run the following short
6178 script to produce this program:
6179      base=check
6180      BASE=`echo $base | tr '[a-z-]' '[A-Z_]'`
6181      cflags="-DTEST_${BASE} `autoopts-config cflags`"
6182      ldflags="`autoopts-config ldflags`"
6183      autogen ${base}.def
6184      cc -o ${base} -g ${cflags} ${base}.c ${ldflags}
6185      ./${base} --help
6186
6187 \1f
6188 File: autogen.info,  Node: quick ao help,  Next: quick ao usage,  Prev: quick ao build,  Up: Quick Start
6189
6190 7.4.4 Example option help text
6191 ------------------------------
6192
6193 Running the build commands yields:
6194
6195
6196      exit 0
6197
6198 \1f
6199 File: autogen.info,  Node: quick ao usage,  Next: quick ao docs,  Prev: quick ao help,  Up: Quick Start
6200
6201 7.4.5 Using the example options
6202 -------------------------------
6203
6204 Normally, however, you would not use the 'main' clause.  Instead, the
6205 file would be named something like 'checkopt.def', you would compile
6206 'checkopt.c' the usual way, and link the object with the rest of your
6207 program.
6208
6209    The options are processed by calling 'optionProcess' (*note
6210 libopts-optionProcess::):
6211
6212      main( int argc, char** argv )
6213      {
6214        {
6215          int optct = optionProcess( &checkOptions, argc, argv );
6216          argc -= optct;
6217          argv += optct;
6218        }
6219
6220    The options are tested and used as in the following fragment.
6221 'ENABLED_OPT' is used instead of 'HAVE_OPT' for the '--show-defs' option
6222 because it is an enabled/disabled option type:
6223
6224        if (  ENABLED_OPT( SHOW_DEFS )
6225           && HAVE_OPT( CHECK_DIRS )) {
6226          int    dirct = STACKCT_OPT( CHECK_DIRS );
6227          char** dirs  = STACKLST_OPT( CHECK_DIRS );
6228          while (dirct-- > 0) {
6229            char* dir = *dirs++;
6230            ...
6231
6232 \1f
6233 File: autogen.info,  Node: quick ao docs,  Prev: quick ao usage,  Up: Quick Start
6234
6235 7.4.6 Example option documentation
6236 ----------------------------------
6237
6238 The 'doc' clauses are used in the flag stanzas for man pages and texinfo
6239 invoking documentation.  With the definition file described above, the
6240 two following commands will produce the two documentation files
6241 'check.1' and 'invoke-check.texi'.  The latter file will be generated as
6242 a chapter, rather than a section or subsection.
6243
6244      autogen -Tagman-cmd check.def
6245      autogen -DLEVEL=chapter -Tagtexi-cmd -binvoke-check.texi check.def
6246
6247 The result of which is left as an exercise for the reader.
6248
6249    A lot of magic happens to make this happen.  The rest of this chapter
6250 will describe the myriad of option attributes supported by AutoOpts.
6251 However, keep in mind that, in general, you won't need much more than
6252 what was described in this "quick start" section.
6253
6254 \1f
6255 File: autogen.info,  Node: Option Definitions,  Next: AutoOpts API,  Prev: Quick Start,  Up: AutoOpts
6256
6257 7.5 Option Definitions
6258 ======================
6259
6260 AutoOpts uses an AutoGen definitions file for the definitions of the
6261 program options and overall configuration attributes.  The complete list
6262 of program and option attributes is quite extensive, so if you are
6263 reading to understand how to use AutoOpts, I recommend reading the
6264 "Quick Start" section (*note Quick Start::) and paying attention to the
6265 following:
6266
6267   1. 'prog-name', 'prog-title', and 'argument', program attributes,
6268      *Note program attributes::.
6269   2. 'name' and 'descrip' option attributes, *Note Required
6270      Attributes::.
6271   3. 'value' (flag character) and 'min' (occurrence counts) option
6272      attributes, *Note Common Attributes::.
6273   4. 'arg-type' from the option argument specification section, *Note
6274      Option Arguments::.
6275   5. Read the overall how to, *Note Using AutoOpts::.
6276   6. Highly recommended, but not required, are the several "man" and
6277      "info" documentation attributes, *Note documentation attributes::.
6278
6279    Keep in mind that the majority are rarely used and can be safely
6280 ignored.  However, when you have special option processing requirements,
6281 the flexibility is there.
6282
6283 * Menu:
6284
6285 * program attributes::          Program Description Attributes
6286 * library attributes::          Options for Library Code
6287 * information attributes::      Program Information Attributes
6288 * Generated main::              Generating main procedures
6289 * option attributes::           Option Attributes
6290 * Option Arguments::            Option Argument Specification
6291 * Option Argument Handling::    Option Argument Handling
6292 * Internationalizing Options::  Internationalizing Options
6293 * documentation attributes::    Man and Info doc Attributes
6294 * automatic options::           Automatically Supported Options
6295 * standard options::            Library of Standard Options
6296
6297 \1f
6298 File: autogen.info,  Node: program attributes,  Next: library attributes,  Up: Option Definitions
6299
6300 7.5.1 Program Description Attributes
6301 ------------------------------------
6302
6303 The following global definitions are used to define attributes of the
6304 entire program.  These generally alter the configuration or global
6305 behavior of the AutoOpts option parser.  The first two are required of
6306 every program.  The third is required if there are to be any left over
6307 arguments (operands) after option processing.  The rest have been
6308 grouped below.  Except as noted, there may be only one copy of each of
6309 these definitions:
6310
6311 'prog-name'
6312      This attribute is required.  Variable names derived from this name
6313      are derived using 'string->c_name!' (*note SCM string->c-name!::).
6314
6315 'prog-title'
6316      This attribute is required and may be any descriptive text.
6317
6318 'argument'
6319      This attribute is required if your program uses operand arguments.
6320      It specifies the syntax of the arguments that *follow* the options.
6321      It may not be empty, but if it is not supplied, then option
6322      processing must consume all the arguments.  If it is supplied and
6323      starts with an open bracket ('['), then there is no requirement on
6324      the presence or absence of command line arguments following the
6325      options.  Lastly, if it is supplied and does not start with an open
6326      bracket, then option processing must *not* consume all of the
6327      command line arguments.
6328
6329 'config-header'
6330      If your build has a configuration header, it must be included
6331      before anything else.  Specifying the configuration header file
6332      name with this attribute will cause that to happen.
6333
6334 * Menu:
6335
6336 * usage attributes::            Usage and Version Info Display
6337 * config attributes::           Program Configuration
6338 * programming attributes::      Programming Details
6339 * presentation attributes::     User Presentation Attributes
6340
6341 \1f
6342 File: autogen.info,  Node: usage attributes,  Next: config attributes,  Up: program attributes
6343
6344 7.5.1.1 Usage and Version Info Display
6345 ......................................
6346
6347 These will affect the way usage is seen and whether or not version
6348 information gets displayed.
6349
6350 'full-usage'
6351      If this attribute is provided, it may specify the full length usage
6352      text, or a variable name assignable to a 'char const *' pointer, or
6353      it may be empty.  The meanings are determined by the length.
6354         * If not provided, the text will be computed as normal.
6355         * If the length is zero, then the usage text will be derived
6356           from the current settings and inserted as text into the
6357           generated .c file.
6358         * If the length is 1 to 32 bytes, then it is presumed to be a
6359           variable name that either points to or is an array of const
6360           chars.
6361         * If it is longer than that, it is presumed to be the help text
6362           itself.  This text will be inserted into the generated .c
6363           file.
6364
6365      This string should be readily translatable.  Provision will be made
6366      to translate it if this is provided, if the source code is compiled
6367      with 'ENABLE_NLS' defined, and 'no-xlate' has not been set to the
6368      value _anything_.  The untranslated text will be handed to
6369      'dgettext("libopts", txt)' and then 'gettext(txt)' for translation,
6370      one paragraph at a time.
6371
6372      To facilitate the creation and maintenance of this text, you can
6373      force the string to be ignored and recomputed by specifying
6374           AUTOOPTS_USAGE=compute
6375      in the environment and requesting help or usage information.  See
6376      *Note Developer and User Notes: Caveats.
6377
6378 'short-usage'
6379      If this attribute is provided, it is used to specify an abbreviated
6380      version of the usage text.  This text is constructed in the same
6381      way as the 'full-usage', described above.
6382
6383 'gnu-usage'
6384      AutoOpts normaly displays usage text in a format that provides more
6385      information than the standard GNU layout, but that also means it is
6386      not the standard GNU layout.  This attribute changes the default to
6387      GNU layout, with the 'AUTOOPTS_USAGE' environment variable used to
6388      request 'autoopts' layout.  See *Note Developer and User Notes:
6389      Caveats.
6390
6391 'usage-opt'
6392      I apologize for too many confusing usages of usage.  This attribute
6393      specifies that '--usage' and/or '-u' be supported.  The help
6394      (usage) text displayed will be abbreviated when compared to the
6395      default help text.
6396
6397 'no-misuse-usage'
6398      When there is a command line syntax error, by default AutoOpts will
6399      display the abbreviated usage text, rather than just a one line
6400      "you goofed it, ask for usage" message.  You can change the default
6401      behavior for your program by supplying this attribute.  The user
6402      may override this choice, again, with the 'AUTOOPTS_USAGE'
6403      environment variable.  See *Note Developer and User Notes: Caveats.
6404
6405 'prog-group'
6406      The version text in the 'getopt.tpl' template will include this
6407      text in parentheses after the program name, when this attribute is
6408      specified.  For example:
6409           mumble (stumble) 1.0
6410      says that the 'mumble' program is version 1.0 and is part of the
6411      'stumble' group of programs.
6412
6413 'usage'
6414      If your program has some cleanup work that must be done before
6415      exiting on usage mode issues, or if you have to customize the usage
6416      message in some way, specify this procedure and it will be called
6417      instead of the default 'optionUsage()' function.  For example, if a
6418      program is using the curses library and needs to invoke the usage
6419      display, then you must arrange to call 'endwin()' before invoking
6420      the library function 'optionUsage()'.  This can be handled by
6421      specifying your own usage function, thus:
6422           void
6423           my_usage(tOptions * opts, int ex)
6424           {
6425               if (curses_window_active)
6426                   endwin();
6427               optionUsage(opts, ex);
6428           }
6429
6430 'version'
6431      Specifies the program version and activates the VERSION option,
6432      *Note automatic options::.
6433
6434 \1f
6435 File: autogen.info,  Node: config attributes,  Next: programming attributes,  Prev: usage attributes,  Up: program attributes
6436
6437 7.5.1.2 Program Configuration
6438 .............................
6439
6440 Programs may be "pre-configured" before normal command line options are
6441 processed (See *note Immediate Action Attributes: Immediate Action.).
6442 How configuration files and environment variables are handled get
6443 specified with these attributes.
6444
6445 'disable-load'
6446 'disable-save'
6447      Indicates that the command line usage of '--load-opts' and/or
6448      '--save-opts' are disallowed.
6449
6450 'environrc'
6451      Indicates looking in the environment for values of variables named,
6452      'PROGRAM_OPTNAME' or 'PROGRAM', where 'PROGRAM' is the upper cased
6453      C-NAME of the program and 'OPTNAME' is the upper cased C-NAME of a
6454      specific option.  The contents of the 'PROGRAM' variable, if found,
6455      are tokenized and processed.  The contents of 'PROGRAM_OPTNAME'
6456      environment variables are taken as the option argument to the
6457      option nameed '--optname'.
6458
6459 'homerc'
6460      Specifies that option settings may be loaded from and stored into
6461      configuration files.  Each instance of this attribute is either a
6462      directory or a file using a specific path, a path based on an
6463      environment variable or a path relative to installation
6464      directories.  The method used depends on the name.  If the one
6465      entry is empty, it enables the loading and storing of settings, but
6466      no specific files are searched for.  Otherwise, a series of
6467      configuration files are hunted down and, if found, loaded.
6468
6469      If the first character of the 'homerc' value is not the dollar
6470      character ('$'), then it is presumed to be a path name based on the
6471      current directory.  Otherwise, the method depends on the second
6472      character:
6473
6474      '$'
6475           The path is relative to the directory where the executable was
6476           found.
6477      '@'
6478           The path is relative to the package data directory, e.g.
6479           '/usr/local/share/autogen'.
6480      '[a-zA-Z]'
6481           The path is derived from the named environment variable.
6482
6483      Use as many as you like.  The presence of this attribute activates
6484      the '--save-opts' and '--load-opts' options.  However, saving into
6485      a file may be disabled with the 'disable-save'.  *Note loading
6486      rcfile::.  See the 'optionMakePath(3AGEN)' man page for
6487      excruciating details.
6488
6489 'rcfile'
6490      Specifies the configuration file name.  This is only useful if you
6491      have provided at least one 'homerc' attribute.
6492           default: .<prog-name>rc
6493
6494 'vendor-opt'
6495      This option implements the '-W' vendor option command line option.
6496
6497      For POSIX specified utilities, the options are constrained to the
6498      options that are specified by POSIX. Extensions should be handled
6499      with '-W' command line options, the short flag form.  Long option
6500      name processing must be disabled.  In fact, the 'long-opts'
6501      attribute must not be provided, and some options must be specified
6502      without flag values.
6503
6504      The '-W long-name' is processed by looking up the long option name
6505      that follows it.  It cannot be a short flag because that would
6506      conflict with the POSIX flag name space.  It will be processed as
6507      if long options were accepted and '--long-name' were found on the
6508      command line.
6509
6510 \1f
6511 File: autogen.info,  Node: programming attributes,  Next: presentation attributes,  Prev: config attributes,  Up: program attributes
6512
6513 7.5.1.3 Programming Details
6514 ...........................
6515
6516 These attributes affect some of the ways that the option data are used
6517 and made available to the program.
6518
6519 'config-header'
6520      The contents of this attribute should be just the name of the
6521      configuration file.  A "#include" naming this file will be inserted
6522      at the top of the generated header.
6523
6524 'exit-name'
6525 'exit-desc'
6526      These values should be defined as indexed values, thus:
6527           exit-name[0] = success;
6528           exit-desc[0] = 'Successful program execution.';
6529           exit-name[1] = failure;
6530           exit-desc[1] = 'The operation failed or command syntax was not valid.';
6531      By default, all programs have these effectively defined for them.
6532      They may be overridden by explicitly defining any or all of these
6533      values.  Additional names and descriptions may be defined.  They
6534      will cause an enumeration to be emitted, like this one for
6535      'getdefs':
6536           typedef enum {
6537               GETDEFS_EXIT_SUCCESS = 0,
6538               GETDEFS_EXIT_FAILURE = 1
6539           } getdefs_exit_code_t;
6540      which will be augmented by any 'exit-name' definitions beyond '1'.
6541
6542      Some of the generated code will exit non-zero if there is an
6543      allocation error.  This exit will always be code '1', unless there
6544      is an exit named 'no_mem' or 'nomem'.  In that case, that value
6545      will be used.  Additionally, if there is such a value, and if
6546      'die-code' is specified, then a function 'nomem_err(size_t len,
6547      char const * what)' will be emitted as an inline function for
6548      reporting out-of-memory conditions.
6549
6550 'usage-message'
6551      This attribute will cause two procedures to be added to the code
6552      file: 'usage_message()' and 'vusage_message()', with any applicable
6553      prefix (see 'prefix', below).  They are declared in the generated
6554      header, thus:
6555           noreturn extern void vusage_message(char const * fmt, va_list ap);
6556           noreturn extern void usage_message(char const * fmt, ...);
6557      These functions print the message to 'stderr' and invoke the usage
6558      function with the exit code set to '1' ('EXIT_FAILURE').
6559
6560 'die-code'
6561      This tells AutoOpts templates to emit code for 'vdie()', 'die()',
6562      'fserr()', and, possibly the 'nomem_err()' functions.  The latter
6563      is emitted if an exit name of 'no-mem' or 'nomem' is specified.  If
6564      the 'die-code' is assigned a text value, then that code will be
6565      inserted in the 'vdie' function immediately before it prints the
6566      death rattle message.
6567
6568      The profiles for these functions are:
6569           noreturn extern void vdie( int exit_code, char const * fmt, va_list);
6570           noreturn extern void die(  int exit_code, char const * fmt, ...);
6571           noreturn extern void fserr(int exit_code, char const * op, char const * fname);
6572           noreturn static inline void
6573           nomem_err(size_t sz, char const * what) {...}
6574
6575 'export'
6576      This string is inserted into the .h interface file.  Generally used
6577      for global variables or '#include' directives required by
6578      'flag-code' text and shared with other program text.  Do not
6579      specify your configuration header ('config.h') in this attribute or
6580      the 'include' attribute.  Instead, use 'config-header', above.
6581
6582 'guard-option-names'
6583      AutoOpts generates macros that presume that there are no 'cpp'
6584      macros with the same name as the option name.  For example, if you
6585      have an option named, '--debug', then you must not use '#ifdef
6586      DEBUG' in your code.  If you specify this attribute, every option
6587      name will be guarded.  If the name is '#define'-d, then a warning
6588      will be issued and the name undefined.  If you do not specify this
6589      and there is a conflict, you will get strange error messages.
6590
6591      This attribute may be set to any of four recognized states:
6592
6593         * Not defined.  AutoOpts will behave as described above.
6594
6595         * Defined, but set to the empty string.  Text will be emitted
6596           into the header to undefine ('#undef') any conflicting
6597           preprocessor macros.  The code will include compiler warnings
6598           (via '#warning').  Some compilers are not ANSI-C-99 compliant
6599           yet and will error out on those warnings.  You may compile
6600           with '-DNO_OPTION_NAME_WARNINGS' to silence or mostly silence
6601           them.
6602
6603         * Defined and set to the string, 'no-warning'.  All of the
6604           needed '#undef's will be emitted, without any conflict
6605           checking '#warning' directives emitted.
6606
6607         * Defined and set to the string, 'full-enum'.  The option
6608           manipulation preprocessor macros will not token paste the
6609           option names to the index enumeration prefix.  e.g.  you will
6610           need to use 'HAVE_OPT(INDEX_OPT_DEBUG)' instead of
6611           'HAVE_OPT(DEBUG)'.
6612
6613 'include'
6614      This string is inserted into the .c file.  Generally used for
6615      global variables required only by 'flag-code' program text.
6616
6617 'no-libopts'
6618      If you are going to handle your option processing with the
6619      'getopt.tpl' template instead of using libopts, then specify this
6620      attribute.  It will suppress mention of '--more-help' in the
6621      generated documentation.  ('getopt_long' does not support
6622      '--more-help'.)
6623
6624 'prefix'
6625      This value is inserted into *all* global names.  This will
6626      disambiguate them if more than one set of options are to be
6627      compiled into a single program.
6628
6629 \1f
6630 File: autogen.info,  Node: presentation attributes,  Prev: programming attributes,  Up: program attributes
6631
6632 7.5.1.4 User Presentation Attributes
6633 ....................................
6634
6635 Attributes that affect the user's experience.
6636
6637 'allow-errors'
6638      The presence of this attribute indicates ignoring any command line
6639      option errors.  This may also be turned on and off by invoking the
6640      macros 'ERRSKIP_OPTERR' and 'ERRSTOP_OPTERR' from the generated
6641      interface file.
6642
6643 'long-opts'
6644      Presence indicates GNU-standard long option processing.  Partial
6645      name matches are accepted, if they are at least two characters long
6646      and the partial match is unique.  The matching is not case
6647      sensitive, and the underscore, hyphen and carat characters are all
6648      equivalent (they match).
6649
6650      If any options do not have an option value (flag character)
6651      specified, and least one does specify such a value, then you must
6652      specify 'long-opts'.  If none of your options specify an option
6653      value (flag character) and you do not specify 'long-opts', then
6654      command line arguments are processed in "named option mode".  This
6655      means that:
6656
6657         * Every command line argument must be a long option.
6658         * The flag markers '-' and '--' are completely optional.
6659         * The 'argument' program attribute is disallowed.
6660         * One of the options may be specified as the default (as long as
6661           it has a required option argument).
6662
6663 'no-xlate'
6664      Modifies when or whether option names get translated.  If provided,
6665      it must be assigned one of these values:
6666      'opt-cfg'
6667           to suppress option name translation for configuration file and
6668           and environment variable processing.
6669      'opt'
6670           to suppress option name translation completely.  The usage
6671           text will always be translated if 'ENABLE_NLS' is defined and
6672           you have translations for that text.
6673      'anything'
6674           Specifies disabling all internationalization support for
6675           option code, completely.
6676      See also the various 'XLAT' interface entries in the AutoOpts
6677      Programmatic Interface section (*note AutoOpts API::).
6678
6679 'reorder-args'
6680      Normally, POSIX compliant commands do not allow for options to be
6681      interleaved with operands.  If this is necessary for historical
6682      reasons, there are two approaches available:
6683         * Allow 'optionProcess' to return the index of the operand like
6684           it normally does and process the operand(s).  When an operand
6685           is encountered that starts with a hyphen, then set the
6686           AutoOpts current index with the 'RESTART_OPT' macro (see *note
6687           RESTART_OPT::), and re-invoke 'optionProcess'.  This will also
6688           allow you to process the operands in context.
6689
6690         * Specify this attribute.  AutoOpts will re-order the command
6691           arguments so that the operands appear (in the original order)
6692           at the end of the argument list.  Differing configuration
6693           state is not possible to detect after all options have been
6694           processed.
6695
6696 'resettable'
6697      Specifies that the '--reset-option' command line option is to be
6698      supported.  This makes it possible to suppress any setting that
6699      might be found in a configuration file or environment variable.
6700
6701 \1f
6702 File: autogen.info,  Node: library attributes,  Next: information attributes,  Prev: program attributes,  Up: Option Definitions
6703
6704 7.5.2 Options for Library Code
6705 ------------------------------
6706
6707 Some libraries provide their own code for processing command line
6708 options, and this may be used by programs that utilize AutoOpts.  You
6709 may also wish to write a library that gets configured with AutoOpts
6710 options and config files.  Such a library may either supply its own
6711 configury routine and process its own options, or it may export its
6712 option descriptions to programs that also use AutoOpts.  This section
6713 will describe how to do all of these different things.
6714
6715 * Menu:
6716
6717 * lib and program::         AutoOpt-ed Library for AutoOpt-ed Program
6718 * lib called::              AutoOpt-ed Library for Regular Program
6719 * prog calls lib::          AutoOpt-ed Program Calls Regular Library
6720
6721 \1f
6722 File: autogen.info,  Node: lib and program,  Next: lib called,  Up: library attributes
6723
6724 7.5.2.1 AutoOpt-ed Library for AutoOpt-ed Program
6725 .................................................
6726
6727 The library source code must provide an option definition file that
6728 consists of only the attribute 'library' and 'flag' entries.  The
6729 'library' attribute does not need any associated value, so it will
6730 generally appeary by itself on a line folowed by a semi-colon.  The
6731 first 'flag' entry must contain the following attributes:
6732
6733 'name'
6734      This name is used in the construction of a global pointer of type
6735      'tOptDesc const*'.  It is always required.
6736 'documentation'
6737      It tells 'AutoOpts' that this option serves no normal purpose.  It
6738      will be used to add usage clarity and to locate option descriptors
6739      in the library code.
6740 'descrip'
6741      This is a string that is inserted in the extended usage display
6742      before the options specific to the current library.  It is always
6743      required.
6744 'lib-name'
6745      This should match the name of the library.  This string is also
6746      used in the construction of the option descriptor pointer name.  In
6747      the end, it looks like this:
6748           extern tOptDesc const* <<lib-name>>_<<name>>_optDesc_p;
6749      and is used in the macros generated for the library's '.h' file.
6750
6751    In order to compile this 'AutoOpts' using library, you must create a
6752 special header that is not used by the client program.  This is
6753 accomplished by creating an option definition file that contains
6754 essentially exactly the following:
6755
6756      AutoGen definitions options;
6757      prog-name  = does-not-matter;  // but is always required
6758      prog-title = 'also does not matter';  // also required
6759      config-header = 'config.h'; // optional, but common
6760      library;
6761      #include library-options-only.def
6762
6763 and nothing else.  AutoGen will produce only the '.h' file.  You may now
6764 compile your library, referencing just this '.h' file.  The macros it
6765 creates will utilize a global variable that will be defined by the
6766 'AutoOpts'-using client program.  That program will need to have the
6767 following '#include' in its option definition file:
6768
6769      #include library-options-only.def
6770
6771 All the right things will magically happen so that the global variables
6772 named <<LIB-NAME>>_<<NAME>>_OPTDESC_P are initialized correctly.  For an
6773 example, please see the 'AutoOpts' test script:
6774 'autoopts/test/library.test'.
6775
6776 \1f
6777 File: autogen.info,  Node: lib called,  Next: prog calls lib,  Prev: lib and program,  Up: library attributes
6778
6779 7.5.2.2 AutoOpt-ed Library for Regular Program
6780 ..............................................
6781
6782 In this case, your library must provide an option processing function to
6783 a calling program.  This is accomplished by setting the 'allow-errors'
6784 global option attribute.  Each time your option handling function is
6785 called, you must determine where your scan is to resume and tell the
6786 AutoOpts library by invoking:
6787
6788      RESTART_OPT(next_arg_index);
6789
6790 and then invoke 'not_opt_index = optionProcess(...)'.  The
6791 'not_opt_index' value can be used to set 'optind', if that is the global
6792 being used to scan the program argument array.
6793
6794    In this method, do *NOT* utilize the global 'library' attribute.
6795 Your library must specify its options as if it were a complete program.
6796 You may choose to specify an alternate 'usage()' function so that usage
6797 for other parts of the option interface may be displayed as well.  See
6798 "Program Information Attributes" (*note information attributes::).
6799
6800    At the moment, there is no method for calling 'optionUsage()' telling
6801 it to produce just the information about the options and not the program
6802 as a whole.  Some later revision after somebody asks.
6803
6804 \1f
6805 File: autogen.info,  Node: prog calls lib,  Prev: lib called,  Up: library attributes
6806
6807 7.5.2.3 AutoOpt-ed Program Calls Regular Library
6808 ................................................
6809
6810 As with providing an 'AutoOpt'-ed library to a non-'AutoOpt'-ed program,
6811 you must write the option description file as if you were writing all
6812 the options for the program, but you should specify the 'allow-errors'
6813 global option attribute and you will likely want an alternate 'usage()'
6814 function (see "Program Information Attributes" *note information
6815 attributes::).  In this case, though, when 'optionProcess()' returns,
6816 you need to test to see if there might be library options.  If there
6817 might be, then call the library's exported routine for handling command
6818 line options, set the next-option-to-process with the 'RESTART_OPT()'
6819 macro, and recall 'optionProcess()'.  Repeat until done.
6820
6821 \1f
6822 File: autogen.info,  Node: information attributes,  Next: Generated main,  Prev: library attributes,  Up: Option Definitions
6823
6824 7.5.3 Program Information Attributes
6825 ------------------------------------
6826
6827 These attributes are used to define how and what information is
6828 displayed to the user of the program.
6829
6830 'copyright'
6831      The 'copyright' is a structured value containing three to five
6832      values.  If 'copyright' is used, then the first three are required.
6833
6834        1. 'date' - the list of applicable dates for the copyright.
6835        2. 'owner' - the name of the copyright holder.
6836        3. 'type' - specifies the type of distribution license.
6837           AutoOpts/AutoGen supports the text of the GNU Public License
6838           ('gpl'), the GNU Lesser General Public License with Library
6839           extensions ('lgpl'), the Modified Free BSD license ('mbsd')
6840           and a few others.  Other licenses may be specified, but you
6841           must provide your own license file.  The list of license files
6842           provided by AutoOpts may be seen by typing:
6843                ls $(autoopts-config pkgdatadir)/*.lic
6844        4. 'text' - the text of the copyright notice.  This must be
6845           provided if 'type' is set to 'NOTE'.
6846        5. 'author' - in case the author name is to appear in the
6847           documentation and is different from the copyright owner.
6848        6. 'eaddr' - email address for receiving praises and complaints.
6849           Typically that of the author or copyright holder.
6850
6851      An example of this might be:
6852           copyright = {
6853               date  = "1992-2015";
6854               owner = "Bruce Korb";
6855               eaddr = 'bkorb@gnu.org';
6856               type  = GPL;
6857           };
6858
6859 'detail'
6860      This string is added to the usage output when the HELP option is
6861      selected.
6862
6863 'explain'
6864      Gives additional information whenever the usage routine is invoked.
6865
6866 'package'
6867      The name of the package the program belongs to.  This will appear
6868      parenthetically after the program name in the version and usage
6869      output, e.g.: 'autogen (GNU autogen) - The Automated Program
6870      Generator'.
6871
6872 'preserve-case'
6873      This attribute will not change anything except appearance.
6874      Normally, the option names are all documented in lower case.
6875      However, if you specify this attribute, then they will display in
6876      the case used in their specification.  Command line options will
6877      still be matched without case sensitivity.  This is useful for
6878      specifying option names in camel-case.
6879
6880 'prog-desc *and*'
6881 'opts-ptr'
6882      These define global pointer variables that point to the program
6883      descriptor and the first option descriptor for a library option.
6884      This is intended for use by certain libraries that need command
6885      line and/or initialization file option processing.  These
6886      definitions have no effect on the option template output, but are
6887      used for creating a library interface file.  Normally, the first
6888      "option" for a library will be a documentation option that cannot
6889      be specified on the command line, but is marked as 'settable'.  The
6890      library client program will invoke the 'SET_OPTION' macro which
6891      will invoke a handler function that will finally set these global
6892      variables.
6893
6894 'usage'
6895      Optionally names the usage procedure, if the library routine
6896      'optionUsage()' does not work for you.  If you specify 'my_usage'
6897      as the value of this attribute, for example, you will use a
6898      procedure by that name for displaying usage.  Of course, you will
6899      need to provide that procedure and it must conform to this profile:
6900           void my_usage( tOptions* pOptions, int exitCode )
6901
6902 'gnu-usage'
6903      Normally, the default format produced by the 'optionUsage'
6904      procedure is AutoOpts Standard.  By specifying this attribute, the
6905      default format will be GNU-ish style.  Either default may be
6906      overridden by the user with the 'AUTOOPTS_USAGE' environment
6907      variable.  If it is set to 'gnu' or 'autoopts', it will alter the
6908      style appropriately.  This attribute will conflict with the 'usage'
6909      attribute.
6910
6911 'reorder-args'
6912      Some applications traditionally require that the command operands
6913      be intermixed with the command options.  In order to handle that,
6914      the arguments must be reordered.  If you are writing such an
6915      application, specify this global option.  All of the options (and
6916      any associated option arguments) will be brought to the beginning
6917      of the argument list.  New applications should not use this
6918      feature, if at all possible.  This feature is disabled if
6919      'POSIXLY_CORRECT' is defined in the environment.
6920
6921 \1f
6922 File: autogen.info,  Node: Generated main,  Next: option attributes,  Prev: information attributes,  Up: Option Definitions
6923
6924 7.5.4 Generating main procedures
6925 --------------------------------
6926
6927 When AutoOpts generates the code to parse the command line options, it
6928 has the ability to produce any of several types of 'main()' procedures.
6929 This is done by specifying a global structured value for 'main'.  The
6930 values that it contains are dependent on the value set for the one value
6931 it must have: 'main-type'.
6932
6933    The recognized values for 'main-type' are 'guile', 'shell-process',
6934 'shell-parser', 'main', 'include', 'invoke', and 'for-each'.
6935
6936 * Menu:
6937
6938 * main guile::              guile: main and inner_main procedures
6939 * main shell-process::      shell-process: emit Bourne shell results
6940 * main shell-parser::       shell-parser: emit Bourne shell script
6941 * main main::               main: user supplied main procedure
6942 * main include::            include: code emitted from included template
6943 * main invoke::             invoke: code emitted from AutoGen macro
6944
6945 The 'for-each' main  procedure has a number of attributes that
6946 must be specified:
6947
6948 * main for-each::           for-each: perform function on each operand
6949 * main-for-each-proc::          procedure to handle each argument
6950 * main-for-each-type::          handler procedure type
6951 * main-for-each-code::          code for handler procedure
6952 * main-for-each-opts::          for-each main procedure options
6953
6954 \1f
6955 File: autogen.info,  Node: main guile,  Next: main shell-process,  Up: Generated main
6956
6957 7.5.4.1 guile: main and inner_main procedures
6958 .............................................
6959
6960 When the 'main-type' is specified to be 'guile', a 'main()' procedure is
6961 generated that calls 'gh_enter()', providing it with a generated
6962 'inner_main()' to invoke.  If you must perform certain tasks before
6963 calling 'gh_enter()', you may specify such code in the value for the
6964 'before-guile-boot' attribute.
6965
6966    The 'inner_main()' procedure itself will process the command line
6967 arguments (by calling 'optionProcess()', *note libopts-optionProcess::),
6968 and then either invoke the code specified with the 'guile-main'
6969 attribute, or else export the parsed options to Guile symbols and invoke
6970 the 'scm_shell()' function from the Guile library.  This latter will
6971 render the program nearly identical to the stock 'guile(1)' program.
6972
6973 \1f
6974 File: autogen.info,  Node: main shell-process,  Next: main shell-parser,  Prev: main guile,  Up: Generated main
6975
6976 7.5.4.2 shell-process: emit Bourne shell results
6977 ................................................
6978
6979 This will produce a 'main()' procedure that parses the command line
6980 options and emits to 'stdout' Bourne shell commands that puts the option
6981 state into environment variables.  This can be used within a shell
6982 script as follows:
6983
6984      unset OPTION_CT
6985      eval "`opt_parser \"$@\"`"
6986      test ${OPTION_CT} -gt 0 && shift ${OPTION_CT}
6987
6988    If the option parsing code detects an error or a request for usage or
6989 version, it will emit a command to exit with an appropriate exit code to
6990 'stdout'.  This form of 'main' will cause all messages, including
6991 requested usage and version information, to be emitted to 'stderr'.
6992 Otherwise, a numeric value for 'OPTION_CT' is guaranteed to be emitted,
6993 along with assignments for all the options parsed, something along the
6994 lines of the following will be written to 'stdout' for evaluation:
6995
6996      OPTION_CT=4
6997      export OPTION_CT
6998      MYPROG_SECOND='first'
6999      export MYPROG_SECOND
7000      MYPROG_ANOTHER=1 # 0x1
7001      export MYPROG_ANOTHER
7002
7003 If the arguments are to be reordered, however, then the resulting set of
7004 operands will be emitted and 'OPTION_CT' will be set to zero.  For
7005 example, the following would be appended to the above:
7006
7007      set -- 'operand1' 'operand2' 'operand3'
7008      OPTION_CT=0
7009
7010 'OPTION_CT' is set to zero since it is not necessary to shift off any
7011 options.
7012
7013 \1f
7014 File: autogen.info,  Node: main shell-parser,  Next: main main,  Prev: main shell-process,  Up: Generated main
7015
7016 7.5.4.3 shell-parser: emit Bourne shell script
7017 ..............................................
7018
7019 This will produce a 'main()' procedure that emits a shell script that
7020 will parse the command line options.  That script can be emitted to
7021 'stdout' or inserted or substituted into a pre-existing shell script
7022 file.  Improbable markers are used to identify previously inserted
7023 parsing text:
7024
7025      # # # # # # # # # # -- do not modify this marker --
7026
7027 The program is also pretty insistent upon starting its parsing script on
7028 the second line.
7029
7030 \1f
7031 File: autogen.info,  Node: main main,  Next: main include,  Prev: main shell-parser,  Up: Generated main
7032
7033 7.5.4.4 main: user supplied main procedure
7034 ..........................................
7035
7036 You must supply a value for the 'main-text' attribute.  You may also
7037 supply a value for 'option-code'.  If you do, then the 'optionProcess'
7038 invocation will not be emitted into the code.  AutoOpts will wrap the
7039 'main-text' inside of:
7040
7041      int
7042      main( int argc, char** argv )
7043      {
7044          int res = <<success-exit-code>>;
7045          { // replaced by option-code, if that exists
7046              int ct = optionProcess( &<<prog-name>>Options, argc, argv);
7047              argc -= ct;
7048              argv += ct;
7049          }
7050      <<main-text>>
7051          return res;
7052      }
7053
7054 so you can most conveniently set the value with a 'here string' (*note
7055 here-string::):
7056
7057      code = <<- _EndOfMainProc_
7058         <<your text goes here>>
7059         _EndOfMainProc_;
7060
7061 \1f
7062 File: autogen.info,  Node: main include,  Next: main invoke,  Prev: main main,  Up: Generated main
7063
7064 7.5.4.5 include: code emitted from included template
7065 ....................................................
7066
7067 You must write a template to produce your main procedure.  You specify
7068 the name of the template with the 'tpl' attribute and it will be
7069 incorporated at the point where AutoOpts is ready to emit the 'main()'
7070 procedure.
7071
7072    This can be very useful if, in your working environment, you have
7073 many programs with highly similar 'main()' procedures.  All you need to
7074 do is parameterize the variations and specify which variant is needed
7075 within the 'main' AutoOpts specification.  Since you are coding the
7076 template for this, the attributes needed for this variation would be
7077 dictated by your template.
7078
7079    Here is an example of an 'include' variation:
7080
7081      main = {
7082        main-type = include;
7083        tpl       = "main-template.tpl";
7084      };
7085
7086 \1f
7087 File: autogen.info,  Node: main invoke,  Next: main for-each,  Prev: main include,  Up: Generated main
7088
7089 7.5.4.6 invoke: code emitted from AutoGen macro
7090 ...............................................
7091
7092 You must write a template to produce your main procedure.  That template
7093 must contain a definition for the function specified with the 'func'
7094 attribute to this 'main()' procedure specification.  This variation
7095 operates in much the same way as 'include' (*note main include::)
7096 method.
7097
7098 \1f
7099 File: autogen.info,  Node: main for-each,  Next: main-for-each-proc,  Prev: main invoke,  Up: Generated main
7100
7101 7.5.4.7 for-each: perform function on each operand
7102 ..................................................
7103
7104 This produces a main procedure that invokes a procedure once for each
7105 operand on the command line (non-option arguments), *OR* once for each
7106 non-blank, non-comment 'stdin' input line.  Leading and trailing white
7107 space is trimmed from the input line and comment lines are lines that
7108 are empty or begin with a comment character, defaulting to a hash ('#')
7109 character.
7110
7111    *NB*: The 'argument' program attribute (*note program attributes::)
7112 must begin with the '[' character, to indicate that there are command
7113 operands, but that they are optional.
7114
7115 For an example of the produced main procedure, in the 'autoopts/test'
7116 build directory, type the following command and look at 'main.c':
7117      make verbose TESTS=main.test
7118
7119 \1f
7120 File: autogen.info,  Node: main-for-each-proc,  Next: main-for-each-type,  Prev: main for-each,  Up: Generated main
7121
7122 procedure to handle each argument
7123 .................................
7124
7125 The 'handler-proc' attribute is required.  It is used to name the
7126 procedure to call.  That procedure is presumed to be external, but if
7127 you provide the code for it, then the procedure is emitted as a static
7128 procedure in the generated code.
7129
7130    This procedure should return 0 on success, a cumulative error code on
7131 warning and exit without returning on an unrecoverable error.  As the
7132 cumulative warning codes are or-ed together, the codes should be some
7133 sort of bit mask in order to be ultimately decipherable (if you need to
7134 do that).
7135
7136    If the called procedure needs to cause a fail-exit, it is expected to
7137 call 'exit(3)' directly.  If you want to cause a warning exit code, then
7138 this handler function should return a non-zero status.  That value will
7139 be *OR*-ed into a result integer for computing the final exit code.
7140 E.g., here is part of the emitted code:
7141
7142        int res = 0;
7143        if (argc > 0) {
7144           do  {
7145               res |= MY_HANDLER( *(argv++) );
7146           } while (--argc > 0);
7147        } else { ...
7148
7149 \1f
7150 File: autogen.info,  Node: main-for-each-type,  Next: main-for-each-code,  Prev: main-for-each-proc,  Up: Generated main
7151
7152 handler procedure type
7153 ......................
7154
7155 If you do not supply the 'handler-type' attribute, your handler
7156 procedure must be the default type.  The profile of the procedure must
7157 be:
7158
7159      int MY_HANDLER(char const * pz_entry);
7160
7161 However, if you do supply this attribute, you may set the value to any
7162 of four alternate flavors:
7163
7164 'name-of-file'
7165      This is essentially the same as the default handler type, except
7166      that before your procedure is invoked, the generated code has
7167      verified that the string names an existing file.  The profile is
7168      unchanged.
7169
7170 'file-X'
7171      Before calling your procedure, the file is f-opened according to
7172      the 'X', where 'X' may be any of the legal modes for 'fopen(3C)'.
7173      In this case, the profile for your procedure must be:
7174
7175           int MY_HANDLER(char const * pz_fname, FILE * entry_fp);
7176
7177      When processing inputs as file pointer stream files, there are
7178      several ways of treating standard input.  It may be an ordinary
7179      input file, or it may contain a list of files to operate on.
7180
7181      If the file handler type is more specifically set to 'file-r' and a
7182      command line operand consists of a single hyphen, then MY_HANDLER
7183      will be called with 'entry_fp' set to 'stdin' and the 'pz_fname'
7184      set to the translatable string, "standard input".  Consequently, in
7185      this case, if the input list is being read from 'stdin', a line
7186      containing a hyphen by itself will be ignored.
7187
7188 'stdin-input'
7189      This attribute specifies that standard input is a data input file.
7190      By default, 'for-each' main procedures will read standard input for
7191      operands if no operands appear on the command line.  If there are
7192      operands after the command line options, then standard input is
7193      typically ignored.  It can always be processed as an input data
7194      file, however, if a single bare hyphen is put on the command line.
7195
7196 'text-of-file'
7197 'some-text-of-file'
7198      Before calling your procedure, the contents of the file are read or
7199      mapped into memory.  (Excessively large files may cause problems.)
7200      The 'some-text-of-file' disallows empty files.  Both require
7201      regular files.  In this case, the profile for your procedure must
7202      be:
7203
7204           program_exit_code_t
7205           MY_HANDLER(char const * fname, char * file_text,
7206                      size_t text_size);
7207
7208      Note that though the 'file_text' is not 'const', any changes made
7209      to it are not written back to the original file.  It is merely a
7210      memory image of the file contents.  Also, the memory allocated to
7211      hold the text is 'text_size + 1' bytes long and the final byte is
7212      always 'NUL'.  The file contents need not be text, as the data are
7213      read with the 'read(2)' system call.
7214
7215      'file_text' is automatically freed, unless you specify a
7216      'handler-frees' attribute.  Then your code must 'free(3)' the text.
7217
7218    If you select one of these file type handlers, then on access or
7219 usage errors the 'PROGRAM_EXIT_FAILURE' exit code will, by default, be
7220 or-ed into the final exit code.  This can be changed by specifying the
7221 global 'file-fail-code' attribute and naming a different value.  That
7222 is, something other than 'failure'.  You may choose 'success', in which
7223 case file access issues will not affect the exit code and the error
7224 message will not be printed.
7225
7226 \1f
7227 File: autogen.info,  Node: main-for-each-code,  Next: main-for-each-opts,  Prev: main-for-each-type,  Up: Generated main
7228
7229 code for handler procedure
7230 ..........................
7231
7232 With the 'MYHANDLER-code' attribute, you provide the code for your
7233 handler procedure in the option definition file.  Note that the spelling
7234 of this attribute depends on the name provided with the 'handler-proc'
7235 attribute, so we represent it here with 'MYHANDLER' as a place holder.
7236 As an example, your 'main()' procedure specification might look
7237 something like this:
7238
7239      main = {
7240        main-type    = for-each;
7241        handler-proc = MYHANDLER;
7242        MYHANDLER-code = <<- EndOfMyCode
7243         /* whatever you want to do */
7244         EndOfMyCode;
7245      };
7246
7247 and instead of an emitted external reference, a procedure will be
7248 emitted that looks like this:
7249
7250      static int
7251      MYHANDLER( char const* pz_entry )
7252      {
7253          int res = 0;
7254          <<MYHANDLER-code goes here>>
7255          return res;
7256      }
7257
7258 \1f
7259 File: autogen.info,  Node: main-for-each-opts,  Prev: main-for-each-code,  Up: Generated main
7260
7261 for-each main procedure options
7262 ...............................
7263
7264 These attributes affect the main procedure and how it processes each
7265 argument or input line.
7266
7267 'interleaved'
7268      If this attribute is specified, then options and operands may be
7269      interleaved.  Arguments or input lines beginning with a hyphen will
7270      cause it to be passed through to an option processing function and
7271      will take effect for the remainder of the operands (or input lines)
7272      processed.
7273
7274 'main-init'
7275      This is code that gets inserted after the options have been
7276      processed, but before the handler procs get invoked.
7277
7278 'main-fini'
7279      This is code that gets inserted after all the entries have been
7280      processed, just before returning from 'main()'.
7281
7282 'comment-char'
7283      When reading operands from standard input, if you wish comment
7284      lines to start with a character other than a hash ('#') character,
7285      then specify one character with this attribute.  If string value is
7286      empty, then only blank lines will be considered comments.
7287
7288 \1f
7289 File: autogen.info,  Node: option attributes,  Next: Option Arguments,  Prev: Generated main,  Up: Option Definitions
7290
7291 7.5.5 Option Attributes
7292 -----------------------
7293
7294 For each option you wish to specify, you must have a block macro named
7295 'flag' defined.  There are two required attributes: 'name' and
7296 'descrip'.  If any options do not have a 'value' (traditional flag
7297 character) attribute, then the 'long-opts' program attribute must also
7298 be defined.  As a special exception, if no options have a 'value' *and*
7299 'long-opts' is not defined *and* 'argument' is not defined, then all
7300 arguments to the program are named options.  In this case, the '-' and
7301 '--' command line option markers are optional.
7302
7303 * Menu:
7304
7305 * Required Attributes::         Required Attributes
7306 * Common Attributes::           Common Option Attributes
7307 * Immediate Action::            Immediate Action Attributes
7308 * Option Conflict Attributes::  Option Conflict Attributes
7309
7310 These option attributes do not fit well with the above categories.
7311
7312 * opt-attr settable::           Program may set option
7313 * opt-attr no-preset::          Option cannot be pre-configured
7314 * opt-attr equivalence::        Option Equivalence Class
7315 * opt-attr aliases::            Option Aliasing
7316 * opt-attr default option::     Default Option
7317 * opt-attr documentation::      Option Sectioning Comment
7318 * opt-attr translators::        Translator Notes
7319
7320 \1f
7321 File: autogen.info,  Node: Required Attributes,  Next: Common Attributes,  Up: option attributes
7322
7323 7.5.5.1 Required Attributes
7324 ...........................
7325
7326 Every option must have exactly one copy of both of these attributes.
7327
7328 'name'
7329      Long name for the option.  Even if you are not accepting long
7330      options and are only accepting flags, it must be provided.
7331      AutoOpts generates private, named storage that requires this name.
7332      This name also causes a '#define'-d name to be emitted.  It must
7333      not conflict with any other names you may be using in your program.
7334
7335      For example, if your option name is, 'debug' or 'munged-up', you
7336      must not use the '#define' names 'DEBUG' (or 'MUNGED_UP') in your
7337      program for non-AutoOpts related purposes.  They are now used by
7338      AutoOpts.
7339
7340      Sometimes (most especially under Windows), you may get a surprise.
7341      For example, 'INTERFACE' is apparently a user space name that one
7342      should be free to use.  Windows usurps this name.  To solve this,
7343      you must do one of the following:
7344
7345        1. Change the name of your option
7346        2. add the program attribute (*note program attributes::):
7347
7348                export = '#undef INTERFACE';
7349        3. add the program attribute:
7350
7351                guard-option-names;
7352
7353 'descrip'
7354      Except for documentation options, a *very* brief description of the
7355      option.  About 40 characters on one line, maximum, not counting any
7356      texinfo markups.  Texinfo markups are stripped before printing in
7357      the usage text.  It appears on the 'usage()' output next to the
7358      option name.
7359
7360      If, however, the option is a documentation option, it will appear
7361      on one or more lines by itself.  It is thus used to visually
7362      separate and comment upon groups of options in the usage text.
7363