~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/erl_interface/doc/src/erl_eterm.xml

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="latin1" ?>
 
2
<!DOCTYPE cref SYSTEM "cref.dtd">
 
3
 
 
4
<cref>
 
5
  <header>
 
6
    <copyright>
 
7
      <year>1996</year>
 
8
      <year>2007</year>
 
9
      <holder>Ericsson AB, All Rights Reserved</holder>
 
10
    </copyright>
 
11
    <legalnotice>
 
12
  The contents of this file are subject to the Erlang Public License,
 
13
  Version 1.1, (the "License"); you may not use this file except in
 
14
  compliance with the License. You should have received a copy of the
 
15
  Erlang Public License along with this software. If not, it can be
 
16
  retrieved online at http://www.erlang.org/.
 
17
 
 
18
  Software distributed under the License is distributed on an "AS IS"
 
19
  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
20
  the License for the specific language governing rights and limitations
 
21
  under the License.
 
22
 
 
23
  The Initial Developer of the Original Code is Ericsson AB.
 
24
    </legalnotice>
 
25
 
 
26
    <title>erl_eterm</title>
 
27
    <prepared>Torbj&ouml;rn T&ouml;rnkvist</prepared>
 
28
    <responsible>Torbj&ouml;rn T&ouml;rnkvist</responsible>
 
29
    <docno></docno>
 
30
    <approved>Bjarne D&auml;cker</approved>
 
31
    <checked>Torbj&ouml;rn T&ouml;rnkvist</checked>
 
32
    <date>980703</date>
 
33
    <rev>A</rev>
 
34
    <file>erl_eterm.sgml</file>
 
35
  </header>
 
36
  <lib>erl_eterm</lib>
 
37
  <libsummary>Functions for Erlang Term Construction</libsummary>
 
38
  <description>
 
39
    <p>This module contains functions for creating and manipulating
 
40
      Erlang terms. </p>
 
41
    <p>An Erlang term is represented by a C structure of type
 
42
      <c><![CDATA[ETERM]]></c>. Applications should not reference any fields in this
 
43
      structure directly, because it may be changed in future releases
 
44
      to provide faster and more compact term storage. Instead,
 
45
      applications should us the macros and functions provided. </p>
 
46
    <p>The following macros each take a single ETERM pointer as an
 
47
      argument. They return a non-zero value if the test is true, and 0
 
48
      otherwise:</p>
 
49
    <taglist>
 
50
      <tag><c><![CDATA[ERL_IS_INTEGER(t)]]></c></tag>
 
51
      <item>True if <c><![CDATA[t]]></c> is an integer.</item>
 
52
      <tag><c><![CDATA[ERL_IS_UNSIGNED_INTEGER(t)]]></c></tag>
 
53
      <item>True if <c><![CDATA[t]]></c> is an integer.</item>
 
54
      <tag><c><![CDATA[ERL_IS_FLOAT(t)]]></c></tag>
 
55
      <item>True if <c><![CDATA[t]]></c> is a floating point number.</item>
 
56
      <tag><c><![CDATA[ERL_IS_ATOM(t)]]></c></tag>
 
57
      <item>True if <c><![CDATA[t]]></c> is an atom.</item>
 
58
      <tag><c><![CDATA[ERL_IS_PID(t)]]></c></tag>
 
59
      <item>True if <c><![CDATA[t]]></c> is a Pid (process identifier).</item>
 
60
      <tag><c><![CDATA[ERL_IS_PORT(t)]]></c></tag>
 
61
      <item>True if <c><![CDATA[t]]></c> is a port.</item>
 
62
      <tag><c><![CDATA[ERL_IS_REF(t)]]></c></tag>
 
63
      <item>True if <c><![CDATA[t]]></c> is a reference.</item>
 
64
      <tag><c><![CDATA[ERL_IS_TUPLE(t)]]></c></tag>
 
65
      <item>True if <c><![CDATA[t]]></c> is a tuple.</item>
 
66
      <tag><c><![CDATA[ERL_IS_BINARY(t)]]></c></tag>
 
67
      <item>True if <c><![CDATA[t]]></c> is a binary.</item>
 
68
      <tag><c><![CDATA[ERL_IS_LIST(t)]]></c></tag>
 
69
      <item>True if <c><![CDATA[t]]></c> is a list with zero or more elements.</item>
 
70
      <tag><c><![CDATA[ERL_IS_EMPTY_LIST(t)]]></c></tag>
 
71
      <item>True if <c><![CDATA[t]]></c> is an empty list.</item>
 
72
      <tag><c><![CDATA[ERL_IS_CONS(t)]]></c></tag>
 
73
      <item>True if <c><![CDATA[t]]></c> is a list with at least one element.</item>
 
74
    </taglist>
 
75
    <p>The following macros can be used for retrieving parts of Erlang
 
76
      terms. None of these do any type checking; results are undefined
 
77
      if you pass an ETERM* containing the wrong type. For example,
 
78
      passing a tuple to ERL_ATOM_PTR() will likely result in garbage.
 
