From 031f9ca91ade7fbb9e31c82545401b8a5531e539 Mon Sep 17 00:00:00 2001
From: xsipewe The library With It also handles C-nodes, C-programs that talks erlang
- distribution with erlang nodes (or other C-nodes) using the
- erlang distribution format. The difference between The decode and encode functions use a buffer an index into the
+ The decode and encode functions use a buffer and an index into the
buffer, which points at the point where to encode and
decode. The index is updated to point right after the term
encoded/decoded. No checking is done whether the term fits in
the buffer or not. If encoding goes outside the buffer, the
- program may crash. All functions takes two parameter, The encode functions all assumes that the All functions take two parameters: The data is thus at All encode functions assume that the There are also encode-functions that uses a dynamic buffer. It
+
+ There are also encode functions that use a dynamic buffer. It
is often more convenient to use these to encode data. All encode
- functions comes in two versions: those starting with All functions return Some of the decode-functions needs a preallocated buffer. This
- buffer must be allocated big enough, and for non compound types
+ functions comes in two versions; those starting with
+ All functions return Some of the decode functions need a pre-allocated buffer. This
+ buffer must be allocated large enough, and for non-compound types
the The character encodings used for atoms. The character encodings used for atoms. This function decodes an atom from the binary format. The
- null terminated name of the atom is placed at Decodes an atom from the binary format. The This function decodes an atom from the binary format. The
- null terminated name of the atom is placed in buffer at The wanted string encoding is specified by Decodes an atom from the binary format. The The wanted string encoding is specified by
+ This function fails if the atom is too long for the buffer
- or if it can not be represented with encoding This function was introduced in R16 release of Erlang/OTP as part of a first step
- to support UTF8 atoms.
+
+
+
typedef enum {
ERLANG_ASCII = 1,
ERLANG_LATIN1 = 2,
ERLANG_UTF8 = 4
-}erlang_char_encoding;
-
-
This function was introduced in Erlang/OTP R16 as part of a first + step to support UTF-8 atoms.
+This function decodes an integer in the binary format to a GMP
Decodes an integer in the binary format to a GMP
+
This function decodes a binary from the binary format. The
-
Decodes a binary from the binary format. Parameter
+
This function decodes a boolean value from the binary
- format. A boolean is actually an atom,
Decodes a boolean value from the binary format.
+ A boolean is actually an atom,
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
Decodes a char (8-bit) integer between 0-255 from the binary format.
+ For historical reasons the returned integer is of
+ type
This function decodes an double-precision (64 bit) floating +
Decodes a double-precision (64-bit) floating point number from the binary format.
This function decodes any term, or at least tries to. If the
- term pointed at by
The function returns 1 on successful decoding, -1 on error,
- and 0 if the term seems alright, but does not fit in the
-
The
Decodes any term, or at least tries to. If the term
+ pointed at by
The function returns
The
This function decodes a fun from the binary format. The
-
Decodes a fun from the binary format. Parameter
+
This function decodes a list header from the binary +
Decodes a list header from the binary
format. The number of elements is returned in
-
Note that lists are encoded as strings, if they consist
- entirely of integers in the range 0..255. This function will
+
Notice that lists are encoded as strings if they consist
+ entirely of integers in the range 0..255. This function do
not decode such strings, use
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().
+Decodes a long integer from the binary format.
+ If the code is 64 bits, the function
This function decodes a GCC
Decodes a GCC
This function decodes a map header from the binary +
Decodes a map header from the binary
format. The number of key-value pairs is returned in
-
Decodes a pid, process identifier, from the binary format.
+Decodes a process identifier (pid) from the binary format.
This function decodes a port identifier from the binary - format.
+Decodes a port identifier from the binary format.
This function decodes a reference from the binary format.
+Decodes a reference from the binary format.
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 +
Decodes a string from the binary format. A
+ string in Erlang is a list of integers between 0 and
+ 255. Notice that as the string is just a list, sometimes
lists are encoded as strings by
The string is copied to
The string is copied to
This function decodes a term from the binary format. The
- term is return in
Note that this function is located in the erl_interface +
Decodes a term from the binary format. The term
+ is return in
Notice that this function is located in the
Decodes an erlang trace token from the binary format.
+Decodes an Erlang trace token from the binary format.
This function decodes a tuple header, the number of elements
- is returned in
Decodes a tuple header, the number of elements
+ is returned in
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().
+Decodes an unsigned long integer from the binary format.
+ If the code is 64 bits, the function
This function decodes a GCC
Decodes a GCC
This function decodes the version magic number for the - erlang binary term format. It must be the first token in a +
Decodes the version magic number for the + Erlang binary term format. It must be the first token in a binary term.
Encodes an atom in the binary format. The
Encodes an atom in the binary format. Parameter
Encodes an atom in the binary format with character encoding
-
The encoding will fail if
These functions were introduced in R16 release of Erlang/OTP as part of a first step
- to support UTF8 atoms. Atoms encoded with
The encoding fails if
These functions were introduced in Erlang/OTP R16 as part of a first
+ step to support UTF-8 atoms. Atoms encoded with
Encodes a GMP
Encodes a boolean value, as the atom
Encodes a boolean value as the atom
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
Encodes a char (8-bit) as an integer between 0-255 in the binary
+ format. For historical reasons the integer argument is of
+ type
Encodes a double-precision (64 bit) floating point number in +
Encodes a double-precision (64-bit) floating point number in the binary format.
-
- The function returns
Returns
This function encodes an empty list. It's often used at the - tail of a list.
+Encodes an empty list. It is often used at the tail of a list.
Encodes a fun in the binary format. The
Encodes a fun in the binary format. Parameter
This function encodes a list header, with a specified +
Encodes a list header, with a specified
arity. The next
E.g. to encode the list
For example, to encode the list
+
ei_encode_list_header(buf, &i, 3); ei_encode_atom(buf, &i, "c"); @@ -486,14 +539,13 @@ ei_encode_atom(buf, &i, "d"); ei_encode_list_header(buf, &i, 1); ei_encode_atom(buf, &i, "e"); ei_encode_atom(buf, &i, "f"); -ei_encode_empty_list(buf, &i); -+ei_encode_empty_list(buf, &i);
It may seem that there is no way to create a list without
knowing the number of elements in advance. But indeed
- there is a way. Note that the list
To encode a list, without knowing the arity in advance:
@@ -501,83 +553,89 @@ while (something()) {
ei_x_encode_list_header(&x, 1);
ei_x_encode_ulong(&x, i); /* just an example */
}
-ei_x_encode_empty_list(&x);
-
+ei_x_encode_empty_list(&x);
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().
+ If the code is 64 bits, the functionEncodes a GCC
Encodes a GCC
This function encodes a map header, with a specified arity. The next +
Encodes a map header, with a specified arity. The next
E.g. to encode the map
For example, to encode the map
ei_x_encode_map_header(&x, 2); ei_x_encode_atom(&x, "a"); ei_x_encode_string(&x, "Apple"); ei_x_encode_atom(&x, "b"); -ei_x_encode_string(&x, "Banana"); --
A correctly encoded map can not have duplicate keys.
+ei_x_encode_string(&x, "Banana"); +A correctly encoded map cannot have duplicate keys.
Encodes an erlang process identifier, pid, in the binary
- format. The
Encodes an Erlang process identifier (pid) in the binary
+ format. Parameter
Encodes an erlang port in the binary format. The
Encodes an Erlang port in the binary format. Parameter
+
Encodes an erlang reference in the binary format. The
-
Encodes an Erlang reference in the binary format. Parameter
+
Encodes a string in the binary format. (A string in erlang +
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
+ format.) The string is to be zero-terminated, except for
the
This function encodes an
Encodes an
This function encodes an erlang trace token in the binary
- format. The
Encodes an Erlang trace token in the binary format.
+ Parameter
This function encodes a tuple header, with a specified +
Encodes a tuple header, with a specified
arity. The next
E.g. to encode the tuple
For example, 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); -+ei_encode_tuple_header(buf, &i, 0);
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().
+ If the code is 64 bits, the functionEncodes a GCC
Encodes a GCC
This function returns the type in
Returns the type in
This function prints a term, in clear text, to the file
- given by
In
Prints a term, in clear text, to the file
+ specified by
In
The return value is the number of characters written to the
- file or string, or -1 if
The argument
The return value is the number of characters written to the file
+ or string, or
Argument
By default, the
A call to
A call to
If this function is called, it may only be called once
- and must be called before any other functions in the
If this function is called, it can only be called once
+ and must be called before any other functions in the
+
You may run into trouble if this feature is used - carelessly. Always make sure that all communicating +
You can run into trouble if this feature is used + carelessly. Always ensure 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 skips a term in the given buffer, it +
Skips a term in the specified buffer; 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.
+ Erlang term.This can be useful when you want to hold arbitrary - terms: just skip them and copy the binary term data to some + terms: skip them and copy the binary term data to some buffer.
The function returns
Returns
These functions appends data at the end of the buffer
Appends data at the end of buffer
Format a term, given as a string, to a buffer. This - functions works like a sprintf for erlang terms. The +
Formats a term, given as a string, to a buffer.
+ Works like a sprintf for Erlang terms.
-~a - an atom, char* -~c - a character, char -~s - a string, char* -~i - an integer, int -~l - a long integer, long int -~u - a unsigned long integer, unsigned long int -~f - a float, float -~d - a double float, double float -~p - an Erlang PID, erlang_pid* --
For instance, to encode a tuple with some stuff:
+~a An atom, char* +~c A character, char +~s A string, char* +~i An integer, int +~l A long integer, long int +~u A unsigned long integer, unsigned long int +~f A float, float +~d A double float, double float +~p An Erlang pid, erlang_pid* +For example, to encode a tuple with some stuff:
ei_x_format("{~a,~i,~d}", "numbers", 12, 3.14159)
-encodes the tuple {numbers,12,3.14159}
-
- The
This function frees an
Frees an
This function allocates a new
Allocates a new
Some tips on what to check when the emulator doesn't seem to - receive the terms that you send.
+Some tips on what to check when the emulator does not seem to + receive the terms that you send:
+erl_interface(3)
+This module enables C programs to communicate with erlang nodes, - using the erlang distribution over TCP/IP.
-A C node appears to Erlang as a - hidden node. +
This module enables C-programs to communicate with Erlang nodes, + using the Erlang distribution over TCP/IP.
+ +A C-node appears to Erlang as a hidden node.
That is, Erlang processes that know the name of the
- C node are able to communicate with it in a normal manner, but
- the node name will not appear in the listing provided by the
- Erlang function
The environment variable
Most functions appear in a version with the suffix
-
Obviously the timeouts are for implementing fault tolerance,
- not to keep hard realtime promises. The
Clearly the time-outs are for implementing fault tolerance,
+ not to keep hard real-time promises. The
A timeout value of
As with all other ei functions, you are not expected - to put the socket in non blocking mode yourself in the program. Every - use of non blocking mode is embedded inside the timeout + socket operations.
+ +A time-out value of
As with all other functions starting with
In all other senses, the
These are convenience functions for some common name lookup functions.
+Convenience functions for some common name lookup functions.
This function is used by a server process to accept a +
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 .
ei_accept with an optional timeout argument, - see the description at the beginning of this document.
+Equivalent to
+
These functions set up a connection to an Erlang node.
-Sets up a connection to an Erlang 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
Additionally,
Also,
Example:
+Example:
These function initializes the
Initializes the
A C node acting as a server will be assigned a creation
+ must be called before other functions that works on the
+
A C-node acting as a server is assigned a creation
number when it calls
A connection is closed by simply closing the socket. Refer - to system documentation to close the socket gracefully (when - there are outgoing packets before close).
-This function return a negative value indicating that an error +
A connection is closed by simply closing the socket. + For information about how to close the socket gracefully (when + there are outgoing packets before close), see the relevant system + documentation.
+These functions return a negative value indicating that an error occurred.
-Example 1: -
+Example 1:
- Example 2: -
+Example 2:
ei_connect and ei_xconnect with an optional timeout argument, - see the description at the beginning of this document.
+Equivalent to
+
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
Used to set tracing on the distribution. The levels are different
+ verbosity levels. A higher level means more information. See also
+ section
These functions are not thread safe.
These functions are used by a server process to register +
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
To unregister with epmd, simply close the returned
- descriptor. Do not use
On success, the functions return a descriptor connecting the
- calling process to epmd. On failure, they return -1 and set
-
Additionally,
To unregister with EPMD, simply close the returned descriptor. Do
+ not use
On success, the function returns a descriptor connecting the
+ calling process to EPMD. On failure,
Also,
ei_publish with an optional timeout argument, - see the description at the beginning of this document.
+Equivalent to
+
This function receives a message consisting of a sequence +
Receives a message consisting of a sequence of bytes in the Erlang external format.
-If a tick occurs, i.e., the Erlang node on the
+
+
+
If a tick occurs, that is, the Erlang node on the
other end of the connection has polled this node to see if it
- is still alive, the function will return
On success, the message is placed in the specified buffer
and the function returns the number of bytes actually read. On
- failure, the function returns
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
-
Furthermore the function returns either ERL_TICK or the
-
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.
+In essence, the function performs the same operation as
+
Returns either
It is recommended to use
ei_receive_encoded with an optional timeout argument, - see the description at the beginning of this document.
+Equivalent to
+
These functions receives a message to the buffer in
-
On success, the function returns
Receives a message to the buffer in
On success, the functions return
- If
If
If
The return value is the same as for
Indicates that an ordinary send operation has occurred.
+
A registered send operation occurred.
+
Indicates a broken link.
The return value is the same as for
+
ei_receive_msg and ei_xreceive_msg with an optional timeout argument, - see the description at the beginning of this document.
+Equivalent to
ei_receive with an optional timeout argument, - see the description at the beginning of this document.
+Equivalent to
+
This function sends an Erlang term to a registered process. -
-This function sends an Erlang term to a process.
-The function returns 0 if successful, otherwise -1, in the
- latter case it will set
Example, send the atom "ok" to the process "worker":
+Sends an Erlang term to a registered process.
+Returns
Example:
+Send the atom "ok" to the process "worker":
ei_reg_send with an optional timeout argument, - see the description at the beginning of this document.
+Equivalent to
+
These functions support calling Erlang functions on remote nodes.
-
Supports calling Erlang functions on remote nodes.
+
Example, check to see if an erlang process is alive:
+Example:
+Check to see if an Erlang process is alive:
This function retrieves the Pid of the C-node. Every C-node
- has a (pseudo) pid used in
Retrieves the pid of the C-node. Every C-node
+ has a (pseudo) pid used in
This function sends an Erlang term to a process.
-The function returns 0 if successful, otherwise -1, in the
- latter case it will set
Sends an Erlang term to a process.
+Returns
Works exactly as ei_send, the alternative name retained for +
Works exactly as
ei_send_encoded with an optional timeout argument, - see the description at the beginning of this document.
+Equivalent 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
A suitable
num = fd;
+ei_cnode ec;
+erlang_pid *self;
+int fd; /* the connection fd */
+...
+self = ei_self(&ec);
+self->num = fd;
]]>
ei_send_reg_encoded with an optional timeout argument, - see the description at the beginning of this document.
+Equivalent to
+
ei_send with an optional timeout argument, - see the description at the beginning of this document.
+Equivalent to
+
These functions can be used to retrieve information about
- the C Node. These values are initially set with
-
They simply fetches the appropriate field from the
Can be used to retrieve information about
+ the C-node. These values are initially set with
+
These function simply fetch the appropriate field from the
+
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 +
Can be called by a process to unregister a
+ specified node from EPMD on the local host. This is, however, usually
+ not allowed, unless EPMD was started with flag
+
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.
If the node was successfully unregistered from epmd, the
- function returns 0. Otherwise, it returns -1 and sets
-
If the node was successfully unregistered from EPMD, the
+ function returns
ei_unpublish with an optional timeout argument, - see the description at the beginning of this document.
+Equivalent to
+
If a connection attempt fails, the following can be checked:
+The connection attempt can be traced by setting a tracelevel by either using
-
The connection attempt can be traced by setting a trace level by either
+ using
The Erl_Interface library contains functions. which help you - integrate programs written in C and Erlang. The functions in - Erl_Interface support the following:
-In the following sections, these topics are described:
-The
By default, the
In the following sections, these topics are described:
+It is assumed that the reader is familiar with the Erlang programming + language.
+In order to use any of the Erl_Interface functions, include the +
To use any of the
- Determine where the top directory of your OTP installation is. You - can find this out by starting Erlang and entering the following + +
Determine where the top directory of your OTP installation is. + To find this, start Erlang and enter the following command at the Eshell prompt:
+ code:root_dir().
/usr/local/otp ]]>
- To compile your code, make sure that your C compiler knows where
- to find
To compile your code, ensure that your C compiler knows where
+ to find
Vsn is the version of the
Compiling the code:
+
- When linking, you will need to specify the path to
-
When linking:
+ +Do this on the command line or add the flags to the
+
Linking the code:
+
- Also, on some systems it may be necessary to link with some
- additional libraries (e.g.
If you are using Erl_Interface functions in a threaded + +
On some systems it can be necessary to link with some more
+ libraries (for example,
If you use the
Before calling any of the other Erl_Interface functions, you
- must call
Before calling any of the other
Data sent between distributed Erlang nodes is encoded in the - Erlang external format. Consequently, you have to encode and decode + Erlang external format. You must therefore encode and decode Erlang terms into byte streams if you want to use the distribution - protocol to communicate between a C program and Erlang.
-The Erl_Interface library supports this activity. It has a - number of C functions which create and manipulate Erlang data + protocol to communicate between a C program and Erlang.
+ +The
+
Alternatively, you can use
Refer to the Reference Manual for a complete description of the - following modules:
+For a complete description, see the following modules:
The previous example can be simplified by using
-
The previous example can be simplified by using the
+ erl_format module
+ to create an Erlang term:
+
- Refer to the Reference Manual, the module, for a
- full description of the different format directives. The following
- example is more complex:
- For a complete description of the different format directives, see
+ the erl_format module.
+
+ The following example is more complex:
+
+
- As in previous examples, it is your responsibility to free the
- memory allocated for Erlang terms. In this example,
- ensures that the complete term pointed to
- by is released. This is necessary, because the pointer from
- the second call to is lost.
- The following
- example shows a slightly different solution:
- As in the previous examples, it is your responsibility to free the
+ memory allocated for Erlang terms. In this example,
+ ensures that the complete term
+ pointed to by is released. This is necessary
+ because the pointer from the second call to erl_format is lost.
+
+ The following example shows a slightly different solution:
+
+
+
In this case, you free the two terms independently. The order in
- which you free the terms and is not important,
- because the Erl_Interface library uses reference counting to
- determine when it is safe to actually remove objects.
- If you are not sure whether you have freed the terms properly, you
+ which you free the terms and
+ is not important,
+ because the Erl_Interface library uses reference counting to
+ determine when it is safe to remove objects.
+
+ If you are unsure whether you have freed the terms properly, you
can use the following function to see the status of the fixed term
allocator:
+
- Refer to the Reference Manual, the module for more
- information.
+
+ For more information, see the
+ erl_malloc module.
An Erlang pattern is a term that may contain unbound variables or
-
An Erlang pattern is a term that can contain unbound variables or
+
+
- is used to perform pattern matching. It takes a
+
+
The
+ erl_format:erl_match function
+ performs pattern matching. It takes a
pattern and a term and tries to match them. As a side effect any unbound
- variables in the pattern will be bound. In the following example, we
- create a pattern with a variable Age which appears at two
+ variables in the pattern will be bound. In the following example, a
+ pattern is created with a variable Age , which is included at two
positions in the tuple. The pattern match is performed as follows:
-
- will bind the contents of
- Age to 21 the first time it reaches the variable
- - the second occurrence of Age will cause a test for
- equality between the terms since Age is already bound to
- 21. Since Age is bound to 21, the equality test will
- succeed and the match continues until the end of the pattern.
- - if the end of the pattern is reached, the match succeeds and you
- can retrieve the contents of the variable
+
+
+ -
+
erl_match binds the contents of Age to 21
+ the first time it reaches the variable.
+
+ -
+
The second occurrence of Age causes a test for
+ equality between the terms, as Age is already bound to
+ 21 . As Age is bound to 21 , the equality test
+ succeeds and the match continues until the end of the pattern.
+
+ -
+
If the end of the pattern is reached, the match succeeds and you
+ can retrieve the contents of the variable.
+
+
- Refer to the Reference Manual, the function for
- more information.
+
+ For more information, see the
+
+ erl_format:erl_match function.
In order to connect to a distributed Erlang node you need to first
- initialize the connection routine with
To connect to a distributed Erlang node, you must first
+ initialize the connection routine with
+
- Refer to the Reference Manual, the
For more information, see the
+
After initialization, you set up the connection to the Erlang node.
- Use
- When you use
When you use
+
C nodes can also register themselves with
C nodes can also register themselves with
Before registering with
Before registering with
- Be aware that on some systems (such as VxWorks), a failed node will - not be detected by this mechanism since the operating system does not + +
Notice that on some systems (such as VxWorks), a failed node is
+ not detected by this mechanism, as the operating system does not
automatically close descriptors that were left open when the node
- failed. If a node has failed in this way,
- This will cause
This causes
Use one of the following two functions to send messages:
+As in Erlang, it is possible to send messages to a - Pid or to a registered name. It is easier to send a - message to a registered name because it avoids the problem of finding - a suitable Pid.
+ +As in Erlang, messages can be sent to a + pid or to a registered name. It is easier to send a + message to a registered name, as it avoids the problem of finding + a suitable pid.
+Use one of the following two functions to receive messages:
+In the following example,
+
The first element of the tuple that is sent is your own
- Pid. This enables
In this example
In this example,
- In order to provide robustness, a distributed Erlang node
- occasionally polls all its connected neighbours in an attempt to
- detect failed nodes or communication links. A node which receives such
- a message is expected to respond immediately with an
To provide robustness, a distributed Erlang node
+ occasionally polls all its connected neighbors in an attempt to
+ detect failed nodes or communication links. A node that receives such
+ a message is expected to respond immediately with an
+
When a message has been received, it is the caller's responsibility
- to free the received message
Refer to the Reference Manual for additional information about the - following modules:
-For more information, see the
+
An Erlang node acting as a client to another Erlang node typically sends a request and waits for a reply. Such a request is included in a function call at a remote node and is called a remote - procedure call. The following example shows how the - Erl_Interface library supports remote procedure calls:
-
+ The following example shows how the
+ Erl_Interface library supports remote procedure calls:
+
+ compiler errors !\n");
erl_free_term(ep);
erl_free_term(reply); ]]>
- is called to compile the specified module on the
- remote node. checks that the compilation was
+
+
is called to compile the specified module on
+ the remote node. checks that the
+ compilation was
successful by testing for the expected .
- Refer to the Reference Manual, the module for
- more information about , and its companions
- and .
+
+ For more information about and its
+ companions and
+ , see the
+ erl_connect module.
A C node has access to names registered through the Erlang Global +
A C node has access to names registered through the
+
Erl_Interface does not provide a native implementation of the global - service. Instead it uses the global services provided by a "nearby" - Erlang node. In order to use the services described in this section, + nodes.
+ +To see what names there are:
+
- It is the caller's responsibility to free the array.
-
To look up one of the names:
+
- If
If
Before registering a name, you should already have registered your
- port number with
Create a pid that Erlang processes can use to communicate with your service:
+
- After registering the name, you should use
Do not forget to free
After registering the name, use
+
Remember to free
To unregister a name:
+
This section describes the use of the registry, a simple mechanism for storing key-value pairs in a C-node, as well as backing them up or - restoring them from a Mnesia table on an Erlang node. More detailed - information about the individual API functions can be found in the - Reference Manual.
-Keys are strings, i.e. 0-terminated arrays of characters, and values
- are arbitrary objects. Although integers and floating point numbers
+ restoring them from an
Keys are strings, that is, zero-terminated arrays of characters, and + values are arbitrary objects. Although integers and floating point numbers are treated specially by the registry, you can store strings or binary objects of any type as pointers.
-To start, you need to open a registry:
+ +To start, open a registry:
+
- The number 45 in the example indicates the approximate number of + +
The number
You can open as many registries as you like (if memory permits).
-Objects are stored and retrieved through set and get functions. In - the following examples you see how to store integers, floats, strings + +
Objects are stored and retrieved through set and get functions. + The following example shows how to store integers, floats, strings, and arbitrary binary objects:
+l = 42;
b->m = 12;
ei_reg_setpval(reg,"jox",b,sizeof(*b)); ]]>
- If you attempt to store an object in the registry and there is an - existing object with the same key, the new value will replace the old + +
If you try to store an object in the registry and there is an + existing object with the same key, the new value replaces the old one. This is done regardless of whether the new object and the old one have the same type, so you can, for example, replace a string with an - integer. If the existing value is a string or binary, it will be freed + integer. If the existing value is a string or binary, it is freed before the new value is assigned.
+Stored values are retrieved from the registry as follows:
+
- In all of the above examples, the object must exist and it must be of + +
In all the above examples, the object must exist and it must be of the right type for the specified operation. If you do not know the - type of a given object, you can ask:
+ type of an object, you can ask: +
- Buf will be initialized to contain object attributes.
+ +Buf is initialized to contain object attributes.
+Objects can be removed from the registry:
+
+
When you are finished with a registry, close it to remove all the objects and free the memory back to the system:
+
The contents of a registry can be backed up to Mnesia on a "nearby"
- Erlang node. You need to provide an open connection to the Erlang node
- (see
The contents of a registry can be backed up to
+
- The example above will backup the contents of the registry to the
- specified Mnesia table
In the same manner, a registry can be restored from a Mnesia table:
+ +This example back up the contents of the registry to the
+ specified
Likewise, a registry can be restored from a
- This will read the entire contents of
This reads the entire contents of
Note that if you restore to a non-empty registry, objects in the - table will overwrite objects in the registry with the same keys. Also, + +
Notice that if you restore to a non-empty registry, objects in the + table overwrite objects in the registry with the same keys. Also, the entire contents of the registry is marked as unmodified after the restore, including any modified objects that were not - overwritten by the restore operation. This may not be your intention.
+ overwritten by the restore operation. This may not be your + intention.When string or binary objects are stored in the registry it is - important that a number of simple guidelines are followed.
+ important that some simple guidelines are followed. +Most importantly, the object must have been created with a single call
- to
You should also be aware that if you store binary objects that are - context-dependent (e.g. containing pointers or open file descriptors), - they will lose their meaning if they are backed up to a Mnesia table - and subsequently restored in a different context.
+ +Notice that if you store binary objects that are context-dependent
+ (for example, containing pointers or open file descriptors),
+ they lose their meaning if they are backed up to a
When you retrieve a stored string or binary value from the registry, the registry maintains a pointer to the object and you are passed a copy of that pointer. You should never free an object retrieved in this manner because when the registry later attempts to free it, a - runtime error will occur that will likely cause the C-node to crash.
+ runtime error occurs that likely causes the C-node to crash. +You are free to modify the contents of an object retrieved this way.
- However when you do so, the registry will not be aware of the changes
- you make, possibly causing it to be missed the next time you make a
- Mnesia backup of the registry contents. This can be avoided if you
- mark the object as dirty after any such changes with
-
The main use is to either start a distributed Erlang node
or to make an ordinary function call. However, it is also
- possible to pipe an Erlang module to
Options, which cause
Options, which cause
Each option flag is described below with its name, type and +
Starts/calls Erlang.
+Each option flag is described below with its name, type, and meaning.
(optional): Applies the specified function
- and returns the result.
(Optional.) Applies the specified function
+ and returns the result.
Notice that this flag takes exactly one argument, so quoting
+ can be necessary to group
(optional): Use this option to specify a certain cookie. If no cookie is specified, the
(Optional.) Use this option to specify a certain cookie.
+ If no cookie is specified, the
(optional): Debug mode. This causes all IO to be output
- to the file
(Optional.) Debug mode. This causes all I/O to be output
+ to the
(optional): Reads a sequence of Erlang expressions, separated
- by ',' and ended with a '.', from
(Optional.) Reads a sequence of Erlang expressions,
+ separated by comma (,) and ended with a full stop (.), from
+
(optional): Specifies the name of the hidden node +
(Optional.) Specifies the name of the hidden node
that
(optional): Reads an Erlang module from
(Optional.) Reads an Erlang module from
+
(one of
(One of
(one of
(One of
(optional): Halts the Erlang node specified - with the -n switch. This switch overrides the -s switch.
- +(Optional.) Halts the Erlang node specified
+ with switch
(optional): Generates a random name of the hidden node +
(Optional.) Generates a random name of the hidden node
that
(optional): Starts a distributed Erlang node if necessary.
- This means that in a sequence of calls, where the '
(Optional.) Starts a distributed Erlang node if
+ necessary. This means that in a sequence of calls, where
+ '
(one of
(One of
(optional): Prints a lot of
(Optional.) Prints a lot of
(optional): Specifies another name of the Erlang start-up script
- to be used. If not specified, the standard
(Optional.) Specifies another name of the Erlang
+ startup script to be used. If not specified, the standard
+
Starts an Erlang node and calls
To start an Erlang node and call
- Terminates an Erlang node by calling
To terminate an Erlang node by calling
+
- An apply with several arguments.
+ +To apply with many arguments:
+
- Evaluates a couple of expressions. The input ends with EOF (Control-D).
+ +To evaluate some expressions + (the input ends with EOF (Control-D)):
+
- Compiles a module and runs it. Again, the input ends with EOF (Control-D). (In the example shown, the output has been formatted afterwards).
+ +To compile a module and run it (again, the input ends with EOF + (Control-D)):
+(In the example, the output has been formatted afterwards.)
+
Bjarne Däcker
Torbjörn Törnkvist
- 980703
+ 1998-07-03
A
erl_connect.xml
erl_connect
- Communicate with Distributed Erlang
+ Communicate with distributed Erlang.
This module provides support for communication between distributed
- Erlang nodes and C nodes, in a manner that is transparent to Erlang
+ Erlang nodes and C-nodes, in a manner that is transparent to Erlang
processes.
- A C node appears to Erlang as a
- hidden node.
+
+
A C-node appears to Erlang as a hidden node.
That is, Erlang processes that know the name of the
- C node are able to communicate with it in a normal manner, but
- the node name will not appear in the listing provided by the
- Erlang function .
+ C-node can communicate with it in a normal manner, but
+ the node name does not appear in the listing provided by
+ erlang:nodes/0
+ in ERTS .
+
int erl_accept(listensock, conp)
Accept a connection.
+
int listensock;
ErlConnect *conp;
@@ -56,10 +59,12 @@
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:
+
+ is an open socket descriptor on
+ which has previously been called.
+ is a pointer to an
+ struct, described as follows:
+
is set to .
+
int erl_close_connection(fd)
Close a connection to an Erlang node.
@@ -79,47 +85,54 @@ typedef struct {
int fd;
- This function closes an open connection to an Erlang node.
+ 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.
+ or
+ .
+ Returns 0 on success. 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.
+
int erl_connect(node)
int erl_xconnect(addr, alive)
- Establishe a connection to an Erlang node.
+ Establish 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
+
Sets up a connection to an Erlang node.
+ requires the IP address of the
+ remote host and the alivename 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:
+
+ is the 32-bit IP address of the remote
+ host.
+ is the alivename of the remote node.
+
+ is the name of the remote node.
+
+ Returns an open file descriptor on success, otherwise a negative
+ value. In the latter case is set to one
+ of:
- - The remote host
is unreachable
+ - The remote host
is unreachable.
- - No more memory available.
+ - No more memory is available.
- I/O error.
- Additionally, values from
- (2) and (2)
- system calls may be propagated into .
+ Also, values from
+ (2) and
+ (2)
+ system calls can be propagated into .
+ Example:
+
int erl_connect_init(number, cookie, creation)
int erl_connect_xinit(host, alive, node, addr, cookie, creation)
Initialize communication.
+
int number;
char *cookie;
@@ -147,47 +162,72 @@ erl_xconnect( &addr , ALIVE );
struct in_addr *addr;
- These functions initialize the
- module. In particular, they are used to identify the name of the
+
Initializes the module.
+ In particular, these functions 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
- name , IP address , cookie ,
- and creation number .
- provides an alternative interface which does not require as much
- information from the caller. Instead,
- 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.
-
- is the name of the host on which the node is running.
- is the alivename of the node.
- is the name of the node. The nodename should
- be of the form alivename@hostname.
- is the 32-bit IP address of .
- is the authorization string required for access
- to the remote node. If NULL the user HOME directory is
- searched for a cookie file . The path to
- the home directory is retrieved from the environment variable
- on Unix and from the and
- variables on Windows. Refer to the
- module for more details.
- helps identify a particular instance of a C
- node. In particular, it can help prevent us from receiving
- messages sent to an earlier process with the same registered
- name.
- A C node acting as a server will be assigned a creation number
+
stores for later use
+ information about:
+
+ - Hostname of the node,
+ - Alivename,
+ - Node name,
+ - IP address,
+ - Cookie,
+ - Creation number,
+
+
+ provides an alternative interface that does not require as much
+ information from the caller. Instead,
+
+ uses to obtain default values.
+ If you use , your node will
+ have a short name, that is, it will not be fully qualified. If you
+ need to use fully qualified (long) names, use
+ instead.
+
+ -
+
is the name of the host on which the node
+ is running.
+
+ -
+
is the alivename of the node.
+
+ -
+
is the node name. It is to
+ be of the form alivename@hostname.
+
+ -
+
is the 32-bit IP address of
+ .
+
+ -
+
is the authorization string required
+ for access to the remote node. If NULL , the user
+ HOME directory is searched for a cookie file
+ . The path to
+ the home directory is retrieved from environment variable
+ on Unix and from the
+ and
+ variables on Windows. For more
+ details, see the
+ kernel:auth module.
+
+ -
+
helps identifying a particular
+ instance of a C-node. In particular, it can help prevent us from
+ receiving messages sent to an earlier process with the same
+ registered name.
+
+
+ A C-node acting as a server is assigned a creation number
when it calls .
- is used by to
- construct the actual node name. In the second example shown
- below, "c17@a.DNS.name" will be the resulting node
- name.
- Example 1:
+ is used by
+ to
+ construct the actual node name. In Example 2
+ below, "c17@a.DNS.name" is the resulting node name.
+ Example 1:
when initializing !");
]]>
- Example 2:
+ Example 2:
when initializing !");
]]>
+
int erl_publish(port)
Publish a node name.
@@ -213,66 +254,74 @@ if (!erl_connect_init(17, "samplecookiestring...", 0))
int port;
- These functions are used by a server process to register
+
This function is 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:
+ Before calling this function, the process should
+ have called and
+ on an open socket.
+ is the local name to register, and is to 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, a descriptor connecting the calling process to EPMD is
+ returned. On failure, -1 is returned and
+ is set to:
- - I/O error
+ - I/O error.
- Additionally, values from (2)
- and (2) system calls may be propagated
- into .
-
+ Also, values from
+ (2)
+ and (2) system calls can be
+ propagated into .
+
int erl_receive(fd, bufp, bufsize)
Receive a message.
+
int fd;
char *bufp;
int bufsize;
- This function receives a message consisting of a sequence
+
Receives a message consisting of a sequence
of bytes in the Erlang external format.
- is an open descriptor to an Erlang connection.
- is a buffer large enough to hold the expected
- message.
- indicates the size of .
- If a tick occurs, i.e., the Erlang node on the
+
+ is an open descriptor to an Erlang
+ connection.
+ is a buffer large enough to hold the
+ expected message.
+ indicates the size of
+ .
+
+
If a tick occurs, that is, the Erlang node on the
other end of the connection has polled this node to see if it
- is still alive, the function will return and
- no message will be placed in the buffer. Also,
- will be set to .
+ is still alive, the function returns and
+ no message is placed in the buffer. Also,
+ is set to .
On success, the message is placed in the specified buffer
and the function returns the number of bytes actually read. On
- failure, the function returns a negative value and will set
+ failure, the function returns a negative value and sets
to one of:
- Temporary error: Try again.
- - Buffer too small.
+ - Buffer is too small.
- I/O error.
+
int erl_receive_msg(fd, bufp, bufsize, emsg)
- Receive and decodes a message.
+ Receive and decode a message.
+
int fd;
unsigned char *bufp;
@@ -280,14 +329,20 @@ if (!erl_connect_init(17, "samplecookiestring...", 0))
ErlMessage *emsg;
- 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.
- indicates the size of .
- is a pointer to an structure,
- into which the message will be decoded. is
- defined as follows:
+ Receives the message into the specified buffer
+ and decodes into .
+
+ is an open descriptor to an Erlang
+ connection.
+ is a buffer large enough to hold the
+ expected message.
+ indicates the size of
+ .
+ - >
is a pointer to an
+ structure
+ into which the message will be decoded.
+ is defined as follows:
+
The definition of has changed since
- earlier versions of Erl_Interface.
+ earlier versions of Erl_Interface .
- identifies the type of message, one of
- , , ,
- and .
-
- If contains
- this indicates that an ordinary send operation has taken
- place, and to]]> contains the Pid of the
- recipient. If contains then a
- registered send operation took place, and from]]>
- contains the Pid of the sender. In both cases, the actual
- message will be in msg]]> .
-
- If contains one of or
- , then to]]> and from]]>
- contain the pids of the sender and recipient of the link or unlink.
- msg]]> is not used in these cases.
-
- If contains , then this
- indicates that a link has been broken. In this case,
- to]]> and from]]> contain the pids of the
- linked processes, and msg]]> contains the reason for
- the exit.
-
+ identifies the type of message, one of the
+ following:
+
+
+ -
+
An ordinary send operation has occurred and
+ to]]> contains the pid of the recipient.
+ The message is in msg]]> .
+
+
+ -
+
A registered send operation has occurred and
+ from]]> contains the pid of the sender.
+ The message is in msg]]> .
+
+ or
+
+ -
+
to]]> and from]]>
+ contain the pids of the sender and recipient of the link or
+ unlink. msg]]> is not used.
+
+
+ -
+
A link is broken. to]]> and
+ from]]> contain the pids of the linked
+ processes, and msg]]> contains the reason
+ for the exit.
+
+
It is the caller's responsibility to release the
- memory pointed to by msg]]> , to]]> and
+ memory pointed to by msg]]> ,
+ to]]> , and
from]]> .
- If a tick occurs, i.e., the Erlang node on the
+
If a tick occurs, that is, the Erlang node on the
other end of the connection has polled this node to see if it
- is still alive, the function will return
+ is still alive, the function returns
indicating that the tick has been received and responded to,
- but no message will be placed in the buffer. In this case you
- should call again.
+ but no message is placed in the buffer. In this case you
+ are to call again.
On success, the function returns and the
- struct will be initialized as described above, or
+ struct is initialized as described above, or
, in which case no message is returned. On
- failure, the function returns and will set
+ failure, the function returns and sets
to one of:
- - Buffer too small.
+ - Buffer is too small.
- - No more memory available.
+ - No more memory is available.
- I/O error.
+
int erl_reg_send(fd, to, msg)
Send a message to a registered name.
+
int fd;
char *to;
ETERM *msg;
- This function sends an Erlang term to a registered process.
- is an open descriptor to an Erlang connection.
- is a string containing the registered name 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:
+ Sends an Erlang term to a registered process.
+
+ is an open descriptor to an Erlang
+ connection.
+ is a string containing the registered name
+ of the intended recipient of the message.
+ is the Erlang term to be sent.
+
+ Returns 1 on success, otherwise 0 . In
+ the latter case is set to one of:
- - No more memory available.
+ - No more memory is available.
- I/O error.
+
ETERM * erl_rpc(fd, mod, fun, args)
int erl_rpc_from(fd, timeout, emsg)
@@ -386,81 +455,97 @@ typedef struct {
ErlMessage *emsg;
- These functions support calling Erlang functions on remote nodes.
- sends an rpc request to a remote node and
- receives the results of such a call.
- combines the functionality of these two functions
- by sending an rpc request and waiting for the results. See also
- .
- is an open descriptor to an Erlang connection.
- is the maximum time (in ms) to wait for
- results. Specify to wait forever.
- When erl_rpc() calls erl_rpc_from(), the call will never
- timeout.
- is the name of the module containing the function
- to be run on the remote node.
- is the name of the function to run.
- is an Erlang list, containing the arguments to be
- passed to the function.
- is a message containing the result of the
- function call.
- The actual message returned by the rpc server
- is a 2-tuple . If you are using
- in your code then this is the message you
- will need to parse. If you are using then the
+
Supports calling Erlang functions on remote nodes.
+ sends an RPC request to a remote node
+ and receives the results of such a
+ call. combines the functionality of
+ these two functions by sending an RPC request and waiting for the
+ results. See also
+ rpc:call/4 in Kernel .
+
+ is an open descriptor to an Erlang
+ connection.
+ is the maximum time (in milliseconds)
+ to wait for
+ results. To wait forever, specify .
+ When erl_rpc() calls erl_rpc_from() , the call will
+ never timeout.
+ is the name of the module containing the
+ function to be run on the remote node.
+ is the name of the function to run.
+
+ is an Erlang list, containing the
+ arguments to be passed to the function.
+ is a message containing the result of
+ the function call.
+
+ The actual message returned by the RPC server
+ is a 2-tuple . If you use
+ in your code, this is the message
+ you will need to parse. If you use , the
tuple itself is parsed for you, and the message returned to your
- program is the erlang term containing only. Replies
- to rpc requests are always ERL_SEND messages.
-
+ program is the Erlang term containing only.
+ Replies to RPC requests are always ERL_SEND messages.
It is the caller's responsibility to free the returned
- structure as well as the memory pointed to by
- msg]]> and to]]> .
+ structure and the memory pointed to by
+ msg]]> and to]]> .
- returns the remote function's return value (or
- if it failed). returns 0 on
- success, and a negative number on failure.
- returns when successful (with now
- containing the reply tuple), and one of ,
- and otherwise. When failing,
+
returns the remote function's return
+ value on success, otherwise .
+ returns 0 on
+ success, otherwise a negative number.
+ returns
+ on success (with now
+ containing the reply tuple), otherwise one of
+ , , or
+ .
+ When failing,
all three functions set to one of:
- - No more memory available.
+ - No more memory is available.
- I/O error.
- - Timeout expired.
+ - Timeout has expired.
- Temporary error: Try again.
+
int erl_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:
+ 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.
+
+ Returns 1 on success, otherwise 0 . In
+ the latter case is set to one of:
- - Invalid argument:
is not a valid Erlang pid.
+ - Invalid argument:
is not a valid Erlang
+ pid.
- - No more memory available.
+ - No more memory is available.
- I/O error.
+
const char * erl_thisalivename()
const char * erl_thiscookie()
@@ -469,11 +554,13 @@ typedef struct {
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
- or .
+ Retrieves information about
+ the C-node. These values are initially set with
+ or
+ .
+
int erl_unpublish(alive)
Forcefully unpublish a node name.
@@ -482,28 +569,28 @@ typedef struct {
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 instead
- close the descriptor that was returned by
- .
-
+ specified node from EPMD on the local host. This is, however, usually
+ not allowed, unless EPMD was started with flag
+ -relaxed_command_check , which it normally is not.
+ To unregister a node you have published, you should instead
+ close the descriptor that was returned by
+ .
This function is deprecated and will be removed in a future
- release.
+ release.
- is the name of the node to unregister, i.e., the
- first component of the nodename, without the .
- If the node was successfully unregistered from epmd, the
- function returns 0. Otherwise, it returns -1 and sets
- is to .
+ is the name of the node to unregister, that
+ is, the first component of the node name, without
+ .
+ If the node was successfully unregistered from EPMD, 0 is
+ returned, otherwise -1 is returned and
+ is set to .
+
int erl_xreceive_msg(fd, bufpp, bufsizep, emsg)
- Receive and decodes a message.
+ Receive and decode a message.
int fd;
unsigned char **bufpp;
@@ -511,33 +598,35 @@ typedef struct {
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.
-
+ 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. Therefore
+ both buffer and buffer length are given as pointers; their values
+ can change by the call.
On success, the function returns and the
- struct will be initialized as described above, or
+ struct is initialized as described above, or
, in which case no message is returned. On
- failure, the function returns and will set
+ failure, the function returns and sets
to one of:
- - Buffer too small.
+ - Buffer is too small.
- - No more memory available.
+ - No more memory is available.
- I/O error.
+
struct hostent *erl_gethostbyaddr(addr, length, type)
struct hostent *erl_gethostbyaddr_r(addr, length, type, hostp, buffer, buflen, h_errnop)
struct hostent *erl_gethostbyname(name)
struct hostent *erl_gethostbyname_r(name, hostp, buffer, buflen, h_errnop)
+
Name lookup functions.
const char *name;
@@ -550,7 +639,7 @@ typedef struct {
int *h_errnop;
- These are convenience functions for some common name lookup functions.
+ Convenience functions for some common name lookup functions.
@@ -558,12 +647,13 @@ typedef struct {
Debug Information
If a connection attempt fails, the following can be checked:
+
- - that the right cookie was used
- - that epmd is running
- - the remote Erlang node on the other side is running the same
- version of Erlang as the
library.
+ - That the correct cookie was used
+ - That EPMD is running
+ - That the remote Erlang node on the other side is running the same
+ version of Erlang as the
library
diff --git a/lib/erl_interface/doc/src/erl_error.xml b/lib/erl_interface/doc/src/erl_error.xml
index 5b8d546e12..a85969d7ff 100644
--- a/lib/erl_interface/doc/src/erl_error.xml
+++ b/lib/erl_interface/doc/src/erl_error.xml
@@ -28,21 +28,23 @@
Bjarne Däcker
Torbjörn Törnkvist
- 961014
+ 1996-10-14
A
erl_error.xml
erl_error
- Error Print Routines
+ Error print routines.
This module contains some error printing routines taken
- from Advanced Programming in the UNIX Environment
- by W. Richard Stevens.
+ 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
- followed by a list of corresponding arguments. All output from
+ , that is, with a string containing format
+ specifiers followed by a list of corresponding arguments. All output from
these functions is to .
+
void erl_err_msg(FormatStr, ... )
@@ -55,6 +57,7 @@
function is simply a wrapper for .
+
void erl_err_quit(FormatStr, ... )
Fatal error, but not system call error.
@@ -63,11 +66,12 @@
Use this function when a fatal error has occurred that
- is not due to a system call. The message provided by the
- caller is printed and the process terminates with an exit
- value of 1. The function does not return.
+ is not because of a system call. The message provided by the
+ caller is printed and the process terminates with exit
+ value 1 . This function does not return.
+
void erl_err_ret(FormatStr, ... )
Non-fatal system call error.
@@ -80,6 +84,7 @@
describing the reason for failure.
+
void erl_err_sys(FormatStr, ... )
Fatal system call error.
@@ -90,7 +95,7 @@
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, and the process
- terminates with an exit value of 1. The function does not
+ terminates with exit value 1 . This function does not
return.
@@ -98,37 +103,41 @@
Error Reporting
- Most functions in erl_interface report failures to the caller by
- returning some otherwise meaningless value (typically
+
Most functions in Erl_Interface report failures to the caller by
+ returning some otherwise meaningless value (typically
+
or a negative number). As this only tells you that things did not
- go well, you will have to examine the error code in
- if you want to find out more about the failure.
+ go well, examine the error code in if you
+ want to find out more about the failure.
+
volatile int erl_errno
- The variable contains the erl_interface error number. You can change the value if you wish.
+ 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
- non-zero error code to indicate what kind of error it
- encountered. A successful function call might change
+
is initially (at program startup) zero
+ and is then set by many Erl_Interface functions on failure to
+ a non-zero error code to indicate what kind of error it
+ encountered. A successful function call can change
(by calling some other function that
- fails), but no function will ever set it to zero. This means
+ fails), but no function does never set it to zero. This means
that you cannot use to see if a
function call failed. Instead, each function reports failure
in its own way (usually by returning a negative number or
- ), in which case you can examine
- for details.
+ ), in which case you can examine
+ for details.
uses the error codes defined in your
system's ]]> .
- Actually, is a "modifiable lvalue" (just
+
is a "modifiable lvalue" (just
like ISO C defines to be) rather than a
- variable. This means it might be implemented as a macro
- (expanding to, e.g., ). For reasons of
- thread- (or task-)safety, this is exactly what we do on most
- platforms.
+ variable. This means it can be implemented as a macro
+ (expanding to, for example, ).
+ For reasons of thread safety (or task safety), this is exactly what
+ we do on most platforms.
diff --git a/lib/erl_interface/doc/src/erl_eterm.xml b/lib/erl_interface/doc/src/erl_eterm.xml
index e5207a271e..8a46c20432 100644
--- a/lib/erl_interface/doc/src/erl_eterm.xml
+++ b/lib/erl_interface/doc/src/erl_eterm.xml
@@ -28,23 +28,26 @@
Bjarne Däcker
Torbjörn Törnkvist
- 980703
+ 1998-07-03
A
erl_eterm.xml
erl_eterm
- Functions for Erlang Term Construction
+ Functions for Erlang term construction.
- This module contains functions for creating and manipulating
- Erlang terms.
+ This module provides functions for creating and manipulating
+ Erlang terms.
+
An Erlang term is represented by a C structure of type
- . Applications should not reference any fields in this
- structure directly, because it may be changed in future releases
+ . Applications should not reference any fields
+ in this structure directly, as it can be changed in future releases
to provide faster and more compact term storage. Instead,
- applications should us the macros and functions provided.
- The following macros each take a single ETERM pointer as an
- argument. They return a non-zero value if the test is true, and 0
- otherwise:
+ applications should use the macros and functions provided.
+
+ Each of the following macros takes a single ETERM pointer as an
+ argument. The macros return a non-zero value if the test is true,
+ otherwise 0 .
+
- True if
is an integer.
@@ -55,7 +58,7 @@
- True if
is an atom.
- - True if
is a Pid (process identifier).
+ - True if
is a pid (process identifier).
- True if
is a port.
@@ -65,29 +68,31 @@
- True if
is a binary.
- - True if
is a list with zero or more elements.
+ - True if
is a list with zero or more
+ elements.
- True if
is an empty list.
- - True if
is a list with at least one element.
+ - True if
is a list with at least one
+ element.
+
The following macros can be used for retrieving parts of Erlang
- terms. None of these do any type checking; results are undefined
- if you pass an ETERM* containing the wrong type. For example,
- passing a tuple to ERL_ATOM_PTR() will likely result in garbage.
-
+ terms. None of these do any type checking. Results are undefined
+ if you pass an ETERM* containing the wrong type. For example,
+ passing a tuple to ERL_ATOM_PTR() likely results in garbage.
+
-
+
- - A string representing atom
.
-
+ - A string representing atom
.
-
+
- - The length (in bytes) of atom t.
+ - The length (in bytes) of atom
.
- - A pointer to the contents of
+ - A pointer to the contents of
.
- The length (in bytes) of binary object
.
@@ -97,9 +102,9 @@
- The floating point value of
.
-
+
- - The Node in pid
.
+ - The node in pid
.
- The sequence number in pid
.
@@ -111,16 +116,18 @@
- The creation number in port
.
-
+
- The node in port
.
- - The first part of the reference number in ref
. Use
- only for compatibility.
+ - The first part of the reference number in ref
.
+ Use only for compatibility.
- - Pointer to the array of reference numbers in ref
.
+ - Pointer to the array of reference numbers in ref
+
.
- - The number of used reference numbers in ref
.
+ - The number of used reference numbers in ref
+
.
- The creation number in ref
.
@@ -128,31 +135,38 @@
- The head element of list
.
- - A List representing the tail elements of list
.
+ - A list representing the tail elements of list
+
.
+
ETERM * erl_cons(head, tail)
- Prepends a term to the head of a list.
+ Prepend a term to the head of a list.
ETERM *head;
ETERM *tail;
- This function concatenates two Erlang terms, prepending
- onto and thereby creating a cell.
- To make a proper list, should always be a
- list or an empty list. Note that NULL is not a valid list.
- is the new term to be added.
- is the existing list to which will
- be concatenated.
+ Concatenates two Erlang terms, prepending
+ onto and thereby creating a
+ cell.
+ To make a proper list, is always to be a list
+ or an empty list. Notice that NULL is not a valid list.
+
+ is the new term to be added.
+ is the existing list to which
+ is concatenated.
+
The function returns a new list.
- and
+
and
+
can be used to retrieve the head and tail components
- from the list. and will do
+ from the list. and
+ do
the same thing, but check that the argument really is a list.
- For example:
+ Example:
+
ETERM * erl_copy_term(term)
- Creates a copy of an Erlang term.
+ Create a copy of an Erlang term.
ETERM *term;
- This function creates and returns a copy of the Erlang term
+
Creates and returns a copy of the Erlang term
.
+
ETERM * erl_element(position, tuple)
- Extracts an element from an Erlang tuple.
+ Extract an element from an Erlang tuple.
int position;
ETERM *tuple;
- This function extracts a specified element from an Erlang
- tuple.
- specifies which element to retrieve from
- . The elements are numbered starting from 1.
- is an Erlang term containing at least
- elements.
- The function returns a new Erlang term corresponding to the
- requested element, or NULL if was greater than
- the arity of .
+ Extracts a specified element from an Erlang tuple.
+
+ specifies which element to retrieve
+ from . The elements are numbered starting
+ from 1.
+ is an Erlang term containing at least
+ elements.
+
+ Returns a new Erlang term corresponding to the requested element, or
+ NULL if was greater
+ than the arity of .
+
ETERM * erl_hd(list)
- Extracts the first element from a list.
+ Extract 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.
+ Returns an Erlang term corresponding to the head
+ head element in the list, or a NULL pointer if
+ was not a list.
+
void erl_init(NULL, 0)
Initialization routine.
@@ -218,42 +238,45 @@ erl_free_compound(list);
- This function must be called before any of the others in
- the library in order to initialize the
+
This function must be called before any of the others in the
+ library to initialize the
library functions. The arguments must be specified as
.
+
int erl_iolist_length(list)
- Return the length of an IO list.
+ Return the length of an I/O 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.
+ Returns the length of an I/O list.
+ is an Erlang term containing an I/O list.
+ Returns the length of , or
+ -1 if is not an I/O list.
+ For the definition of an I/O list, see
+
+ erl_iolist_to_binary .
+
ETERM * erl_iolist_to_binary(term)
- Converts an IO list to a binary.
+ Convert an I/O list to a binary.
ETERM *list;
- This function converts an IO list to a binary term.
+ Converts an I/O list to a binary term.
is an Erlang term containing a list.
- This function an Erlang binary term, or NULL if
- was not an IO list.
- Informally, an IO list is a deep list of characters and
- binaries which can be sent to an Erlang port. In BNF, an IO
- list is formally defined as follows:
+ Returns an Erlang binary term, or NULL if
+ was not an I/O list.
+
+ Informally, an I/O list is a deep list of characters and
+ binaries that can be sent to an Erlang port. In BNF, an I/O
+ list is formally defined as follows:
+
char * erl_iolist_to_string(list)
- Converts an IO list to a zero terminated string.
+ Convert an I/O list to a zero-terminated string.
ETERM *list;
- This function converts an IO list to a '\0' terminated C
- string.
- is an Erlang term containing an IO list. The IO
- list must not contain the integer 0, since C strings may not
+
Converts an I/O list to a '\0' terminated C string.
+ is an Erlang term containing an I/O list.
+ The I/O list must not contain the integer 0, as C strings may not
contain this value except as a terminating marker.
- This function returns a pointer to a dynamically allocated
- buffer containing a string. If is not an IO list,
- or if contains the integer 0, NULL is returned. It
- is the caller's responsibility free the allocated buffer
- with .
- Refer to for the definition of an
- IO list.
+ Returns a pointer to a dynamically allocated
+ buffer containing a string. If is not an I/O
+ list, or if contains the integer 0,
+ NULL is returned. It
+ is the caller's responsibility to free the allocated buffer
+ with .
+ For the definition of an I/O list, see
+
+ erl_iolist_to_binary .
+
int erl_length(list)
- Determines the length of a list.
+ Determine the length of a list.
ETERM *list;
Determines the length of a proper list.
- is an Erlang term containing proper list. In a
- proper list, all tails except the last point to another list
+
is an Erlang term containing a proper list.
+ In a proper list, all tails except the last point to another list
cell, and the last tail points to an empty list.
- Returns -1 if is not a proper list.
+ Returns -1 if is not a proper
+ list.
+
ETERM * erl_mk_atom(string)
- Creates an atom.
+ Create an atom.
const char *string;
@@ -311,97 +339,114 @@ iohead ::= Binary
Creates an atom.
is the sequence of characters that will be
used to create the atom.
- Returns an Erlang term containing an atom. Note that it is
- the callers responsibility to make sure that
+
Returns an Erlang term containing an atom. Notice that it is
+ the caller's responsibility to ensure that
contains a valid name for an atom.
- and
- can be used to retrieve the atom name (as a null terminated string).
- and returns the length of the atom name.
- Note that the UTF8 variants were introduced in Erlang/OTP releases R16
- and the string returned by ERL_ATOM_PTR(atom) was not null terminated on older releases.
+ and
+
+ can be used to retrieve the atom name (as a null-terminated string).
+
+ and return the length
+ of the atom name.
+
+ The UTF-8 variants were introduced in Erlang/OTP R16 and the
+ string returned by ERL_ATOM_PTR(atom) was not
+ null-terminated on older releases.
+
ETERM * erl_mk_binary(bptr, size)
- Creates a binary object.
+ Create a binary object.
char *bptr;
int size;
- This function produces an Erlang binary object from a
+
Produces an Erlang binary object from a
buffer containing a sequence of bytes.
- is a pointer to a buffer containing data to be converted.
- indicates the length of .
- The function returns an Erlang binary object.
+
+ is a pointer to a buffer containing
+ data to be converted.
+ indicates the length of
+ .
+
+ Returns an Erlang binary object.
retrieves a pointer to
the binary data. retrieves the
- size.
+ size.
+
ETERM * erl_mk_empty_list()
- Creates an empty Erlang list.
+ Create an empty Erlang list.
- This function creates and returns an empty Erlang list.
- Note that NULL is not used to represent an empty list;
+
Creates and returns an empty Erlang list.
+ Notice that NULL is not used to represent an empty list;
Use this function instead.
+
ETERM * erl_mk_estring(string, len)
- Creates an Erlang string.
+ Create an Erlang string.
char *string;
int len;
- This function creates a list from a sequence of bytes.
- is a buffer containing a sequence of
- bytes. The buffer does not need to be zero-terminated.
- is the length of .
- The function returns an Erlang list object corresponding to
+
Creates a list from a sequence of bytes.
+
+ is a buffer containing a sequence of
+ bytes. The buffer does not need to be zero-terminated.
+ is the length of
+ .
+
+ Returns an Erlang list object corresponding to
the character sequence in .
+
ETERM * erl_mk_float(f)
- Creates an Erlang float.
+ Create an Erlang float.
double f;
Creates an Erlang float.
- is a value to be converted to an Erlang float.
-
- The function returns an Erlang float object with the value
- specified in or if
- is not finite.
-
+ is a value to be converted to an Erlang
+ float.
+ Returns an Erlang float object with the value
+ specified in or if
+ is not finite.
can be used to retrieve the
- value from an Erlang float.
+ value from an Erlang float.
+
ETERM * erl_mk_int(n)
- Creates an Erlang integer.
+ Create an Erlang integer.
int n;
Creates an Erlang integer.
- is a value to be converted to an Erlang integer.
-
- The function returns an Erlang integer object with the
+
is a value to be converted to an Erlang
+ integer.
+ Returns an Erlang integer object with the
value specified in .
- can be used to retrieve the value
+
can be used to retrieve the
value from an Erlang integer.
+
ETERM * erl_mk_list(array, arrsize)
- Creates a list from an array.
+ Create a list from an array.
ETERM **array;
int arrsize;
@@ -409,44 +454,51 @@ iohead ::= Binary
Creates an Erlang list from an array of Erlang terms, such
that each element in the list corresponds to one element in
- the array.
- is an array of Erlang terms.
- is the number of elements in .
+ the array.
+
+ is an array of Erlang terms.
+ is the number of elements in
+ .
+
The function creates an Erlang list object, whose length
- and whose elements are taken from the terms in
- .
+ and whose elements are taken from the
+ terms in .
+
ETERM * erl_mk_long_ref(node, n1, n2, n3, creation)
- Creates an Erlang reference.
+ Create 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.
+ Creates an Erlang reference, with 82 bits.
+
+ is the name of the C-node.
+ , , and
+ can be seen as one big number
+ , which is to be chosen
+ uniquely for each reference created for a given C-node.
+ is an arbitrary number.
+
+ Notice that and
+ are limited in precision, so only the low 18 and 2 bits of these
+ numbers are used.
+ Returns an Erlang reference object.
+ ,
+ ,
+ , and
+ can be used to retrieve the
+ values used to create the reference.
+
ETERM * erl_mk_pid(node, number, serial, creation)
- Creates a process identifier.
+ Create a process identifier.
const char *node;
unsigned int number;
@@ -454,106 +506,125 @@ iohead ::= Binary
unsigned int creation;
- This function creates an Erlang process identifier. The
+
Creates an Erlang process identifier (pid). The
resulting pid can be used by Erlang processes wishing to
- communicate with the C node.
- is the name of the C node.
- , and are
- arbitrary numbers. Note though, that these are limited in
- precision, so only the low 15, 3 and 2 bits of these numbers
- are actually used.
- The function returns an Erlang pid object.
- , ,
- and
+ communicate with the C-node.
+
+ is the name of the C-node.
+ , , and
+ are
+ arbitrary numbers. Notice that these are limited in
+ precision, so only the low 15, 3, and 2 bits of these numbers
+ are used.
+
+ Returns an Erlang pid object.
+ ,
+ ,
+ , and
+
can be used to retrieve the four values used to create the pid.
+
ETERM * erl_mk_port(node, number, creation)
- Creates a port identifier.
+ Create a port identifier.
const char *node;
unsigned int number;
unsigned int creation;
- This function creates an Erlang port identifier.
- is the name of the C node.
- and are arbitrary numbers.
- Note though, that these are limited in
- precision, so only the low 18 and 2 bits of these numbers
- are actually used.
- The function returns an Erlang port object.
- ,
- and can be used to retrieve the three
- values used to create the port.
+ Creates an Erlang port identifier.
+
+ is the name of the C-node.
+ and are
+ arbitrary numbers. Notice that these are limited in
+ precision, so only the low 18 and 2 bits of these numbers
+ are used.
+
+ Returns an Erlang port object.
+ ,
+ ,
+ and can be used to retrieve the
+ three values used to create the port.
+
ETERM * erl_mk_ref(node, number, creation)
- Creates an old Erlang reference.
+ Create an old Erlang reference.
const char *node;
unsigned int number;
unsigned int creation;
- This function creates an old Erlang reference, with
+
Creates an old Erlang reference, with
only 18 bits - use instead.
- is the name of the C node.
- 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 three values used
- to create the reference.
+
+ is the name of the C-node.
+ is to be chosen uniquely for each
+ reference created for a given C-node.
+ is an arbitrary number.
+
+ Notice that and
+ are limited in precision, so only the low 18 and 2 bits of these
+ numbers are used.
+ Returns an Erlang reference object.
+ ,
+ , and
+ can be used to retrieve the
+ three values used to create the reference.
+
ETERM * erl_mk_string(string)
- Creates a string.
+ Create a string.
char *string;
- This function creates a list from a zero terminated string.
- is the zero-terminated sequence of characters
- (i.e. a C string) from which the list will be created.
- The function returns an Erlang list.
+ Creates a list from a zero-terminated string.
+ is the zero-terminated sequence of
+ characters
+ (that is, a C string) from which the list will be created.
+ Returns an Erlang list.
+
ETERM * erl_mk_tuple(array, arrsize)
- Creates an Erlang tuple from an array.
+ Create an Erlang tuple from an array.
ETERM **array;
int arrsize;
Creates an Erlang tuple from an array of Erlang terms.
- is an array of Erlang terms.
- is the number of elements in .
+
+ is an array of Erlang terms.
+ is the number of elements in
+ .
+
The function creates an Erlang tuple, whose arity is
- and whose elements are taken from the terms in
- .
- To retrieve the size of a tuple, either use the
- function (which checks the type of the checked
- term and works for a binary as well as for a tuple), or the
+ and whose elements are taken from the terms
+ in .
+ To retrieve the size of a tuple, either use function
+ (which checks the type of the
+ checked term and works for a binary as well as for a tuple) or
returns the arity of a tuple.
- will do the same thing, but it checks that
- the argument really is a tuple.
+ does the same thing, but it checks
+ that the argument is a tuple.
returns the element
- corresponding to a given position in the tuple.
+ corresponding to a given position in the tuple.
+
ETERM * erl_mk_uint(n)
- Creates an unsigned integer.
+ Create an unsigned integer.
unsigned int n;
@@ -561,76 +632,83 @@ iohead ::= Binary
Creates an Erlang unsigned integer.
is a value to be converted to an Erlang
unsigned integer.
-
- The function returns an Erlang unsigned integer object with
+
Returns an Erlang unsigned integer object with
the value specified in .
can be used to retrieve the
value from an Erlang unsigned integer.
+
ETERM * erl_mk_var(name)
- Creates an Erlang variable.
+ Create an Erlang variable.
char *name;
- This function creates an unbound Erlang variable. The
- variable can later be bound through pattern matching or assignment.
+ Creates an unbound Erlang variable. The variable can later be bound
+ through pattern matching or assignment.
specifies a name for the variable.
- The function returns an Erlang variable object with the
- name .
+ Returns an Erlang variable object with the
+ name .
+
int erl_print_term(stream, term)
- Prints an Erlang term.
+ Print an Erlang term.
FILE *stream;
ETERM *term;
- This function prints the specified Erlang term to the given
- output stream.
- indicates where the function should send its
- output.
- is the Erlang term to print.
- The function returns the number of characters written, or a
- negative value if there was an error.
+ Prints the specified Erlang term to the specified output stream.
+
+ indicates where the function is to
+ send its output.
+ is the Erlang term to print.
+
+ Returns the number of characters written on success, otherwise a
+ negative value.
+
void erl_set_compat_rel(release_number)
- Set the erl_interface library in compatibility mode.
+ Set the Erl_Interface 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
+
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 Erlang/OTP R10
+ is not compatible
+ with an Erlang emulator from Erlang/OTP R9 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
- directly after the call to the
- erl_init() function.
+ directly after the call to function
+ erl_init() .
You may run into trouble if this feature is used
- carelessly. Always make sure that all communicating
+ carelessly. Always ensure 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.
+
int erl_size(term)
Return the arity of a tuple or binary.
@@ -638,49 +716,55 @@ iohead ::= Binary
ETERM *term;
- Returns the arity of an Erlang tuple, or the
- number of bytes in an Erlang binary object.
- is an Erlang tuple or an Erlang binary object.
- The function returns the size of as described
- above, or -1 if is not one of the two supported
- types.
+ Returns either the arity of an Erlang tuple or the
+ number of bytes in an Erlang binary object.
+ is an Erlang tuple or an Erlang binary
+ object.
+ Returns the size of as described
+ above, or -1 if is not one of the two
+ supported types.
+
ETERM * erl_tl(list)
- Extracts the tail from a list.
+ Extract the tail from a list.
ETERM *list;
Extracts the tail from a list.
is an Erlang term containing a list.
- The function returns an Erlang list corresponding to the
- original list minus the first element, or NULL pointer if
+
Returns an Erlang list corresponding to the
+ original list minus the first element, or NULL pointer if
was not a list.
+
ETERM * erl_var_content(term, name)
- Extracts the content of a variable.
+ Extract the content of a variable.
ETERM *term;
char *name;
- This function returns the contents of the specified
- variable in an Erlang term.
-
- is an Erlang term. In order for this function
- to succeed, must be an Erlang variable with the
- specified name, or it must be an Erlang list or tuple
- containing a variable with the specified name. Other Erlang
- types cannot contain variables.
- is the name of an Erlang variable.
+ Returns the contents of the specified variable in an Erlang term.
+
+ is an Erlang term. In order for this
+ function to succeed,
+ must either be an Erlang variable with
+ the specified name, or it must be an Erlang list or tuple
+ containing a variable with the specified name. Other Erlang
+ types cannot contain variables.
+ is the name of an Erlang variable.
+
+
Returns the Erlang object corresponding to the value of
- in . If no variable with the name
- was found in , or if is
- not a valid Erlang term, NULL is returned.
+ in . If no variable
+ with the name is found in
+ , or if is
+ not a valid Erlang term, NULL is returned.
diff --git a/lib/erl_interface/doc/src/erl_format.xml b/lib/erl_interface/doc/src/erl_format.xml
index ce5163fbc7..9fe405d51c 100644
--- a/lib/erl_interface/doc/src/erl_format.xml
+++ b/lib/erl_interface/doc/src/erl_format.xml
@@ -28,51 +28,42 @@
Bjarne Däcker
Torbjörn Törnkvist
- 961016
+ 1996-10-16
A
erl_format.xml
erl_format
- Create and Match Erlang Terms
+ Create and match Erlang terms.
- This module contains two routines - one general function for
+
This module contains two routines: one general function for
creating Erlang terms and one for pattern matching Erlang terms.
+
- ETERM * erl_format(FormatStr, ... )
- Creates an Erlang term.
+ ETERM * erl_format(FormatStr, ...)
+ Create an Erlang term.
char *FormatStr;
- This is a general function for creating Erlang terms using
+
A general function for creating Erlang terms using
a format specifier and a corresponding set of arguments, much
in the way works.
- is a format specification string. The set
- of valid format specifiers is as follows:
+ is a format specification string.
+ The valid format specifiers are as follows:
- -
-
~i - Integer
-
- -
-
~f - Floating point
-
- -
-
~a - Atom
-
- -
-
~s - String
-
- -
-
~w - Arbitrary Erlang term
-
+ ~i - Integer
+ ~f - Floating point
+ ~a - Atom
+ ~s - String
+ ~w - Arbitrary Erlang term
- For each format specifier that appears in ,
+
For each format specifier included in ,
there must be a corresponding argument following
- . An Erlang term is built according to the
- with values and Erlang terms substituted from
- the corresponding arguments and according to the individual
+ . An Erlang term is built according to
+ with values and Erlang terms substituted
+ from the corresponding arguments, and according to the individual
format specifiers. For example:
- This will create an structure corresponding
- to the Erlang term:
+
This creates an structure corresponding
+ to the Erlang term
- The function returns an Erlang term, or NULL if
- does not describe a valid Erlang term.
+ The function returns an Erlang term, or NULL if
+ does not describe a valid Erlang
+ term.
+
int erl_match(Pattern, Term)
- Performs pattern matching.
+ Perform pattern matching.
+
ETERM *Pattern,*Term;
This function is used to perform pattern matching similar
- to that done in Erlang. Refer to an Erlang manual for matching
- rules and more examples.
- is an Erlang term, possibly containing unbound
- variables.
- is an Erlang term that we wish to match against
- .
- and are compared, and any
- unbound variables in are bound to corresponding
- values in .
- If and can be matched, the
- function returns a non-zero value and binds any unbound
- variables in . If do
- not match, the function returns 0. For example:
+ to that done in Erlang. For matching rules and more exemples, see
+ section
+ Pattern Matching in the Erlang Reference Manual.
+
+ is an Erlang term, possibly
+ containing unbound variables.
+ is an Erlang term that we wish to match
+ against .
+
+ and are compared
+ and any unbound variables in are bound to
+ corresponding values in .
+ If and can be
+ matched, the function returns a non-zero value and binds any unbound
+ variables in . If
+ and do
+ not match, 0 is returned. For example:
Gordon Beaton
Gordon Beaton
- 980703
+ 1998-07-03
A
erl_global.xml
erl_global
- Access globally registered names
+ Access globally registered names.
This module provides support for registering, looking
- 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
+ up, and unregistering names in the global module.
+ For more information, see
+ kernel:global .
+
+ Notice 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
- function may receive unexpected data and fail.
+ not be used for other traffic during the global operation, as the
+ function can then 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;
- Retrieve a list of all known global names.
-
- is an open descriptor to an Erlang connection.
-
- is the address of an integer, or NULL. If
- is not NULL, it will be set by the function to
- the number of names found.
-
+ Retrieves a list of all known global names.
+
+ is an open descriptor to an Erlang
+ connection.
+ is the address of an integer, or
+ NULL . If is not NULL , it is
+ set by the function to the number of names found.
+
On success, the function returns an array of strings, each
- containing a single registered name, and sets to
+ containing a single registered name, and sets
+ to
the number of names found. The array is terminated
- by a single NULL pointer. On failure, the function returns
- NULL and is not modified.
-
+ by a single NULL pointer. On failure, the function returns
+ NULL and is not modified.
It is the caller's responsibility to free the array
afterwards. It has been allocated by the function with a
- single call to , so a single is
- all that is necessary.
+ single call to , so a single
+ is all that is necessary.
+
int erl_global_register(fd,name,pid)
- Register a name in Global.
+ Register a name in global.
int fd;
const char *name;
ETERM *pid;
- This function registers a name in Global.
-
- is an open descriptor to an Erlang connection.
-
- is the name to register in Global.
-
- is the pid that should be associated with
- . This is the value that Global will return when
- processes request the location of .
-
- The function returns 0 on success, or -1 on failure.
+ Registers a name in global .
+
+ is an open descriptor to an Erlang
+ connection.
+ is the name to register in
+ global .
+ is the pid that is to be associated with
+ . This value is returned by global
+ when processes request the location of .
+
+
+ Returns 0 on success, otherwise -1 .
+
int erl_global_unregister(fd,name)
- Unregister a name in Global.
+ Unregister a name from global.
int fd;
const char *name;
- This function unregisters a name from Global.
-
- is an open descriptor to an Erlang connection.
-
- is the name to unregister from Global.
-
- The function returns 0 on success, or -1 on failure.
+ Unregisters a name from global .
+
+ is an open descriptor to an Erlang
+ connection.
+ is the name to unregister from
+ global .
+
+ Returns 0 on success, otherwise -1 .
+
ETERM * erl_global_whereis(fd,name,node)
Look up a name in global.
@@ -122,19 +131,22 @@
char *node;
- is an open descriptor to an Erlang connection.
-
- is the name that is to be looked up in Global.
-
- If is not NULL, it is a pointer to a buffer
- where the function can fill in the name of the node where
- is found. can be passed directly to
- if necessary.
-
- On success, the function returns an Erlang Pid containing the address
- of the given name, and node will be initialized to
- the nodename where is found. On failure NULL will be
- returned and will not be modified.
+ Looks up a name in global .
+
+ is an open descriptor to an Erlang
+ connection.
+ is the name that is to be looked up in
+ global .
+
+ If is not NULL , it is a pointer to a
+ buffer where the function can fill in the name of the node where
+ is found. can be
+ passed directly to if necessary.
+ On success, the function returns an Erlang pid containing the address
+ of the specified name, and the node is initialized to
+ the node name where is found. On failure,
+ NULL is returned and is not
+ modified.
diff --git a/lib/erl_interface/doc/src/erl_malloc.xml b/lib/erl_interface/doc/src/erl_malloc.xml
index ba1f59a492..28de9dfa88 100644
--- a/lib/erl_interface/doc/src/erl_malloc.xml
+++ b/lib/erl_interface/doc/src/erl_malloc.xml
@@ -28,172 +28,177 @@
Bjarne Däcker
Torbjörn Törnkvist
- 980703
+ 1998-07-03
A
erl_malloc.xml
erl_malloc
- Memory Allocation Functions
+ Memory allocation functions.
This module provides functions for allocating and deallocating
memory.
+
ETERM * erl_alloc_eterm(etype)
- Allocates an ETERM structure.
+ Allocate an ETERM structure.
unsigned char etype;
- This function allocates an structure.
- Specify as one of the following constants:
+ Allocates an structure.
+ Specify as one of the following
+ constants:
- -
-
ERL_INTEGER
+ ERL_INTEGER
- -
-
ERL_U_INTEGER
+ ERL_U_INTEGER (unsigned integer)
- -
-
ERL_ATOM
+ ERL_ATOM
- -
-
ERL_PID
+ ERL_PID (Erlang process identifier)
- -
-
ERL_PORT
+ ERL_PORT
- -
-
ERL_REF
+ ERL_REF (Erlang reference)
- -
-
ERL_LIST
+ ERL_LIST
- -
-
ERL_EMPTY_LIST
+ ERL_EMPTY_LIST
- -
-
ERL_TUPLE
+ ERL_TUPLE
- -
-
ERL_BINARY
+ ERL_BINARY
- -
-
ERL_FLOAT
+ ERL_FLOAT
- -
-
ERL_VARIABLE
+ ERL_VARIABLE
- -
-
ERL_SMALL_BIG
+ ERL_SMALL_BIG (bignum)
- -
-
ERL_U_SMALL_BIG
+ ERL_U_SMALL_BIG (bignum)
- and are for
- creating Erlang , which can contain integers of
- arbitrary size. The size of an integer in Erlang is machine
- dependent, but in general any integer larger than 2^28
- requires a bignum.
+ and
+ are for
+ creating Erlang , which can contain integers
+ of any size. The size of an integer in Erlang is machine-dependent,
+ but any integer > 2^28 requires a bignum.
+
void erl_eterm_release(void)
- Clears the ETERM freelist.
+ Clear the ETERM freelist.
- Clears the
- freelist, where blocks are placed when they are
+
Clears the freelist, where blocks are placed when they are
released by and
- .
+ .
+
void erl_eterm_statistics(allocated, freed)
- Reports term allocation statistics.
+ Report term allocation statistics.
long *allocated;
long *freed;
- and are initialized to
+
Reports term allocation statistics.
+ and are
+ initialized to
contain information about the fix-allocator used to allocate
- ETERM components. is the number of blocks
- currently allocated to ETERM objects. is the
- length of the freelist, where blocks are placed when they are
- released by and
- .
+ ETERM components.
+
+ -
+
is the number of blocks currently
+ allocated to ETERM objects.
+
+ -
+
is the length of the freelist, where
+ blocks are placed when they are
+ released by and
+ .
+
+
+
void erl_free(ptr)
- Frees some memory.
+ Free some memory.
void *ptr;
- This function calls the standard
- function.
+ Calls the standard
+ function.
+
void erl_free_array(array, size)
- Frees an array of ETERM structures.
+ Free an array of ETERM structures.
ETERM **array;
int size;
- This function frees an array of Erlang terms.
- is an array of ETERM* objects.
-
- is the number of terms in the array.
+ Frees an array of Erlang terms.
+
+ is an array of ETERM* objects.
+ is the number of terms in the array.
+
+
+
void erl_free_compound(t)
- Frees an array of ETERM structures.
+ Free an array of ETERM structures.
ETERM *t;
Normally it is the programmer's responsibility to free each
Erlang term that has been returned from any of the
- functions. However since many of the
+ functions. However, as many of the
functions that build new Erlang terms in fact share objects
- with other existing terms, it may be difficult for the
- programmer to maintain pointers to all such terms in order to
- free them individually.
-
- will recursively free all of the
- sub-terms associated with a given Erlang term, regardless of
- whether we are still holding pointers to the sub-terms.
-
- There is an example in the User Manual under "Building
- Terms and Patterns"
-
+ with other existing terms, it can be difficult for the
+ programmer to maintain pointers to all such terms to
+ free them individually.
+ recursively frees all of the
+ subterms associated with a specified Erlang term, regardless of
+ whether we are still holding pointers to the subterms.
+ For an example, see section
+ Building Terms and
+ Patterns"> in the User's Guide.
+
void erl_free_term(t)
- Frees an ETERM structure.
+ Free an ETERM structure.
+
ETERM *t;
- Use this function to free an Erlang term.
+ Frees an Erlang term.
+
void erl_malloc(size)
- Allocates some memory.
+ Allocate some memory.
long size;
- This function calls the standard
- 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 c70bdb53e1..30b7281a51 100644
--- a/lib/erl_interface/doc/src/erl_marshal.xml
+++ b/lib/erl_interface/doc/src/erl_marshal.xml
@@ -28,244 +28,240 @@
Bjarne Däcker
Torbjörn Törnkvist
- 980703
+ 1998-07-03
A
erl_marshal.xml
erl_marshal
- Encoding and Decoding of Erlang terms
+ Encoding and decoding of Erlang terms.
This module contains functions for encoding Erlang terms into
a sequence of bytes, and for decoding Erlang terms from a
sequence of bytes.
+
int erl_compare_ext(bufp1, bufp2)
- Compares encoded byte sequences.
+ Compare encoded byte sequences.
unsigned char *bufp1,*bufp2;
- This function compares two encoded terms.
-
- is a buffer containing an encoded Erlang
- term term1.
-
- is a buffer containing an encoded Erlang
- 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.
-
+ Compares two encoded terms.
+
+ is a buffer containing an encoded
+ Erlang term term1.
+ is a buffer containing an encoded
+ Erlang term term2.
+
+ Returns 0 if the terms are equal, -1 if
+ term1 < term2 , or 1 if term2 <
+ term1.
+
ETERM * erl_decode(bufp)
ETERM * erl_decode_buf(bufpp)
- Converts a term from Erlang external format.
+ Convert a term from Erlang external format.
unsigned char *bufp;
unsigned char **bufpp;
- and decode
+
and
+ decode
the contents of a buffer and return the corresponding
- Erlang term. provides a simple
+ Erlang term. provides a simple
mechanism for dealing with several encoded terms stored
consecutively in the buffer.
- is a pointer to a buffer containing one or
- more encoded Erlang terms.
-
- is the address of a buffer pointer. The buffer
- contains one or more consecutively encoded Erlang terms.
- Following a successful call to ,
- will be updated so that it points to the next
- encoded term.
-
+
+ -
+
is a pointer to a buffer containing one
+ or more encoded Erlang terms.
+
+ -
+
is the address of a buffer pointer. The
+ buffer contains one or more consecutively encoded Erlang terms.
+ Following a successful call to
+ , is
+ updated so that it points to the next encoded term.
+
+
returns an Erlang term
- corresponding to the contents of on success, or
- NULL on failure. returns an Erlang
+ corresponding to the contents of on success,
+ otherwise NULL .
+ returns an Erlang
term corresponding to the first of the consecutive terms in
- and moves forward to point to the
+ and moves forward
+ to point to the
next term in the buffer. On failure, each of the functions
- returns NULL.
-
+ return NULL .
+
int erl_encode(term, bufp)
int erl_encode_buf(term, bufpp)
- Converts a term into Erlang external format.
+ Convert 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
- buffer.
-
- term is an Erlang term to be encoded.
-
- bufp is a pointer to a buffer containing one or
- more encoded Erlang terms.
-
- bufpp is a pointer to a pointer to a buffer
- containing one or more consecutively encoded Erlang terms.
- 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.
-
- Note that no bounds checking is done on the buffer. It is
- the caller's responsibility to make sure that the buffer is
+ encoding several terms consecutively in the same buffer.
+
+ -
+
term is an Erlang term to be encoded.
+
+ -
+
bufp is a pointer to a buffer containing one or
+ more encoded Erlang terms.
+
+ -
+
bufpp is a pointer to a pointer to a buffer
+ containing one or more consecutively encoded Erlang terms.
+ Following a successful call to
+ , bufpp is updated so
+ that it points to the
+ position for the next encoded term.
+
+
+ These functions return the number of bytes written to buffer
+ on success, otherwise 0 .
+ Notice that no bounds checking is done on the buffer. It is
+ the caller's responsibility to ensure that the buffer is
large enough to hold the encoded terms. You can either use a
- static buffer that is large enough to hold the terms you
- expect to need in your program, or use
- to determine the exact requirements for a given term.
-
+ static buffer that is large enough to hold the terms you expect
+ to need in your program, or use
+ to determine the exact requirements for a given term.
The following can help you estimate the buffer
- requirements for a term. Note that this information is
- implementation specific, and may change in future versions.
- If you are unsure, use .
-
+ requirements for a term. Notice that this information is
+ implementation-specific, and can change in future versions.
+ If you are unsure, use .
Erlang terms are encoded with a 1 byte tag that
identifies the type of object, a 2- or 4-byte length field,
- and then the data itself. Specifically:
-
+ and then the data itself. Specifically:
- - need 5 bytes, plus the space for each element.
+ - Need 5 bytes, plus the space for each element.
- - need 5 bytes, plus the space for each element, and 1
- additional byte for the empty list at the end.
+ - Need 5 bytes, plus the space for each element, and 1
+ more byte for the empty list at the end.
- - need 3 bytes, plus 1 byte for each character (the
- terminating 0 is not encoded). Really long strings (more
- than 64k characters) are encoded as lists. Atoms cannot
- contain more than 256 characters.
+ - Need 3 bytes, plus 1 byte for each character (the
+ terminating 0 is not encoded). Really long strings (more
+ than 64k characters) are encoded as lists. Atoms cannot
+ contain more than 256 characters.
- - need 5 bytes.
+ - Need 5 bytes.
- - (integers < 256) need 2 bytes.
+ - (Integers < 256) need 2 bytes.
- - need 32 bytes.
+ - Need 32 bytes.
- - need 10 bytes, plus the space for the node name, which
- is an atom.
+ - Need 10 bytes, plus the space for the node name, which
+ is an atom.
- - need 6 bytes, plus the space for the node name, which
- is an atom.
+ - Need 6 bytes, plus the space for the node name, which
+ is an atom.
- The total space required will be the result calculated
- from the information above, plus 1 additional byte for a
- version identifier.
-
+ The total space required is the result calculated
+ from the information above, plus 1 more byte for a
+ version identifier.
+
int erl_ext_size(bufp)
- Counts elements in encoded term.
+ Count elements in encoded term.
unsigned char *bufp;
- This function returns the number of elements in an
- encoded term.
+ Returns the number of elements in an encoded term.
+
unsigned char erl_ext_type(bufp)
- Determines type of an encoded byte sequence.
+ Determine type of an encoded byte sequence.
unsigned char *bufp;
- This function identifies and returns the type of Erlang term encoded
- in a buffer. It will skip a trailing magic identifier.
- Returns if the type can't be determined or one of
+ Identifies and returns the type of Erlang term encoded
+ in a buffer. It skips a trailing magic identifier.
+ Returns if the type cannot be determined or
+ one of:
- -
-
ERL_INTEGER
+ ERL_INTEGER
- -
-
ERL_ATOM
+ ERL_ATOM
- -
-
ERL_PID
+ ERL_PID (Erlang process identifier)
- -
-
ERL_PORT
+ ERL_PORT
- -
-
ERL_REF
+ ERL_REF (Erlang reference)
- -
-
ERL_EMPTY_LIST
+ ERL_EMPTY_LIST
- -
-
ERL_LIST
+ ERL_LIST
- -
-
ERL_TUPLE
+ ERL_TUPLE
- -
-
ERL_FLOAT
+ ERL_FLOAT
- -
-
ERL_BINARY
+ ERL_BINARY
- -
-
ERL_FUNCTION
+ ERL_FUNCTION
+
unsigned char * erl_peek_ext(bufp, pos)
- Steps over encoded term.
+ Step over encoded term.
unsigned char *bufp;
int pos;
This function is used for stepping over one or more
- encoded terms in a buffer, in order to directly access a
- later term.
-
- is a pointer to a buffer containing one or
- more encoded Erlang terms.
-
- indicates how many terms to step over in the
- buffer.
-
- The function returns a pointer to a sub-term that can be
- used in a subsequent call to in order to retrieve
- the term at that position. If there is no term, or
- would exceed the size of the terms in the buffer, NULL is returned.
-
+ encoded terms in a buffer, to directly access later term.
+
+ is a pointer to a buffer containing one
+ or more encoded Erlang terms.
+ indicates how many terms to step over in
+ the buffer.
+
+ Returns a pointer to a subterm that can be
+ used in a later call to to retrieve
+ the term at that position. If there is no term, or
+ would exceed the size of the terms in the
+ buffer, NULL is returned.
+
int erl_term_len(t)
- Determines encoded size of term.
+ Determine encoded size of term.
ETERM *t;
- This function determines the buffer space that would be
+
Determines the buffer space that would be
needed by if it were encoded into Erlang external
- format by .
-
- The size in bytes is returned.
-
+ format by .
+ Returns the size in bytes.
diff --git a/lib/erl_interface/doc/src/part.xml b/lib/erl_interface/doc/src/part.xml
index d044e2b981..3b761df221 100644
--- a/lib/erl_interface/doc/src/part.xml
+++ b/lib/erl_interface/doc/src/part.xml
@@ -22,7 +22,7 @@
- EI User's Guide
+ Erl_Interface User's Guide
Gordon Beaton
1998-11-30
diff --git a/lib/erl_interface/doc/src/ref_man.xml b/lib/erl_interface/doc/src/ref_man.xml
index e23f00956a..1e20637cb7 100644
--- a/lib/erl_interface/doc/src/ref_man.xml
+++ b/lib/erl_interface/doc/src/ref_man.xml
@@ -21,7 +21,7 @@
limitations under the License.
- Erl_Interface Command Reference
+ Erl_Interface Reference Manual
Gordon Beaton
1998-11.30
@@ -29,17 +29,6 @@
ref_man.xml
- The ei and erl_interface are C interface libraries for
- communication with Erlang .
-
- By default, the ei and erl_interface libraries are only guaranteed
- to be compatible with other Erlang/OTP components from the same
- release as the libraries themself. See the documentation of the
- ei_set_compat_rel() and
- erl_set_compat_rel()
- functions on how to communicate with Erlang/OTP components from earlier
- releases.
-
diff --git a/lib/erl_interface/doc/src/registry.xml b/lib/erl_interface/doc/src/registry.xml
index fd3e29c30f..022af85149 100644
--- a/lib/erl_interface/doc/src/registry.xml
+++ b/lib/erl_interface/doc/src/registry.xml
@@ -28,18 +28,20 @@
Gordon Beaton
Gordon Beaton
- 980707
+ 1998-07-07
A
registry.xml
registry
- Store and backup key-value pairs.
+ Store and back up key-value pairs.
This module provides support for storing key-value
pairs in a table known as a registry, backing up registries to
- Mnesia in an atomic manner, and later restoring the contents of a
- registry from Mnesia.
+ Mnesia
+ in an atomic manner, and later restoring the contents of a
+ registry from Mnesia .
+
int ei_reg_close(reg)
@@ -49,14 +51,13 @@
A registry that has previously been created with
- is closed, and all the objects it contains
- are freed.
-
- is the registry to close.
-
- The function returns 0.
+ is closed, and all the objects it
+ contains are freed.
+ is the registry to close.
+ Returns 0 .
+
int ei_reg_delete(reg,key)
Delete an object from the registry.
@@ -65,27 +66,28 @@
const char *key;
- 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
+
Deletes an object from the registry. The object is not
+ removed from the registry, it is only marked for later
+ removal so that on later 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
+ object will be reused.
+ The object is removed from the registry after a call to
or .
-
- is the registry containing .
-
- is the object to remove.
-
- If the object was found, the function returns 0 indicating
- success. Otherwise the function returns -1.
+
+
+ is the registry containing
+ .
+ is the object to remove.
+
+ Returns 0 on success, otherwise -1 .
+
int ei_reg_dump(fd,reg,mntab,flags)
Back up a registry to Mnesia.
+
int fd;
ei_reg *reg;
@@ -93,38 +95,36 @@
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
+
Dumps the contents of a registry to a Mnesia table in an
+ atomic manner, that is, either all data or no data is updated.
+ 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 is to be placed. If the table does not
+ exist, it is created automatically using configurable defaults.
+ For information about configuring this behavior, see
+ Mnesia .
+
+ If is 0 , the backup includes only
+ those objects that have been created, modified, or deleted since the
+ last backup or restore (that is, 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.
+ objects that had been marked for deletion are deleted.
+ Alternatively, setting flags to EI_FORCE causes a full
+ backup to be done, and EI_NOPURGE causes the deleted objects
+ to be left in the registry afterwards. These can be bitwise OR'ed
+ together if both behaviors are desired. If EI_NOPURGE was
+ specified, can be used to
+ explicitly remove the deleted items from the registry later.
+ Returns 0 on success, otherwise -1 .
+
double ei_reg_getfval(reg,key)
Get a floating point object.
@@ -133,22 +133,24 @@
const char *key;
- Get the value associated with in the
- registry. The value must be a floating point type.
-
- is the registry where the object will be looked
- up.
-
- 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
- valid result) use the more general function
- instead.
+ Gets the value associated with in the
+ registry. The value must be a floating point type.
+
+ is the registry where the object will be
+ looked up.
+ is the name of the object to look up.
+
+
+ On success, the function returns the value associated with
+ .
+ If the object is not found or if it is not a floating point
+ object, -1.0 is returned. To avoid problems with in-band error
+ reporting (that is, if you cannot distinguish between -1.0 and
+ a valid result), use the more general function
+ instead.
+
int ei_reg_getival(reg,key)
Get an integer object.
@@ -157,22 +159,24 @@
const char *key;
- Get the value associated with in the
- registry. The value must be an integer.
-
- is the registry where the object will be looked
- up.
-
- 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
- valid result) use the more general function
- instead.
+ Gets the value associated with in the
+ registry. The value must be an integer.
+
+ is the registry where the object will be
+ looked up.
+ is the name of the object to look up.
+
+
+ On success, the function returns the value associated with
+ .
+ If the object is not found or if it is not an integer
+ object, -1 is returned. To avoid problems with in-band error
+ reporting (that is, if you cannot distinguish between -1 and a
+ valid result), use the more general function
+ instead.
+
const void * ei_reg_getpval(reg,key,size)
Get a binary object.
@@ -182,26 +186,27 @@
int size;
- Get the value associated with in the
- 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.
-
+ Gets the value associated with in the
+ 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.
+
+ is 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,
- 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
- instead.
+ and indicates its length in
+ .
+ If the object is not found or if it is not a binary object,
+ NULL is returned. To avoid problems with in-band error
+ reporting (that is, if you cannot distinguish between NULL and
+ a valid result), use the more general function
+ instead.
+
const char * ei_reg_getsval(reg,key)
Get a string object.
@@ -210,22 +215,23 @@
const char *key;
- Get the value associated with in the
- 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.
-
+ Gets the value associated with in the
+ 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.
+
+
On success, the function returns the value associated with
- . 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
- instead.
+ . If the object is not found or if it is not a
+ string, NULL is returned. To avoid problems with in-band error
+ reporting (that is, if you cannot distinguish between NULL and
+ a valid result), use the more general function
+ instead.
+
int ei_reg_getval(reg,key,flags,v,...)
Get any object.
@@ -236,56 +242,70 @@
void *v (see below)
- This is a general function for retrieving any kind of
- object from the registry.
-
- is the registry where the object will be looked
- up.
-
- is the name of the object to look up.
-
- indicates the type of object that you are
- looking for. If is 0, then any kind of object will
- be returned. If is one of EI_INT, EI_FLT, EI_STR or
- EI_BIN, then only values of that kind will be returned. The
- buffer pointed to by must be large enough to hold the return
- data, i.e. it must be a pointer to one of ,
- , or , respectively. Also,
- if is EI_BIN, then a fifth argument is required, so that the size of the object can be
- returned.
-
- If the function succeeds, (and if the
- object is binary) will be initialized with the value associated
- with , and the function will return one of EI_INT,
- EI_FLT, EI_STR or EI_BIN, indicating the type of object. On failure the
- function will return -1 and the arguments will not be updated.
+ A general function for retrieving any kind of
+ object from the registry.
+
+ -
+
is the registry where the object will be
+ looked up.
+
+ -
+
is the name of the object to look up.
+
+ -
+
indicates the type of object that you
+ are looking for. If is 0 , any
+ kind of object is returned.
+ If is EI_INT , EI_FLT ,
+ EI_STR , or EI_BIN , then only values of
+ that kind are returned.
+ The buffer pointed to by
+ must be large enough to hold the return data, that is, it must be
+ a pointer to one of ,
+ , , or
+ , respectively.
+ If is EI_BIN , a fifth argument
+ is required, so that the size of the
+ object can be returned.
+
+
+ On success, (and if the
+ object is binary) is initialized with the value associated
+ with , and the function returns EI_INT ,
+ EI_FLT , EI_STR , or EI_BIN , indicating the type
+ of object. On failure, -1 is returned and the
+ arguments are not updated.
+
int ei_reg_markdirty(reg,key)
Mark an object as dirty.
+
ei_reg *reg;
const char *key;
- Mark a registry object as dirty. This will ensure that
- it is included in the next backup to Mnesia. Normally this
- operation will not be necessary since all of the normal registry
- 'set' functions do this automatically. However if you have
+
Marks a registry object as dirty. This ensures that
+ it is included in the next backup to Mnesia . Normally this
+ operation is not necessary, as all of the normal registry
+ 'set' functions do this automatically. However, if you have
retrieved the value of a string or binary object from the
- registry and modified the contents, then the change will be
- invisible to the registry and the object will be assumed to be
+ registry and modified the contents, then the change is
+ invisible to the registry and the object is assumed to be
unmodified. This function allows you to make such modifications
- and then let the registry know about them.
-
- is the registry containing the object.
-
- is the name of the object to mark.
-
- The function returns 0 on success, or -1 on failure.
+ and then let the registry know about them.
+
+ is the registry containing the object.
+
+ is the name of the object to mark.
+
+
+ Returns 0 on success, otherwise -1 .
+
ei_reg * ei_reg_open(size)
Create and open a registry.
@@ -293,24 +313,20 @@
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
+
Opens (creates) a registry, which initially is empty. To
+ close the registry later, use .
+ is the approximate number of objects you
+ intend to store in the registry. As the registry uses a hash table
+ with collision chaining, no absolute upper limit exists 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.
+ appropriate for your needs. To change the size later, use
+ . Notice that the number
+ you provide is increased to the nearest larger prime number.
+ Returns an empty registry on success, otherwise NULL .
+
int ei_reg_purge(reg)
Remove deleted objects.
@@ -318,20 +334,19 @@
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.
-
+ Removes all objects marked for deletion. When objects
+ are deleted with they are not
+ removed from the registry, only marked for later removal.
+ On a later backup to Mnesia , the
+ objects can also be removed from the Mnesia table. If you are
+ not backing up to Mnesia , 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.
+ deletion.
+ Returns 0 on success, otherwise -1 .
+
int ei_reg_resize(reg,newsize)
Resize a registry.
@@ -340,16 +355,15 @@
int newsize;
- Change the size of a registry.
-
+ Changes 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.
+ number is increased to the nearest larger prime number.
+ On success, the registry is resized, all contents
+ rehashed, and 0 is returned. On failure, the
+ registry is left unchanged and -1 is returned.
+
int ei_reg_restore(fd,reg,mntab)
Restore a registry from Mnesia.
@@ -359,35 +373,33 @@
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
+
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 is to be
+ placed.
+ is the name of the Mnesia table
+ to read data from.
+
+ Notice that only tables of a certain format can be
+ restored, that is, those that have been created and backed up to
+ with . If the registry was not empty
+ before the operation, 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.
-
+ are overwritten with the new values. If the registry
+ contains objects that were not in the table, they are
+ unchanged by this operation.
After the restore operation, the entire contents of the
- registry is marked as unmodified. Note that this includes any
+ registry is marked as unmodified. Notice 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.
+ overwritten by the restore.
+ Returns 0 on success, otherwise -1 .
+
int ei_reg_setfval(reg,key,f)
Assign a floating point object.
@@ -397,20 +409,22 @@
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.
+ Creates a key-value pair with the specified
+ and floating point value . If an object already
+ exists 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 is to be
+ placed.
+ is the object name.
+ is the floating point value to assign.
+
+
+ Returns 0 on success, otherwise -1 .
+
int ei_reg_setival(reg,key,i)
Assign an integer object.
@@ -420,20 +434,21 @@
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.
+ Creates a key-value pair with the specified
+ and integer value . If an object already exists
+ 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 is to be
+ placed.
+ is the object name.
+ is the integer value to assign.
+
+ Returns 0 on success, otherwise -1 .
+
int ei_reg_setpval(reg,key,p,size)
Assign a binary object.
@@ -444,26 +459,27 @@
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.
+ Creates a key-value pair with the specified
+ whose "value" is the binary object pointed to by .
+ If an object already exists 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 is to be
+ placed.
+ is the object name.
+ is a pointer to the binary object. The
+ object itself must have been created through a single call to
+ or a similar function, so that the
+ registry can later delete it if necessary by calling
+ .
+ is the length in bytes of the binary
+ object.
+
+ Returns 0 on success, otherwise -1 .
+
int ei_reg_setsval(reg,key,s)
Assign a string object.
@@ -473,24 +489,25 @@
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.
+ Creates a key-value pair with the specified
+ whose "value" is the specified string . If an
+ object already exists 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 is to be
+ placed.
+ is the object name.
+ is the string to assign. The string itself
+ must have been created through a single call to
+ or similar a function,
+ so that the registry can later delete it if
+ necessary by calling .
+
+ Returns 0 on success, otherwise -1 .
+
int ei_reg_setval(reg,key,flags,v,...)
Assign a value to any object type.
@@ -501,31 +518,41 @@
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 .
-
+ Creates a key-value pair with the specified
+ whose value is specified by . If an object already
+ exists 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 is to be
+ placed.
+
+ -
+
is the object name.
+
+ -
+
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 , 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.
+ specify a of 0 . In this case, the
+ object itself is not transferred by an
+ operation, only the pointer
+ value.
+ Returns 0 on success, otherwise -1 .
+
int ei_reg_stat(reg,key,obuf)
Get object information.
@@ -535,34 +562,35 @@
struct ei_reg_stat *obuf;
- Return information about an object.
-
- is the registry containing the object.
-
- is the name of the object.
-
- is a pointer to an structure,
- defined below:
-
+ Returns information about an object.
+
+ is the registry containing the object.
+
+ is the object name.
+ is a pointer to an
+ structure, defined as follows:
+
- 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).
-
- The field indicates the size in bytes required to store
- EI_STR (including the terminating 0) and EI_BIN objects, or 0
- for EI_INT and EI_FLT.
-
- The function returns 0 and initializes on
- success, or returns -1 on failure.
+ In the attributes of the object 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 ).
+ Field indicates the size in bytes required
+ to store EI_STR (including the terminating 0 ) and
+ EI_BIN objects, or 0 for EI_INT and
+ EI_FLT .
+ Returns 0 and initializes on success,
+ otherwise -1 .
+
int ei_reg_tabstat(reg,obuf)
Get registry information.
@@ -571,15 +599,16 @@ struct ei_reg_stat {
struct ei_reg_tabstat *obuf;
- Return information about a registry. Using information
+
Returns information about a registry. Using information
returned by this function, you can see whether the size of the
- registry is suitable for the amount of data it contains.
-
- is the registry to return information about.
-
- is a pointer to an structure,
- defined below:
-
+ registry is suitable for the amount of data it contains.
+
+ is the registry to return information
+ about.
+ is a pointer to an
+ structure, defined as follows:
+
+
- The field indicates the number of hash positions
+
Field indicates the number of hash positions
in the registry. This is the number you provided when you
created or last resized the registry, rounded up to the nearest
- prime.
-
- indicates the number of elements stored in the
- registry. It includes objects that are deleted but not purged.
-
- indicates the number of unique positions that are
- occupied in the registry.
-
- indicates how many elements are sharing
- positions in the registry.
-
- On success, the function returns 0 and is
- initialized to contain table statistics. On failure, the function
- returns -1.
+ prime number.
+
+ indicates the number of elements stored
+ in the registry. It includes objects that are deleted but not
+ purged.
+ indicates the number of unique positions
+ that are occupied in the registry.
+ indicates how many elements are
+ sharing positions in the registry.
+
+ On success, 0 is returned and
+ is initialized to contain table statistics,
+ otherwise -1 is returned.
--
cgit v1.2.3