File: erl_eterm.html

package info (click to toggle)
erlang-doc-html 1%3A11.b.2-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 23,284 kB
  • ctags: 10,724
  • sloc: erlang: 505; ansic: 323; makefile: 62; perl: 61; sh: 45
file content (1171 lines) | stat: -rw-r--r-- 28,577 bytes parent folder | download
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- This document was generated using DocBuilder 3.3.3 -->
<HTML>
<HEAD>
  <TITLE>erl_eterm</TITLE>
  <SCRIPT type="text/javascript" src="../../../../doc/erlresolvelinks.js">
</SCRIPT>
  <STYLE TYPE="text/css">
<!--
    .REFBODY     { margin-left: 13mm }
    .REFTYPES    { margin-left: 8mm }
-->
  </STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#FF00FF"
      ALINK="#FF0000">
<!-- refpage -->
<CENTER>
<A HREF="http://www.erlang.se">
  <IMG BORDER=0 ALT="[Ericsson AB]" SRC="min_head.gif">
</A>
<H1>erl_eterm</H1>
</CENTER>

<H3>C LIBRARY</H3>
<DIV CLASS=REFBODY>
erl_eterm
</DIV>

<H3>C LIBRARY SUMMARY</H3>
<DIV CLASS=REFBODY>
Functions for Erlang Term Construction
</DIV>

<H3>DESCRIPTION</H3>
<DIV CLASS=REFBODY>

<P>This module contains functions for creating and manipulating
Erlang terms. 

<P> An Erlang term is represented by a C structure of type
<CODE>ETERM</CODE>. Applications should not reference any fields in this
structure directly, because it may be changed in future releases
to provide faster and more compact term storage. Instead,
applications should us the macros and functions provided. 

<P>The following macros each take a single ETERM pointer as an
argument. They return a non-zero value if the test is true, and 0
otherwise:

<P>
<DL>

<DT>
<CODE>ERL_IS_INTEGER(t)</CODE>
</DT>

<DD>
True if <CODE>t</CODE> is an integer.
</DD>

<DT>
<CODE>ERL_IS_UNSIGNED_INTEGER(t)</CODE>
</DT>

<DD>
True if <CODE>t</CODE> is an integer.
</DD>

<DT>
<CODE>ERL_IS_FLOAT(t)</CODE>
</DT>

<DD>
True if <CODE>t</CODE> is a floating point number.
</DD>

<DT>
<CODE>ERL_IS_ATOM(t)</CODE>
</DT>

<DD>
True if <CODE>t</CODE> is an atom.
</DD>

<DT>
<CODE>ERL_IS_PID(t)</CODE>
</DT>

<DD>
True if <CODE>t</CODE> is a Pid (process identifier).
</DD>

<DT>
<CODE>ERL_IS_PORT(t)</CODE>
</DT>

<DD>
True if <CODE>t</CODE> is a port.
</DD>

<DT>
<CODE>ERL_IS_REF(t)</CODE>
</DT>

<DD>
True if <CODE>t</CODE> is a reference.
</DD>

<DT>
<CODE>ERL_IS_TUPLE(t)</CODE>
</DT>

<DD>
True if <CODE>t</CODE> is a tuple.
</DD>

<DT>
<CODE>ERL_IS_BINARY(t)</CODE>
</DT>

<DD>
True if <CODE>t</CODE> is a binary.
</DD>

<DT>
<CODE>ERL_IS_LIST(t)</CODE>
</DT>

<DD>
True if <CODE>t</CODE> is a list with zero or more elements.
</DD>

<DT>
<CODE>ERL_IS_EMPTY_LIST(t)</CODE>
</DT>

<DD>
True if <CODE>t</CODE> is an empty list.
</DD>

<DT>
<CODE>ERL_IS_CONS(t)</CODE>
</DT>

<DD>
True if <CODE>t</CODE> is a list with at least one element.
</DD>

</DL>

<P>The following macros can be used for retrieving parts of Erlang
terms. None of these do any type checking; results are undefined
if you pass an ETERM* containing the wrong type. For example,
passing a tuple to ERL_ATOM_PTR() will likely result in garbage.


<P>
<DL>