79
      </p>
 
80
    <taglist>
 
81
      <tag><c><![CDATA[char *ERL_ATOM_PTR(t)]]></c></tag>
 
82
      <item>A string representing atom <c><![CDATA[t]]></c>.
 
83
      </item>
 
84
      <tag><c><![CDATA[int ERL_ATOM_SIZE(t)]]></c></tag>
 
85
      <item>The length (in characters) of atom t.</item>
 
86
      <tag><c><![CDATA[void *ERL_BIN_PTR(t)]]></c></tag>
 
87
      <item>A pointer to the contents of <c><![CDATA[t]]></c></item>
 
88
      <tag><c><![CDATA[int ERL_BIN_SIZE(t)]]></c></tag>
 
89
      <item>The length (in bytes) of binary object <c><![CDATA[t]]></c>.</item>
 
90
      <tag><c><![CDATA[int ERL_INT_VALUE(t)]]></c></tag>
 
91
      <item>The integer of <c><![CDATA[t]]></c>.</item>
 
92
      <tag><c><![CDATA[unsigned int ERL_INT_UVALUE(t)]]></c></tag>
 
93
      <item>The unsigned integer value of <c><![CDATA[t]]></c>.</item>
 
94
      <tag><c><![CDATA[double ERL_FLOAT_VALUE(t)]]></c></tag>
 
95
      <item>The floating point value of <c><![CDATA[t]]></c>.</item>
 
96
      <tag><c><![CDATA[ETERM *ERL_PID_NODE(t)]]></c></tag>
 
97
      <item>The Node in pid <c><![CDATA[t]]></c>.</item>
 
98
      <tag><c><![CDATA[int ERL_PID_NUMBER(t)]]></c></tag>
 
99
      <item>The sequence number in pid <c><![CDATA[t]]></c>.</item>
 
100
      <tag><c><![CDATA[int ERL_PID_SERIAL(t)]]></c></tag>
 
101
      <item>The serial number in pid <c><![CDATA[t]]></c>.</item>
 
102
      <tag><c><![CDATA[int ERL_PID_CREATION(t)]]></c></tag>
 
103
      <item>The creation number in pid <c><![CDATA[t]]></c>.</item>
 
104
      <tag><c><![CDATA[int ERL_PORT_NUMBER(t)]]></c></tag>
 
105
      <item>The sequence number in port <c><![CDATA[t]]></c>.</item>
 
106
      <tag><c><![CDATA[int ERL_PORT_CREATION(t)]]></c></tag>
 
107
      <item>The creation number in port <c><![CDATA[t]]></c>.</item>
 
108
      <tag><c><![CDATA[ETERM *ERL_PORT_NODE(t)]]></c></tag>
 
109
      <item>The node in port <c><![CDATA[t]]></c>.</item>
 
110
      <tag><c><![CDATA[int ERL_REF_NUMBER(t)]]></c></tag>
 
111
      <item>The first part of the reference number in ref <c><![CDATA[t]]></c>. Use
 
112
       only for compatibility.</item>
 
113
      <tag><c><![CDATA[int ERL_REF_NUMBERS(t)]]></c></tag>
 
114
      <item>Pointer to the array of reference numbers in ref <c><![CDATA[t]]></c>.</item>
 
115
      <tag><c><![CDATA[int ERL_REF_LEN(t)]]></c></tag>
 
116
      <item>The number of used reference numbers in ref <c><![CDATA[t]]></c>.</item>
 
117
      <tag><c><![CDATA[int ERL_REF_CREATION(t)]]></c></tag>
 
118
      <item>The creation number in ref <c><![CDATA[t]]></c>.</item>
 
119
      <tag><c><![CDATA[int ERL_TUPLE_SIZE(t)]]></c></tag>
 
120
      <item>The number of elements in tuple <c><![CDATA[t]]></c>.</item>
 
121
      <tag><c><![CDATA[ETERM *ERL_CONS_HEAD(t)]]></c></tag>
 
122
      <item>The head element of list <c><![CDATA[t]]></c>.</item>
 
123
      <tag><c><![CDATA[ETERM *ERL_CONS_TAIL(t)]]></c></tag>
 
124
      <item>A List representing the tail elements of list <c><![CDATA[t]]></c>.</item>
 
125
    </taglist>
 
126
  </description>
 
127
  <funcs>
 
128
    <func>
 
129
      <name><ret>ETERM *</ret><nametext>erl_cons(head, tail)</nametext></name>
 
130
      <fsummary>Prepends a term to the head of a list.</fsummary>
 
131
      <type>
 
132
        <v>ETERM *head;</v>
 
133
        <v>ETERM *tail;</v>
 
134
      </type>
 
135
      <desc>
 
136
        <p>This function concatenates two Erlang terms, prepending
 
137
          <c><![CDATA[head]]></c> onto <c><![CDATA[tail]]></c> and thereby creating a <c><![CDATA[cons]]></c> cell.
 
138
          To make a proper list, <c><![CDATA[tail]]></c> should always be a
 
