luametatex-libraries.tex /size: 21 Kb    last modification: 2023-12-21 09:43
1% language=us runpath=texruns:manuals/luametatex
2
3\environment luametatex-style
4
5\startcomponent luametatex-libraries
6
7\startchapter[reference=libraries,title={Extra libraries}]
8
9\startsection[title=Introduction]
10
11The libraries can be grouped in categories like fonts, languages, \TEX,
12\METAPOST, \PDF, etc. There are however also some that are more general purpose
13and these are discussed here.
14
15\stopsection
16
17\startsection[title=File and string readers: \type {fio} and type {sio}]
18
19This library provides a set of functions for reading numbers from a file and
20in addition to the regular \type {io} library functions. The following
21work on normal \LUA\ file handles.
22
23\starttabulate[|Tw(12em)|T|T|]
24\DB name        \BC arguments \BC results \NC \NR
25\TB
26\NC readcardinal1     \NC (f)      \NC a 1 byte unsigned integer \NC \NR
27\NC readcardinal2     \NC (f)      \NC a 2 byte unsigned integer \NC \NR
28\NC readcardinal3     \NC (f)      \NC a 3 byte unsigned integer \NC \NR
29\NC readcardinal4     \NC (f)      \NC a 4 byte unsigned integer \NC \NR
30\NC readcardinaltable \NC (f,n,b)  \NC \type {n} cardinals of \type {b} bytes \NC \NR
31\NC readinteger1      \NC (f)      \NC a 1 byte signed integer \NC \NR
32\NC readinteger2      \NC (f)      \NC a 2 byte signed integer \NC \NR
33\NC readinteger3      \NC (f)      \NC a 3 byte signed integer \NC \NR
34\NC readinteger4      \NC (f)      \NC a 4 byte signed integer \NC \NR
35\NC readintegertable  \NC (f,n,b)  \NC \type {n} integers of \type {b} bytes \NC \NR
36\NC readfixed2        \NC (f)      \NC a float made from a 2 byte fixed format \NC \NR
37\NC readfixed4        \NC (f)      \NC a float made from a 4 byte fixed format \NC \NR
38\NC read2dot14        \NC (f)      \NC a float made from a 2 byte in 2dot4 format \NC \NR
39\NC setposition       \NC (f,p)    \NC goto position \type {p} \NC \NR
40\NC getposition       \NC (f)      \NC get the current position \NC \NR
41\NC skipposition      \NC (f,n)    \NC skip \type {n} positions \NC \NR
42\NC readbytes         \NC (f,n)    \NC \type {n} bytes \NC \NR
43\NC readbytetable     \NC (f,n)    \NC \type {n} bytes\NC \NR
44\LL
45\stoptabulate
46
47When relevant there are also variants that end with \type {le} that do it the
48little endian way. The fixed and dot floating points formats are found in font
49files and return \LUA\ doubles.
50
51A similar set of function as in the \type {fio} library is available in the \type
52{sio} library: \libidx {sio} {readcardinal1}, \libidx {sio} {readcardinal2},
53\libidx {sio} {readcardinal3}, \libidx {sio} {readcardinal4}, \libidx {sio}
54{readcardinaltable}, \libidx {sio} {readinteger1}, \libidx {sio} {readinteger2},
55\libidx {sio} {readinteger3}, \libidx {sio} {readinteger4}, \libidx {sio}
56{readintegertable}, \libidx {sio} {readfixed2}, \libidx {sio} {readfixed4},
57\libidx {sio} {read2dot14}, \libidx {sio} {setposition}, \libidx {sio}
58{getposition}, \libidx {sio} {skipposition}, \libidx {sio} {readbytes} and
59\libidx {sio} {readbytetable}. Here the first argument is a string instead of a
60file handle.
61
62\stopsection
63
64\startsection[title=\type{md5}]
65
66\starttabulate[|Tw(12em)|T|T|]
67\DB name \BC arguments \BC results \NC \NR
68\TB
69\NC sum  \NC \NC \NC \NR
70\NC hex  \NC \NC \NC \NR
71\NC HEX  \NC \NC \NC \NR
72\LL
73\stoptabulate
74
75\stopsection
76
77\startsection[title=\type{sha2}]
78
79\starttabulate[|Tw(12em)|T|T|]
80\DB name      \BC arguments \BC results \NC \NR
81\TB
82\NC digest256 \NC \NC \NC \NR
83\NC digest384 \NC \NC \NC \NR
84\NC digest512 \NC \NC \NC \NR
85\LL
86\stoptabulate
87
88\stopsection
89
90% \startsection[title=\type{flate}]
91%
92% \starttabulate[|Tw(12em)|T|T|]
93% \DB name             \BC arguments \BC results \NC \NR
94% \TB
95% \NC flate_compress   \NC \NC \NC \NR
96% \NC flate_decompress \NC \NC \NC \NR
97% \NC zip_compress     \NC \NC \NC \NR
98% \NC zip_decompress   \NC \NC \NC \NR
99% \NC gz_compress      \NC \NC \NC \NR
100% \NC gz_decompress    \NC \NC \NC \NR
101% \NC update_adler32   \NC \NC \NC \NR
102% \NC update_crc32     \NC \NC \NC \NR
103% \LL
104% \stoptabulate
105%
106% \stopsection
107
108\startsection[title=\type{xzip}]
109
110\starttabulate[|Tw(12em)|T|T|]
111\DB name             \BC arguments \BC results \NC \NR
112\TB
113\NC compress   \NC \NC \NC \NR
114\NC decompress \NC \NC \NC \NR
115\NC adler32    \NC \NC \NC \NR
116\NC crc32      \NC \NC \NC \NR
117\LL
118\stoptabulate
119
120\stopsection
121
122\startsection[title=\type{xmath}]
123
124This library just opens up standard \CCODE\ math library and the main reason for
125it being there is that it permits advanced graphics in \METAPOST\ (via the \LUA\
126interface). There are three constant values:
127
128\starttabulate[|Tw(12em)|T|T|]
129\DB name \BC arguments \BC results \NC \NR
130\TB
131\NC inf  \NC \emdash \NC \cldcontext{xmath.inf} \NC \NR
132\NC nan  \NC \emdash \NC \cldcontext{xmath.nan} \NC \NR
133\NC pi   \NC \emdash \NC \cldcontext{xmath.pi}  \NC \NR
134\LL
135\stoptabulate
136
137and a lot of functions:
138
139\starttabulate[|Tw(12em)|T|T|]
140\DB name       \BC arguments \BC results \NC \NR
141\TB
142\NC acos       \NC (a)       \NC \NC \NR
143\NC acosh      \NC (a)       \NC \NC \NR
144\NC asin       \NC (a)       \NC \NC \NR
145\NC asinh      \NC (a)       \NC \NC \NR
146\NC atan       \NC (a[,b])   \NC \NC \NR
147\NC atan2      \NC (a[,b])   \NC \NC \NR
148\NC atanh      \NC (a)       \NC \NC \NR
149\NC cbrt       \NC (a)       \NC \NC \NR
150\NC ceil       \NC (a)       \NC \NC \NR
151\NC copysign   \NC (a,b)     \NC \NC \NR
152\NC cos        \NC (a)       \NC \NC \NR
153\NC cosh       \NC (a)       \NC \NC \NR
154\NC deg        \NC (a)       \NC \NC \NR
155\NC erf        \NC (a)       \NC \NC \NR
156\NC erfc       \NC (a)       \NC \NC \NR
157\NC exp        \NC (a)       \NC \NC \NR
158\NC exp2       \NC (a)       \NC \NC \NR
159\NC expm1      \NC (a)       \NC \NC \NR
160\NC fabs       \NC (a)       \NC \NC \NR
161\NC fdim       \NC (a,b)     \NC \NC \NR
162\NC floor      \NC (a)       \NC \NC \NR
163\NC fma        \NC (a,b,c)   \NC \NC \NR
164\NC fmax       \NC (...)     \NC \NC \NR
165\NC fmin       \NC (...)     \NC \NC \NR
166\NC fmod       \NC (a,b)     \NC \NC \NR
167\NC frexp      \NC (a,b)     \NC \NC \NR
168\NC gamma      \NC (a)       \NC \NC \NR
169\NC hypot      \NC (a,b)     \NC \NC \NR
170\NC isfinite   \NC (a)       \NC \NC \NR
171\NC isinf      \NC (a)       \NC \NC \NR
172\NC isnan      \NC (a)       \NC \NC \NR
173\NC isnormal   \NC (a)       \NC \NC \NR
174\NC j0         \NC (a)       \NC \NC \NR
175\NC j1         \NC (a)       \NC \NC \NR
176\NC jn         \NC (a,b)     \NC \NC \NR
177\NC ldexp      \NC (a,b)     \NC \NC \NR
178\NC lgamma     \NC (a)       \NC \NC \NR
179\NC l0         \NC (a)       \NC \NC \NR
180\NC l1         \NC (a)       \NC \NC \NR
181\NC ln         \NC (a,b)     \NC \NC \NR
182\NC log        \NC (a[,b])   \NC \NC \NR
183\NC log10      \NC (a)       \NC \NC \NR
184\NC log1p      \NC (a)       \NC \NC \NR
185\NC log2       \NC (a)       \NC \NC \NR
186\NC logb       \NC (a)       \NC \NC \NR
187\NC modf       \NC (a,b)     \NC \NC \NR
188\NC nearbyint  \NC (a)       \NC \NC \NR
189\NC nextafter  \NC (a,b)     \NC \NC \NR
190\NC pow        \NC (a,b)     \NC \NC \NR
191\NC rad        \NC (a)       \NC \NC \NR
192\NC remainder  \NC (a,b)     \NC \NC \NR
193\NC remquo     \NC (a,b)     \NC \NC \NR
194\NC round      \NC (a)       \NC \NC \NR
195\NC scalbn     \NC (a,b)     \NC \NC \NR
196\NC sin        \NC (a)       \NC \NC \NR
197\NC sinh       \NC (a)       \NC \NC \NR
198\NC sqrt       \NC (a)       \NC \NC \NR
199\NC tan        \NC (a)       \NC \NC \NR
200\NC tanh       \NC (a)       \NC \NC \NR
201\NC tgamma     \NC (a)       \NC \NC \NR
202\NC trunc      \NC (a)       \NC \NC \NR
203\NC y0         \NC (a)       \NC \NC \NR
204\NC y1         \NC (a)       \NC \NC \NR
205\NC yn         \NC (a)       \NC \NC \NR
206\LL
207\stoptabulate
208
209\stopsection
210
211\startsection[title=\type{xcomplex}]
212
213\LUAMETATEX\ also provides a complex library \type {xcomplex}. The complex
214number is a userdatum:
215
216\starttabulate[|Tw(12em)|T|T|]
217\DB name       \BC arguments \BC results \NC \NR
218\TB
219\NC new        \NC (r,i)     \NC a complex userdata type \NC \NR
220\NC tostring   \NC (z)       \NC a string representation \NC \NR
221\NC topair     \NC (z)       \NC two numbers \NC \NR
222\LL
223\stoptabulate
224
225There is a bunch of functions that take a complex number:
226
227\starttabulate[|Tw(12em)|T|T|]
228\DB name       \BC arguments \BC results \NC \NR
229\TB
230\NC abs       \NC (a)       \NC \NC \NR
231\NC arg       \NC (a)       \NC \NC \NR
232\NC imag      \NC (a)       \NC \NC \NR
233\NC real      \NC (a)       \NC \NC \NR
234\NC onj       \NC (a)       \NC \NC \NR
235\NC proj      \NC (a)       \NC \NC \NR
236\NC exp"      \NC (a)       \NC \NC \NR
237\NC log       \NC (a)       \NC \NC \NR
238\NC sqrt      \NC (a)       \NC \NC \NR
239\NC pow       \NC (a,b)     \NC \NC \NR
240\NC sin       \NC (a)       \NC \NC \NR
241\NC cos       \NC (a)       \NC \NC \NR
242\NC tan       \NC (a)       \NC \NC \NR
243\NC asin      \NC (a)       \NC \NC \NR
244\NC acos      \NC (a)       \NC \NC \NR
245\NC atan      \NC (a)       \NC \NC \NR
246\NC sinh      \NC (a)       \NC \NC \NR
247\NC cosh      \NC (a)       \NC \NC \NR
248\NC tanh      \NC (a)       \NC \NC \NR
249\NC asinh     \NC (a)       \NC \NC \NR
250\NC acosh     \NC (a)       \NC \NC \NR
251\NC atanh     \NC (a)       \NC \NC \NR
252\LL
253\stoptabulate
254
255These are accompanied by \type {libcerf} functions:
256
257\starttabulate[|Tw(12em)|T|Tpl|]
258\DB name       \BC arguments \BC results \NC \NR
259\TB
260\NC erf        \NC (a)       \NC The complex error function erf(z) \NC \NR
261\NC erfc       \NC (a)       \NC The complex complementary error function erfc(z) = 1 - erf(z) \NC \NR
262\NC erfcx      \NC (a)       \NC The underflow-compensating function erfcx(z) = exp(z^2) erfc(z) \NC \NR
263\NC erfi       \NC (a)       \NC The imaginary error function erfi(z) = -i erf(iz) \NC \NR
264\NC dawson     \NC (a)       \NC Dawson's integral D(z) = sqrt(pi)/2 * exp(-z^2) * erfi(z) \NC \NR
265\NC voigt      \NC (a,b,c)   \NC The convolution of a Gaussian and a Lorentzian \NC \NR
266\NC voigt_hwhm \NC (a,b)     \NC The half width at half maximum of the Voigt profile \NC \NR
267\LL
268\stoptabulate
269
270\stopsection
271
272\startsection[title=\type{xdecimal}]
273
274As an experiment \LUAMETATEX\ provides an interface to the \type {decNumber}
275library that we have on board for \METAPOST\ anyway. Apart from the usual
276support for operators there are some functions.
277
278\starttabulate[|Tw(12em)|T|T|]
279\DB name         \BC arguments  \BC results \NC \NR
280\TB
281\NC abs          \NC (a)        \NC \NC \NR
282\NC new          \NC ([n or s]) \NC \NC \NR
283\NC copy         \NC (a)        \NC \NC \NR
284\NC trim         \NC (a)        \NC \NC \NR
285\NC tostring     \NC (a)        \NC \NC \NR
286\NC tonumber     \NC (a)        \NC \NC \NR
287\NC setprecision \NC (n)        \NC \NC \NR
288\NC getprecision \NC ()         \NC \NC \NR
289\NC conj         \NC (a)        \NC \NC \NR
290\NC abs          \NC (a)        \NC \NC \NR
291\NC pow          \NC (a,b)      \NC \NC \NR
292\NC sqrt         \NC (a)        \NC \NC \NR
293\NC ln           \NC (a)        \NC \NC \NR
294\NC log          \NC (a)        \NC \NC \NR
295\NC exp          \NC (a)        \NC \NC \NR
296\NC bor          \NC (a,b)      \NC \NC \NR
297\NC bxor         \NC (a,b)      \NC \NC \NR
298\NC band         \NC (a,b)      \NC \NC \NR
299\NC shift        \NC (a,b)      \NC \NC \NR
300\NC rotate       \NC (a,b)      \NC \NC \NR
301\NC minus        \NC (a)        \NC \NC \NR
302\NC plus         \NC (a)        \NC \NC \NR
303\NC min          \NC (a,b)      \NC \NC \NR
304\NC max          \NC (a,b)      \NC \NC \NR
305\LL
306\stoptabulate
307
308\stopsection
309
310\startsection[title=\type{lfs}]
311
312The original \type {lfs} module has been adapted a bit to our needs but for
313practical reasons we kept the namespace. This module will probably evolve a bit
314over time.
315
316\starttabulate[|Tw(12em)|T|Tp|]
317\DB name              \BC arguments \BC results \NC \NR
318\TB
319\NC attributes        \NC (name) \NC \NC \NR
320\NC chdir             \NC (name) \NC \NC \NR
321\NC currentdir        \NC ()     \NC \NC \NR
322\NC dir               \NC (name) \NC \type {name}, \type {mode}, \type {size} and \type {mtime} \NC \NR
323\NC mkdir             \NC (name) \NC \NC \NR
324\NC rmdir             \NC (name) \NC \NC \NR
325\NC touch             \NC (name) \NC \NC \NR
326\NC link              \NC (name) \NC \NC \NR
327\NC symlinkattributes \NC (name) \NC \NC \NR
328\NC isdir             \NC (name) \NC \NC \NR
329\NC isfile            \NC (name) \NC \NC \NR
330\NC iswriteabledir    \NC (name) \NC \NC \NR
331\NC iswriteablefile   \NC (name) \NC \NC \NR
332\NC isreadabledir     \NC (name) \NC \NC \NR
333\NC isreadablefile    \NC (name) \NC \NC \NR
334\LL
335\stoptabulate
336
337The \type {dir} function is a traverser which in addition to the name returns
338some more properties. Keep in mind that the traverser loops over a directory and
339that it doesn't run well when used nested. This is a side effect of the operating
340system. It is also the reason why we return some properties because querying them
341via \type {attributes} would interfere badly.
342
343The following attributes are returned by \type {attributes}:
344
345\starttabulate[|Tw(12em)|T|]
346\DB name         \BC value \NC \NR
347\TB
348\NC mode         \NC \NC \NR
349\NC size         \NC \NC \NR
350\NC modification \NC \NC \NR
351\NC access       \NC \NC \NR
352\NC change       \NC \NC \NR
353\NC permissions  \NC \NC \NR
354\NC nlink        \NC \NC \NR
355\LL
356\stoptabulate
357
358\stopsection
359
360\startsection[title=\type{pngdecode}]
361
362This module is experimental and used in image inclusion. It is not some general
363purpose module and is supposed to be used in a very controlled way. The
364interfaces might evolve.
365
366\starttabulate[|Tw(12em)|T|T|]
367\DB name        \BC arguments                      \BC results \NC \NR
368\TB
369\NC applyfilter \NC (str,nx,ny,slice)              \NC string \NC \NR
370\NC splitmask   \NC (str,nx,ny,bpp,bytes)          \NC string \NC \NR
371\NC interlace   \NC (str,nx,ny,slice,pass)         \NC string \NC \NR
372\NC expand      \NC (str,nx,ny,parts,xline,factor) \NC string \NC \NR
373\LL
374\stoptabulate
375
376\stopsection
377
378\startsection[title=\type{basexx}]
379
380Some more experimental helpers:
381
382\starttabulate[|Tw(12em)|T|T|]
383\DB name      \BC arguments \BC results \NC \NR
384\TB
385\NC encode16  \NC (str[,newline])  \NC string \NC \NR
386\NC decode16  \NC (str)            \NC string \NC \NR
387\NC encode64  \NC (str[,newline])  \NC string \NC \NR
388\NC decode64  \NC (str)            \NC string \NC \NR
389\NC encode85  \NC (str[,newline])  \NC string \NC \NR
390\NC decode85  \NC (str)            \NC string \NC \NR
391\NC encodeRL  \NC (str)            \NC string \NC \NR
392\NC decodeRL  \NC (str)            \NC string \NC \NR
393\NC encodeLZW \NC (str[,defaults]) \NC string \NC \NR
394\NC decodeLZW \NC (str[,defaults]) \NC string \NC \NR
395\LL
396\stoptabulate
397
398\stopsection
399
400\startsection[title={Multibyte \type {string} functions}]
401
402The \type {string} library has a few extra functions, for example \libidx
403{string} {explode}. This function takes upto two arguments: \type
404{string.explode(s[,m])} and returns an array containing the string argument \type
405{s} split into sub-strings based on the value of the string argument \type {m}.
406The second argument is a string that is either empty (this splits the string into
407characters), a single character (this splits on each occurrence of that
408character, possibly introducing empty strings), or a single character followed by
409the plus sign \type {+} (this special version does not create empty sub-strings).
410The default value for \type {m} is \quote {\type { +}} (multiple spaces). Note:
411\type {m} is not hidden by surrounding braces as it would be if this function was
412written in \TEX\ macros.
413
414The \type {string} library also has six extra iterators that return strings
415piecemeal: \libidx {string} {utfvalues}, \libidx {string} {utfcharacters},
416\libidx {string} {characters}, \libidx {string} {characterpairs}, \libidx
417{string} {bytes} and \libidx {string} {bytepairs}.
418
419\startitemize
420\startitem
421    \type {string.utfvalues(s)}: an integer value in the \UNICODE\ range
422\stopitem
423\startitem
424    \type {string.utfcharacters(s)}: a string with a single \UTF-8 token in it
425\stopitem
426\startitem
427    \type {string.characters(s)}: a string containing one byte
428\stopitem
429\startitem
430    \type {string.characterpairs(s)}: two strings each containing one byte or an
431    empty second string if the string length was odd
432\stopitem
433\startitem
434    \type {string.bytes(s)}: a single byte value
435\stopitem
436\startitem
437    \type {string.bytepairs(s)}: two byte values or nil instead of a number as
438    its second return value if the string length was odd
439\stopitem
440\stopitemize
441
442The \type {string.characterpairs()} and \type {string.bytepairs()} iterators
443are useful especially in the conversion of \UTF16 encoded data into \UTF8.
444
445There is also a two|-|argument form of \type {string.dump()}. The second argument
446is a boolean which, if true, strips the symbols from the dumped data. This
447matches an extension made in \type {luajit}. This is typically a function that
448gets adapted as \LUA\ itself progresses.
449
450The \type {string} library functions \type {len}, \type {lower}, \type {sub}
451etc.\ are not \UNICODE|-|aware. For strings in the \UTF8 encoding, i.e., strings
452containing characters above code point 127, the corresponding functions from the
453\type {slnunicode} library can be used, e.g., \type {unicode.utf8.len}, \type
454{unicode.utf8.lower} etc.\ The exceptions are \type {unicode.utf8.find}, that
455always returns byte positions in a string, and \type {unicode.utf8.match} and
456\type {unicode.utf8.gmatch}. While the latter two functions in general {\it
457are} \UNICODE|-|aware, they fall|-|back to non|-|\UNICODE|-|aware behavior when
458using the empty capture \type {()} but other captures work as expected. For the
459interpretation of character classes in \type {unicode.utf8} functions refer to
460the library sources at \hyphenatedurl {http://luaforge.net/projects/sln}.
461
462Version 5.3 of \LUA\ provides some native \UTF8 support but we have added a few
463similar helpers too: \libidx {string} {utfvalue}, \libidx {string} {utfcharacter}
464and \libidx {string} {utflength}.
465
466\startitemize
467\startitem
468    \type {string.utfvalue(s)}: returns the codepoints of the characters in the
469    given string
470\stopitem
471\startitem
472    \type {string.utfcharacter(c,...)}: returns a string with the characters of
473    the given code points
474\stopitem
475\startitem
476    \type {string.utflength(s)}: returns the length of the given string
477\stopitem
478\stopitemize
479
480These three functions are relative fast and don't do much checking. They can be
481used as building blocks for other helpers.
482
483\stopsection
484
485\startsection[title={Extra \type {os} library functions}]
486
487The \type {os} library has a few extra functions and variables: \libidx {os}
488{selfdir}, \libidx {os} {selfarg}, \libidx {os} {setenv}, \libidx {os} {env}, \libidx {os}
489{gettimeofday}, \libidx {os} {type}, \libidx {os} {name} and \libidx {os}
490{uname}, that we will discuss here. There are also some time related helpers in
491the \type {lua} namespace.
492
493\startitemize
494
495% selfbin
496% selfpath
497% selfdir
498% selfbase
499% selfname
500% selfcore
501
502\startitem
503    \type {os.selfdir} is a variable that holds the directory path of the
504    actual executable. For example: \type {\directlua {tex.sprint(os.selfdir)}}.
505\stopitem
506
507\startitem
508    \type {os.selfarg} is a table with the command line arguments.
509\stopitem
510
511\startitem
512    \type {os.setenv(key,value)} sets a variable in the environment. Passing
513    \type {nil} instead of a value string will remove the variable.
514\stopitem
515
516\startitem
517    \type {os.env} is a hash table containing a dump of the variables and
518    values in the process environment at the start of the run. It is writeable,
519    but the actual environment is \notabene {not} updated automatically.
520\stopitem
521
522\startitem
523    \type {os.gettimeofday} returns the current \quote {\UNIX\ time}, but as a
524    float. Keep in mind that there might be platforms where this function is
525    not available.
526\stopitem
527
528\startitem
529    \type {os.type} is a string that gives a global indication of the class of
530    operating system. The possible values are currently \type {windows}, \type
531    {unix}, and \type {msdos} (you are unlikely to find this value \quote {in the
532    wild}).
533\stopitem
534
535\startitem
536    \type {os.name} is a string that gives a more precise indication of the
537    operating system. These possible values are not yet fixed, and for \type
538    {os.type} values \type {windows} and \type {msdos}, the \type {os.name}
539    values are simply \type {windows} and \type {msdos}
540
541    The list for the type \type {unix} is more precise: \type {linux}, \type
542    {freebsd}, \type {kfreebsd}, \type {cygwin}, \type {openbsd}, \type
543    {solaris}, \type {sunos} (pre-solaris), \type {hpux}, \type {irix}, \type
544    {macosx}, \type {gnu} (hurd), \type {bsd} (unknown, but \BSD|-|like), \type
545    {sysv}, \type {generic} (unknown). But \unknown\ we only provide \LUAMETATEX\
546    binaries for the mainstream variants.
547
548    Officially we only support mainstream systems: \MSWINDOWS, \LINUX, \FREEBSD\
549    and \OSX. Of course one can build \LUAMETATEX\ for other systems, in which
550    case on has to check the above.
551\stopitem
552
553\startitem
554    \type {os.uname} returns a table with specific operating system
555    information acquired at runtime. The keys in the returned table are all
556    string values, and their names are: \type {sysname}, \type {machine}, \type
557    {release}, \type {version}, and \type {nodename}.
558\stopitem
559
560\stopitemize
561
562\stopsection
563
564\startsection[title={The \type {lua} library functions}]
565
566The \type {lua} library provides some general helpers.
567
568\startitemize
569
570\startitem
571    The \type {newtable} and \type {newindex} functions can be used to create
572    tables with space reserved beforehand for the given amount of entries.
573\stopitem
574
575\startitem
576    The \type {getstacktop} function returns a number that can be used for
577    diagnostic purposes.
578\stopitem
579
580\startitem
581    The functions \type {getruntime}, \type {getcurrenttime}, \type
582    {getpreciseticks} and \type {getpreciseseconds} return what their name
583    suggests.
584\stopitem
585
586\startitem
587    On \MSWINDOWS\ the \type {getcodepage} function returns two numbers, one
588    for the command handler and one for the graphical user interface.
589\stopitem
590
591\startitem
592    The name of the startup file is reported by \type {getstartupfile}.
593\stopitem
594
595\startitem
596    The \LUA\ version is reported by \type {getversion}.
597\stopitem
598
599\startitem
600    The \type {lua.openfile} function can be used instead of \type {io.open}. On
601    \MSWINDOWS\ it will convert the filename to a so called wide one which means
602    that filenames in \UTF8 encoding will work ok. On the other hand, names given
603    in the codepage won't.
604\stopitem
605
606\stopitemize
607
608\stopsection
609
610\stopchapter
611
612\stopcomponent
613