<DT>
<CODE>char *ERL_ATOM_PTR(t)</CODE>
</DT>

<DD>
A string representing atom <CODE>t</CODE>.


</DD>

<DT>
<CODE>int ERL_ATOM_SIZE(t)</CODE>
</DT>

<DD>
The length (in characters) of atom t.
</DD>

<DT>
<CODE>void *ERL_BIN_PTR(t)</CODE>
</DT>

<DD>
A pointer to the contents of <CODE>t</CODE>
</DD>

<DT>
<CODE>int ERL_BIN_SIZE(t)</CODE>
</DT>

<DD>
The length (in bytes) of binary object <CODE>t</CODE>.
</DD>

<DT>
<CODE>int ERL_INT_VALUE(t)</CODE>
</DT>

<DD>
The integer of <CODE>t</CODE>.
</DD>

<DT>
<CODE>unsigned int ERL_INT_UVALUE(t)</CODE>
</DT>

<DD>
The unsigned integer value of <CODE>t</CODE>.
</DD>

<DT>
<CODE>double ERL_FLOAT_VALUE(t)</CODE>
</DT>

<DD>
The floating point value of <CODE>t</CODE>.
</DD>

<DT>
<CODE>ETERM *ERL_PID_NODE(t)</CODE>
</DT>

<DD>
The Node in pid <CODE>t</CODE>.
</DD>

<DT>
<CODE>int ERL_PID_NUMBER(t)</CODE>
</DT>

<DD>
The sequence number in pid <CODE>t</CODE>.
</DD>

<DT>
<CODE>int ERL_PID_SERIAL(t)</CODE>
</DT>

<DD>
The serial number in pid <CODE>t</CODE>.
</DD>

<DT>
<CODE>int ERL_PID_CREATION(t)</CODE>
</DT>

<DD>
The creation number in pid <CODE>t</CODE>.
</DD>

<DT>
<CODE>int ERL_PORT_NUMBER(t)</CODE>
</DT>

<DD>
The sequence number in port <CODE>t</CODE>.
</DD>

<DT>
<CODE>int ERL_PORT_CREATION(t)</CODE>
</DT>

<DD>
The creation number in port <CODE>t</CODE>.
</DD>

<DT>
<CODE>ETERM *ERL_PORT_NODE(t)</CODE>
</DT>

<DD>
The node in port <CODE>t</CODE>.
</DD>

<DT>
<CODE>int ERL_REF_NUMBER(t)</CODE>
</DT>

<DD>
The first part of the reference number in ref <CODE>t</CODE>. Use
only for compatibility.
</DD>

<DT>
<CODE>int ERL_REF_NUMBERS(t)</CODE>
</DT>

<DD>
Pointer to the array of reference numbers in ref <CODE>t</CODE>.
</DD>

<DT>
<CODE>int ERL_REF_LEN(t)</CODE>
</DT>

<DD>
The number of used reference numbers in ref <CODE>t</CODE>.
</DD>

<DT>
<CODE>int ERL_REF_CREATION(t)</CODE>
</DT>

<DD>
The creation number in ref <CODE>t</CODE>.
</DD>

<DT>
<CODE>int ERL_TUPLE_SIZE(t)</CODE>
</DT>

<DD>
The number of elements in tuple <CODE>t</CODE>.
</DD>

<DT>
<CODE>ETERM *ERL_CONS_HEAD(t)</CODE>
</DT>

<DD>
The head element of list <CODE>t</CODE>.
</DD>

<DT>
<CODE>ETERM *ERL_CONS_TAIL(t)</CODE>
</DT>

<DD>
A List representing the tail elements of list <CODE>t</CODE>.
</DD>

</DL>

</DIV>

<H3>EXPORTS</H3>

<P><A NAME="erl_cons/2"><STRONG><CODE>ETERM *erl_cons(head, tail)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ETERM *head;</CODE></STRONG><BR>
<STRONG><CODE>ETERM *tail;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function concatenates two Erlang terms, prepending
        <CODE>head</CODE> onto <CODE>tail</CODE> and thereby creating a <CODE>cons</CODE> cell.
         To make a proper list, <CODE>tail</CODE> should always be a
         list or an empty list. Note that NULL is not a valid list.
        