139
          list or an empty list. Note that NULL is not a valid list.</p>
 
140
        <p><c><![CDATA[head]]></c> is the new term to be added.</p>
 
141
        <p><c><![CDATA[tail]]></c> is the existing list to which <c><![CDATA[head]]></c> will
 
142
          be concatenated.</p>
 
143
        <p>The function returns a new list.</p>
 
144
        <p><c><![CDATA[ERL_CONS_HEAD(list)]]></c> and <c><![CDATA[ERL_CONS_TAIL(list)]]></c>
 
145
          can be used to retrieve the head and tail components
 
146
          from the list. <c><![CDATA[erl_hd(list)]]></c> and <c><![CDATA[erl_tl(list)]]></c> will do
 
147
          the same thing, but check that the argument really is a list.</p>
 
148
        <p>For example:</p>
 
149
        <code type="none"><![CDATA[
 
150
ETERM *list,*anAtom,*anInt;
 
151
anAtom = erl_mk_atom("madonna");
 
152
anInt  = erl_mk_int(21);
 
153
list   = erl_mk_empty_list();
 
154
list   = erl_cons(anAtom, list);
 
155
list   = erl_cons(anInt, list);
 
156
 ... /* do some work */
 
157
erl_free_compound(list);
 
158
        ]]></code>
 
159
      </desc>
 
160
    </func>
 
161
    <func>
 
162
      <name><ret>ETERM *</ret><nametext>erl_copy_term(term)</nametext></name>
 
163
      <fsummary>Creates a copy of an Erlang term</fsummary>
 
164
      <type>
 
165
        <v>ETERM *term;</v>
 
166
      </type>
 
167
      <desc>
 
168
        <p>This function creates and returns a copy of the Erlang term 
 
169
          <c><![CDATA[term]]></c>.</p>
 
170
      </desc>
 
171
    </func>
 
172
    <func>
 
173
      <name><ret>ETERM *</ret><nametext>erl_element(position, tuple)</nametext></name>
 
174
      <fsummary>Extracts an element from an Erlang tuple</fsummary>
 
175
      <type>
 
176
        <v>int position;</v>
 
177
        <v>ETERM *tuple;</v>
 
178
      </type>
 
179
      <desc>
 
180
        <p>This function extracts a specified element from an Erlang
 
181
          tuple. </p>
 
182
        <p><c><![CDATA[position]]></c> specifies which element to retrieve from
 
183
          <c><![CDATA[tuple]]></c>. The elements are numbered starting from 1.</p>
 
184
        <p><c><![CDATA[tuple]]></c> is an Erlang term containing at least
 
185
          <c><![CDATA[position]]></c> elements.</p>
 
186
        <p>The function returns a new Erlang term corresponding to the
 
187
          requested element, or NULL if <c><![CDATA[position]]></c> was greater than
 
188
          the arity of <c><![CDATA[tuple]]></c>.</p>
 
189
      </desc>
 
190
    </func>
 
191
    <func>
 
192
      <name><ret>void</ret><nametext>erl_init(NULL, 0)</nametext></name>
 
193
      <fsummary>Initialization routine</fsummary>
 
194
      <type>
 
195
        <v>void *NULL;</v>
 
196
        <v>int 0;</v>
 
197
      </type>
 
198
      <desc>
 
199
        <marker id="erl_init"></marker>
 
200
        <p>This function must be called before any of the others in 
 
201
          the <c><![CDATA[erl_interface]]></c> library in order to initialize the
 
202
          library functions. The arguments must be specified as 
 
203
          <c><![CDATA[erl_init(NULL,0)]]></c>.</p>
 
204
      </desc>
 
205
    </func>
 
206
    <func>
 
207
      <name><ret>ETERM *</ret><nametext>erl_hd(list)</nametext></name>
 
208
      <fsummary>Extracts the first element from a list</fsummary>
 
209
      <type>
 
210
        <v>ETERM *list;</v>
 
211
      </type>
 
212
      <desc>
 
213
        <p>Extracts the first element from a list.</p>
 
214
        <p><c><![CDATA[list]]></c> is an Erlang term containing a list.</p>
 
215
        <p>The function returns an Erlang term corresponding to the
 
216
          head element in the list, or a NULL pointer if <c><![CDATA[list]]></c> was
 
217
          not a list.</p>
 
218
      </desc>
 
219
    </func>
 
220
    <func>
 
221
      <name><ret>ETERM *</ret><nametext>erl_iolist_to_binary(term)</nametext></name>
 
222
      <fsummary>Converts an IO list to a binary</fsummary>
 
223
      <type>
 
224
        <v>ETERM *list;</v>
 
225
      </type>
 
226
      <desc>
 
227
        <p>This function converts an IO list to a binary term.</p>
 
228
        <p><c><![CDATA[list]]></c> is an Erlang term containing a list.</p>
 
229
        <p>This function an Erlang binary term, or NULL if <c><![CDATA[list]]></c>
 
230
          was not an IO list. </p>
 
231
        <p>Informally, an IO list is a deep list of characters and
 
