From 9f5b69e8def226f1d1ce9262477d5bbd1cbc1fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Mon, 17 Oct 2016 15:07:55 +0200 Subject: erl_interface: Refactor documentation --- lib/erl_interface/doc/src/book.xml | 11 +- lib/erl_interface/doc/src/ei.xml | 869 ++++++++++++++------------- lib/erl_interface/doc/src/ei_connect.xml | 515 ++++++++-------- lib/erl_interface/doc/src/ei_users_guide.xml | 9 +- lib/erl_interface/doc/src/erl_call.xml | 35 +- lib/erl_interface/doc/src/erl_connect.xml | 373 ++++++------ lib/erl_interface/doc/src/erl_error.xml | 21 +- lib/erl_interface/doc/src/erl_eterm.xml | 169 +++--- lib/erl_interface/doc/src/erl_format.xml | 13 +- lib/erl_interface/doc/src/erl_global.xml | 19 +- lib/erl_interface/doc/src/erl_malloc.xml | 59 +- lib/erl_interface/doc/src/erl_marshal.xml | 35 +- lib/erl_interface/doc/src/ref_man.xml | 5 +- lib/erl_interface/doc/src/registry.xml | 625 ++++++++++--------- 14 files changed, 1373 insertions(+), 1385 deletions(-) (limited to 'lib/erl_interface') diff --git a/lib/erl_interface/doc/src/book.xml b/lib/erl_interface/doc/src/book.xml index c9194d96ff..94bfef7455 100644 --- a/lib/erl_interface/doc/src/book.xml +++ b/lib/erl_interface/doc/src/book.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,19 +19,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + - Erlang Interface + Erl_Interface Gordon Beaton 1998-11-30 1.2 - book.sgml + book.xml - Erlang Interface + Erl_Interface @@ -47,4 +47,3 @@ - diff --git a/lib/erl_interface/doc/src/ei.xml b/lib/erl_interface/doc/src/ei.xml index 1177954eb9..7928e4f5d1 100644 --- a/lib/erl_interface/doc/src/ei.xml +++ b/lib/erl_interface/doc/src/ei.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -30,7 +30,7 @@ 2000-11-27 PA1 - ei.sgml + ei.xml ei routines for handling the erlang binary term format @@ -106,149 +106,265 @@ typedef enum { + + intei_decode_atom(const char *buf, int *index, char *p) + Decode an atom. + +

This function decodes an atom from the binary format. The + null terminated name of the atom is placed at . There can be at most + bytes placed in the buffer.

+
+
+ + intei_decode_atom_as(const char *buf, int *index, char *p, int plen, erlang_char_encoding want, erlang_char_encoding* was, erlang_char_encoding* result) + Decode an atom. + +

This function decodes an atom from the binary format. The + null terminated name of the atom is placed in buffer at p of length + plen bytes.

+

The wanted string encoding is specified by + want. The original encoding used in the + binary format (latin1 or utf8) can be obtained from *was. The actual encoding of the resulting string + (7-bit ascii, latin1 or utf8) can be obtained from *result. Both was and result can be NULL. + + *result may differ from want if want is a bitwise-or'd combination like + ERLANG_LATIN1|ERLANG_UTF8 or if *result turn out to be pure 7-bit ascii + (compatible with both latin1 and utf8).

+

This function fails if the atom is too long for the buffer + or if it can not be represented with encoding want.

+

This function was introduced in R16 release of Erlang/OTP as part of a first step + to support UTF8 atoms.

+
+
+ + intei_decode_bignum(const char *buf, int *index, mpz_t obj) + Decode a GMP arbitrary precision integer. + +

This function decodes an integer in the binary format to a GMP integer. + To use this function the ei library needs to be configured and compiled + to use the GMP library.

+
+
+ + intei_decode_binary(const char *buf, int *index, void *p, long *len) + Decode a binary. + +

This function decodes a binary from the binary format. The + parameter is set to the actual size of the + binary. Note that assumes that there + are enough room for the binary. The size required can be + fetched by .

+
+
+ + intei_decode_boolean(const char *buf, int *index, int *p) + Decode a boolean. + +

This function decodes a boolean value from the binary + format. A boolean is actually an atom, decodes 1 + and decodes 0.

+
+
+ + intei_decode_char(const char *buf, int *index, char *p) + Decode an 8-bit integer between 0-255. + +

This function decodes a char (8-bit) integer between 0-255 + from the binary format. + Note that for historical reasons the returned integer is of + type . Your C code should consider the + returned value to be of type even if + the C compilers and system may define to be + signed.

+
+
+ + intei_decode_double(const char *buf, int *index, double *p) + Decode a double. + +

This function decodes an double-precision (64 bit) floating + point number from the binary format.

+
+
- voidei_set_compat_rel(release_number) - Set the ei library in compatibility mode - - unsigned release_number; - + intei_decode_ei_term(const char* buf, int* index, ei_term* term) + Decode a term, without prior knowledge of type. - -

By default, the library is only guaranteed - to be compatible with other Erlang/OTP components from the same - release as the library itself. For example, from - the OTP R10 release is not compatible with an Erlang emulator - from the OTP R9 release by default.

-

A call to sets the - library in compatibility mode of release - . Valid range of - is [7, current release]. This makes it possible to - communicate with Erlang/OTP components from earlier releases.

- -

If this function is called, it may only be called once - and must be called before any other functions in the - library is called.

-
- -

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.

-
+

This function decodes any term, or at least tries to. If the + term pointed at by in fits in the + union, it is decoded, and the appropriate field + in value]]> is set, and is + incremented by the term size.

+

The function returns 1 on successful decoding, -1 on error, + and 0 if the term seems alright, but does not fit in the + structure. If it returns 1, the + will be incremented, and the contains the + decoded term.

+

The structure will contain the arity for a tuple + or list, size for a binary, string or atom. It will contains + a term if it's any of the following: integer, float, atom, + pid, port or ref.

- intei_encode_version(char *buf, int *index) - intei_x_encode_version(ei_x_buff* x) - Encode version + intei_decode_fun(const char *buf, int *index, erlang_fun *p) + voidfree_fun(erlang_fun* f) + Decode a fun. -

Encodes a version magic number for the binary format. Must - be the first token in a binary term.

+

This function decodes a fun from the binary format. The + parameter should be NULL or point to an + structure. This is the only decode + function that allocates memory; when the + is no longer needed, it should be freed with + . (This has to do with the arbitrary size of + the environment for a fun.)

- intei_encode_long(char *buf, int *index, long p) - intei_x_encode_long(ei_x_buff* x, long p) - Encode integer + intei_decode_list_header(const char *buf, int *index, int *arity) + Decode a list. -

Encodes a long integer in the binary format. - Note that if the code is 64 bits the function ei_encode_long() is - exactly the same as ei_encode_longlong().

+

This function decodes a list header from the binary + format. The number of elements is returned in + . The elements follows (the last + one is the tail of the list, normally an empty list.) If + is , it's an empty list.

+

Note that lists are encoded as strings, if they consist + entirely of integers in the range 0..255. This function will + not decode such strings, use + instead.

- intei_encode_ulong(char *buf, int *index, unsigned long p) - intei_x_encode_ulong(ei_x_buff* x, unsigned long p) - Encode unsigned integer + intei_decode_long(const char *buf, int *index, long *p) + Decode integer. -

Encodes an unsigned long integer in the binary format. - Note that if the code is 64 bits the function ei_encode_ulong() is - exactly the same as ei_encode_ulonglong().

+

This function decodes a long integer from the binary format. + Note that if the code is 64 bits the function ei_decode_long() is + exactly the same as ei_decode_longlong().

- intei_encode_longlong(char *buf, int *index, long long p) - intei_x_encode_longlong(ei_x_buff* x, long long p) - Encode integer + intei_decode_longlong(const char *buf, int *index, long long *p) + Decode integer. -

Encodes a GCC or Visual C++ (64 bit) - integer in the binary format. Note that this function is missing - in the VxWorks port.

+

This function decodes a GCC or Visual C++ + (64 bit) integer from the binary format. Note that this + function is missing in the VxWorks port.

- intei_encode_ulonglong(char *buf, int *index, unsigned long long p) - intei_x_encode_ulonglong(ei_x_buff* x, unsigned long long p) - Encode unsigned integer + intei_decode_map_header(const char *buf, int *index, int *arity) + Decode a map. -

Encodes a GCC or Visual C++ (64 bit) integer in the binary format. Note that - this function is missing in the VxWorks port.

+

This function decodes a map header from the binary + format. The number of key-value pairs is returned in + *arity. Keys and values follow in the following order: + K1, V1, K2, V2, ..., Kn, Vn. This makes a total of + arity*2 terms. If arity is zero, it's an empty map. + A correctly encoded map does not have duplicate keys.

- intei_encode_bignum(char *buf, int *index, mpz_t obj) - intei_x_encode_bignum(ei_x_buff *x, mpz_t obj) - Encode an arbitrary precision integer + intei_decode_pid(const char *buf, int *index, erlang_pid *p) + Decode a . -

Encodes a GMP integer to binary format. - To use this function the ei library needs to be configured and compiled - to use the GMP library.

+

Decodes a pid, process identifier, from the binary format.

- intei_encode_double(char *buf, int *index, double p) - intei_x_encode_double(ei_x_buff* x, double p) - Encode a double float + intei_decode_port(const char *buf, int *index, erlang_port *p) + Decode a port. -

Encodes a double-precision (64 bit) floating point number in - the binary format.

-

- The function returns if the floating point number is not finite. -

+

This function decodes a port identifier from the binary + format.

- intei_encode_boolean(char *buf, int *index, int p) - intei_x_encode_boolean(ei_x_buff* x, int p) - Encode a boolean + intei_decode_ref(const char *buf, int *index, erlang_ref *p) + Decode a reference. -

Encodes a boolean value, as the atom if p is not - zero or if p is zero.

+

This function decodes a reference from the binary format.

- intei_encode_char(char *buf, int *index, char p) - intei_x_encode_char(ei_x_buff* x, char p) - Encode an 8-bit integer between 0-255 + intei_decode_string(const char *buf, int *index, char *p) + Decode a string. -

Encodes a char (8-bit) as an integer between 0-255 in the binary format. - Note that for historical reasons the integer argument is of - type . Your C code should consider the - given argument to be of type even if - the C compilers and system may define to be - signed.

+

This function decodes a string from the binary format. A + string in erlang is a list of integers between 0 and + 255. Note that since the string is just a list, sometimes + lists are encoded as strings by , + even if it was not intended.

+

The string is copied to , and enough space must be + allocated. The returned string is null terminated so you + need to add an extra byte to the memory requirement.

- intei_encode_string(char *buf, int *index, const char *p) - intei_encode_string_len(char *buf, int *index, const char *p, int len) - intei_x_encode_string(ei_x_buff* x, const char *p) - intei_x_encode_string_len(ei_x_buff* x, const char* s, int len) - Encode a string + intei_decode_term(const char *buf, int *index, void *t) + Decode a . -

Encodes a string in the binary format. (A string in erlang - is a list, but is encoded as a character array in the binary - format.) The string should be zero-terminated, except for - the function.

+

