summaryrefslogtreecommitdiff
path: root/docs/index.html
blob: cd95fc2cca89191d44d378d4d9821442acf0264d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Lua-System docs</title>
    <link rel="stylesheet" href="ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>Lua-System</h1>


<h2>Contents</h2>
<ul>
<li><a href="#environment_Functions">environment Functions</a></li>
<li><a href="#random_Functions">random Functions</a></li>
<li><a href="#term_Functions">term Functions</a></li>
<li><a href="#time_Functions">time Functions</a></li>
</ul>


<h2>Modules</h2>
<ul class="nowrap">
  <li><strong>system</strong></li>
</ul>
<h2>Topics</h2>
<ul class="">
  <li><a href="topics/01-introduction.md.html">1. Introduction</a></li>
  <li><a href="topics/CHANGELOG.md.html">CHANGELOG</a></li>
  <li><a href="topics/LICENSE.md.html">MIT License</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>system</code></h1>
<p>Platform independent system calls for Lua.</p>
<p>

</p>


<h2><a href="#environment_Functions">environment Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#getenv">getenv (name)</a></td>
	<td class="summary">Gets the value of an environment variable.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#getenvs">getenvs ()</a></td>
	<td class="summary">Returns a table with all environment variables.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#setenv">setenv (name[, value])</a></td>
	<td class="summary">Sets an environment variable.</td>
	</tr>
</table>
<h2><a href="#random_Functions">random Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#random">random ([length=1])</a></td>
	<td class="summary">Generate random bytes.</td>
	</tr>
</table>
<h2><a href="#term_Functions">term Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#isatty">isatty (file)</a></td>
	<td class="summary">Checks if a file-handle is a TTY.</td>
	</tr>
</table>
<h2><a href="#time_Functions">time Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#gettime">gettime ()</a></td>
	<td class="summary">Get system time.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#monotime">monotime ()</a></td>
	<td class="summary">Get monotonic time.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#sleep">sleep (seconds[, precision=16])</a></td>
	<td class="summary">Sleep without a busy loop.</td>
	</tr>
</table>

<br/>
<br/>


    <h2 class="section-header "><a name="environment_Functions"></a>environment Functions</h2>

    <dl class="function">
    <dt>
    <a name = "getenv"></a>
    <strong>getenv (name)</strong>
    </dt>
    <dd>
    Gets the value of an environment variable. </p>

<p><strong>NOTE</strong>: Windows has multiple copies of environment variables. For this reason,
the <a href="index.html#setenv">setenv</a> function will not work with Lua's <a href="https://www.lua.org/manual/5.1/manual.html#pdf-os.getenv">os.getenv</a> on Windows. If you want
to use <a href="index.html#setenv">setenv</a> then consider patching <a href="https://www.lua.org/manual/5.1/manual.html#pdf-os.getenv">os.getenv</a> with this implementation of <a href="index.html#getenv">getenv</a>.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">name</span>
            <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
         name of the environment variable
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

           <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">nil</span></span>
        value of the environment variable, or nil if the variable is not set
    </ol>




</dd>
    <dt>
    <a name = "getenvs"></a>
    <strong>getenvs ()</strong>
    </dt>
    <dd>
    Returns a table with all environment variables.



    <h3>Returns:</h3>
    <ol>

           <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
        table with all environment variables and their values
    </ol>




</dd>
    <dt>
    <a name = "setenv"></a>
    <strong>setenv (name[, value])</strong>
    </dt>
    <dd>
    Sets an environment variable. </p>

<p><strong>NOTE</strong>: Windows has multiple copies of environment variables. For this reason, the
<a href="index.html#setenv">setenv</a> function will not work with Lua's <a href="https://www.lua.org/manual/5.1/manual.html#pdf-os.getenv">os.getenv</a> on Windows. If you want to use
it then consider patching <a href="https://www.lua.org/manual/5.1/manual.html#pdf-os.getenv">os.getenv</a> with the implementation of <a href="index.html#getenv">system.getenv</a>.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">name</span>
            <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
         name of the environment variable
        </li>
        <li><span class="parameter">value</span>
            <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
         value of the environment variable, if <code>nil</code> the variable will be deleted (on
Windows, setting an empty string, will also delete the variable)
         (<em>optional</em>)
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

           <span class="types"><span class="type">boolean</span></span>
        success
    </ol>




</dd>
</dl>
    <h2 class="section-header "><a name="random_Functions"></a>random Functions</h2>

    <dl class="function">
    <dt>
    <a name = "random"></a>
    <strong>random ([length=1])</strong>
    </dt>
    <dd>
    Generate random bytes.
This uses <code>CryptGenRandom()</code> on Windows, and <code>/dev/urandom</code> on other platforms. It will return the
requested number of bytes, or an error, never a partial result.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">length</span>
            <span class="types"><span class="type">int</span></span>
         number of bytes to get
         (<em>default</em> 1)
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

           <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
        string of random bytes
    </ol>
     <h3>Or</h3>
    <ol>
        <li>
           <span class="types"><span class="type">nil</span></span>


</li>
        <li>
           <span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
        error message</li>
    </ol>




</dd>
</dl>
    <h2 class="section-header "><a name="term_Functions"></a>term Functions</h2>

    <dl class="function">
    <dt>
    <a name = "isatty"></a>
    <strong>isatty (file)</strong>
    </dt>
    <dd>
    Checks if a file-handle is a TTY.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">file</span>
            <span class="types"><span class="type">file</span></span>
         the file-handle to check
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

           <span class="types"><span class="type">boolean</span></span>
        true if the file is a tty
    </ol>




</dd>
</dl>
    <h2 class="section-header "><a name="time_Functions"></a>time Functions</h2>

    <dl class="function">
    <dt>
    <a name = "gettime"></a>
    <strong>gettime ()</strong>
    </dt>
    <dd>
    Get system time.
The time is returned as the seconds since the epoch (1 January 1970 00:00:00).



    <h3>Returns:</h3>
    <ol>

           <span class="types"><span class="type">number</span></span>
        seconds (fractional)
    </ol>




</dd>
    <dt>
    <a name = "monotime"></a>
    <strong>monotime ()</strong>
    </dt>
    <dd>
    Get monotonic time.
The time is returned as the seconds since system start.



    <h3>Returns:</h3>
    <ol>

           <span class="types"><span class="type">number</span></span>
        seconds (fractional)
    </ol>




</dd>
    <dt>
    <a name = "sleep"></a>
    <strong>sleep (seconds[, precision=16])</strong>
    </dt>
    <dd>
    Sleep without a busy loop.
This function will sleep, without doing a busy-loop and wasting CPU cycles.


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">seconds</span>
            <span class="types"><span class="type">number</span></span>
         seconds to sleep (fractional).
        </li>
        <li><span class="parameter">precision</span>
            <span class="types"><span class="type">integer</span></span>
         minimum stepsize in milliseconds (Windows only, ignored elsewhere)
         (<em>default</em> 16)
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        <code>true</code> on success, or <code>nil+err</code> on failure
    </ol>




</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2023-12-15 13:15:09 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>