232
          binaries which can be sent to an Erlang port. In BNF, an IO
 
233
          list is formally defined as follows: </p>
 
234
        <code type="none"><![CDATA[
 
235
iolist ::= []
 
236
        |   Binary
 
237
        |   [iohead | iolist]
 
238
\011;
 
239
iohead ::= Binary
 
240
        |   Byte (integer in the range [0..255])
 
241
\011|   iolist
 
242
\011;
 
243
        ]]></code>
 
244
      </desc>
 
245
    </func>
 
246
    <func>
 
247
      <name><ret>char *</ret><nametext>erl_iolist_to_string(list)</nametext></name>
 
248
      <fsummary>Converts an IO list to a zero terminated string</fsummary>
 
249
      <type>
 
250
        <v>ETERM *list;</v>
 
251
      </type>
 
252
      <desc>
 
253
        <p>This function converts an IO list to a '\\0' terminated C
 
254
          string. </p>
 
255
        <p><c><![CDATA[list]]></c> is an Erlang term containing an IO list. The IO
 
256
          list must not contain the integer 0, since C strings may not
 
257
          contain this value except as a terminating marker.</p>
 
258
        <p>This function returns a pointer to a dynamically allocated
 
259
          buffer containing a string. If <c><![CDATA[list]]></c> is not an IO list,
 
260
          or if <c><![CDATA[list]]></c> contains the integer 0, NULL is returned. It
 
261
          is the caller's responsibility free the allocated buffer
 
262
          with <c><![CDATA[erl_free()]]></c>. </p>
 
263
        <p>Refer to <c><![CDATA[erl_iolist_to_binary()]]></c> for the definition of an
 
264
          IO list. </p>
 
265
      </desc>
 
266
    </func>
 
267
    <func>
 
268
      <name><ret>int</ret><nametext>erl_iolist_length(list)</nametext></name>
 
269
      <fsummary>Return the length of an IO list</fsummary>
 
270
      <type>
 
271
        <v>ETERM *list;</v>
 
272
      </type>
 
273
      <desc>
 
274
        <p>Returns the length of an IO list.
 
275
          </p>
 
276
        <p><c><![CDATA[list]]></c> is an Erlang term containing an IO list. </p>
 
277
        <p>The function returns the length of <c><![CDATA[list]]></c>, or -1 if
 
278
          <c><![CDATA[list]]></c> is not an IO list.</p>
 
279
        <p>Refer to <c><![CDATA[erl_iolist_to_binary()]]></c> for the definition of
 
280
          an IO list. </p>
 
281
      </desc>
 
282
    </func>
 
283
    <func>
 
284
      <name><ret>int</ret><nametext>erl_length(list)</nametext></name>
 
285
      <fsummary>Determines the length of a list</fsummary>
 
286
      <type>
 
287
        <v>ETERM *list;</v>
 
288
      </type>
 
289
      <desc>
 
290
        <p>Determines the length of a proper list.</p>
 
291
        <p><c><![CDATA[list]]></c> is an Erlang term containing proper list. In a
 
292
          proper list, all tails except the last point to another list
 
293
          cell, and the last tail points to an empty list.</p>
 
294
        <p>Returns -1 if <c><![CDATA[list]]></c> is not a proper list.</p>
 
295
      </desc>
 
296
    </func>
 
297
    <func>
 
298
      <name><ret>ETERM *</ret><nametext>erl_mk_atom(string)</nametext></name>
 
299
      <fsummary>Creates an atom</fsummary>
 
300
      <type>
 
301
        <v>char *string;</v>
 
302
      </type>
 
303
      <desc>
 
304
        <p>Creates an atom.</p>
 
305
        <p><c><![CDATA[string]]></c> is the sequence of characters that will be
 
306
          used to create the atom.</p>
 
307
        <p>Returns an Erlang term containing an atom. Note that it is
 
308
          the callers responsibility to make sure that <c><![CDATA[string]]></c>
 
309
          contains a valid name for an atom.</p>
 
310
        <p><c><![CDATA[ERL_ATOM_PTR(atom)]]></c> can be used to retrieve the 
 
311
          atom name (as a string). Note that the string is not
 
312
          0-terminated in the atom. <c><![CDATA[ERL_ATOM_SIZE(atom)]]></c>returns
 
313
          the length of the atom name.</p>
 
314
      </desc>
 
315
    </func>
 
316
    <func>
 
317
      <name><ret>ETERM *</ret><nametext>erl_mk_binary(bptr, size)</nametext></name>
 
318
      <fsummary>Creates a binary object</fsummary>
 
319
      <type>
 
320
        <v>char *bptr;</v>
 
321
        <v>int size;</v>
 
322
      </type>
 
323
      <desc>
 
324
        <p>This function produces an Erlang binary object from a
 
325
          buffer containing a sequence of bytes.</p>
 
326
        <p><c><![CDATA[bptr]]></c> is a pointer to a buffer containg data to be converted.</p>
 