<P><CODE>head</CODE> is the new term to be added.
        
<P><CODE>tail</CODE> is the existing list to which <CODE>head</CODE> will
        be concatenated.
        
<P>The function returns a new list.
        
<P><CODE>ERL_CONS_HEAD(list)</CODE> and <CODE>ERL_CONS_TAIL(list)</CODE>
        can be used to retrieve the head and tail components
        from the list. <CODE>erl_hd(list)</CODE> and <CODE>erl_tl(list)</CODE> will do
        the same thing, but check that the argument really is a list.
        
<P>For example:
        
<PRE>
ETERM *list,*anAtom,*anInt;
anAtom = erl_mk_atom(&#34;madonna&#34;);
anInt  = erl_mk_int(21);
list   = erl_mk_empty_list();
list   = erl_cons(anAtom, list);
list   = erl_cons(anInt, list);
 ... /* do some work */
erl_free_compound(list);
        
</PRE>

</DIV>

<P><A NAME="erl_copy_term/1"><STRONG><CODE>ETERM *erl_copy_term(term)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ETERM *term;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function creates and returns a copy of the Erlang term 
         <CODE>term</CODE>.
        
</DIV>

<P><A NAME="erl_element/2"><STRONG><CODE>ETERM *erl_element(position, tuple)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>int position;</CODE></STRONG><BR>
<STRONG><CODE>ETERM *tuple;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function extracts a specified element from an Erlang
        tuple. 
        
<P><CODE>position</CODE> specifies which element to retrieve from
        <CODE>tuple</CODE>. The elements are numbered starting from 1.
        
<P><CODE>tuple</CODE> is an Erlang term containing at least
        <CODE>position</CODE> elements.
        
<P>The function returns a new Erlang term corresponding to the
        requested element, or NULL if <CODE>position</CODE> was greater than
        the arity of <CODE>tuple</CODE>.

</DIV>

<P><A NAME="erl_init/2"><STRONG><CODE>void erl_init(NULL, 0)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>void *NULL;</CODE></STRONG><BR>
<STRONG><CODE>int 0;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>
<A NAME="erl_init"><!-- Empty --></A>
<P>This function must be called before any of the others in 
        the <CODE>erl_interface</CODE> library in order to initialize the
        library functions. The arguments must be specified as 
        <CODE>erl_init(NULL,0)</CODE>.
        
</DIV>

<P><A NAME="erl_hd/1"><STRONG><CODE>ETERM *erl_hd(list)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ETERM *list;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Extracts the first element from a list.
        
<P><CODE>list</CODE> is an Erlang term containing a list.
        
<P>The function returns an Erlang term corresponding to the
        head element in the list, or a NULL pointer if <CODE>list</CODE> was
        not a list.
        
</DIV>

<P><A NAME="erl_iolist_to_binary/1"><STRONG><CODE>ETERM *erl_iolist_to_binary(term)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ETERM *list;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function converts an IO list to a binary term.
        
<P><CODE>list</CODE> is an Erlang term containing a list.
        
<P>This function an Erlang binary term, or NULL if <CODE>list</CODE>
        was not an IO list. 
        
<P>Informally, an IO list is a deep list of characters and
        binaries which can be sent to an Erlang port. In BNF, an IO
        list is formally defined as follows: 
        
<PRE>
iolist ::= []
        |   Binary
        |   [iohead | iolist]
        ;
iohead ::= Binary
        |   Byte (integer in the range [0..255])
        |   iolist
        ;
        
</PRE>

</DIV>

<P><A NAME="erl_iolist_to_string/1"><STRONG><CODE>char *erl_iolist_to_string(list)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ETERM *list;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function converts an IO list to a '\0' terminated C
        string. 
        
<P><CODE>list</CODE> is an Erlang term containing an IO list. The IO
        list must not contain the integer 0, since C strings may not
        contain this value except as a terminating marker.
        
<P>This function returns a pointer to a dynamically allocated
        buffer containing a string. If <CODE>list</CODE> is not an IO list,
        or if <CODE>list</CODE> contains the integer 0, NULL is returned. It
        is the caller's responsibility free the allocated buffer
        with <CODE>erl_free()</CODE>. 
        
<P>Refer to <CODE>erl_iolist_to_binary()</CODE> for the definition of an
        IO list. 
        
</DIV>

<P><A NAME="erl_iolist_length/1"><STRONG><CODE>int erl_iolist_length(list)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ETERM *list;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Returns the length of an IO list.

        
<P><CODE>list</CODE> is an Erlang term containing an IO list. 
        
<P>The function returns the length of <CODE>list</CODE>, or -1 if
        <CODE>list</CODE> is not an IO list.
        
<P>Refer to <CODE>erl_iolist_to_binary()</CODE> for the definition of
        an IO list. 
        
</DIV>

<P><A NAME="erl_length/1"><STRONG><CODE>int erl_length(list)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ETERM *list;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Determines the length of a proper list.
        
<P><CODE>list</CODE> is an Erlang term containing proper list. In a
        proper list, all tails except the last point to another list
        cell, and the last tail points to an empty list.
        
<P>Returns -1 if <CODE>list</CODE> is not a proper list.
        
</DIV>

<P><A NAME="erl_mk_atom/1"><STRONG><CODE>ETERM *erl_mk_atom(string)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>char *string;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Creates an atom.
        
<P><CODE>string</CODE> is the sequence of characters that will be
        used to create the atom.
        
<P>Returns an Erlang term containing an atom. Note that it is
        the callers responsibility to make sure that <CODE>string</CODE>
        contains a valid name for an atom.
        
<P><CODE>ERL_ATOM_PTR(atom)</CODE> can be used to retrieve the 
        atom name (as a string). Note that the string is not
        0-terminated in the atom. <CODE>ERL_ATOM_SIZE(atom)</CODE>returns
        the length of the atom name.
        
</DIV>

<P><A NAME="erl_mk_binary/2"><STRONG><CODE>ETERM *erl_mk_binary(bptr, size)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>char *bptr;</CODE></STRONG><BR>
<STRONG><CODE>int size;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function produces an Erlang binary object from a
        buffer containing a sequence of bytes.
        
<P><CODE>bptr</CODE> is a pointer to a buffer containg data to be converted.
        
<P><CODE>size</CODE> indicates the length of <CODE>bptr</CODE>.
        
<P>The function returns an Erlang binary object.
        
<P><CODE>ERL_BIN_PTR(bin)</CODE> retrieves a pointer to
        the binary data. <CODE>ERL_BIN_SIZE(bin)</CODE> retrieves the 
        size. 
        
</DIV>

<P><A NAME="erl_mk_empty_list/0"><STRONG><CODE>ETERM *erl_mk_empty_list()</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY>

<P>This function creates and returns an empty Erlang list.
        Note that NULL is not used to represent an empty list;
        Use this function instead.
        
</DIV>

<P><A NAME="erl_mk_estring/2"><STRONG><CODE>ETERM *erl_mk_estring(string, len)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>char *string;</CODE></STRONG><BR>
<STRONG><CODE>int len;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function creates a list from a sequence of bytes.
        
<P><CODE>string</CODE> is a buffer containing a sequence of
        bytes. The buffer does not need to be zero-terminated.
        
<P><CODE>len</CODE> is the length of <CODE>string</CODE>.
        
<P>The function returns an Erlang list object corresponding to
        the character sequence in <CODE>string</CODE>.
        
</DIV>

<P><A NAME="erl_mk_float/1"><STRONG><CODE>ETERM *erl_mk_float(f)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>double f;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Creates an Erlang float.
        
<P><CODE>f</CODE> is a value to be converted to an Erlang float.
        
<P>
        
<P>The function returns an Erlang float object with the value
        specified in <CODE>f</CODE>.
        
<P><CODE>ERL_FLOAT_VALUE(t)</CODE> can be used to retrieve the
        value from an Erlang float.
        
</DIV>

<P><A NAME="erl_mk_int/1"><STRONG><CODE>ETERM *erl_mk_int(n)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE> int n;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Creates an Erlang integer.
        
<P><CODE>n</CODE> is a value to be converted to an Erlang integer.
        
<P>
        
<P>The function returns an Erlang integer object with the
        value specified in <CODE>n</CODE>.
        
<P><CODE>ERL_INT_VALUE(t)</CODE> can be used to retrieve the value 
        value from an Erlang integer.
        
</DIV>

<P><A NAME="erl_mk_list/2"><STRONG><CODE>ETERM *erl_mk_list(array, arrsize)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ETERM **array;</CODE></STRONG><BR>
<STRONG><CODE>int arrsize;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Creates an Erlang list from an array of Erlang terms, such
        that each element in the list corresponds to one element in
        the array. 
        
<P><CODE>array</CODE> is an array of Erlang terms.
        
<P><CODE>arrsize</CODE> is the number of elements in <CODE>array</CODE>.
        
<P>The function creates an Erlang list object, whose length
        <CODE>arrsize</CODE> and whose elements are taken from the terms in
        <CODE>array</CODE>.
        
</DIV>

<P><A NAME="erl_mk_pid/4"><STRONG><CODE>ETERM *erl_mk_pid(node, number, serial, creation)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>const char *node;</CODE></STRONG><BR>
<STRONG><CODE>unsigned int number;</CODE></STRONG><BR>
<STRONG><CODE>unsigned int serial;</CODE></STRONG><BR>
<STRONG><CODE>unsigned int creation;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function creates an Erlang process identifier. The
        resulting pid can be used by Erlang processes wishing to
        communicate with the C node.
        
<P><CODE>node</CODE> is the name of the C node.
        
<P><CODE>number</CODE>, <CODE>serial</CODE> and <CODE>creation</CODE> are
        arbitrary numbers. Note though, that these are limited in
        precision, so only the low 15, 3 and 2 bits of these numbers
        are actually used.
        
<P>The function returns an Erlang pid object.
        
<P><CODE>ERL_PID_NODE(pid)</CODE>, <CODE>ERL_PID_NUMBER(pid)</CODE>,
        <CODE>ERL_PID_SERIAL(pid)</CODE> and <CODE>ERL_PID_CREATION(pid)</CODE>
        can be used to retrieve the four values used to create the pid.
        
</DIV>

<P><A NAME="erl_mk_port/3"><STRONG><CODE>ETERM *erl_mk_port(node, number, creation)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>const char *node;</CODE></STRONG><BR>
<STRONG><CODE>unsigned int number;</CODE></STRONG><BR>
<STRONG><CODE>unsigned int creation;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function creates an Erlang port identifier. 
        
<P><CODE>node</CODE> is the name of the C node.
        
<P><CODE>number</CODE> and <CODE>creation</CODE> are arbitrary numbers.
        Note though, that these are limited in
        precision, so only the low 18 and 2 bits of these numbers
        are actually used.      
<P>The function returns an Erlang port object.
        
<P><CODE>ERL_PORT_NODE(port)</CODE>, <CODE>ERL_PORT_NUMBER(port)</CODE>
        and <CODE>ERL_PORT_CREATION</CODE> can be used to retrieve the three
        values used to create the port. 
        
</DIV>

<P><A NAME="erl_mk_ref/3"><STRONG><CODE>ETERM *erl_mk_ref(node, number, creation)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>const char *node;</CODE></STRONG><BR>
<STRONG><CODE>unsigned int number;</CODE></STRONG><BR>
<STRONG><CODE>unsigned int creation;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function creates an old Erlang reference, with
        only 18 bits - use <CODE>erl_mk_long_ref</CODE> instead.
        
<P><CODE>node</CODE> is the name of the C node.
        
<P><CODE>number</CODE> should be chosen uniquely for each reference
        created for a given C node.
        
<P><CODE>creation</CODE> is an arbitrary number.
        
<P>Note that <CODE>number</CODE> and <CODE>creation</CODE> are limited in
        precision, so only the low 18 and 2 bits of these numbers
        are actually used.

        
<P>The function returns an Erlang reference object.
        
<P><CODE>ERL_REF_NODE(ref)</CODE>, <CODE>ERL_REF_NUMBER(ref)</CODE>, and
        <CODE>ERL_REF_CREATION(ref)</CODE> to retrieve the three values used
        to create the reference. 
        
</DIV>

<P><A NAME="erl_mk_long_ref/5"><STRONG><CODE>ETERM *erl_mk_long_ref(node, n1, n2, n3, creation)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>const char *node;</CODE></STRONG><BR>
<STRONG><CODE>unsigned int n1, n2, n3;</CODE></STRONG><BR>
<STRONG><CODE>unsigned int creation;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function creates an Erlang reference, with 82 bits.
        
<P><CODE>node</CODE> is the name of the C node.
        
<P><CODE>n1</CODE>, <CODE>n2</CODE> and <CODE>n3</CODE> can be seen as one big number
        <CODE>n1*2^64+n2*2^32+n3</CODE> which should be chosen uniquely for
        each reference
        created for a given C node.
        
<P><CODE>creation</CODE> is an arbitrary number.
        
<P>Note that <CODE>n3</CODE> and <CODE>creation</CODE> are limited in
        precision, so only the low 18 and 2 bits of these numbers
        are actually used.

        
<P>The function returns an Erlang reference object.
        
<P><CODE>ERL_REF_NODE(ref)</CODE>, <CODE>ERL_REF_NUMBERS(ref)</CODE>,
        <CODE>ERL_REF_LEN(ref)</CODE> and
        <CODE>ERL_REF_CREATION(ref)</CODE> to retrieve the values used
        to create the reference. 
        
</DIV>

<P><A NAME="erl_mk_string/1"><STRONG><CODE>ETERM *erl_mk_string(string)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>char *string;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function creates a list from a zero terminated string.
        
<P><CODE>string</CODE> is the zero-terminated sequence of characters
        (i.e. a C string) from which the list will be created.
        
<P>The function returns an Erlang list.
        
</DIV>

<P><A NAME="erl_mk_tuple/2"><STRONG><CODE>ETERM *erl_mk_tuple(array, arrsize)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ETERM **array;</CODE></STRONG><BR>
<STRONG><CODE>int arrsize;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Creates an Erlang tuple from an array of Erlang terms.
        
<P><CODE>array</CODE> is an array of Erlang terms.
        
<P><CODE>arrsize</CODE> is the number of elements in <CODE>array</CODE>.
        
<P>The function creates an Erlang tuple, whose arity is
        <CODE>size</CODE> and whose elements are taken from the terms in
        <CODE>array</CODE>.
        
<P>To retrieve the size of a tuple, either use the
        <CODE>erl_size</CODE> function (which checks the type of the checked
        term and works for a binary as well as for a tuple), or the

        <CODE>ERL_TUPLE_SIZE(tuple)</CODE> returns the arity of a tuple.
        <CODE>erl_size()</CODE> will do the same thing, but it checks that
        the argument really is a tuple.
        <CODE>erl_element(index,tuple)</CODE> returns the element
        corresponding to a given position in the tuple. 
        
</DIV>

<P><A NAME="erl_mk_uint/1"><STRONG><CODE>ETERM *erl_mk_uint(n)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>unsigned int n;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Creates an Erlang unsigned integer.
        
<P><CODE>n</CODE> is a value to be converted to an Erlang
        unsigned integer.
        
<P>
        
<P>The function returns an Erlang unsigned integer object with
        the value specified in <CODE>n</CODE>.
        
<P><CODE>ERL_INT_UVALUE(t)</CODE> can be used to retrieve the
        value from an Erlang unsigned integer.
        
</DIV>

<P><A NAME="erl_mk_var/1"><STRONG><CODE>ETERM *erl_mk_var(name)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>char *name;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function creates an unbound Erlang variable. The
        variable can later be bound through pattern matching or assignment.
        
<P><CODE>name</CODE> specifies a name for the variable.
        
<P>The function returns an Erlang variable object with the
        name <CODE>name</CODE>. 

</DIV>

<P><A NAME="erl_print_term/2"><STRONG><CODE>int erl_print_term(stream, term)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>FILE *stream;</CODE></STRONG><BR>
<STRONG><CODE>ETERM *term;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function prints the specified Erlang term to the given
        output stream.
        
<P><CODE>stream</CODE> indicates where the function should send its
        output.
        
<P><CODE>term</CODE> is the Erlang term to print.
        
<P>The function returns the number of characters written, or a
        negative value if there was an error.
        
</DIV>

<P><A NAME="erl_set_compat_rel/1"><STRONG><CODE>void erl_set_compat_rel(release_number)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>unsigned release_number;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>
<A NAME="erl_set_compat_rel"><!-- Empty --></A>
<P>By default, the <CODE>erl_interface</CODE> library is only guaranteed
        to be compatible with other Erlang/OTP components from the same
        release as the <CODE>erl_interface</CODE> library itself. For example,
        <CODE>erl_interface</CODE> from the OTP R10 release is not compatible
        with an Erlang emulator from the OTP R9 release by default.
        
<P>     A call to <CODE>erl_set_compat_rel(release_number)</CODE> sets the
        <CODE>erl_interface</CODE> library in compatibility mode of release
        <CODE>release_number</CODE>. Valid range of <CODE>release_number</CODE>
        is [7, current release]. This makes it possible to
        communicate with Erlang/OTP components from earlier releases.
        
<P>
<TABLE CELLPADDING=4>
  <TR>
    <TD VALIGN=TOP><IMG ALT="Note!" SRC="note.gif"></TD>
    <TD>

<P>If this function is called, it may only be called once
        directly after the call to the
        <A HREF="#erl_init">erl_init()</A> function.
            </TD>
  </TR>
</TABLE>

<P>
<TABLE CELLPADDING=4>
  <TR>
    <TD VALIGN=TOP><IMG ALT="Warning!" SRC="warning.gif"></TD>
    <TD>

<P>You may run into trouble if this feature is used
        carelessly. Always make sure that all communicating
        components are either from the same Erlang/OTP release, or
        from release X and release Y where all components
        from release Y are in compatibility mode of release X.
            </TD>
  </TR>
</TABLE>

</DIV>

<P><A NAME="erl_size/1"><STRONG><CODE>int erl_size(term)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ETERM *term;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Returns the arity of an Erlang tuple, or the
number of bytes in an Erlang binary object. 

<P><CODE>term</CODE> is an Erlang tuple or an Erlang binary object.

<P>The function returns the size of <CODE>term</CODE> as described
above, or -1 if <CODE>term</CODE> is not one of the two supported
types. 

</DIV>

<P><A NAME="erl_tl/1"><STRONG><CODE>ETERM *erl_tl(list)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ETERM *list;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>Extracts the tail from a list.
        
<P><CODE>list</CODE> is an Erlang term containing a list.
        
<P>The function returns an Erlang list corresponding to the
        original list minus the first element, or NULL pointer if
        <CODE>list</CODE> was not a list.
        
</DIV>

<P><A NAME="erl_var_content/2"><STRONG><CODE>ETERM *erl_var_content(term, name)</CODE></STRONG></A><BR>

<DIV CLASS=REFBODY><P>Types:
  <DIV CLASS=REFTYPES>
<P>
<STRONG><CODE>ETERM *term;</CODE></STRONG><BR>
<STRONG><CODE>char *name;</CODE></STRONG><BR>

  </DIV>
</DIV>

<DIV CLASS=REFBODY>

<P>This function returns the contents of the specified
        variable in an Erlang term. 

        
<P><CODE>term</CODE> is an Erlang term. In order for this function
        to succeed, <CODE>term</CODE> must be an Erlang variable with the
        specified name, or it must be an Erlang list or tuple
        containing a variable with the specified name. Other Erlang
        types cannot contain variables.
        
<P><CODE>name</CODE> is the name of an Erlang variable.
        
<P>Returns the Erlang object corresponding to the value of
        <CODE>name</CODE> in <CODE>term</CODE>. If no variable with the name
        <CODE>name</CODE> was found in <CODE>term</CODE>, or if <CODE>term</CODE> is
        not a valid Erlang term, NULL is returned.
        
</DIV>

<H3>AUTHORS</H3>
<DIV CLASS=REFBODY>
T.Trnkvist - support@erlang.ericsson.se<BR>
Gordon Beaton - support@erlang.ericsson.se<BR>

</DIV>
<CENTER>
<HR>
<SMALL>erl_interface 3.5.5.2<BR>
Copyright &copy; 1991-2006
<A HREF="http://www.erlang.se">Ericsson AB</A><BR>
</SMALL>
</CENTER>
</BODY>
</HTML>