This function decodes a term from the binary format. The + term is return in as a , so + is actually an (see + . The term should later be + deallocated.

+

Note that this function is located in the erl_interface + library.

+
+
+ + intei_decode_trace(const char *buf, int *index, erlang_trace *p) + Decode a trace token. + +

Decodes an erlang trace token from the binary format.

+
+
+ + intei_decode_tuple_header(const char *buf, int *index, int *arity) + Decode a tuple. + +

This function decodes a tuple header, the number of elements + is returned in . The tuple elements follows in order in + the buffer.

+
+
+ + intei_decode_ulong(const char *buf, int *index, unsigned long *p) + Decode unsigned integer. + +

This function decodes an unsigned long integer from + the binary format. + Note that if the code is 64 bits the function ei_decode_ulong() is + exactly the same as ei_decode_ulonglong().

+
+
+ + intei_decode_ulonglong(const char *buf, int *index, unsigned long long *p) + Decode unsigned integer. + +

This function decodes a GCC or Visual C++ + (64 bit) integer from the binary format. + Note that this function is missing in the VxWorks port.

+
+
+ + intei_decode_version(const char *buf, int *index, int *version) + Encode an empty list (). + +

This function decodes the version magic number for the + erlang binary term format. It must be the first token in a + binary term.

+ intei_encode_atom(char *buf, int *index, const char *p) intei_encode_atom_len(char *buf, int *index, const char *p, int len) intei_x_encode_atom(ei_x_buff* x, const char *p) intei_x_encode_atom_len(ei_x_buff* x, const char *p, int len) - Encode an atom + Encode an atom.

Encodes an atom in the binary format. The parameter is the name of the atom in latin1 encoding. Only upto MAXATOMLEN-1 bytes @@ -261,7 +377,7 @@ typedef enum { intei_encode_atom_len_as(char *buf, int *index, const char *p, int len, erlang_char_encoding from_enc, erlang_char_encoding to_enc) intei_x_encode_atom_as(ei_x_buff* x, const char *p, erlang_char_encoding from_enc, erlang_char_encoding to_enc) intei_x_encode_atom_len_as(ei_x_buff* x, const char *p, int len, erlang_char_encoding from_enc, erlang_char_encoding to_enc) - Encode an atom + Encode an atom.

Encodes an atom in the binary format with character encoding to_enc (latin1 or utf8). @@ -278,106 +394,84 @@ typedef enum { can not be decoded by earlier releases than R16.

+ + intei_encode_bignum(char *buf, int *index, mpz_t obj) + intei_x_encode_bignum(ei_x_buff *x, mpz_t obj) + Encode an arbitrary precision integer. + +

Encodes a GMP integer to binary format. + To use this function the ei library needs to be configured and compiled + to use the GMP library.

+
+
intei_encode_binary(char *buf, int *index, const void *p, long len) intei_x_encode_binary(ei_x_buff* x, const void *p, long len) - Encode a binary + Encode a binary.

Encodes a binary in the binary format. The data is at , of bytes length.

- intei_encode_pid(char *buf, int *index, const erlang_pid *p) - intei_x_encode_pid(ei_x_buff* x, const erlang_pid *p) - Encode a pid + intei_encode_boolean(char *buf, int *index, int p) + intei_x_encode_boolean(ei_x_buff* x, int p) + Encode a boolean. -

Encodes an erlang process identifier, pid, in the binary - format. The parameter points to an - structure (which should have been obtained - earlier with ).

+

Encodes a boolean value, as the atom if p is not + zero or if p is zero.

- intei_encode_fun(char *buf, int *index, const erlang_fun *p) - intei_x_encode_fun(ei_x_buff* x, const erlang_fun* fun) - Encode a fun + intei_encode_char(char *buf, int *index, char p) + intei_x_encode_char(ei_x_buff* x, char p) + Encode an 8-bit integer between 0-255. -

Encodes a fun in the binary format. The parameter - points to an structure. The - is not freed automatically, the - should be called if the fun is not needed - after encoding.

+

Encodes a char (8-bit) as an integer between 0-255 in the binary format. + Note that for historical reasons the integer argument is of + type . Your C code should consider the + given argument to be of type even if + the C compilers and system may define to be + signed.

- intei_encode_port(char *buf, int *index, const erlang_port *p) - intei_x_encode_port(ei_x_buff* x, const erlang_port *p) - Encodes a port + intei_encode_double(char *buf, int *index, double p) + intei_x_encode_double(ei_x_buff* x, double p) + Encode a double float. -

Encodes an erlang port in the binary format. The - parameter points to a structure (which - should have been obtained earlier with - .

+

Encodes a double-precision (64 bit) floating point number in + the binary format.

+

+ The function returns if the floating point number is not finite. +

- intei_encode_ref(char *buf, int *index, const erlang_ref *p) - intei_x_encode_ref(ei_x_buff* x, const erlang_ref *p) - Encodes a ref + intei_encode_empty_list(char* buf, int* index) + intei_x_encode_empty_list(ei_x_buff* x) + Encode an empty list (). -

Encodes an erlang reference in the binary format. The - parameter points to a structure - (which should have been obtained earlier with - .

+

This function encodes an empty list. It's often used at the + tail of a list.

- intei_encode_term(char *buf, int *index, void *t) - intei_x_encode_term(ei_x_buff* x, void *t) - Encode an term - -

This function encodes an , as obtained from - . The parameter is actually an - pointer. This function doesn't free the - .

-
-
- - intei_encode_trace(char *buf, int *index, const erlang_trace *p) - intei_x_encode_trace(ei_x_buff* x, const erlang_trace *p) - Encode a trace token - -

This function encodes an erlang trace token in the binary - format. The parameter points to a - structure (which should have been - obtained earlier with .

-
-
- - intei_encode_tuple_header(char *buf, int *index, int arity) - intei_x_encode_tuple_header(ei_x_buff* x, int arity) - Encode a tuple + intei_encode_fun(char *buf, int *index, const erlang_fun *p) + intei_x_encode_fun(ei_x_buff* x, const erlang_fun* fun) + Encode a fun. -

This function encodes a tuple header, with a specified - arity. The next terms encoded will be the - elements of the tuple. Tuples and lists are encoded - recursively, so that a tuple may contain another tuple or - list.

-

E.g. to encode the tuple :

-
-ei_encode_tuple_header(buf, &i, 2);
-ei_encode_atom(buf, &i, "a");
-ei_encode_tuple_header(buf, &i, 2);
-ei_encode_atom(buf, &i, "b");
-ei_encode_tuple_header(buf, &i, 0);
-        
+

Encodes a fun in the binary format. The parameter + points to an structure. The + is not freed automatically, the + should be called if the fun is not needed + after encoding.

intei_encode_list_header(char *buf, int *index, int arity) intei_x_encode_list_header(ei_x_buff* x, int arity) - Encode a list + Encode a list.

This function encodes a list header, with a specified arity. The next terms are the elements @@ -412,18 +506,29 @@ ei_x_encode_empty_list(&x); - intei_encode_empty_list(char* buf, int* index) - intei_x_encode_empty_list(ei_x_buff* x) - Encode an empty list () + intei_encode_long(char *buf, int *index, long p) + intei_x_encode_long(ei_x_buff* x, long p) + Encode integer. -

This function encodes an empty list. It's often used at the - tail of a list.

+

Encodes a long integer in the binary format. + Note that if the code is 64 bits the function ei_encode_long() is + exactly the same as ei_encode_longlong().

+
+
+ + intei_encode_longlong(char *buf, int *index, long long p) + intei_x_encode_longlong(ei_x_buff* x, long long p) + Encode integer. + +

Encodes a GCC or Visual C++ (64 bit) + integer in the binary format. Note that this function is missing + in the VxWorks port.

intei_encode_map_header(char *buf, int *index, int arity) intei_x_encode_map_header(ei_x_buff* x, int arity) - Encode a map + Encode a map.

This function encodes a map header, with a specified arity. The next arity*2 terms encoded will be the keys and values of the map @@ -441,275 +546,139 @@ ei_x_encode_string(&x, "Banana"); - intei_get_type(const char *buf, const int *index, int *type, int *size) - Fetch the type and size of an encoded term - -

This function returns the type in and size in - of the encoded term. - For strings and atoms, size - is the number of characters not including the - terminating 0. For binaries, is the number of - bytes. For lists and tuples, is the arity of the - object. For other types, is 0. In all cases, - is left unchanged.

-
-
- - intei_decode_version(const char *buf, int *index, int *version) - Encode an empty list () - -

This function decodes the version magic number for the - erlang binary term format. It must be the first token in a - binary term.

-
-
- - intei_decode_long(const char *buf, int *index, long *p) - Decode integer - -

This function decodes a long integer from the binary format. - Note that if the code is 64 bits the function ei_decode_long() is - exactly the same as ei_decode_longlong().

-
-
- - intei_decode_ulong(const char *buf, int *index, unsigned long *p) - Decode unsigned integer - -

This function decodes an unsigned long integer from - the binary format. - Note that if the code is 64 bits the function ei_decode_ulong() is - exactly the same as ei_decode_ulonglong().

-
-
- - intei_decode_longlong(const char *buf, int *index, long long *p) - Decode integer - -

This function decodes a GCC or Visual C++ - (64 bit) integer from the binary format. Note that this - function is missing in the VxWorks port.

-
-
- - intei_decode_ulonglong(const char *buf, int *index, unsigned long long *p) - Decode unsigned integer - -

This function decodes a GCC or Visual C++ - (64 bit) integer from the binary format. - Note that this function is missing in the VxWorks port.

-
-
- - intei_decode_bignum(const char *buf, int *index, mpz_t obj) - Decode a GMP arbitrary precision integer - -

This function decodes an integer in the binary format to a GMP integer. - To use this function the ei library needs to be configured and compiled - to use the GMP library.

-
-
- - intei_decode_double(const char *buf, int *index, double *p) - Decode a double - -

This function decodes an double-precision (64 bit) floating - point number from the binary format.

-
-
- - intei_decode_boolean(const char *buf, int *index, int *p) - Decode a boolean - -

This function decodes a boolean value from the binary - format. A boolean is actually an atom, decodes 1 - and decodes 0.

-
-
- - intei_decode_char(const char *buf, int *index, char *p) - Decode an 8-bit integer between 0-255 - -

This function decodes a char (8-bit) integer between 0-255 - from the binary format. - Note that for historical reasons the returned integer is of - type . Your C code should consider the - returned value to be of type even if - the C compilers and system may define to be - signed.

-
-
- - intei_decode_string(const char *buf, int *index, char *p) - Decode a string - -

This function decodes a string from the binary format. A - string in erlang is a list of integers between 0 and - 255. Note that since the string is just a list, sometimes - lists are encoded as strings by , - even if it was not intended.

-

The string is copied to , and enough space must be - allocated. The returned string is null terminated so you - need to add an extra byte to the memory requirement.

-
-
- - intei_decode_atom(const char *buf, int *index, char *p) - Decode an atom - -

This function decodes an atom from the binary format. The - null terminated name of the atom is placed at . There can be at most - bytes placed in the buffer.

-
-
- - intei_decode_atom_as(const char *buf, int *index, char *p, int plen, erlang_char_encoding want, erlang_char_encoding* was, erlang_char_encoding* result) - Decode an atom - -

This function decodes an atom from the binary format. The - null terminated name of the atom is placed in buffer at p of length - plen bytes.

-

The wanted string encoding is specified by - want. The original encoding used in the - binary format (latin1 or utf8) can be obtained from *was. The actual encoding of the resulting string - (7-bit ascii, latin1 or utf8) can be obtained from *result. Both was and result can be NULL. - - *result may differ from want if want is a bitwise-or'd combination like - ERLANG_LATIN1|ERLANG_UTF8 or if *result turn out to be pure 7-bit ascii - (compatible with both latin1 and utf8).

-

This function fails if the atom is too long for the buffer - or if it can not be represented with encoding want.

-

This function was introduced in R16 release of Erlang/OTP as part of a first step - to support UTF8 atoms.

-
-
- - intei_decode_binary(const char *buf, int *index, void *p, long *len) - Decode a binary + intei_encode_pid(char *buf, int *index, const erlang_pid *p) + intei_x_encode_pid(ei_x_buff* x, const erlang_pid *p) + Encode a pid. -

This function decodes a binary from the binary format. The - parameter is set to the actual size of the - binary. Note that assumes that there - are enough room for the binary. The size required can be - fetched by .

+

Encodes an erlang process identifier, pid, in the binary + format. The parameter points to an + structure (which should have been obtained + earlier with ).

- intei_decode_fun(const char *buf, int *index, erlang_fun *p) - voidfree_fun(erlang_fun* f) - Decode a fun + intei_encode_port(char *buf, int *index, const erlang_port *p) + intei_x_encode_port(ei_x_buff* x, const erlang_port *p) + Encodes a port. -

This function decodes a fun from the binary format. The - parameter should be NULL or point to an - structure. This is the only decode - function that allocates memory; when the - is no longer needed, it should be freed with - . (This has to do with the arbitrary size of - the environment for a fun.)

+

Encodes an erlang port in the binary format. The + parameter points to a structure (which + should have been obtained earlier with + .

- intei_decode_pid(const char *buf, int *index, erlang_pid *p) - Decode a + intei_encode_ref(char *buf, int *index, const erlang_ref *p) + intei_x_encode_ref(ei_x_buff* x, const erlang_ref *p) + Encodes a ref. -

Decodes a pid, process identifier, from the binary format.

+

Encodes an erlang reference in the binary format. The + parameter points to a structure + (which should have been obtained earlier with + .

- intei_decode_port(const char *buf, int *index, erlang_port *p) - Decode a port + intei_encode_string(char *buf, int *index, const char *p) + intei_encode_string_len(char *buf, int *index, const char *p, int len) + intei_x_encode_string(ei_x_buff* x, const char *p) + intei_x_encode_string_len(ei_x_buff* x, const char* s, int len) + Encode a string. -

This function decodes a port identifier from the binary - format.

+

Encodes a string in the binary format. (A string in erlang + is a list, but is encoded as a character array in the binary + format.) The string should be zero-terminated, except for + the function.

- intei_decode_ref(const char *buf, int *index, erlang_ref *p) - Decode a reference + intei_encode_term(char *buf, int *index, void *t) + intei_x_encode_term(ei_x_buff* x, void *t) + Encode an term. -

This function decodes a reference from the binary format.

+

This function encodes an , as obtained from + . The parameter is actually an + pointer. This function doesn't free the + .

- intei_decode_trace(const char *buf, int *index, erlang_trace *p) - Decode a trace token + intei_encode_trace(char *buf, int *index, const erlang_trace *p) + intei_x_encode_trace(ei_x_buff* x, const erlang_trace *p) + Encode a trace token. -

Decodes an erlang trace token from the binary format.

+

This function encodes an erlang trace token in the binary + format. The parameter points to a + structure (which should have been + obtained earlier with .

- intei_decode_tuple_header(const char *buf, int *index, int *arity) - Decode a tuple + intei_encode_tuple_header(char *buf, int *index, int arity) + intei_x_encode_tuple_header(ei_x_buff* x, int arity) + Encode a tuple. -

This function decodes a tuple header, the number of elements - is returned in . The tuple elements follows in order in - the buffer.

+

This function encodes a tuple header, with a specified + arity. The next terms encoded will be the + elements of the tuple. Tuples and lists are encoded + recursively, so that a tuple may contain another tuple or + list.

+

E.g. to encode the tuple :

+
+ei_encode_tuple_header(buf, &i, 2);
+ei_encode_atom(buf, &i, "a");
+ei_encode_tuple_header(buf, &i, 2);
+ei_encode_atom(buf, &i, "b");
+ei_encode_tuple_header(buf, &i, 0);
+        
- intei_decode_list_header(const char *buf, int *index, int *arity) - Decode a list + intei_encode_ulong(char *buf, int *index, unsigned long p) + intei_x_encode_ulong(ei_x_buff* x, unsigned long p) + Encode unsigned integer. -

This function decodes a list header from the binary - format. The number of elements is returned in - . The elements follows (the last - one is the tail of the list, normally an empty list.) If - is , it's an empty list.

-

Note that lists are encoded as strings, if they consist - entirely of integers in the range 0..255. This function will - not decode such strings, use - instead.

+

Encodes an unsigned long integer in the binary format. + Note that if the code is 64 bits the function ei_encode_ulong() is + exactly the same as ei_encode_ulonglong().

- intei_decode_map_header(const char *buf, int *index, int *arity) - Decode a map + intei_encode_ulonglong(char *buf, int *index, unsigned long long p) + intei_x_encode_ulonglong(ei_x_buff* x, unsigned long long p) + Encode unsigned integer. -

This function decodes a map header from the binary - format. The number of key-value pairs is returned in - *arity. Keys and values follow in the following order: - K1, V1, K2, V2, ..., Kn, Vn. This makes a total of - arity*2 terms. If arity is zero, it's an empty map. - A correctly encoded map does not have duplicate keys.

+

Encodes a GCC or Visual C++ (64 bit) integer in the binary format. Note that + this function is missing in the VxWorks port.

- intei_decode_ei_term(const char* buf, int* index, ei_term* term) - Decode a term, without prior knowledge of type + intei_encode_version(char *buf, int *index) + intei_x_encode_version(ei_x_buff* x) + Encode version. -

This function decodes any term, or at least tries to. If the - term pointed at by in fits in the - union, it is decoded, and the appropriate field - in value]]> is set, and is - incremented by the term size.

-

The function returns 1 on successful decoding, -1 on error, - and 0 if the term seems alright, but does not fit in the - structure. If it returns 1, the - will be incremented, and the contains the - decoded term.

-

The structure will contain the arity for a tuple - or list, size for a binary, string or atom. It will contains - a term if it's any of the following: integer, float, atom, - pid, port or ref.

+

Encodes a version magic number for the binary format. Must + be the first token in a binary term.

- intei_decode_term(const char *buf, int *index, void *t) - Decode a + intei_get_type(const char *buf, const int *index, int *type, int *size) + Fetch the type and size of an encoded term. -

This function decodes a term from the binary format. The - term is return in as a , so - is actually an (see - . The term should later be - deallocated.

-

Note that this function is located in the erl_interface - library.

+

This function returns the type in and size in + of the encoded term. + For strings and atoms, size + is the number of characters not including the + terminating 0. For binaries, is the number of + bytes. For lists and tuples, is the arity of the + object. For other types, is 0. In all cases, + is left unchanged.

intei_print_term(FILE* fp, const char* buf, int* index) intei_s_print_term(char** s, const char* buf, int* index) - Print a term in clear text + Print a term in clear text.

This function prints a term, in clear text, to the file given by , or the buffer pointed to by . It @@ -729,6 +698,67 @@ ei_x_encode_string(&x, "Banana"); human readable format.

+ + voidei_set_compat_rel(release_number) + Set the ei library in compatibility mode. + + unsigned release_number; + + + +

By default, the library is only guaranteed + to be compatible with other Erlang/OTP components from the same + release as the library itself. For example, from + the OTP R10 release is not compatible with an Erlang emulator + from the OTP R9 release by default.

+

A call to sets the + library in compatibility mode of release + . Valid range of + is [7, current release]. This makes it possible to + communicate with Erlang/OTP components from earlier releases.

+ +

If this function is called, it may only be called once + and must be called before any other functions in the + library is called.

+
+ +

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.

+
+
+
+ + intei_skip_term(const char* buf, int* index) + skip a term. + +

This function skips a term in the given buffer, it + recursively skips elements of lists and tuples, so that a + full term is skipped. This is a way to get the size of an + erlang term.

+

is the buffer.

+

is updated to point right after the term in the + buffer.

+ +

This can be useful when you want to hold arbitrary + terms: just skip them and copy the binary term data to some + buffer.

+
+

The function returns on success and on + failure.

+
+
+ + intei_x_append(ei_x_buff* x, const ei_x_buff* x2) + intei_x_append_buf(ei_x_buff* x, const char* buf, int len) + Appends a buffer at the end. + +

These functions appends data at the end of the buffer .

+
+
+ intei_x_format(ei_x_buff* x, const char* fmt, ...) intei_x_format_wo_ver(ei_x_buff* x, const char *fmt, ... ) @@ -760,10 +790,18 @@ encodes the tuple {numbers,12,3.14159} the initial version byte.

+ + intei_x_free(ei_x_buff* x) + Frees a buffer. + +

This function frees an buffer. The memory + used by the buffer is returned to the OS.

+
+
intei_x_new(ei_x_buff* x) intei_x_new_with_version(ei_x_buff* x) - Allocate a new buffer + Allocate a new buffer.

This function allocates a new buffer. The fields of the structure pointed to by parameter is @@ -773,43 +811,7 @@ encodes the tuple {numbers,12,3.14159} won't be needed.)

- - intei_x_free(ei_x_buff* x) - Frees a buffer - -

This function frees an buffer. The memory - used by the buffer is returned to the OS.

-
-
- - intei_x_append(ei_x_buff* x, const ei_x_buff* x2) - intei_x_append_buf(ei_x_buff* x, const char* buf, int len) - Appends a buffer at the end - -

These functions appends data at the end of the buffer .

-
-
- - intei_skip_term(const char* buf, int* index) - skip a term - -

This function skips a term in the given buffer, it - recursively skips elements of lists and tuples, so that a - full term is skipped. This is a way to get the size of an - erlang term.

-

is the buffer.

-

is updated to point right after the term in the - buffer.

- -

This can be useful when you want to hold arbitrary - terms: just skip them and copy the binary term data to some - buffer.

-
-

The function returns on success and on - failure.

-
-
-
+
Debug Information @@ -828,4 +830,3 @@ encodes the tuple {numbers,12,3.14159}

erl_interface(3)

- diff --git a/lib/erl_interface/doc/src/ei_connect.xml b/lib/erl_interface/doc/src/ei_connect.xml index 516357b6a3..8cc08f86cd 100644 --- a/lib/erl_interface/doc/src/ei_connect.xml +++ b/lib/erl_interface/doc/src/ei_connect.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + ei_connect @@ -29,7 +29,7 @@ ? 2001-09-01 A - ei_connect.sgml + ei_connect.xml ei_connect Communicate with distributed erlang @@ -72,11 +72,96 @@ the operations are completed (regardless of the result). To avoid problems, leave the socket options alone. Ei will handle any socket options that need modification.

-

In all other senses, the functions inherit all - the return values and the semantics from the functions without +

In all other senses, the functions inherit all + the return values and the semantics from the functions without the suffix.

+ + struct hostent*ei_gethostbyaddr(const char *addr, int len, int type) + struct hostent*ei_gethostbyaddr_r(const char *addr, int length, int type, struct hostent *hostp, char *buffer, int buflen, int *h_errnop) + struct hostent*ei_gethostbyname(const char *name) + struct hostent*ei_gethostbyname_r(const char *name, struct hostent *hostp, char *buffer, int buflen, int *h_errnop) + Name lookup functions. + +

These are convenience functions for some common name lookup functions.

+
+
+ + intei_accept(ei_cnode *ec, int listensock, ErlConnect *conp) + Accept a connection from another node. + +

This function is used by a server process to accept a + connection from a client process.

+

is the C-node structure.

+

is an open socket descriptor on which + has previously been called.

+

is a pointer to an struct, + described as follows:

+ +

On success, is filled in with the address and + node name of the connecting client and a file descriptor is + returned. On failure, is returned and + is set to .

+
+
+ + intei_accept_tmo(ei_cnode *ec, int listensock, ErlConnect *conp, unsigned timeout_ms) + Accept a connection from another node with optional timeout. + +

ei_accept with an optional timeout argument, + see the description at the beginning of this document.

+
+
+ + intei_connect(ei_cnode* ec, char *nodename) + intei_xconnect(ei_cnode* ec, Erl_IpAddr adr, char *alivename) + Establishe a connection to an Erlang node. + +

These functions set up a connection to an Erlang node.

+

requires the IP address of the remote + host and the alive name of the remote node + to be specified. provides an alternative + interface, and determines the information from the node name + provided.

+

is the 32-bit IP address of the remote host.

+

is the alivename of the remote node.

+

is the name of the remote node.

+

These functions return an open file descriptor on success, or + a negative value indicating that an error occurred --- in + which case they will set to one of:

+ + + The remote host is unreachable + + No more memory available. + + I/O error. + +

Additionally, values from + (2) and (2) + system calls may be propagated into .

+

Example:

+ +
+
intei_connect_init(ei_cnode* ec, const char* this_node_name, const char *cookie, short creation) intei_connect_xinit(ei_cnode* ec, const char *thishostname, const char *thisalivename, const char *thisnodename, Erl_IpAddr thisipaddr, const char *cookie, short creation) @@ -140,61 +225,58 @@ if (ei_connect_init(&ec, "madonna", "cookie...", n++) < 0) { - intei_connect(ei_cnode* ec, char *nodename) - intei_xconnect(ei_cnode* ec, Erl_IpAddr adr, char *alivename) - Establishe a connection to an Erlang node + intei_connect_tmo(ei_cnode* ec, char *nodename, unsigned timeout_ms) + intei_xconnect_tmo(ei_cnode* ec, Erl_IpAddr adr, char *alivename, unsigned timeout_ms) + Establish a connection to an Erlang node with optional timeout. -

These functions set up a connection to an Erlang node.

-

requires the IP address of the remote - host and the alive name of the remote node - to be specified. provides an alternative - interface, and determines the information from the node name - provided.

-

is the 32-bit IP address of the remote host.

-

is the alivename of the remote node.

-

is the name of the remote node.

-

These functions return an open file descriptor on success, or - a negative value indicating that an error occurred --- in - which case they will set to one of:

- - - The remote host is unreachable - - No more memory available. - - I/O error. - -

Additionally, values from - (2) and (2) - system calls may be propagated into .

-

Example:

- +

ei_connect and ei_xconnect with an optional timeout argument, + see the description at the beginning of this document.

- intei_connect_tmo(ei_cnode* ec, char *nodename, unsigned timeout_ms) - intei_xconnect_tmo(ei_cnode* ec, Erl_IpAddr adr, char *alivename, unsigned timeout_ms) - Establish a connection to an Erlang node with optional timeout + intei_get_tracelevel(void) + voidei_set_tracelevel(int level) + Get and set functions for tracing. -

ei_connect and ei_xconnect with an optional timeout argument, +

These functions are used to set tracing on the distribution. The levels are different verbosity levels. A higher level means more information. + See also Debug Information and below.

+

and are not thread safe.

+
+
+ + intei_publish(ei_cnode *ec, int port) + Publish a node name. + +

These functions are used by a server process to register + with the local name server epmd, thereby allowing + other processes to send messages by using the registered name. + Before calling either of these functions, the process should + have called and on an open socket.

+

is the C-node structure.

+

is the local name to register, and should be the + same as the port number that was previously bound to the socket.

+

is the 32-bit IP address of the local host.

+

To unregister with epmd, simply close the returned + descriptor. Do not use , which is deprecated anyway.

+

On success, the functions return a descriptor connecting the + calling process to epmd. On failure, they return -1 and set + to .

+

Additionally, values from (2) + and (2) system calls may be propagated + into .

+
+
+ + intei_publish_tmo(ei_cnode *ec, int port, unsigned timeout_ms) + Publish a node name with optional timeout. + +

ei_publish with an optional timeout argument, see the description at the beginning of this document.

intei_receive(int fd, unsigned char* bufp, int bufsize) - Receive a message + Receive a message.

This function receives a message consisting of a sequence of bytes in the Erlang external format.

@@ -224,17 +306,44 @@ fd = ei_xconnect(&ec, &addr, ALIVE);
- intei_receive_tmo(int fd, unsigned char* bufp, int bufsize, unsigned timeout_ms) - Receive a message with optional timeout + intei_receive_encoded(int fd, char **mbufp, int *bufsz, erlang_msg *msg, int *msglen) + Obsolete function for receiving a message. -

ei_receive with an optional timeout argument, +

This function is retained for compatibility with code + generated by the interface compiler and with code following + examples in the same application.

+

In essence the function performs the same operation as + , but instead of using an ei_x_buff, the + function expects a pointer to a character pointer + (), where the character pointer should point to a + memory area allocated by . The argument + should be a pointer to an integer containing the + exact size (in bytes) of the memory area. The function may + reallocate the memory area and will in such cases put the new + size in and update .

+

Furthermore the function returns either ERL_TICK or the + field of the . The actual + length of the message is put in . On error it + will return a value .

+

It is recommended to use ei_xreceive_msg instead when + possible, for the sake of readability. The function will + however be retained in the interface for compatibility and + will not be removed not be removed in future releases + without notice.

+
+
+ + intei_receive_encoded_tmo(int fd, char **mbufp, int *bufsz, erlang_msg *msg, int *msglen, unsigned timeout_ms) + Obsolete function for receiving a message with timeout. + +

ei_receive_encoded with an optional timeout argument, see the description at the beginning of this document.

intei_receive_msg(int fd, erlang_msg* msg, ei_x_buff* x) intei_xreceive_msg(int fd, erlang_msg* msg, ei_x_buff* x) - Receive a message + Receive a message.

These functions receives a message to the buffer in . allows the buffer in @@ -279,90 +388,23 @@ typedef struct { intei_receive_msg_tmo(int fd, erlang_msg* msg, ei_x_buff* x, unsigned imeout_ms) intei_xreceive_msg_tmo(int fd, erlang_msg* msg, ei_x_buff* x, unsigned timeout_ms) - Receive a message with optional timeout + Receive a message with optional timeout.

ei_receive_msg and ei_xreceive_msg with an optional timeout argument, see the description at the beginning of this document.

- intei_receive_encoded(int fd, char **mbufp, int *bufsz, erlang_msg *msg, int *msglen) - Obsolete function for receiving a message - -

This function is retained for compatibility with code - generated by the interface compiler and with code following - examples in the same application.

-

In essence the function performs the same operation as - , but instead of using an ei_x_buff, the - function expects a pointer to a character pointer - (), where the character pointer should point to a - memory area allocated by . The argument - should be a pointer to an integer containing the - exact size (in bytes) of the memory area. The function may - reallocate the memory area and will in such cases put the new - size in and update .

-

Furthermore the function returns either ERL_TICK or the - field of the . The actual - length of the message is put in . On error it - will return a value .

-

It is recommended to use ei_xreceive_msg instead when - possible, for the sake of readability. The function will - however be retained in the interface for compatibility and - will not be removed not be removed in future releases - without notice.

-
-
- - intei_receive_encoded_tmo(int fd, char **mbufp, int *bufsz, erlang_msg *msg, int *msglen, unsigned timeout_ms) - Obsolete function for receiving a message with timeout - -

ei_receive_encoded with an optional timeout argument, - see the description at the beginning of this document.

-
-
- - intei_send(int fd, erlang_pid* to, char* buf, int len) - Send a message - -

This function sends an Erlang term to a process.

-

is an open descriptor to an Erlang connection.

-

is the Pid of the intended recipient of the - message.

-

is the buffer containing the term in binary - format.

-

is the length of the message in bytes.

-

The function returns 0 if successful, otherwise -1, in the - latter case it will set to .

-
-
- - intei_send_tmo(int fd, erlang_pid* to, char* buf, int len, unsigned timeout_ms) - Send a message with optional timeout - -

ei_send with an optional timeout argument, - see the description at the beginning of this document.

-
-
- - intei_send_encoded(int fd, erlang_pid* to, char* buf, int len) - Obsolete function to send a message - -

Works exactly as ei_send, the alternative name retained for - backward compatibility. The function will not be - removed without notice.

-
-
- - intei_send_encoded_tmo(int fd, erlang_pid* to, char* buf, int len, unsigned timeout_ms) - Obsolete function to send a message with optional timeout + intei_receive_tmo(int fd, unsigned char* bufp, int bufsize, unsigned timeout_ms) + Receive a message with optional timeout. -

ei_send_encoded with an optional timeout argument, +

ei_receive with an optional timeout argument, see the description at the beginning of this document.

intei_reg_send(ei_cnode* ec, int fd, char* server_name, char* buf, int len) - Send a message to a registered name + Send a message to a registered name.

This function sends an Erlang term to a registered process.

@@ -387,49 +429,17 @@ if (ei_reg_send(&ec, fd, x.buff, x.index) < 0)
intei_reg_send_tmo(ei_cnode* ec, int fd, char* server_name, char* buf, int len, unsigned timeout_ms) - Send a message to a registered name with optional timeout + Send a message to a registered name with optional timeout.

ei_reg_send with an optional timeout argument, see the description at the beginning of this document.

- - intei_send_reg_encoded(int fd, const erlang_pid *from, const char *to, const char *buf, int len) - Obsolete function to send a message to a registered name - -

This function is retained for compatibility with code - generated by the interface compiler and with code following - examples in the same application.

-

The function works as with one - exception. Instead of taking the as a first - argument, it takes a second argument, an - which should be the process identifier of the sending process - (in the erlang distribution protocol).

-

A suitable can be constructed from the - structure by the following example code:

- num = fd; - ]]> -
-
- - intei_send_reg_encoded_tmo(int fd, const erlang_pid *from, const char *to, const char *buf, int len) - Obsolete function to send a message to a registered name with timeout - -

ei_send_reg_encoded with an optional timeout argument, - see the description at the beginning of this document.

-
-
intei_rpc(ei_cnode *ec, int fd, char *mod, char *fun, const char *argbuf, int argbuflen, ei_x_buff *x) intei_rpc_to(ei_cnode *ec, int fd, char *mod, char *fun, const char *argbuf, int argbuflen) intei_rpc_from(ei_cnode *ec, int fd, int timeout, erlang_msg *msg, ei_x_buff *x) - Remote Procedure Call from C to Erlang + Remote Procedure Call from C to Erlang.

These functions support calling Erlang functions on remote nodes. sends an rpc request to a remote node and @@ -496,95 +506,85 @@ if (ei_decode_version(result.buff, &index) < 0 - intei_publish(ei_cnode *ec, int port) - Publish a node name + erlang_pid *ei_self(ei_cnode *ec) + Retrieve the Pid of the C-node. -

These functions are used by a server process to register - with the local name server epmd, thereby allowing - other processes to send messages by using the registered name. - Before calling either of these functions, the process should - have called and on an open socket.

-

is the C-node structure.

-

is the local name to register, and should be the - same as the port number that was previously bound to the socket.

-

is the 32-bit IP address of the local host.

-

To unregister with epmd, simply close the returned - descriptor. Do not use , which is deprecated anyway.

-

On success, the functions return a descriptor connecting the - calling process to epmd. On failure, they return -1 and set - to .

-

Additionally, values from (2) - and (2) system calls may be propagated - into .

+

This function retrieves the Pid of the C-node. Every C-node + has a (pseudo) pid used in , + and others. This is contained in a field in the + structure. It will be safe for a long time to fetch this + field directly from the structure.

- intei_publish_tmo(ei_cnode *ec, int port, unsigned timeout_ms) - Publish a node name with optional timeout + intei_send(int fd, erlang_pid* to, char* buf, int len) + Send a message. -

ei_publish with an optional timeout argument, - see the description at the beginning of this document.

+

This function sends an Erlang term to a process.

+

is an open descriptor to an Erlang connection.

+

is the Pid of the intended recipient of the + message.

+

is the buffer containing the term in binary + format.

+

is the length of the message in bytes.

+

The function returns 0 if successful, otherwise -1, in the + latter case it will set to .

- intei_accept(ei_cnode *ec, int listensock, ErlConnect *conp) - Accept a connection from another node + intei_send_encoded(int fd, erlang_pid* to, char* buf, int len) + Obsolete function to send a message. -

This function is used by a server process to accept a - connection from a client process.

-

is the C-node structure.

-

is an open socket descriptor on which - has previously been called.

-

is a pointer to an struct, - described as follows:

- -

On success, is filled in with the address and - node name of the connecting client and a file descriptor is - returned. On failure, is returned and - is set to .

+

Works exactly as ei_send, the alternative name retained for + backward compatibility. The function will not be + removed without notice.

- intei_accept_tmo(ei_cnode *ec, int listensock, ErlConnect *conp, unsigned timeout_ms) - Accept a connection from another node with optional timeout + intei_send_encoded_tmo(int fd, erlang_pid* to, char* buf, int len, unsigned timeout_ms) + Obsolete function to send a message with optional timeout. -

ei_accept with an optional timeout argument, +

ei_send_encoded with an optional timeout argument, see the description at the beginning of this document.

- intei_unpublish(ei_cnode *ec) - Forcefully unpublish a node name + intei_send_reg_encoded(int fd, const erlang_pid *from, const char *to, const char *buf, int len) + Obsolete function to send a message to a registered name. -

This function can be called by a process to unregister a - specified node from epmd on the localhost. This is however usually not - allowed, unless epmd was started with the -relaxed_command_check - flag, which it normally isn't.

- -

To unregister a node you have published, you should - close the descriptor that was returned by - .

- - -

This function is deprecated and will be removed in a future - release.

-
-

is the node structure of the node to unregister.

-

If the node was successfully unregistered from epmd, the - function returns 0. Otherwise, it returns -1 and sets - is to .

+

This function is retained for compatibility with code + generated by the interface compiler and with code following + examples in the same application.

+

The function works as with one + exception. Instead of taking the as a first + argument, it takes a second argument, an + which should be the process identifier of the sending process + (in the erlang distribution protocol).

+

A suitable can be constructed from the + structure by the following example code:

+ num = fd; + ]]>
- intei_unpublish_tmo(ei_cnode *ec, unsigned timeout_ms) - Unpublish a node name with optional timeout + intei_send_reg_encoded_tmo(int fd, const erlang_pid *from, const char *to, const char *buf, int len) + Obsolete function to send a message to a registered name with timeout. -

ei_unpublish with an optional timeout argument, +

ei_send_reg_encoded with an optional timeout argument, + see the description at the beginning of this document.

+
+
+ + intei_send_tmo(int fd, erlang_pid* to, char* buf, int len, unsigned timeout_ms) + Send a message with optional timeout. + +

ei_send with an optional timeout argument, see the description at the beginning of this document.

@@ -592,7 +592,7 @@ typedef struct { const char *ei_thisnodename(ei_cnode *ec) const char *ei_thishostname(ei_cnode *ec) const char *ei_thisalivename(ei_cnode *ec) - Retrieve some values + Retrieve some values.

These functions can be used to retrieve information about the C Node. These values are initially set with @@ -603,37 +603,37 @@ typedef struct { - erlang_pid *ei_self(ei_cnode *ec) - Retrieve the Pid of the C-node - -

This function retrieves the Pid of the C-node. Every C-node - has a (pseudo) pid used in , - and others. This is contained in a field in the - structure. It will be safe for a long time to fetch this - field directly from the structure.

-
- - - struct hostent*ei_gethostbyname(const char *name) - struct hostent*ei_gethostbyaddr(const char *addr, int len, int type) - struct hostent*ei_gethostbyname_r(const char *name, struct hostent *hostp, char *buffer, int buflen, int *h_errnop) - struct hostent*ei_gethostbyaddr_r(const char *addr, int length, int type, struct hostent *hostp, char *buffer, int buflen, int *h_errnop) - Name lookup functions + intei_unpublish(ei_cnode *ec) + Forcefully unpublish a node name. -

These are convenience functions for some common name lookup functions.

+

This function can be called by a process to unregister a + specified node from epmd on the localhost. This is however usually not + allowed, unless epmd was started with the -relaxed_command_check + flag, which it normally isn't.

+ +

To unregister a node you have published, you should + close the descriptor that was returned by + .

+ + +

This function is deprecated and will be removed in a future + release.

+
+

is the node structure of the node to unregister.

+

If the node was successfully unregistered from epmd, the + function returns 0. Otherwise, it returns -1 and sets + is to .

- intei_get_tracelevel(void) - voidei_set_tracelevel(int level) - Get and set functions for tracing. + intei_unpublish_tmo(ei_cnode *ec, unsigned timeout_ms) + Unpublish a node name with optional timeout. -

These functions are used to set tracing on the distribution. The levels are different verbosity levels. A higher level means more information. - See also Debug Information and below.

-

and are not thread safe.

+

ei_unpublish with an optional timeout argument, + see the description at the beginning of this document.

-
+
Debug Information @@ -652,13 +652,12 @@ typedef struct { or by setting the environment variable . The different tracelevels has the following messages:

- 1: Verbose error messages - 2: Above messages and verbose warning messages - 3: Above messages and progress reports for connection handling - 4: Above messages and progress reports for communication - 5: Above messages and progress reports for data conversion + 1: Verbose error messages + 2: Above messages and verbose warning messages + 3: Above messages and progress reports for connection handling + 4: Above messages and progress reports for communication + 5: Above messages and progress reports for data conversion
- diff --git a/lib/erl_interface/doc/src/ei_users_guide.xml b/lib/erl_interface/doc/src/ei_users_guide.xml index 4b9809aee4..4beb4c6c73 100644 --- a/lib/erl_interface/doc/src/ei_users_guide.xml +++ b/lib/erl_interface/doc/src/ei_users_guide.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + The El Library User's Guide @@ -77,7 +77,7 @@ Eshell V4.7.4 (abort with ^G) definition in your . The correct value for this path is Vsn, where is the path reported by in the above example, and Vsn is - the version of the Erl_interface application, for example + the version of the Erl_interface application, for example

@@ -147,7 +147,7 @@ i = erl_encode(tuple, buf); ]]>
Building Terms and Patterns -

The previous example can be simplified by using +

The previous example can be simplified by using to create an Erlang term.

- diff --git a/lib/erl_interface/doc/src/erl_call.xml b/lib/erl_interface/doc/src/erl_call.xml index 46015621ac..f8fe409560 100644 --- a/lib/erl_interface/doc/src/erl_call.xml +++ b/lib/erl_interface/doc/src/erl_call.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -30,14 +30,14 @@ Torbjörn Törnkvist 97-05-16 B - erl_call.sgml + erl_call.xml erl_call - Call/Start a Distributed Erlang Node + Call/start a distributed Erlang node. -

makes it possible to start and/or communicate with - a distributed Erlang node. It is built upon the - library as an example application. Its purpose is to use an Unix shell script to interact with a distributed Erlang node. It performs all +

makes it possible to start and/or communicate with + a distributed Erlang node. It is built upon the + library as an example application. Its purpose is to use an Unix shell script to interact with a distributed Erlang node. It performs all communication with the Erlang rex server, using the standard Erlang RPC facility. It does not require any special software to be run at the Erlang target node.

The main use is to either start a distributed Erlang node @@ -46,17 +46,17 @@ compiled, or to pipe a sequence of Erlang expressions to be evaluated (similar to the Erlang shell).

Options, which cause to be read, can be used with - advantage - as scripts from within (Unix) shell scripts. Another + advantage + as scripts from within (Unix) shell scripts. Another nice use of could be from (http) CGI-bin scripts.

erl_call <options> - Start/Call Erlang + Start/call Erlang.

Each option flag is described below with its name, type and - meaning.

+ meaning.

-a [Mod [Fun [Args]]]] @@ -85,7 +85,7 @@

(optional): Reads a sequence of Erlang expressions, separated by ',' and ended with a '.', from until - EOF (Control-D). Evaluates the expressions and returns the result from + EOF (Control-D). Evaluates the expressions and returns the result from the last expression. Returns if successful.

@@ -103,18 +103,18 @@
-n Node -

(one of is required): - Has the same meaning as and can still be used for +

(one of is required): + Has the same meaning as and can still be used for backwards compatibility reasons.

-name Node

(one of is required): is the name of the node to be - started or communicated with. It is assumed that - is started with , which means that fully - qualified long node names are used. - If the option is given, an Erlang node will (if necessary) + started or communicated with. It is assumed that + is started with , which means that fully + qualified long node names are used. + If the option is given, an Erlang node will (if necessary) be started with .

@@ -238,4 +238,3 @@ start() -> ]]> - diff --git a/lib/erl_interface/doc/src/erl_connect.xml b/lib/erl_interface/doc/src/erl_connect.xml index 0fad98cd17..0799e30905 100644 --- a/lib/erl_interface/doc/src/erl_connect.xml +++ b/lib/erl_interface/doc/src/erl_connect.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + erl_connect @@ -30,7 +30,7 @@ Torbjörn Törnkvist 980703 A - erl_connect.sgml + erl_connect.xml erl_connect Communicate with Distributed Erlang @@ -46,10 +46,99 @@ Erlang function .

+ + interl_accept(listensock, conp) + Accept a connection. + + int listensock; + ErlConnect *conp; + + +

This function is used by a server process to accept a + connection from a client process.

+

is an open socket descriptor on which + has previously been called.

+

is a pointer to an struct, + described as follows:

+ +

On success, is filled in with the address and + node name of the connecting client and a file descriptor is + returned. On failure, is returned and + is set to .

+
+
+ + interl_close_connection(fd) + Close a connection to an Erlang node. + + int fd; + + +

This function closes an open connection to an Erlang node.

+

is a file descriptor obtained from + or .

+

On success, 0 is returned. If the call fails, a non-zero value + is returned, and the reason for + the error can be obtained with the appropriate platform-dependent + call.

+
+
+ + interl_connect(node) + interl_xconnect(addr, alive) + Establishe a connection to an Erlang node. + + char *node, *alive; + struct in_addr *addr; + + +

These functions set up a connection to an Erlang node.

+

requires the IP address of the remote + host and the alive name of the remote node + to be specified. provides an alternative + interface, and determines the information from the node name + provided.

+

is the 32-bit IP address of the remote host.

+

is the alivename of the remote node.

+

is the name of the remote node.

+

These functions return an open file descriptor on success, or + a negative value indicating that an error occurred --- in + which case they will set to one of:

+ + + The remote host is unreachable + + No more memory available. + + I/O error. + +

Additionally, values from + (2) and (2) + system calls may be propagated into .

+ +
+
interl_connect_init(number, cookie, creation) interl_connect_xinit(host, alive, node, addr, cookie, creation) - Initialize communication + Initialize communication. int number; char *cookie; @@ -61,7 +150,7 @@

These functions initialize the module. In particular, they are used to identify the name of the C-node from which they are called. One of these functions must - be called before any of the other functions in the erl_connect + be called before any of the other functions in the erl_connect module are used.

stores for later use information about the node's host name , alive name , node @@ -69,12 +158,12 @@ and creation number . provides an alternative interface which does not require as much information from the caller. Instead, - uses to obtain default values. + uses to obtain default values.

If you use your node will have a short name, i.e., it will not be fully qualified. If you need to use fully qualified (a.k.a. long) names, use - instead. + instead.

is the name of the host on which the node is running.

is the alivename of the node.

@@ -118,71 +207,38 @@ if (!erl_connect_init(17, "samplecookiestring...", 0))
- interl_connect(node) - interl_xconnect(addr, alive) - Establishe a connection to an Erlang node + interl_publish(port) + Publish a node name. - char *node, *alive; - struct in_addr *addr; + int port; -

These functions set up a connection to an Erlang node.

-

requires the IP address of the remote - host and the alive name of the remote node - to be specified. provides an alternative - interface, and determines the information from the node name - provided.

-

is the 32-bit IP address of the remote host.

-

is the alivename of the remote node.

-

is the name of the remote node.

-

These functions return an open file descriptor on success, or - a negative value indicating that an error occurred --- in - which case they will set to one of:

+

These functions are used by a server process to register + with the local name server epmd, thereby allowing + other processes to send messages by using the registered name. + Before calling either of these functions, the process should + have called and on an open socket.

+

is the local name to register, and should be the + same as the port number that was previously bound to the socket.

+

To unregister with epmd, simply close the returned + descriptor. +

+

On success, the functions return a descriptor connecting the + calling process to epmd. On failure, they return -1 and set + to:

- - The remote host is unreachable - - No more memory available. - I/O error. + I/O error -

Additionally, values from - (2) and (2) - system calls may be propagated into .

- -
-
- - interl_close_connection(fd) - Close a connection to an Erlang node - - int fd; - - -

This function closes an open connection to an Erlang node.

-

is a file descriptor obtained from - or .

-

On success, 0 is returned. If the call fails, a non-zero value - is returned, and the reason for - the error can be obtained with the appropriate platform-dependent - call.

+

Additionally, values from (2) + and (2) system calls may be propagated + into . +

interl_receive(fd, bufp, bufsize) - Receive a message + Receive a message. int fd; char *bufp; @@ -216,7 +272,7 @@ erl_xconnect( &addr , ALIVE ); interl_receive_msg(fd, bufp, bufsize, emsg) - Receive and decodes a message + Receive and decodes a message. int fd; unsigned char *bufp; @@ -224,7 +280,7 @@ erl_xconnect( &addr , ALIVE ); ErlMessage *emsg; -

This function receives the message into the specified buffer, +

This function receives the message into the specified buffer, and decodes into the .

is an open descriptor to an Erlang connection.

is a buffer large enough to hold the expected message.

@@ -245,9 +301,9 @@ typedef struct {

The definition of has changed since earlier versions of Erl_Interface.

-

identifies the type of message, one of +

identifies the type of message, one of , , , - and . + and .

If contains this indicates that an ordinary send operation has taken @@ -294,66 +350,9 @@ typedef struct { - - interl_xreceive_msg(fd, bufpp, bufsizep, emsg) - Receive and decodes a message - - int fd; - unsigned char **bufpp; - int *bufsizep; - ErlMessage *emsg; - - -

This function is similar to . The - difference is that expects the buffer to - have been allocated by , and reallocates it if the received - message does not fit into the original buffer. For that reason, - both buffer and buffer length are given as pointers - their values - may change by the call. -

-

On success, the function returns and the - struct will be initialized as described above, or - , in which case no message is returned. On - failure, the function returns and will set - to one of:

- - - Buffer too small. - - No more memory available. - - I/O error. - -
-
- - interl_send(fd, to, msg) - Send a message - - int fd; - ETERM *to, *msg; - - -

This function sends an Erlang term to a process.

-

is an open descriptor to an Erlang connection.

-

is an Erlang term containing the Pid of the - intended recipient of the message.

-

is the Erlang term to be sent.

-

The function returns 1 if successful, otherwise 0 --- in - which case it will set to one of:

- - - Invalid argument: is not a valid Erlang pid. - - No more memory available. - - I/O error. - -
-
interl_reg_send(fd, to, msg) - Send a message to a registered name + Send a message to a registered name. int fd; char *to; @@ -377,9 +376,9 @@ typedef struct { ETERM *erl_rpc(fd, mod, fun, args) - interl_rpc_to(fd, mod, fun, args) interl_rpc_from(fd, timeout, emsg) - Remote Procedure Call + interl_rpc_to(fd, mod, fun, args) + Remote Procedure Call. int fd, timeout; char *mod, *fun; @@ -438,68 +437,37 @@ typedef struct { - interl_publish(port) - Publish a node name + interl_send(fd, to, msg) + Send a message. - int port; + int fd; + ETERM *to, *msg; -

These functions are used by a server process to register - with the local name server epmd, thereby allowing - other processes to send messages by using the registered name. - Before calling either of these functions, the process should - have called and on an open socket.

-

is the local name to register, and should be the - same as the port number that was previously bound to the socket.

-

To unregister with epmd, simply close the returned - descriptor. -

-

On success, the functions return a descriptor connecting the - calling process to epmd. On failure, they return -1 and set - to:

+

This function sends an Erlang term to a process.

+

is an open descriptor to an Erlang connection.

+

is an Erlang term containing the Pid of the + intended recipient of the message.

+

is the Erlang term to be sent.

+

The function returns 1 if successful, otherwise 0 --- in + which case it will set to one of:

+ + Invalid argument: is not a valid Erlang pid. + + No more memory available. - I/O error + I/O error. -

Additionally, values from (2) - and (2) system calls may be propagated - into . -

-
-
- - interl_accept(listensock, conp) - Accept a connection - - int listensock; - ErlConnect *conp; - - -

This function is used by a server process to accept a - connection from a client process.

-

is an open socket descriptor on which - has previously been called.

-

is a pointer to an struct, - described as follows:

- -

On success, is filled in with the address and - node name of the connecting client and a file descriptor is - returned. On failure, is returned and - is set to .

- const char *erl_thiscookie() - const char *erl_thisnodename() - const char *erl_thishostname() const char *erl_thisalivename() + const char *erl_thiscookie() shorterl_thiscreation() - Retrieve some values + const char *erl_thishostname() + const char *erl_thisnodename() + Retrieve some values.

These functions can be used to retrieve information about the C Node. These values are initially set with @@ -508,22 +476,22 @@ typedef struct { interl_unpublish(alive) - Forcefully unpublish a node name + Forcefully unpublish a node name. char *alive;

This function can be called by a process to unregister a - specified node from epmd on the localhost. This is however usually not - allowed, unless epmd was started with the -relaxed_command_check + specified node from epmd on the localhost. This is however usually not + allowed, unless epmd was started with the -relaxed_command_check flag, which it normally isn't.

To unregister a node you have published, you should instead - close the descriptor that was returned by - .

+ close the descriptor that was returned by + .

-

This function is deprecated and will be removed in a future +

This function is deprecated and will be removed in a future release.

is the name of the node to unregister, i.e., the @@ -534,11 +502,43 @@ typedef struct { - struct hostent*erl_gethostbyname(name) + interl_xreceive_msg(fd, bufpp, bufsizep, emsg) + Receive and decodes a message. + + int fd; + unsigned char **bufpp; + int *bufsizep; + ErlMessage *emsg; + + +

This function is similar to . The + difference is that expects the buffer to + have been allocated by , and reallocates it if the received + message does not fit into the original buffer. For that reason, + both buffer and buffer length are given as pointers - their values + may change by the call. +

+

On success, the function returns and the + struct will be initialized as described above, or + , in which case no message is returned. On + failure, the function returns and will set + to one of:

+ + + Buffer too small. + + No more memory available. + + I/O error. + +
+
+ struct hostent*erl_gethostbyaddr(addr, length, type) - struct hostent*erl_gethostbyname_r(name, hostp, buffer, buflen, h_errnop) struct hostent*erl_gethostbyaddr_r(addr, length, type, hostp, buffer, buflen, h_errnop) - Name lookup functions + struct hostent*erl_gethostbyname(name) + struct hostent*erl_gethostbyname_r(name, hostp, buffer, buflen, h_errnop) + Name lookup functions. const char *name; const char *addr; @@ -567,4 +567,3 @@ typedef struct { - diff --git a/lib/erl_interface/doc/src/erl_error.xml b/lib/erl_interface/doc/src/erl_error.xml index abe84780e1..5b8d546e12 100644 --- a/lib/erl_interface/doc/src/erl_error.xml +++ b/lib/erl_interface/doc/src/erl_error.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + erl_error @@ -30,13 +30,13 @@ Torbjörn Törnkvist 961014 A - erl_error.sgml + erl_error.xml erl_error Error Print Routines

This module contains some error printing routines taken - from Advanced Programming in the UNIX Environment + from Advanced Programming in the UNIX Environment by W. Richard Stevens.

These functions are all called in the same manner as , i.e. with a string containing format specifiers @@ -46,7 +46,7 @@ voiderl_err_msg(FormatStr, ... ) - Non-fatal error, and not system call error + Non-fatal error, and not system call error. const char *FormatStr; @@ -57,7 +57,7 @@ voiderl_err_quit(FormatStr, ... ) - Fatal error, but not system call error + Fatal error, but not system call error. const char *FormatStr; @@ -70,19 +70,19 @@ voiderl_err_ret(FormatStr, ... ) - Non-fatal system call error + Non-fatal system call error. const char *FormatStr;

Use this function after a failed system call. The message provided by the caller is printed followed by a string - describing the reason for failure.

+ describing the reason for failure.

voiderl_err_sys(FormatStr, ... ) - Fatal system call error + Fatal system call error. const char *FormatStr; @@ -107,7 +107,7 @@ volatile interl_errno - The variable contains the erl_interface error number. You can change the value if you wish. + The variable contains the erl_interface error number. You can change the value if you wish.

is initially (at program startup) zero and is then set by many erl_interface functions on failure to a @@ -134,4 +134,3 @@ - diff --git a/lib/erl_interface/doc/src/erl_eterm.xml b/lib/erl_interface/doc/src/erl_eterm.xml index 800f8a3207..e5207a271e 100644 --- a/lib/erl_interface/doc/src/erl_eterm.xml +++ b/lib/erl_interface/doc/src/erl_eterm.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + erl_eterm @@ -30,7 +30,7 @@ Torbjörn Törnkvist 980703 A - erl_eterm.sgml + erl_eterm.xml erl_eterm Functions for Erlang Term Construction @@ -167,18 +167,18 @@ erl_free_compound(list); ETERM *erl_copy_term(term) - Creates a copy of an Erlang term + Creates a copy of an Erlang term. ETERM *term; -

This function creates and returns a copy of the Erlang term +

This function creates and returns a copy of the Erlang term .

ETERM *erl_element(position, tuple) - Extracts an element from an Erlang tuple + Extracts an element from an Erlang tuple. int position; ETERM *tuple; @@ -195,38 +195,54 @@ erl_free_compound(list); the arity of .

+ + ETERM *erl_hd(list) + Extracts the first element from a list. + + ETERM *list; + + +

Extracts the first element from a list.

+

is an Erlang term containing a list.

+

The function returns an Erlang term corresponding to the + head element in the list, or a NULL pointer if was + not a list.

+
+
voiderl_init(NULL, 0) - Initialization routine + Initialization routine. void *NULL; int 0; -

This function must be called before any of the others in +

This function must be called before any of the others in the library in order to initialize the - library functions. The arguments must be specified as + library functions. The arguments must be specified as .

- ETERM *erl_hd(list) - Extracts the first element from a list + interl_iolist_length(list) + Return the length of an IO list. ETERM *list; -

Extracts the first element from a list.

-

is an Erlang term containing a list.

-

The function returns an Erlang term corresponding to the - head element in the list, or a NULL pointer if was - not a list.

+

Returns the length of an IO list. +

+

is an Erlang term containing an IO list.

+

The function returns the length of , or -1 if + is not an IO list.

+

Refer to for the definition of + an IO list.

ETERM *erl_iolist_to_binary(term) - Converts an IO list to a binary + Converts an IO list to a binary. ETERM *list; @@ -252,7 +268,7 @@ iohead ::= Binary char *erl_iolist_to_string(list) - Converts an IO list to a zero terminated string + Converts an IO list to a zero terminated string. ETERM *list; @@ -271,25 +287,9 @@ iohead ::= Binary IO list.

- - interl_iolist_length(list) - Return the length of an IO list - - ETERM *list; - - -

Returns the length of an IO list. -

-

is an Erlang term containing an IO list.

-

The function returns the length of , or -1 if - is not an IO list.

-

Refer to for the definition of - an IO list.

-
-
interl_length(list) - Determines the length of a list + Determines the length of a list. ETERM *list; @@ -303,7 +303,7 @@ iohead ::= Binary ETERM *erl_mk_atom(string) - Creates an atom + Creates an atom. const char *string; @@ -324,7 +324,7 @@ iohead ::= Binary ETERM *erl_mk_binary(bptr, size) - Creates a binary object + Creates a binary object. char *bptr; int size; @@ -336,13 +336,13 @@ iohead ::= Binary

indicates the length of .

The function returns an Erlang binary object.

retrieves a pointer to - the binary data. retrieves the + the binary data. retrieves the size.

ETERM *erl_mk_empty_list() - Creates an empty Erlang list + Creates an empty Erlang list.

This function creates and returns an empty Erlang list. Note that NULL is not used to represent an empty list; @@ -351,7 +351,7 @@ iohead ::= Binary ETERM *erl_mk_estring(string, len) - Creates an Erlang string + Creates an Erlang string. char *string; int len; @@ -367,7 +367,7 @@ iohead ::= Binary ETERM *erl_mk_float(f) - Creates an Erlang float + Creates an Erlang float. double f; @@ -385,7 +385,7 @@ iohead ::= Binary ETERM *erl_mk_int(n) - Creates an Erlang integer + Creates an Erlang integer. int n; @@ -395,13 +395,13 @@ iohead ::= Binary

The function returns an Erlang integer object with the value specified in .

-

can be used to retrieve the value +

can be used to retrieve the value value from an Erlang integer.

ETERM *erl_mk_list(array, arrsize) - Creates a list from an array + Creates a list from an array. ETERM **array; int arrsize; @@ -417,9 +417,36 @@ iohead ::= Binary .

+ + ETERM *erl_mk_long_ref(node, n1, n2, n3, creation) + Creates an Erlang reference. + + const char *node; + unsigned int n1, n2, n3; + unsigned int creation; + + +

This function creates an Erlang reference, with 82 bits.

+

is the name of the C node.

+

, and can be seen as one big number + which should be chosen uniquely for + each reference + created for a given C node.

+

is an arbitrary number.

+

Note that and are limited in + precision, so only the low 18 and 2 bits of these numbers + are actually used. +

+

The function returns an Erlang reference object.

+

, , + and + to retrieve the values used + to create the reference.

+
+
ETERM *erl_mk_pid(node, number, serial, creation) - Creates a process identifier + Creates a process identifier. const char *node; unsigned int number; @@ -443,7 +470,7 @@ iohead ::= Binary ETERM *erl_mk_port(node, number, creation) - Creates a port identifier + Creates a port identifier. const char *node; unsigned int number; @@ -464,7 +491,7 @@ iohead ::= Binary ETERM *erl_mk_ref(node, number, creation) - Creates an old Erlang reference + Creates an old Erlang reference. const char *node; unsigned int number; @@ -487,36 +514,9 @@ iohead ::= Binary to create the reference.

- - ETERM *erl_mk_long_ref(node, n1, n2, n3, creation) - Creates an Erlang reference - - const char *node; - unsigned int n1, n2, n3; - unsigned int creation; - - -

This function creates an Erlang reference, with 82 bits.

-

is the name of the C node.

-

, and can be seen as one big number - which should be chosen uniquely for - each reference - created for a given C node.

-

is an arbitrary number.

-

Note that and are limited in - precision, so only the low 18 and 2 bits of these numbers - are actually used. -

-

The function returns an Erlang reference object.

-

, , - and - to retrieve the values used - to create the reference.

-
-
ETERM *erl_mk_string(string) - Creates a string + Creates a string. char *string; @@ -529,7 +529,7 @@ iohead ::= Binary ETERM *erl_mk_tuple(array, arrsize) - Creates an Erlang tuple from an array + Creates an Erlang tuple from an array. ETERM **array; int arrsize; @@ -553,7 +553,7 @@ iohead ::= Binary ETERM *erl_mk_uint(n) - Creates an unsigned integer + Creates an unsigned integer. unsigned int n; @@ -570,7 +570,7 @@ iohead ::= Binary ETERM *erl_mk_var(name) - Creates an Erlang variable + Creates an Erlang variable. char *name; @@ -584,7 +584,7 @@ iohead ::= Binary interl_print_term(stream, term) - Prints an Erlang term + Prints an Erlang term. FILE *stream; ETERM *term; @@ -601,7 +601,7 @@ iohead ::= Binary voiderl_set_compat_rel(release_number) - Set the erl_interface library in compatibility mode + Set the erl_interface library in compatibility mode. unsigned release_number; @@ -633,7 +633,7 @@ iohead ::= Binary interl_size(term) - Return the arity of a tuple or binary + Return the arity of a tuple or binary. ETERM *term; @@ -648,7 +648,7 @@ iohead ::= Binary ETERM *erl_tl(list) - Extracts the tail from a list + Extracts the tail from a list. ETERM *list; @@ -662,14 +662,14 @@ iohead ::= Binary ETERM *erl_var_content(term, name) - Extracts the content of a variable + Extracts the content of a variable. ETERM *term; char *name;

This function returns the contents of the specified - variable in an Erlang term. + variable in an Erlang term.

is an Erlang term. In order for this function to succeed, must be an Erlang variable with the @@ -685,4 +685,3 @@ iohead ::= Binary - diff --git a/lib/erl_interface/doc/src/erl_format.xml b/lib/erl_interface/doc/src/erl_format.xml index 6e3ac4f0c9..ce5163fbc7 100644 --- a/lib/erl_interface/doc/src/erl_format.xml +++ b/lib/erl_interface/doc/src/erl_format.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + erl_format @@ -30,7 +30,7 @@ Torbjörn Törnkvist 961016 A - erl_format.sgml + erl_format.xml erl_format Create and Match Erlang Terms @@ -41,7 +41,7 @@ ETERM *erl_format(FormatStr, ... ) - Creates an Erlang term + Creates an Erlang term. char *FormatStr; @@ -81,7 +81,7 @@ erl_format("[{name,~a},{age,~i},{data,~w}]", erl_format("[{adr,~s,~i}]","E-street",42)); ]]>

This will create an structure corresponding - to the Erlang term: + to the Erlang term:

The function returns an Erlang term, or NULL if does not describe a valid Erlang term.

@@ -89,7 +89,7 @@ erl_format("[{name,~a},{age,~i},{data,~w}]",
interl_match(Pattern, Term) - Performs pattern matching + Performs pattern matching. ETERM *Pattern,*Term; @@ -139,4 +139,3 @@ if (erl_match(pattern2, term2)) {
- diff --git a/lib/erl_interface/doc/src/erl_global.xml b/lib/erl_interface/doc/src/erl_global.xml index d6bfffc69d..69f303722d 100644 --- a/lib/erl_interface/doc/src/erl_global.xml +++ b/lib/erl_interface/doc/src/erl_global.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + erl_global @@ -30,7 +30,7 @@ Gordon Beaton 980703 A - erl_global.sgml + erl_global.xml erl_global Access globally registered names @@ -39,14 +39,14 @@ up and unregistering names in the Erlang Global module. For more information, see the description of Global in the reference manual.

Note that the functions below perform an RPC using an open file - descriptor provided by the caller. This file descriptor must - not be used for other traffic during the global operation or the + descriptor provided by the caller. This file descriptor must + not be used for other traffic during the global operation or the function may receive unexpected data and fail.

char **erl_global_names(fd,count) - Obtain list of Global names + Obtain list of Global names. int fd; int *count; @@ -76,7 +76,7 @@ interl_global_register(fd,name,pid) - Register a name in Global + Register a name in Global. int fd; const char *name; @@ -98,7 +98,7 @@ interl_global_unregister(fd,name) - Unregister a name in Global + Unregister a name in Global. int fd; const char *name; @@ -115,7 +115,7 @@ ETERM *erl_global_whereis(fd,name,node) - Look up a name in global + Look up a name in global. int fd; const char *name; @@ -139,4 +139,3 @@ - diff --git a/lib/erl_interface/doc/src/erl_malloc.xml b/lib/erl_interface/doc/src/erl_malloc.xml index 799c903b1a..ba1f59a492 100644 --- a/lib/erl_interface/doc/src/erl_malloc.xml +++ b/lib/erl_interface/doc/src/erl_malloc.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + erl_malloc @@ -30,7 +30,7 @@ Torbjörn Törnkvist 980703 A - erl_malloc.sgml + erl_malloc.xml erl_malloc Memory Allocation Functions @@ -41,7 +41,7 @@ ETERM *erl_alloc_eterm(etype) - Allocates an ETERM structure + Allocates an ETERM structure. unsigned char etype; @@ -101,9 +101,9 @@ voiderl_eterm_release(void) - Clears the ETERM freelist + Clears the ETERM freelist. -

Clears the +

Clears the freelist, where blocks are placed when they are released by and .

@@ -111,7 +111,7 @@
voiderl_eterm_statistics(allocated, freed) - Reports term allocation statistics + Reports term allocation statistics. long *allocated; long *freed; @@ -126,9 +126,20 @@ .

+ + voiderl_free(ptr) + Frees some memory. + + void *ptr; + + +

This function calls the standard + function.

+
+
voiderl_free_array(array, size) - Frees an array of ETERM structures + Frees an array of ETERM structures. ETERM **array; int size; @@ -140,19 +151,9 @@

is the number of terms in the array.

- - voiderl_free_term(t) - Frees an ETERM structure - - ETERM *t; - - -

Use this function to free an Erlang term.

-
-
voiderl_free_compound(t) - Frees an array of ETERM structures + Frees an array of ETERM structures. ETERM *t; @@ -175,27 +176,25 @@ - voiderl_malloc(size) - Allocates some memory + voiderl_free_term(t) + Frees an ETERM structure. - long size; + ETERM *t; -

This function calls the standard - function.

+

Use this function to free an Erlang term.

- voiderl_free(ptr) - Frees some memory + voiderl_malloc(size) + Allocates some memory. - void *ptr; + long size; -

This function calls the standard - function.

+

This function calls the standard + function.

- diff --git a/lib/erl_interface/doc/src/erl_marshal.xml b/lib/erl_interface/doc/src/erl_marshal.xml index 7c56089016..c70bdb53e1 100644 --- a/lib/erl_interface/doc/src/erl_marshal.xml +++ b/lib/erl_interface/doc/src/erl_marshal.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + erl_marshal @@ -30,7 +30,7 @@ Torbjörn Törnkvist 980703 A - erl_marshal.sgml + erl_marshal.xml erl_marshal Encoding and Decoding of Erlang terms @@ -42,7 +42,7 @@ interl_compare_ext(bufp1, bufp2) - Compares encoded byte sequences + Compares encoded byte sequences. unsigned char *bufp1,*bufp2; @@ -56,14 +56,14 @@ term term2.

The function returns 0 if the terms are equal, -1 if term1 - is less than term2, or 1 if term2 is less than term1. + is less than term2, or 1 if term2 is less than term1.

ETERM *erl_decode(bufp) ETERM *erl_decode_buf(bufpp) - Converts a term from Erlang external format + Converts a term from Erlang external format. unsigned char *bufp; unsigned char **bufpp; @@ -79,7 +79,7 @@

is the address of a buffer pointer. The buffer contains one or more consecutively encoded Erlang terms. - Following a successful call to , + Following a successful call to , will be updated so that it points to the next encoded term.

@@ -96,14 +96,14 @@ interl_encode(term, bufp) interl_encode_buf(term, bufpp) - Converts a term into Erlang external format + Converts a term into Erlang external format. ETERM *term; unsigned char *bufp; unsigned char **bufpp; -

and encode +

and encode Erlang terms into external format for storage or transmission. provides a simple mechanism for encoding several terms consecutively in the same @@ -116,13 +116,13 @@

bufpp is a pointer to a pointer to a buffer containing one or more consecutively encoded Erlang terms. - Following a successful call to , + Following a successful call to , bufpp will be updated so that it points to the position for the next encoded term.

These functions returns the number of bytes written to buffer - if successful, otherwise returns 0. + if successful, otherwise returns 0.

Note that no bounds checking is done on the buffer. It is the caller's responsibility to make sure that the buffer is @@ -165,14 +165,14 @@ is an atom.

The total space required will be the result calculated - from the information above, plus 1 additional byte for a + from the information above, plus 1 additional byte for a version identifier.

interl_ext_size(bufp) - Counts elements in encoded term + Counts elements in encoded term. unsigned char *bufp; @@ -183,7 +183,7 @@ unsigned charerl_ext_type(bufp) - Determines type of an encoded byte sequence + Determines type of an encoded byte sequence. unsigned char *bufp; @@ -230,7 +230,7 @@ unsigned char *erl_peek_ext(bufp, pos) - Steps over encoded term + Steps over encoded term. unsigned char *bufp; int pos; @@ -244,7 +244,7 @@ more encoded Erlang terms.

indicates how many terms to step over in the - buffer. + buffer.

The function returns a pointer to a sub-term that can be used in a subsequent call to in order to retrieve @@ -255,7 +255,7 @@ interl_term_len(t) - Determines encoded size of term + Determines encoded size of term. ETERM *t; @@ -270,4 +270,3 @@ - diff --git a/lib/erl_interface/doc/src/ref_man.xml b/lib/erl_interface/doc/src/ref_man.xml index 0cf060829b..e23f00956a 100644 --- a/lib/erl_interface/doc/src/ref_man.xml +++ b/lib/erl_interface/doc/src/ref_man.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + Erl_Interface Command Reference Gordon Beaton @@ -53,4 +53,3 @@ - diff --git a/lib/erl_interface/doc/src/registry.xml b/lib/erl_interface/doc/src/registry.xml index 285a2402b8..fd3e29c30f 100644 --- a/lib/erl_interface/doc/src/registry.xml +++ b/lib/erl_interface/doc/src/registry.xml @@ -11,7 +11,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software @@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - + registry @@ -30,10 +30,10 @@ Gordon Beaton 980707 A - registry.sgml + registry.xml registry - Store and backup key-value pairs + Store and backup key-value pairs.

This module provides support for storing key-value pairs in a table known as a registry, backing up registries to @@ -41,52 +41,9 @@ registry from Mnesia.

- - ei_reg *ei_reg_open(size) - Create and open a registry - - int size; - - -

Open (create) a registry. The registry will be - initially empty. Use to close the registry - later. -

-

is the approximate number of objects you intend - to store in the registry. Since the registry uses a hash table - with collision chaining, there is no absolute upper limit on the - number of objects that can be stored in it. However for reasons - of efficiency, it is a good idea to choose a number that is - appropriate for your needs. It is possible to use - to change the size later. Note that the - number you provide will be increased to the nearest larger prime - number. -

-

On success, an empty registry will be returned. On failure, NULL - will be returned.

-
-
- - intei_reg_resize(reg,newsize) - Resize a registry - - ei_reg *reg; - int newsize; - - -

Change the size of a registry. -

-

is the new size to make the registry. The - number will be increased to the nearest larger prime number. -

-

On success, the registry will be resized, all contents - rehashed, and the function will return 0. On failure, the - registry will be left unchanged and the function will return -1.

-
-
intei_reg_close(reg) - Close a registry + Close a registry. ei_reg *reg; @@ -101,153 +58,83 @@ - intei_reg_setival(reg,key,i) - Assign an integer object - - ei_reg *reg; - const char *key; - int i; - - -

Create a key-value pair with the specified and integer - value . If an object already existed with the same - , the new value replaces the old one. If the previous - value was a binary or string, it is freed with . -

-

is the registry where the object should be placed. -

-

is the name of the object. -

-

is the integer value to assign. -

-

The function returns 0 on success, or -1 on failure.

-
-
- - intei_reg_setfval(reg,key,f) - Assign a floating point object - - ei_reg *reg; - const char *key; - double f; - - -

Create a key-value pair with the specified and - floating point value . If an object already existed with - the same , the new value replaces the old one. If the - previous value was a binary or string, it is freed with . -

-

is the registry where the object should be placed. -

-

is the name of the object. -

-

is the floating point value to assign. -

-

The function returns 0 on success, or -1 on failure.

-
-
- - intei_reg_setsval(reg,key,s) - Assign a string object - - ei_reg *reg; - const char *key; - const char *s; - - -

Create a key-value pair with the specified whose - "value" is the specified string . If an object already - existed with the same , the new value replaces the old - one. If the previous value was a binary or string, it is freed - with . -

-

is the registry where the object should be placed. -

-

is the name of the object. -

-

is the string to assign. The string itself - must have been created through a single call to or - similar function, so that the registry can later delete it if - necessary by calling . -

-

The function returns 0 on success, or -1 on failure.

-
-
- - intei_reg_setpval(reg,key,p,size) - Assign a binary object + intei_reg_delete(reg,key) + Delete an object from the registry. ei_reg *reg; const char *key; - const void *p; - int size; -

Create a key-value pair with the specified whose - "value" is the binary object pointed to by . If an - object already existed with the same , the new value - replaces the old one. If the previous value was a binary or - string, it is freed with . -

-

is the registry where the object should be placed. +

Delete an object from the registry. The object is not + actually removed from the registry, it is only marked for later + removal so that on subsequent backups to Mnesia, the + corresponding object can be removed from the Mnesia table as + well. If another object is later created with the same key, the + object will be reused.

-

is the name of the object. +

The object will be removed from the registry after a call to + or .

-

is a pointer to the binary object. The object itself - must have been created through a single call to or - similar function, so that the registry can later delete it if - necessary by calling . +

is the registry containing .

-

is the length in bytes of the binary object. +

is the object to remove.

-

The function returns 0 on success, or -1 on failure.

+

If the object was found, the function returns 0 indicating + success. Otherwise the function returns -1.

- intei_reg_setval(reg,key,flags,v,...) - Assign a value to any object type + intei_reg_dump(fd,reg,mntab,flags) + Back up a registry to Mnesia. + int fd; ei_reg *reg; - const char *key; + const char *mntab; int flags; - v (see below) -

Create a key-value pair with the specified whose - value is specified by . If an object already - existed with the same , the new value replaces the old - one. If the previous value was a binary or string, it is freed - with . +

Dump the contents of a registry to a Mnesia table in an + atomic manner, i.e. either all data will be updated, or none of + it will. If any errors are encountered while backing up + the data, the entire operation is aborted.

-

is the registry where the object should be placed. +

is an open connection to Erlang. + Mnesia 3.0 or later must be running on the Erlang node.

-

is the name of the object. +

is the registry to back up.

-

indicates the type of the object specified by - . Flags must be one of EI_INT, EI_FLT, EI_STR and - EI_BIN, indicating whether is , , - or . If is EI_BIN, then a - fifth argument is required, indicating the size - in bytes of the object pointed to by . +

is the name of the Mnesia table where the backed + up data should be placed. If the table does not exist, it will + be created automatically using configurable defaults. See your + Mnesia documentation for information about configuring this + behaviour.

-

If you wish to store an arbitrary pointer in the registry, - specify a of 0. In this case, the object itself will - not be transferred by an operation, just - the pointer value. +

If is 0, the backup will include only those + objects which have been created, modified or deleted since the + last backup or restore (i.e. an incremental backup). After the + backup, any objects that were marked dirty are now clean, and any + objects that had been marked for deletion are deleted. +

+

Alternatively, setting flags to EI_FORCE will cause a full + backup to be done, and EI_NOPURGE will cause the deleted objects + to be left in the registry afterwards. These can be bitwise ORed + together if both behaviours are desired. If EI_NOPURGE was + specified, you can use to explicitly remove + the deleted items from the registry later.

The function returns 0 on success, or -1 on failure.

- intei_reg_getival(reg,key) - Get an integer object + doubleei_reg_getfval(reg,key) + Get a floating point object. ei_reg *reg; const char *key;

Get the value associated with in the - registry. The value must be an integer. + registry. The value must be a floating point type.

is the registry where the object will be looked up. @@ -255,23 +142,23 @@

is the name of the object to look up.

On success, the function returns the value associated with . - If the object was not found or it was not an integer - object, -1 is returned. To avoid problems with in-band error - reporting (i.e. if you cannot distinguish between -1 and a + If the object was not found or it was not a floating point + object, -1.0 is returned. To avoid problems with in-band error + reporting (i.e. if you cannot distinguish between -1.0 and a valid result) use the more general function instead.

- doubleei_reg_getfval(reg,key) - Get a floating point object + intei_reg_getival(reg,key) + Get an integer object. ei_reg *reg; const char *key;

Get the value associated with in the - registry. The value must be a floating point type. + registry. The value must be an integer.

is the registry where the object will be looked up. @@ -279,31 +166,36 @@

is the name of the object to look up.

On success, the function returns the value associated with . - If the object was not found or it was not a floating point - object, -1.0 is returned. To avoid problems with in-band error - reporting (i.e. if you cannot distinguish between -1.0 and a + If the object was not found or it was not an integer + object, -1 is returned. To avoid problems with in-band error + reporting (i.e. if you cannot distinguish between -1 and a valid result) use the more general function instead.

- const char *ei_reg_getsval(reg,key) - Get a string object + const void *ei_reg_getpval(reg,key,size) + Get a binary object. ei_reg *reg; const char *key; + int size;

Get the value associated with in the - registry. The value must be a string. + registry. The value must be a binary (pointer) type.

is the registry where the object will be looked up.

is the name of the object to look up.

+

will be initialized to contain the length in + bytes of the object, if it is found. +

On success, the function returns the value associated with - . If the object was not found or it was not a string, + and indicates its length in . + If the object was not found or it was not a binary object, NULL is returned. To avoid problems with in-band error reporting (i.e. if you cannot distinguish between NULL and a valid result) use the more general function @@ -311,28 +203,23 @@ - const void *ei_reg_getpval(reg,key,size) - Get a binary object + const char *ei_reg_getsval(reg,key) + Get a string object. ei_reg *reg; const char *key; - int size;

Get the value associated with in the - registry. The value must be a binary (pointer) type. + registry. The value must be a string.

is the registry where the object will be looked up.

is the name of the object to look up.

-

will be initialized to contain the length in - bytes of the object, if it is found. -

On success, the function returns the value associated with - and indicates its length in . - If the object was not found or it was not a binary object, + . If the object was not found or it was not a string, NULL is returned. To avoid problems with in-band error reporting (i.e. if you cannot distinguish between NULL and a valid result) use the more general function @@ -341,7 +228,7 @@ intei_reg_getval(reg,key,flags,v,...) - Get any object + Get any object. ei_reg *reg; const char *key; @@ -350,7 +237,7 @@

This is a general function for retrieving any kind of - object from the registry. + object from the registry.

is the registry where the object will be looked up. @@ -376,7 +263,7 @@ intei_reg_markdirty(reg,key) - Mark an object as dirty + Mark an object as dirty. ei_reg *reg; const char *key; @@ -390,7 +277,7 @@ registry and modified the contents, then the change will be invisible to the registry and the object will be assumed to be unmodified. This function allows you to make such modifications - and then let the registry know about them. + and then let the registry know about them.

is the registry containing the object.

@@ -400,34 +287,248 @@
- intei_reg_delete(reg,key) - Delete an object from the registry + ei_reg *ei_reg_open(size) + Create and open a registry. - ei_reg *reg; - const char *key; + int size; -

Delete an object from the registry. The object is not - actually removed from the registry, it is only marked for later - removal so that on subsequent backups to Mnesia, the - corresponding object can be removed from the Mnesia table as - well. If another object is later created with the same key, the - object will be reused. -

-

The object will be removed from the registry after a call to - or . -

-

is the registry containing . +

Open (create) a registry. The registry will be + initially empty. Use to close the registry + later.

-

is the object to remove. +

is the approximate number of objects you intend + to store in the registry. Since the registry uses a hash table + with collision chaining, there is no absolute upper limit on the + number of objects that can be stored in it. However for reasons + of efficiency, it is a good idea to choose a number that is + appropriate for your needs. It is possible to use + to change the size later. Note that the + number you provide will be increased to the nearest larger prime + number.

-

If the object was found, the function returns 0 indicating - success. Otherwise the function returns -1.

+

On success, an empty registry will be returned. On failure, NULL + will be returned.

+
+
+ + intei_reg_purge(reg) + Remove deleted objects. + + ei_reg *reg; + + +

Remove all objects marked for deletion. When objects + are deleted with they are not actually + removed from the registry, only marked for later removal. This + is so that on a subsequent backup to Mnesia, the + objects can also be removed from the Mnesia table. If you are + not backing up to Mnesia then you may wish to remove the objects + manually with this function. +

+

is a registry containing objects marked for + deletion. +

+

The function returns 0 on success, or -1 on failure.

+
+
+ + intei_reg_resize(reg,newsize) + Resize a registry. + + ei_reg *reg; + int newsize; + + +

Change the size of a registry. +

+

is the new size to make the registry. The + number will be increased to the nearest larger prime number. +

+

On success, the registry will be resized, all contents + rehashed, and the function will return 0. On failure, the + registry will be left unchanged and the function will return -1.

+
+
+ + intei_reg_restore(fd,reg,mntab) + Restore a registry from Mnesia. + + int fd; + ei_reg *reg; + const char *mntab; + + +

The contents of a Mnesia table are read into the + registry. +

+

is an open connection to Erlang. + Mnesia 3.0 or later must be running on the Erlang node. +

+

is the registry where the data should be placed. +

+

is the name of the Mnesia table to read data + from. +

+

Note that only tables of a certain format can be + restored, i.e. those that have been created and backed up to + with . If the registry was not empty before + the operation, then the contents of the table are added to the + contents of the registry. If the table contains objects with the + same keys as those already in the registry, the registry objects + will be overwritten with the new values. If the registry + contains objects that were not in the table, they will be + unchanged by this operation. +

+

After the restore operation, the entire contents of the + registry is marked as unmodified. Note that this includes any + objects that were modified before the restore and not + overwritten by the restore. +

+

The function returns 0 on success, or -1 on failure.

+
+
+ + intei_reg_setfval(reg,key,f) + Assign a floating point object. + + ei_reg *reg; + const char *key; + double f; + + +

Create a key-value pair with the specified and + floating point value . If an object already existed with + the same , the new value replaces the old one. If the + previous value was a binary or string, it is freed with . +

+

is the registry where the object should be placed. +

+

is the name of the object. +

+

is the floating point value to assign. +

+

The function returns 0 on success, or -1 on failure.

+
+
+ + intei_reg_setival(reg,key,i) + Assign an integer object. + + ei_reg *reg; + const char *key; + int i; + + +

Create a key-value pair with the specified and integer + value . If an object already existed with the same + , the new value replaces the old one. If the previous + value was a binary or string, it is freed with . +

+

is the registry where the object should be placed. +

+

is the name of the object. +

+

is the integer value to assign. +

+

The function returns 0 on success, or -1 on failure.

+
+
+ + intei_reg_setpval(reg,key,p,size) + Assign a binary object. + + ei_reg *reg; + const char *key; + const void *p; + int size; + + +

Create a key-value pair with the specified whose + "value" is the binary object pointed to by . If an + object already existed with the same , the new value + replaces the old one. If the previous value was a binary or + string, it is freed with . +

+

is the registry where the object should be placed. +

+

is the name of the object. +

+

is a pointer to the binary object. The object itself + must have been created through a single call to or + similar function, so that the registry can later delete it if + necessary by calling . +

+

is the length in bytes of the binary object. +

+

The function returns 0 on success, or -1 on failure.

+
+
+ + intei_reg_setsval(reg,key,s) + Assign a string object. + + ei_reg *reg; + const char *key; + const char *s; + + +

Create a key-value pair with the specified whose + "value" is the specified string . If an object already + existed with the same , the new value replaces the old + one. If the previous value was a binary or string, it is freed + with . +

+

is the registry where the object should be placed. +

+

is the name of the object. +

+

is the string to assign. The string itself + must have been created through a single call to or + similar function, so that the registry can later delete it if + necessary by calling . +

+

The function returns 0 on success, or -1 on failure.

+
+
+ + intei_reg_setval(reg,key,flags,v,...) + Assign a value to any object type. + + ei_reg *reg; + const char *key; + int flags; + v (see below) + + +

Create a key-value pair with the specified whose + value is specified by . If an object already + existed with the same , the new value replaces the old + one. If the previous value was a binary or string, it is freed + with . +

+

is the registry where the object should be placed. +

+

is the name of the object. +

+

indicates the type of the object specified by + . Flags must be one of EI_INT, EI_FLT, EI_STR and + EI_BIN, indicating whether is , , + or . If is EI_BIN, then a + fifth argument is required, indicating the size + in bytes of the object pointed to by . +

+

If you wish to store an arbitrary pointer in the registry, + specify a of 0. In this case, the object itself will + not be transferred by an operation, just + the pointer value. +

+

The function returns 0 on success, or -1 on failure.

intei_reg_stat(reg,key,obuf) - Get object information + Get object information. ei_reg *reg; const char *key; @@ -452,7 +553,7 @@ struct ei_reg_stat {

In the object's attributes are stored as the logical OR of its type (one of EI_INT, EI_FLT, EI_BIN and EI_STR), whether it is marked for deletion (EI_DELET) and whether it has - been modified since the last backup to Mnesia (EI_DIRTY). + been modified since the last backup to Mnesia (EI_DIRTY).

The field indicates the size in bytes required to store EI_STR (including the terminating 0) and EI_BIN objects, or 0 @@ -464,7 +565,7 @@ struct ei_reg_stat { intei_reg_tabstat(reg,obuf) - Get registry information + Get registry information. ei_reg *reg; struct ei_reg_tabstat *obuf; @@ -496,7 +597,7 @@ struct ei_reg_tabstat { registry. It includes objects that are deleted but not purged.

indicates the number of unique positions that are - occupied in the registry. + occupied in the registry.

indicates how many elements are sharing positions in the registry. @@ -506,107 +607,5 @@ struct ei_reg_tabstat { returns -1.

- - intei_reg_dump(fd,reg,mntab,flags) - Back up a registry to Mnesia - - int fd; - ei_reg *reg; - const char *mntab; - int flags; - - -

Dump the contents of a registry to a Mnesia table in an - atomic manner, i.e. either all data will be updated, or none of - it will. If any errors are encountered while backing up - the data, the entire operation is aborted. -

-

is an open connection to Erlang. - Mnesia 3.0 or later must be running on the Erlang node. -

-

is the registry to back up. -

-

is the name of the Mnesia table where the backed - up data should be placed. If the table does not exist, it will - be created automatically using configurable defaults. See your - Mnesia documentation for information about configuring this - behaviour. -

-

If is 0, the backup will include only those - objects which have been created, modified or deleted since the - last backup or restore (i.e. an incremental backup). After the - backup, any objects that were marked dirty are now clean, and any - objects that had been marked for deletion are deleted. -

-

Alternatively, setting flags to EI_FORCE will cause a full - backup to be done, and EI_NOPURGE will cause the deleted objects - to be left in the registry afterwards. These can be bitwise ORed - together if both behaviours are desired. If EI_NOPURGE was - specified, you can use to explicitly remove - the deleted items from the registry later. -

-

The function returns 0 on success, or -1 on failure.

-
-
- - intei_reg_restore(fd,reg,mntab) - Restore a registry from Mnesia - - int fd; - ei_reg *reg; - const char *mntab; - - -

The contents of a Mnesia table are read into the - registry. -

-

is an open connection to Erlang. - Mnesia 3.0 or later must be running on the Erlang node. -

-

is the registry where the data should be placed. -

-

is the name of the Mnesia table to read data - from. -

-

Note that only tables of a certain format can be - restored, i.e. those that have been created and backed up to - with . If the registry was not empty before - the operation, then the contents of the table are added to the - contents of the registry. If the table contains objects with the - same keys as those already in the registry, the registry objects - will be overwritten with the new values. If the registry - contains objects that were not in the table, they will be - unchanged by this operation. -

-

After the restore operation, the entire contents of the - registry is marked as unmodified. Note that this includes any - objects that were modified before the restore and not - overwritten by the restore. -

-

The function returns 0 on success, or -1 on failure.

-
-
- - intei_reg_purge(reg) - Remove deleted objects - - ei_reg *reg; - - -

Remove all objects marked for deletion. When objects - are deleted with they are not actually - removed from the registry, only marked for later removal. This - is so that on a subsequent backup to Mnesia, the - objects can also be removed from the Mnesia table. If you are - not backing up to Mnesia then you may wish to remove the objects - manually with this function. -

-

is a registry containing objects marked for - deletion. -

-

The function returns 0 on success, or -1 on failure.

-
-
- -- cgit v1.2.3