327
        <p><c><![CDATA[size]]></c> indicates the length of <c><![CDATA[bptr]]></c>.</p>
 
328
        <p>The function returns an Erlang binary object.</p>
 
329
        <p><c><![CDATA[ERL_BIN_PTR(bin)]]></c> retrieves a pointer to
 
330
          the binary data. <c><![CDATA[ERL_BIN_SIZE(bin)]]></c> retrieves the 
 
331
          size. </p>
 
332
      </desc>
 
333
    </func>
 
334
    <func>
 
335
      <name><ret>ETERM *</ret><nametext>erl_mk_empty_list()</nametext></name>
 
336
      <fsummary>Creates an empty Erlang list</fsummary>
 
337
      <desc>
 
338
        <p>This function creates and returns an empty Erlang list.
 
339
          Note that NULL is not used to represent an empty list;
 
340
          Use this function instead.</p>
 
341
      </desc>
 
342
    </func>
 
343
    <func>
 
344
      <name><ret>ETERM *</ret><nametext>erl_mk_estring(string, len)</nametext></name>
 
345
      <fsummary>Creates an Erlang string</fsummary>
 
346
      <type>
 
347
        <v>char *string;</v>
 
348
        <v>int len;</v>
 
349
      </type>
 
350
      <desc>
 
351
        <p>This function creates a list from a sequence of bytes.</p>
 
352
        <p><c><![CDATA[string]]></c> is a buffer containing a sequence of
 
353
          bytes. The buffer does not need to be zero-terminated.</p>
 
354
        <p><c><![CDATA[len]]></c> is the length of <c><![CDATA[string]]></c>.</p>
 
355
        <p>The function returns an Erlang list object corresponding to
 
356
          the character sequence in <c><![CDATA[string]]></c>.</p>
 
357
      </desc>
 
358
    </func>
 
359
    <func>
 
360
      <name><ret>ETERM *</ret><nametext>erl_mk_float(f)</nametext></name>
 
361
      <fsummary>Creates an Erlang float</fsummary>
 
362
      <type>
 
363
        <v>double f;</v>
 
364
      </type>
 
365
      <desc>
 
366
        <p>Creates an Erlang float.</p>
 
367
        <p><c><![CDATA[f]]></c> is a value to be converted to an Erlang float.</p>
 
368
        <p></p>
 
369
        <p>The function returns an Erlang float object with the value
 
370
          specified in <c><![CDATA[f]]></c>.</p>
 
371
        <p><c><![CDATA[ERL_FLOAT_VALUE(t)]]></c> can be used to retrieve the
 
372
          value from an Erlang float.</p>
 
373
      </desc>
 
374
    </func>
 
375
    <func>
 
376
      <name><ret>ETERM *</ret><nametext>erl_mk_int(n)</nametext></name>
 
377
      <fsummary>Creates an Erlang integer</fsummary>
 
378
      <type>
 
379
        <v>int n;</v>
 
380
      </type>
 
381
      <desc>
 
382
        <p>Creates an Erlang integer.</p>
 
383
        <p><c><![CDATA[n]]></c> is a value to be converted to an Erlang integer.</p>
 
384
        <p></p>
 
385
        <p>The function returns an Erlang integer object with the
 
386
          value specified in <c><![CDATA[n]]></c>.</p>
 
387
        <p><c><![CDATA[ERL_INT_VALUE(t)]]></c> can be used to retrieve the value 
 
388
          value from an Erlang integer.</p>
 
389
      </desc>
 
390
    </func>
 
391
    <func>
 
392
      <name><ret>ETERM *</ret><nametext>erl_mk_list(array, arrsize)</nametext></name>
 
393
      <fsummary>Creates a list from an array</fsummary>
 
394
      <type>
 
395
        <v>ETERM **array;</v>
 
396
        <v>int arrsize;</v>
 
397
      </type>
 
398
      <desc>
 
399
        <p>Creates an Erlang list from an array of Erlang terms, such
 
400
          that each element in the list corresponds to one element in
 
401
          the array. </p>
 
402
        <p><c><![CDATA[array]]></c> is an array of Erlang terms.</p>
 
403
        <p><c><![CDATA[arrsize]]></c> is the number of elements in <c><![CDATA[array]]></c>.</p>
 
404
        <p>The function creates an Erlang list object, whose length
 
405
          <c><![CDATA[arrsize]]></c> and whose elements are taken from the terms in
 
406
          <c><![CDATA[array]]></c>.</p>
 
407
      </desc>
 
408
    </func>
 
409
    <func>
 
410
      <name><ret>ETERM *</ret><nametext>erl_mk_pid(node, number, serial, creation)</nametext></name>
 
411
      <fsummary>Creates a process identifier</fsummary>
 
412
      <type>
 
413
        <v>const char *node;</v>
 
414
        <v>unsigned int number;</v>
 
415
        <v>unsigned int serial;</v>
 
416
        <v>unsigned int creation;</v>
 
417
      </type>
 
418
      <desc>
 
419
        <p>This function creates an Erlang process identifier. The
 
