2019-02-04 22:26:45 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
< html >
< head >
2020-04-09 17:32:37 +00:00
< title > Foundation Module< / title >
2020-04-23 22:23:44 +00:00
< link href = "../docs-assets/Breadcrumbs.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
2020-03-19 00:03:04 +00:00
< meta name = "viewport" content = "width=device-width initial-scale=1" >
2019-02-04 22:26:45 +00:00
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" >
< meta http-equiv = "Content-Language" content = "en-gb" >
2020-04-20 22:26:08 +00:00
2020-05-02 22:50:23 +00:00
< link href = "../docs-assets/Contents.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
2020-04-30 22:36:38 +00:00
< link href = "../docs-assets/Progress.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
2020-04-25 10:33:39 +00:00
< link href = "../docs-assets/Navigation.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
< link href = "../docs-assets/Fonts.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
2020-04-20 22:26:08 +00:00
< link href = "../docs-assets/Base.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
2020-04-21 16:55:17 +00:00
< link href = "../docs-assets/Colours.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
2020-04-23 22:23:44 +00:00
2019-02-04 22:26:45 +00:00
< / head >
2020-04-25 10:33:39 +00:00
< body class = "commentary-font" >
2020-03-19 00:03:04 +00:00
< nav role = "navigation" >
2020-04-13 16:06:45 +00:00
< h1 > < a href = "../index.html" >
2020-04-20 22:26:08 +00:00
< img src = "../docs-assets/Octagram.png" width = 72 height = 72" >
2020-04-13 16:06:45 +00:00
< / a > < / h1 >
< ul > < li > < a href = "../inweb/index.html" > inweb< / a > < / li >
< / ul > < h2 > Foundation Module< / h2 > < ul >
< li > < a href = "index.html" > < span class = "selectedlink" > foundation< / span > < / a > < / li >
2020-03-19 00:03:04 +00:00
< li > < a href = "../foundation-test/index.html" > foundation-test< / a > < / li >
2020-04-13 16:06:45 +00:00
< / ul > < h2 > Example Webs< / h2 > < ul >
2020-04-12 16:24:23 +00:00
< li > < a href = "../goldbach/index.html" > goldbach< / a > < / li >
< li > < a href = "../twinprimes/twinprimes.html" > twinprimes< / a > < / li >
2020-04-15 22:45:08 +00:00
< li > < a href = "../eastertide/index.html" > eastertide< / a > < / li >
2020-04-14 17:36:42 +00:00
< / ul > < h2 > Repository< / h2 > < ul >
2020-04-20 22:34:44 +00:00
< li > < a href = "https://github.com/ganelson/inweb" > < img src = "../docs-assets/github.png" height = 18 > github< / a > < / li >
2020-04-14 17:36:42 +00:00
< / ul > < h2 > Related Projects< / h2 > < ul >
< li > < a href = "../../../inform/docs/index.html" > inform< / a > < / li >
< li > < a href = "../../../intest/docs/index.html" > intest< / a > < / li >
2020-03-19 00:03:04 +00:00
2020-04-13 16:06:45 +00:00
< / ul >
2020-03-19 00:03:04 +00:00
< / nav >
< main role = "main" >
2020-04-23 22:23:44 +00:00
<!-- Weave of 'Foundation Module' generated by Inweb -->
2020-04-30 22:36:38 +00:00
< div class = "breadcrumbs" >
< ul class = "crumbs" > < li > < a href = "../index.html" > Home< / a > < / li > < li > < a href = "index.html" > foundation< / a > < / li > < li > < a href = "index.html#1" > Chapter 1: Setting Up< / a > < / li > < li > < b > Foundation Module< / b > < / li > < / ul > < / div >
< p class = "purpose" > Starting up and shutting down.< / p >
2019-02-04 22:26:45 +00:00
2020-04-15 22:45:08 +00:00
< ul class = "toc" > < li > < a href = "1-fm.html#SP1" > § 1. Introduction< / a > < / li > < li > < a href = "1-fm.html#SP2" > § 2. Basic definitions< / a > < / li > < li > < a href = "1-fm.html#SP8" > § 8. The beginning and the end< / a > < / li > < / ul > < hr class = "tocbar" >
2019-02-04 22:26:45 +00:00
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP1" > < / a > < b > § 1. Introduction. < / b > The Foundation module supplies some of the conveniences of more modern
2019-02-04 22:26:45 +00:00
programming languages to ANSI C. It offers the usual stuff of standard
libraries everywhere: memory management, collection classes, filename
and file system accesss, regular-expression matching and so on. At one
time the higher-level material formed a second module called "Foundation
and Empire", but now it's all consolidated into a single everything-you-need
module. Almost all functionality is optional and can be ignored if not
wanted. With a few provisos, the code is thread-safe, sturdy and well
tested, since it forms the support code for the Inform programming
language's compiler and outlying tools, including Inweb itself. If you
need to write a command-line utility in ANSI C with no dependencies on
other tools or libraries to speak of, you could do worse.
< / p >
2020-04-24 23:06:02 +00:00
< p class = "commentary" > To use < span class = "extract" > < span class = "extract-syntax" > foundation< / span > < / span > , the Contents section of a web should include:
2019-02-04 22:26:45 +00:00
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "displayed-code all-displayed-code code-font" >
2020-04-21 16:55:17 +00:00
< span class = "plain-syntax" > Import: foundation< / span >
2019-02-04 22:26:45 +00:00
< / pre >
2020-04-24 23:06:02 +00:00
< p class = "commentary" > before beginning the chapter rundown. There are then a few conventions
2020-04-22 22:57:09 +00:00
which must be followed. The < span class = "extract" > < span class = "extract-syntax" > main< / span > < / span > routine for the client should, as one
of its very first acts, call < span class = "extract" > < span class = "extract-syntax" > Foundation::start()< / span > < / span > , and should similarly, just
before it exits, call < span class = "extract" > < span class = "extract-syntax" > Foundation::end()< / span > < / span > . Any other module used should be
2019-02-04 22:26:45 +00:00
started after Foundation starts, and ended before Foundation ends.
< / p >
2020-04-24 23:06:02 +00:00
< p class = "commentary" > In addition, the client's source code needs to define a few symbols to indicate
2019-02-04 22:26:45 +00:00
what it needs in the way of memory allocation. For an example, see the code
for Inweb itself.
< / p >
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP2" > < / a > < b > § 2. Basic definitions. < / b > These are all from the ANSI C standard library (or the pthread POSIX standard),
2019-02-04 22:26:45 +00:00
which means that Inweb will tangle them up to the top of the C source code.
Because pthread is not normally available on Windows, a special header is
supplied instead for that case.
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "displayed-code all-displayed-code code-font" >
2020-05-09 12:05:00 +00:00
< span class = "plain-syntax" > #< / span > < span class = "identifier-syntax" > include< / span > < span class = "plain-syntax" > < / span > < span class = "function-syntax" > < ctype.h> < / span >
< span class = "plain-syntax" > #< / span > < span class = "identifier-syntax" > include< / span > < span class = "plain-syntax" > < / span > < span class = "function-syntax" > < stdarg.h> < / span >
< span class = "plain-syntax" > #< / span > < span class = "identifier-syntax" > include< / span > < span class = "plain-syntax" > < / span > < span class = "function-syntax" > < stdio.h> < / span >
< span class = "plain-syntax" > #< / span > < span class = "identifier-syntax" > include< / span > < span class = "plain-syntax" > < / span > < span class = "function-syntax" > < stdlib.h> < / span >
< span class = "plain-syntax" > #< / span > < span class = "identifier-syntax" > include< / span > < span class = "plain-syntax" > < / span > < span class = "function-syntax" > < string.h> < / span >
< span class = "plain-syntax" > #< / span > < span class = "identifier-syntax" > include< / span > < span class = "plain-syntax" > < / span > < span class = "function-syntax" > < time.h> < / span >
< span class = "plain-syntax" > #< / span > < span class = "identifier-syntax" > include< / span > < span class = "plain-syntax" > < / span > < span class = "function-syntax" > < math.h> < / span >
< span class = "plain-syntax" > #< / span > < span class = "identifier-syntax" > include< / span > < span class = "plain-syntax" > < / span > < span class = "function-syntax" > < wchar.h> < / span >
2020-04-24 10:26:18 +00:00
< / pre >
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP3" > < / a > < b > § 3. < / b > < / p >
2020-04-21 16:55:17 +00:00
2020-04-25 10:33:39 +00:00
< pre class = "displayed-code all-displayed-code code-font" >
2020-04-24 23:06:02 +00:00
< span class = "reserved-syntax" > text_stream< / span > < span class = "plain-syntax" > *< / span > < span class = "identifier-syntax" > DL< / span > < span class = "plain-syntax" > = < / span > < span class = "identifier-syntax" > NULL< / span > < span class = "plain-syntax" > ; < / span > < span class = "comment-syntax" > Current destination of debugging text: kept < / span > < span class = "extract" > < span class = "extract-syntax" > NULL< / span > < / span > < span class = "comment-syntax" > until opened< / span >
2020-04-24 10:26:18 +00:00
< / pre >
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP4" > < / a > < b > § 4. < / b > We'll use three truth states, the third of which can also mean "unknown".
2019-02-04 22:26:45 +00:00
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "definitions code-font" > < span class = "definition-keyword" > define< / span > < span class = "constant-syntax" > TRUE< / span > < span class = "plain-syntax" > < / span > < span class = "constant-syntax" > 1< / span >
2020-04-24 10:26:18 +00:00
< span class = "definition-keyword" > define< / span > < span class = "constant-syntax" > FALSE< / span > < span class = "plain-syntax" > < / span > < span class = "constant-syntax" > 0< / span >
< span class = "definition-keyword" > define< / span > < span class = "constant-syntax" > NOT_APPLICABLE< / span > < span class = "plain-syntax" > < / span > < span class = "constant-syntax" > 2< / span >
2019-02-04 22:26:45 +00:00
< / pre >
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP5" > < / a > < b > § 5. < / b > And we recognise two different encodings for narrow (i.e., < span class = "extract" > < span class = "extract-syntax" > char *< / span > < / span > ) C strings.
2019-02-04 22:26:45 +00:00
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "definitions code-font" > < span class = "definition-keyword" > define< / span > < span class = "constant-syntax" > UTF8_ENC< / span > < span class = "plain-syntax" > < / span > < span class = "constant-syntax" > 1< / span > < span class = "plain-syntax" > < / span > < span class = "comment-syntax" > Write as UTF-8 without BOM< / span >
2020-04-24 23:06:02 +00:00
< span class = "definition-keyword" > define< / span > < span class = "constant-syntax" > ISO_ENC< / span > < span class = "plain-syntax" > < / span > < span class = "constant-syntax" > 2< / span > < span class = "plain-syntax" > < / span > < span class = "comment-syntax" > Write as ISO Latin-1 (i.e., no conversion needed)< / span >
2019-02-04 22:26:45 +00:00
< / pre >
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP6" > < / a > < b > § 6. < / b > It is assumed that our host filing system can manage at least 30-character
2019-02-04 22:26:45 +00:00
filenames, that space is legal as a character in a filename, and that trailing
2020-04-22 22:57:09 +00:00
extensions can be longer than 3 characters (in particular, that < span class = "extract" > < span class = "extract-syntax" > .html< / span > < / span > is
allowed). There are no clear rules but on Windows < span class = "extract" > < span class = "extract-syntax" > MAX_PATH< / span > < / span > can be as low as
2019-02-04 22:26:45 +00:00
260, and on Mac OS X the equivalent limit is 1024; both systems can house
files buried more deeply, but in both cases the user interface to the
operating system fails to recognise them. Some Linux implementations raise the
2020-04-22 22:57:09 +00:00
equivalent < span class = "extract" > < span class = "extract-syntax" > PATH_MAX< / span > < / span > limit as high as 4096. This seems a reasonable
2019-02-04 22:26:45 +00:00
compromise in practice:
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "definitions code-font" > < span class = "definition-keyword" > define< / span > < span class = "constant-syntax" > MAX_FILENAME_LENGTH< / span > < span class = "plain-syntax" > < / span > < span class = "constant-syntax" > 1025< / span >
2019-02-04 22:26:45 +00:00
< / pre >
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP7" > < / a > < b > § 7. < / b > Very occasionally we'll store a pointer as data:
2019-02-04 22:26:45 +00:00
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "displayed-code all-displayed-code code-font" >
2020-04-21 16:55:17 +00:00
< span class = "reserved-syntax" > typedef< / span > < span class = "plain-syntax" > < / span > < span class = "reserved-syntax" > long< / span > < span class = "plain-syntax" > < / span > < span class = "reserved-syntax" > int< / span > < span class = "plain-syntax" > < / span > < span class = "identifier-syntax" > pointer_sized_int< / span > < span class = "plain-syntax" > ;< / span >
2020-04-24 10:26:18 +00:00
< / pre >
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP8" > < / a > < b > § 8. The beginning and the end. < / b > As noted above, the client needs to call these when starting up and when
2019-02-04 22:26:45 +00:00
shutting down.
< / p >
2020-04-24 23:06:02 +00:00
< p class = "commentary" > The Inweb notation < span class = "extract" > < span class = "extract-syntax" > [[textliterals]]< / span > < / span > inserts declarations of I-literals,
2020-05-09 12:05:00 +00:00
that is, literal < span class = "extract" > < span class = "extract-syntax" > text_stream *< / span > < / span > values written as < span class = "extract" > < span class = "extract-syntax" > I"strings"< / span > < / span > . It should
never be used anywhere but here.
2019-02-04 22:26:45 +00:00
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "displayed-code all-displayed-code code-font" >
2020-04-25 12:26:09 +00:00
< span class = "reserved-syntax" > void< / span > < span class = "plain-syntax" > < / span > < span class = "function-syntax" > Foundation::start< / span > < span class = "plain-syntax" > (< / span > < span class = "reserved-syntax" > void< / span > < span class = "plain-syntax" > ) {< / span >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "2-mmr.html#SP5" class = "function-link" > < span class = "function-syntax" > Memory::start< / span > < / a > < span class = "plain-syntax" > ();< / span >
2020-04-27 22:43:23 +00:00
< span class = "plain-syntax" > < / span > < span class = "named-paragraph-container code-font" > < a href = "1-fm.html#SP8_1" class = "named-paragraph-link" > < span class = "named-paragraph" > Register the default stream writers< / span > < span class = "named-paragraph-number" > 8.1< / span > < / a > < / span > < span class = "plain-syntax" > ;< / span >
2020-04-21 16:55:17 +00:00
< span class = "plain-syntax" > [[< / span > < span class = "identifier-syntax" > textliterals< / span > < span class = "plain-syntax" > ]];< / span >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "3-tm.html#SP1" class = "function-link" > < span class = "function-syntax" > Time::begin< / span > < / a > < span class = "plain-syntax" > ();< / span >
< span class = "plain-syntax" > < / span > < a href = "3-pth.html#SP2" class = "function-link" > < span class = "function-syntax" > Pathnames::start< / span > < / a > < span class = "plain-syntax" > ();< / span >
2020-04-27 22:43:23 +00:00
< span class = "plain-syntax" > < / span > < span class = "named-paragraph-container code-font" > < a href = "1-fm.html#SP8_2" class = "named-paragraph-link" > < span class = "named-paragraph" > Register the default debugging log aspects< / span > < span class = "named-paragraph-number" > 8.2< / span > < / a > < / span > < span class = "plain-syntax" > ;< / span >
< span class = "plain-syntax" > < / span > < span class = "named-paragraph-container code-font" > < a href = "1-fm.html#SP8_3" class = "named-paragraph-link" > < span class = "named-paragraph" > Register the default debugging log writers< / span > < span class = "named-paragraph-number" > 8.3< / span > < / a > < / span > < span class = "plain-syntax" > ;< / span >
< span class = "plain-syntax" > < / span > < span class = "named-paragraph-container code-font" > < a href = "1-fm.html#SP8_5" class = "named-paragraph-link" > < span class = "named-paragraph" > Register the default command line switches< / span > < span class = "named-paragraph-number" > 8.5< / span > < / a > < / span > < span class = "plain-syntax" > ;< / span >
2020-04-21 16:55:17 +00:00
< span class = "plain-syntax" > }< / span >
2020-04-24 10:26:18 +00:00
< / pre >
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP8_1" > < / a > < b > § 8.1. < / b > After calling < span class = "extract" > < span class = "extract-syntax" > Foundation::start()< / span > < / span > , the client can register further stream
2019-02-04 22:26:45 +00:00
writing routines, following these models: they define the meaning of escape
2020-04-22 22:57:09 +00:00
characters in < span class = "extract" > < span class = "extract-syntax" > WRITE< / span > < / span > , our version of formatted printing. < span class = "extract" > < span class = "extract-syntax" > %f< / span > < / span > , for example,
prints a filename by calling < span class = "extract" > < span class = "extract-syntax" > Filenames::writer< / span > < / span > .
2019-02-04 22:26:45 +00:00
< / p >
2020-04-25 10:33:39 +00:00
< p class = "commentary" > < span class = "named-paragraph-container code-font" > < span class = "named-paragraph-defn" > Register the default stream writers< / span > < span class = "named-paragraph-number" > 8.1< / span > < / span > < span class = "comment-syntax" > =< / span >
2020-04-24 10:26:18 +00:00
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "displayed-code all-displayed-code code-font" >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "2-wal.html#SP4" class = "function-link" > < span class = "function-syntax" > Writers::register_writer< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "character-syntax" > 'f'< / span > < span class = "plain-syntax" > , & < / span > < a href = "3-fln.html#SP4" class = "function-link" > < span class = "function-syntax" > Filenames::writer< / span > < / a > < span class = "plain-syntax" > );< / span >
< span class = "plain-syntax" > < / span > < a href = "2-wal.html#SP4" class = "function-link" > < span class = "function-syntax" > Writers::register_writer< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "character-syntax" > 'p'< / span > < span class = "plain-syntax" > , & < / span > < a href = "3-pth.html#SP6" class = "function-link" > < span class = "function-syntax" > Pathnames::writer< / span > < / a > < span class = "plain-syntax" > );< / span >
< span class = "plain-syntax" > < / span > < a href = "2-wal.html#SP4" class = "function-link" > < span class = "function-syntax" > Writers::register_writer< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "character-syntax" > 'v'< / span > < span class = "plain-syntax" > , & < / span > < a href = "7-vn.html#SP6" class = "function-link" > < span class = "function-syntax" > VersionNumbers::writer< / span > < / a > < span class = "plain-syntax" > );< / span >
< span class = "plain-syntax" > < / span > < a href = "2-wal.html#SP4" class = "function-link" > < span class = "function-syntax" > Writers::register_writer< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "character-syntax" > 'S'< / span > < span class = "plain-syntax" > , & < / span > < a href = "2-str.html#SP43" class = "function-link" > < span class = "function-syntax" > Streams::writer< / span > < / a > < span class = "plain-syntax" > );< / span >
2020-04-24 10:26:18 +00:00
< / pre >
< ul class = "endnotetexts" > < li > This code is used in < a href = "1-fm.html#SP8" > § 8< / a > .< / li > < / ul >
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP8_2" > < / a > < b > § 8.2. < / b > We provide a full logging service, in which different "aspects" can be
2019-02-04 22:26:45 +00:00
switched on or off. Each aspect represents an activity of the program about
which a narrative is printed, or not printed, to the debugging log file.
The following are always provided, but are all off by default.
< / p >
2020-04-25 10:33:39 +00:00
< p class = "commentary" > < span class = "named-paragraph-container code-font" > < span class = "named-paragraph-defn" > Register the default debugging log aspects< / span > < span class = "named-paragraph-number" > 8.2< / span > < / span > < span class = "comment-syntax" > =< / span >
2020-04-24 10:26:18 +00:00
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "displayed-code all-displayed-code code-font" >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "2-dl.html#SP4" class = "function-link" > < span class = "function-syntax" > Log::declare_aspect< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > DEBUGGING_LOG_INCLUSIONS_DA< / span > < span class = "plain-syntax" > , < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "debugging log inclusions"< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > FALSE< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > FALSE< / span > < span class = "plain-syntax" > );< / span >
< span class = "plain-syntax" > < / span > < a href = "2-dl.html#SP4" class = "function-link" > < span class = "function-syntax" > Log::declare_aspect< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > SHELL_USAGE_DA< / span > < span class = "plain-syntax" > , < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "shell usage"< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > FALSE< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > FALSE< / span > < span class = "plain-syntax" > );< / span >
< span class = "plain-syntax" > < / span > < a href = "2-dl.html#SP4" class = "function-link" > < span class = "function-syntax" > Log::declare_aspect< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > MEMORY_USAGE_DA< / span > < span class = "plain-syntax" > , < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "memory usage"< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > FALSE< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > FALSE< / span > < span class = "plain-syntax" > );< / span >
< span class = "plain-syntax" > < / span > < a href = "2-dl.html#SP4" class = "function-link" > < span class = "function-syntax" > Log::declare_aspect< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > TEXT_FILES_DA< / span > < span class = "plain-syntax" > , < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "text files"< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > FALSE< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > FALSE< / span > < span class = "plain-syntax" > );< / span >
2020-04-24 10:26:18 +00:00
< / pre >
< ul class = "endnotetexts" > < li > This code is used in < a href = "1-fm.html#SP8" > § 8< / a > .< / li > < / ul >
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP8_3" > < / a > < b > § 8.3. < / b > Debugging log writers are similar to stream writers, but implement the < span class = "extract" > < span class = "extract-syntax" > $< / span > < / span >
2020-04-22 22:57:09 +00:00
escapes only available to the debugging log. For example, < span class = "extract" > < span class = "extract-syntax" > $S< / span > < / span > calls the
< span class = "extract" > < span class = "extract-syntax" > Streams::log< / span > < / span > function to print a textual representation of the current
2019-02-04 22:26:45 +00:00
state of a stream.
< / p >
2020-04-25 10:33:39 +00:00
< p class = "commentary" > < span class = "named-paragraph-container code-font" > < span class = "named-paragraph-defn" > Register the default debugging log writers< / span > < span class = "named-paragraph-number" > 8.3< / span > < / span > < span class = "comment-syntax" > =< / span >
2020-04-24 10:26:18 +00:00
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "displayed-code all-displayed-code code-font" >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "2-wal.html#SP4" class = "function-link" > < span class = "function-syntax" > Writers::register_logger< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "character-syntax" > 'a'< / span > < span class = "plain-syntax" > , & < / span > < a href = "4-taa.html#SP9" class = "function-link" > < span class = "function-syntax" > Tries::log_avinue< / span > < / a > < span class = "plain-syntax" > );< / span >
< span class = "plain-syntax" > < / span > < a href = "2-wal.html#SP4" class = "function-link" > < span class = "function-syntax" > Writers::register_logger< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "character-syntax" > 'S'< / span > < span class = "plain-syntax" > , & < / span > < a href = "2-str.html#SP21" class = "function-link" > < span class = "function-syntax" > Streams::log< / span > < / a > < span class = "plain-syntax" > );< / span >
2020-04-24 10:26:18 +00:00
< / pre >
< ul class = "endnotetexts" > < li > This code is used in < a href = "1-fm.html#SP8" > § 8< / a > .< / li > < / ul >
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP8_4" > < / a > < b > § 8.4. < / b > We provide an optional service for parsing the command line. By default,
2020-04-22 22:57:09 +00:00
the < span class = "extract" > < span class = "extract-syntax" > -log A< / span > < / span > switch makes that aspect active, though it's hyphenated, so
for example < span class = "extract" > < span class = "extract-syntax" > -log memory-usage< / span > < / span > or < span class = "extract" > < span class = "extract-syntax" > -log no-memory-usage< / span > < / span > . < span class = "extract" > < span class = "extract-syntax" > -fixtime< / span > < / span > is
2019-02-04 22:26:45 +00:00
used to ease automated testing: we don't want to reject the output from
some tool just because it contains today's date and not the date when the
2020-04-22 22:57:09 +00:00
test was set up. < span class = "extract" > < span class = "extract-syntax" > -crash< / span > < / span > tells the tool to crash on a fatal error, rather
2019-02-04 22:26:45 +00:00
than to exit cleanly, to make it easier to diagnose in a debugger.
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "definitions code-font" > < span class = "definition-keyword" > enum< / span > < span class = "constant-syntax" > LOG_CLSW< / span > < span class = "plain-syntax" > < / span > < span class = "identifier-syntax" > from< / span > < span class = "plain-syntax" > < / span > < span class = "constant-syntax" > 0< / span >
2020-04-24 10:26:18 +00:00
< span class = "definition-keyword" > enum< / span > < span class = "constant-syntax" > VERSION_CLSW< / span >
< span class = "definition-keyword" > enum< / span > < span class = "constant-syntax" > CRASH_CLSW< / span >
< span class = "definition-keyword" > enum< / span > < span class = "constant-syntax" > HELP_CLSW< / span >
< span class = "definition-keyword" > enum< / span > < span class = "constant-syntax" > FIXTIME_CLSW< / span >
< span class = "definition-keyword" > enum< / span > < span class = "constant-syntax" > AT_CLSW< / span >
2019-02-04 22:26:45 +00:00
< / pre >
2020-04-25 10:33:39 +00:00
< p class = "commentary firstcommentary" > < a id = "SP8_5" > < / a > < b > § 8.5. < / b > < span class = "named-paragraph-container code-font" > < span class = "named-paragraph-defn" > Register the default command line switches< / span > < span class = "named-paragraph-number" > 8.5< / span > < / span > < span class = "comment-syntax" > =< / span >
2020-04-24 10:26:18 +00:00
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "displayed-code all-displayed-code code-font" >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "3-cla.html#SP5" class = "function-link" > < span class = "function-syntax" > CommandLine::begin_group< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > FOUNDATION_CLSG< / span > < span class = "plain-syntax" > , < / span > < span class = "identifier-syntax" > NULL< / span > < span class = "plain-syntax" > );< / span >
< span class = "plain-syntax" > < / span > < a href = "3-cla.html#SP5" class = "function-link" > < span class = "function-syntax" > CommandLine::declare_switch< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > LOG_CLSW< / span > < span class = "plain-syntax" > , < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "log"< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > 2< / span > < span class = "plain-syntax" > ,< / span >
2020-04-21 16:55:17 +00:00
< span class = "plain-syntax" > < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "write the debugging log to include diagnostics on X"< / span > < span class = "plain-syntax" > );< / span >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "3-cla.html#SP5" class = "function-link" > < span class = "function-syntax" > CommandLine::declare_switch< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > VERSION_CLSW< / span > < span class = "plain-syntax" > , < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "version"< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > 1< / span > < span class = "plain-syntax" > ,< / span >
2020-04-21 16:55:17 +00:00
< span class = "plain-syntax" > < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "print out version number"< / span > < span class = "plain-syntax" > );< / span >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "3-cla.html#SP6" class = "function-link" > < span class = "function-syntax" > CommandLine::declare_boolean_switch< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > CRASH_CLSW< / span > < span class = "plain-syntax" > , < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "crash"< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > 1< / span > < span class = "plain-syntax" > ,< / span >
2020-04-21 16:55:17 +00:00
< span class = "plain-syntax" > < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "intentionally crash on internal errors, for backtracing"< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > FALSE< / span > < span class = "plain-syntax" > );< / span >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "3-cla.html#SP5" class = "function-link" > < span class = "function-syntax" > CommandLine::declare_switch< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > HELP_CLSW< / span > < span class = "plain-syntax" > , < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "help"< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > 1< / span > < span class = "plain-syntax" > ,< / span >
2020-04-21 16:55:17 +00:00
< span class = "plain-syntax" > < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "print this help information"< / span > < span class = "plain-syntax" > );< / span >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "3-cla.html#SP6" class = "function-link" > < span class = "function-syntax" > CommandLine::declare_boolean_switch< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > FIXTIME_CLSW< / span > < span class = "plain-syntax" > , < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "fixtime"< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > 1< / span > < span class = "plain-syntax" > ,< / span >
2020-04-21 16:55:17 +00:00
< span class = "plain-syntax" > < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "pretend the time is 11 a.m. on 28 March 2016 for testing"< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > FALSE< / span > < span class = "plain-syntax" > );< / span >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "3-cla.html#SP5" class = "function-link" > < span class = "function-syntax" > CommandLine::declare_switch< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > AT_CLSW< / span > < span class = "plain-syntax" > , < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "at"< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > 2< / span > < span class = "plain-syntax" > ,< / span >
2020-04-21 16:55:17 +00:00
< span class = "plain-syntax" > < / span > < span class = "identifier-syntax" > L< / span > < span class = "string-syntax" > "specify that this tool is installed at X"< / span > < span class = "plain-syntax" > );< / span >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "3-cla.html#SP5" class = "function-link" > < span class = "function-syntax" > CommandLine::end_group< / span > < / a > < span class = "plain-syntax" > ();< / span >
2020-04-24 10:26:18 +00:00
< / pre >
< ul class = "endnotetexts" > < li > This code is used in < a href = "1-fm.html#SP8" > § 8< / a > .< / li > < / ul >
2020-04-24 23:06:02 +00:00
< p class = "commentary firstcommentary" > < a id = "SP9" > < / a > < b > § 9. < / b > Once the following has been called, it is not safe to use any of the
2020-04-22 22:57:09 +00:00
< span class = "extract" > < span class = "extract-syntax" > foundation< / span > < / span > facilities. It should be called on any normal exit, but not on
2019-02-04 22:26:45 +00:00
an early termination due to a fatal error, as this may lead to thread
safety problems.
< / p >
2020-04-25 10:33:39 +00:00
< pre class = "displayed-code all-displayed-code code-font" >
2020-04-25 12:26:09 +00:00
< span class = "reserved-syntax" > void< / span > < span class = "plain-syntax" > < / span > < span class = "function-syntax" > Foundation::end< / span > < span class = "plain-syntax" > (< / span > < span class = "reserved-syntax" > void< / span > < span class = "plain-syntax" > ) {< / span >
2020-05-17 22:05:11 +00:00
< span class = "plain-syntax" > < / span > < span class = "reserved-syntax" > if< / span > < span class = "plain-syntax" > (< / span > < a href = "2-dl.html#SP7" class = "function-link" > < span class = "function-syntax" > Log::aspect_switched_on< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > MEMORY_USAGE_DA< / span > < span class = "plain-syntax" > )) < / span > < a href = "2-mmr.html#SP27" class = "function-link" > < span class = "function-syntax" > Memory::log_statistics< / span > < / a > < span class = "plain-syntax" > ();< / span >
2020-04-21 23:52:25 +00:00
< span class = "plain-syntax" > < / span > < a href = "2-dl.html#SP5" class = "function-link" > < span class = "function-syntax" > Log::close< / span > < / a > < span class = "plain-syntax" > ();< / span >
< span class = "plain-syntax" > < / span > < a href = "2-mmr.html#SP12" class = "function-link" > < span class = "function-syntax" > Memory::free< / span > < / a > < span class = "plain-syntax" > ();< / span >
2020-04-21 16:55:17 +00:00
< span class = "plain-syntax" > }< / span >
2020-04-24 10:26:18 +00:00
< / pre >
2020-04-30 22:36:38 +00:00
< nav role = "progress" > < div class = "progresscontainer" >
< ul class = "progressbar" > < li class = "progressprev" > < a href = "P-abgtf.html" > ❮ < / a > < / li > < li class = "progresschapter" > < a href = "P-abgtf.html" > P< / a > < / li > < li class = "progresscurrentchapter" > 1< / li > < li class = "progresscurrent" > fm< / li > < li class = "progresssection" > < a href = "1-pp.html" > pp< / a > < / li > < li class = "progresssection" > < a href = "1-wp.html" > wp< / a > < / li > < li class = "progresschapter" > < a href = "2-dl.html" > 2< / a > < / li > < li class = "progresschapter" > < a href = "3-em.html" > 3< / a > < / li > < li class = "progresschapter" > < a href = "4-chr.html" > 4< / a > < / li > < li class = "progresschapter" > < a href = "5-htm.html" > 5< / a > < / li > < li class = "progresschapter" > < a href = "6-bf.html" > 6< / a > < / li > < li class = "progresschapter" > < a href = "7-vn.html" > 7< / a > < / li > < li class = "progresschapter" > < a href = "8-ws.html" > 8< / a > < / li > < li class = "progressnext" > < a href = "1-pp.html" > ❯ < / a > < / li > < / ul > < / div >
< / nav > <!-- End of weave -->
2020-04-23 22:23:44 +00:00
2020-03-19 00:03:04 +00:00
< / main >
2019-02-04 22:26:45 +00:00
< / body >
< / html >