420
          resulting pid can be used by Erlang processes wishing to
 
421
          communicate with the C node.</p>
 
422
        <p><c><![CDATA[node]]></c> is the name of the C node.</p>
 
423
        <p><c><![CDATA[number]]></c>, <c><![CDATA[serial]]></c> and <c><![CDATA[creation]]></c> are
 
424
          arbitrary numbers. Note though, that these are limited in
 
425
          precision, so only the low 15, 3 and 2 bits of these numbers
 
426
          are actually used.</p>
 
427
        <p>The function returns an Erlang pid object.</p>
 
428
        <p><c><![CDATA[ERL_PID_NODE(pid)]]></c>, <c><![CDATA[ERL_PID_NUMBER(pid)]]></c>,
 
429
          <c><![CDATA[ERL_PID_SERIAL(pid)]]></c> and <c><![CDATA[ERL_PID_CREATION(pid)]]></c>
 
430
          can be used to retrieve\011the four values used to create the pid.</p>
 
431
      </desc>
 
432
    </func>
 
433
    <func>
 
434
      <name><ret>ETERM *</ret><nametext>erl_mk_port(node, number, creation)</nametext></name>
 
435
      <fsummary>Creates a port identifier</fsummary>
 
436
      <type>
 
437
        <v>const char *node;</v>
 
438
        <v>unsigned int number;</v>
 
439
        <v>unsigned int creation;</v>
 
440
      </type>
 
441
      <desc>
 
442
        <p>This function creates an Erlang port identifier. </p>
 
443
        <p><c><![CDATA[node]]></c> is the name of the C node.</p>
 
444
        <p><c><![CDATA[number]]></c> and <c><![CDATA[creation]]></c> are arbitrary numbers.
 
445
          Note though, that these are limited in
 
446
          precision, so only the low 18 and 2 bits of these numbers
 
447
          are actually used.\011</p>
 
448
        <p>The function returns an Erlang port object.</p>
 
449
        <p><c><![CDATA[ERL_PORT_NODE(port)]]></c>, <c><![CDATA[ERL_PORT_NUMBER(port)]]></c>
 
450
          and <c><![CDATA[ERL_PORT_CREATION]]></c> can be used to retrieve the three
 
451
          values used to create the port. </p>
 
452
      </desc>
 
453
    </func>
 
454
    <func>
 
455
      <name><ret>ETERM *</ret><nametext>erl_mk_ref(node, number, creation)</nametext></name>
 
456
      <fsummary>Creates an old Erlang reference</fsummary>
 
457
      <type>
 
458
        <v>const char *node;</v>
 
459
        <v>unsigned int number;</v>
 
460
        <v>unsigned int creation;</v>
 
461
      </type>
 
462
      <desc>
 
463
        <p>This function creates an old Erlang reference, with
 
464
          only 18 bits - use <c><![CDATA[erl_mk_long_ref]]></c> instead.</p>
 
465
        <p><c><![CDATA[node]]></c> is the name of the C node.</p>
 
466
        <p><c><![CDATA[number]]></c> should be chosen uniquely for each reference
 
467
          created for a given C node.</p>
 
468
        <p><c><![CDATA[creation]]></c> is an arbitrary number.</p>
 
469
        <p>Note  that <c><![CDATA[number]]></c> and <c><![CDATA[creation]]></c> are limited in
 
470
          precision, so only the low 18 and 2 bits of these numbers
 
471
          are actually used.
 
472
          </p>
 
473
        <p>The function returns an Erlang reference object.</p>
 
474
        <p><c><![CDATA[ERL_REF_NODE(ref)]]></c>, <c><![CDATA[ERL_REF_NUMBER(ref)]]></c>, and
 
475
          <c><![CDATA[ERL_REF_CREATION(ref)]]></c> to retrieve the three values used
 
476
          to create the reference. </p>
 
477
      </desc>
 
478
    </func>
 
479
    <func>
 
480
      <name><ret>ETERM *</ret><nametext>erl_mk_long_ref(node, n1, n2, n3, creation)</nametext></name>
 
481
      <fsummary>Creates an Erlang reference</fsummary>
 
482
      <type>
 
483
        <v>const char *node;</v>
 
484
        <v>unsigned int n1, n2, n3;</v>
 
485
        <v>unsigned int creation;</v>
 
486
      </type>
 
487
      <desc>
 
488
        <p>This function creates an Erlang reference, with 82 bits.</p>
 
489
        <p><c><![CDATA[node]]></c> is the name of the C node.</p>
 
490
        <p><c><![CDATA[n1]]></c>, <c><![CDATA[n2]]></c> and <c><![CDATA[n3]]></c> can be seen as one big number
 
491
          <c><![CDATA[n1*2^64+n2*2^32+n3]]></c> which should be chosen uniquely for
 
492
          each reference
 
493
          created for a given C node.</p>
 
494
        <p><c><![CDATA[creation]]></c> is an arbitrary number.</p>
 
495
        <p>Note that <c><![CDATA[n3]]></c> and <c><![CDATA[creation]]></c> are limited in
 
496
          precision, so only the low 18 and 2 bits of these numbers
 
497
          are actually used.
 
498
          </p>
 
499
        <p>The function returns an Erlang reference object.</p>
 
500
        <p><c><![CDATA[ERL_REF_NODE(ref)]]></c>, <c><![CDATA[ERL_REF_NUMBERS(ref)]]></c>,
 
501
          <c><![CDATA[ERL_REF_LEN(ref)]]></c> and
 
502
          <c><![CDATA[ERL_REF_CREATION(ref)]]></c> to retrieve the values used
 
503
          to create the reference. </p>
 
504
      </desc>
 
505
    </func>
 
506
    <func>
 
507
      <name><ret>ETERM *</ret><nametext>erl_mk_string(string)</nametext></name>
 
508
      <fsummary>Creates a string</fsummary>
 
509
      <type>
 
510
        <v>char *string;</v>
 
511
      </type>
 
512
      <desc>
 
513
        <p>This function creates a list from a zero terminated string.</p>
 
514
        <p><c><![CDATA[string]]></c> is the zero-terminated sequence of characters
 
515
          (i.e. a C string) from which the list will be created.</p>
 
516
        <p>The function returns an Erlang list.</p>
 
517
      </desc>
 
518
    </func>
 
519
    <func>
 
520
      <name><ret>ETERM *</ret><nametext>erl_mk_tuple(array, arrsize)</nametext></name>
 
521
      <fsummary>Creates an Erlang tuple from an array</fsummary>
 
522
      <type>
 
523
        <v>ETERM **array;</v>
 
524
        <v>int arrsize;</v>
 
525
      </type>
 
526
      <desc>
 
527
        <p>Creates an Erlang tuple from an array of Erlang terms.</p>
 
528
        <p><c><![CDATA[array]]></c> is an array of Erlang terms.</p>
 
529
        <p><c><![CDATA[arrsize]]></c> is the number of elements in <c><![CDATA[array]]></c>.</p>
 
530
        <p>The function creates an Erlang tuple, whose arity is
 
531
          <c><![CDATA[size]]></c> and whose elements are taken from the terms in
 
532
          <c><![CDATA[array]]></c>.</p>
 
533
        <p>To retrieve the size of a tuple, either use the
 
534
          <c><![CDATA[erl_size]]></c> function (which checks the type of the checked
 
535
          term and works for a binary as well as for a tuple), or the
 
536
          <c><![CDATA[ERL_TUPLE_SIZE(tuple)]]></c> returns the arity of a tuple.
 
537
          <c><![CDATA[erl_size()]]></c> will do the same thing, but it checks that
 
538
          the argument really is a tuple.
 
539
          <c><![CDATA[erl_element(index,tuple)]]></c> returns the element
 
540
          corresponding to a given position in the tuple. </p>
 
541
      </desc>
 
542
    </func>
 
543
    <func>
 
544
      <name><ret>ETERM *</ret><nametext>erl_mk_uint(n)</nametext></name>
 
545
      <fsummary>Creates an unsigned integer</fsummary>
 
546
      <type>
 
547
        <v>unsigned int n;</v>
 
548
      </type>
 
549
      <desc>
 
550
        <p>Creates an Erlang unsigned integer.</p>
 
551
        <p><c><![CDATA[n]]></c> is a value to be converted to an Erlang
 
552
          unsigned integer.</p>
 
553
        <p></p>
 
554
        <p>The function returns an Erlang unsigned integer object with
 
555
          the value specified in <c><![CDATA[n]]></c>.</p>
 
556
        <p><c><![CDATA[ERL_INT_UVALUE(t)]]></c> can be used to retrieve the
 
557
          value from an Erlang unsigned integer.</p>
 
558
      </desc>
 
559
    </func>
 
560
    <func>
 
561
      <name><ret>ETERM *</ret><nametext>erl_mk_var(name)</nametext></name>
 
562
      <fsummary>Creates an Erlang variable</fsummary>
 
563
      <type>
 
564
        <v>char *name;</v>
 
565
      </type>
 
566
      <desc>
 
567
        <p>This function creates an unbound Erlang variable. The
 
568
          variable can later be bound through pattern matching or assignment.</p>
 
569
        <p><c><![CDATA[name]]></c> specifies a name for the variable.</p>
 
570
        <p>The function returns an Erlang variable object with the
 
571
          name <c><![CDATA[name]]></c>. </p>
 
572
      </desc>
 
573
    </func>
 
574
    <func>
 
575
      <name><ret>int</ret><nametext>erl_print_term(stream, term)</nametext></name>
 
576
      <fsummary>Prints an Erlang term</fsummary>
 
577
      <type>
 
578
        <v>FILE *stream;</v>
 
579
        <v>ETERM *term;</v>
 
580
      </type>
 
581
      <desc>
 
582
        <p>This function prints the specified Erlang term to the given
 
583
          output stream.</p>
 
584
        <p><c><![CDATA[stream]]></c> indicates where the function should send its
 
585
          output.</p>
 
586
        <p><c><![CDATA[term]]></c> is the Erlang term to print.</p>
 
587
        <p>The function returns the number of characters written, or a
 
588
          negative value if there was an error.</p>
 
589
      </desc>
 
590
    </func>
 
591
    <func>
 
592
      <name><ret>void</ret><nametext>erl_set_compat_rel(release_number)</nametext></name>
 
593
      <fsummary>Set the erl_interface library in compatibility mode</fsummary>
 
594
      <type>
 
595
        <v>unsigned release_number;</v>
 
596
      </type>
 
597
      <desc>
 
598
        <marker id="erl_set_compat_rel"></marker>
 
599
        <p>By default, the <c><![CDATA[erl_interface]]></c> library is only guaranteed
 
600
          to be compatible with other Erlang/OTP components from the same
 
601
          release as the <c><![CDATA[erl_interface]]></c> library itself. For example,
 
602
          <c><![CDATA[erl_interface]]></c> from the OTP R10 release is not compatible
 
603
          with an Erlang emulator from the OTP R9 release by default.</p>
 
604
        <p>A call to <c><![CDATA[erl_set_compat_rel(release_number)]]></c> sets the
 
605
          <c><![CDATA[erl_interface]]></c> library in compatibility mode of release
 
606
          <c><![CDATA[release_number]]></c>. Valid range of <c><![CDATA[release_number]]></c>
 
607
          is [7, current release]. This makes it possible to
 
608
          communicate with Erlang/OTP components from earlier releases.</p>
 
609
        <note>
 
610
          <p>If this function is called, it may only be called once
 
611
            directly after the call to the
 
612
            <seealso marker="#erl_init">erl_init()</seealso> function.</p>
 
613
        </note>
 
614
        <warning>
 
615
          <p>You may run into trouble if this feature is used
 
616
            carelessly. Always make sure that all communicating
 
617
            components are either from the same Erlang/OTP release, or
 
618
            from release X and release Y where all components
 
619
            from release Y are in compatibility mode of release X.</p>
 
620
        </warning>
 
621
      </desc>
 
622
    </func>
 
623
    <func>
 
624
      <name><ret>int</ret><nametext>erl_size(term)</nametext></name>
 
625
      <fsummary>Return the arity of a tuple or binary</fsummary>
 
626
      <type>
 
627
        <v>ETERM *term;</v>
 
628
      </type>
 
629
      <desc>
 
630
        <p>Returns the arity of an Erlang tuple, or the
 
631
          number of bytes in an Erlang binary object. </p>
 
632
        <p><c><![CDATA[term]]></c> is an Erlang tuple or an Erlang binary object.</p>
 
633
        <p>The function returns the size of <c><![CDATA[term]]></c> as described
 
634
          above, or -1 if <c><![CDATA[term]]></c> is not one of the two supported
 
635
          types. </p>
 
636
      </desc>
 
637
    </func>
 
638
    <func>
 
639
      <name><ret>ETERM *</ret><nametext>erl_tl(list)</nametext></name>
 
640
      <fsummary>Extracts the tail from a list</fsummary>
 
641
      <type>
 
642
        <v>ETERM *list;</v>
 
643
      </type>
 
644
      <desc>
 
645
        <p>Extracts the tail from a list.</p>
 
646
        <p><c><![CDATA[list]]></c> is an Erlang term containing a list.</p>
 
647
        <p>The function returns an Erlang list corresponding to the
 
648
          original list minus the first element, or NULL pointer if
 
649
          <c><![CDATA[list]]></c> was not a list.</p>
 
650
      </desc>
 
651
    </func>
 
652
    <func>
 
653
      <name><ret>ETERM *</ret><nametext>erl_var_content(term, name)</nametext></name>
 
654
      <fsummary>Extracts the content of a variable</fsummary>
 
655
      <type>
 
656
        <v>ETERM *term;</v>
 
657
        <v>char *name;</v>
 
658
      </type>
 
659
      <desc>
 
660
        <p>This function returns the contents of the specified
 
661
          variable in an Erlang term. 
 
662
          </p>
 
663
        <p><c><![CDATA[term]]></c> is an Erlang term. In order for this function
 
664
          to succeed, <c><![CDATA[term]]></c> must be an Erlang variable with the
 
665
          specified name, or it must be an Erlang list or tuple
 
666
          containing a variable with the specified name. Other Erlang
 
667
          types cannot contain variables.</p>
 
668
        <p><c><![CDATA[name]]></c> is the name of an Erlang variable.</p>
 
669
        <p>Returns the Erlang object corresponding to the value of
 
670
          <c><![CDATA[name]]></c> in <c><![CDATA[term]]></c>. If no variable with the name
 
671
          <c><![CDATA[name]]></c> was found in <c><![CDATA[term]]></c>, or if <c><![CDATA[term]]></c> is
 
672
          not a valid Erlang term, NULL is returned.</p>
 
673
      </desc>
 
674
    </func>
 
675
  </funcs>
 
676
</cref>
 
677