dl_builtin_addr
dl_builtin_addr (fname)
This function returns the address of specified built-in Arbortext Editor function. This address may be passed to a dynamically loaded function with dl_call to allow such functions to call back into Arbortext Editor to request various services, in particular, to execute and evaluate ACL commands and expressions.
The parameter fname may be one of the following:
acl_exec
Returns the address of the ACL interpreter. This is an interface to the ACL function exec. The built-in function has the signature:
typedef unsigned int (*ACLEXEC) (char *cmd);
where cmd is the ACL command to execute. The return value is the command status variable main::status. The command string is interpreted as a multi-byte string.
acl_execU
Same as acl_exec except the input string is a Unicode string.
acl_eval
Returns the address of the ACL expression evaluator. This is an interface to the ACL function eval. The built-in function has the signature:
typedef char* (*ACLEVAL) (char* expr, char* buf, int bufsize);
where expr is the string to evaluate, buf is an output buffer to receive the result of the expression as a string, and bufsize is the maximum size of the buffer. At most bufsize bytes will be written to buf.
The result will not be null-terminated if it is longer than bufsize-1 bytes. All strings are interpreted as multi-byte strings.
You can retrieve the value of an ACL variable by passing its name as the expr argument.
acl_evalU
Same as acl_eval except the strings are Unicode, (that is, the char* types in the acl_eval example are replaced by unsigned short*.
application
Returns the address of the C++ binding for the Application interface.
The function returns 0 if fname is not recognized.
|
The function call dl_builtin_addr('acl_exec') replaces interpreter_addr.
|
The following is an example of some C functions that might be part of a dynamically loaded library.
typedef unsigned int (*CMDFUNC) (char * acl_string);
CMDFUNC acl_execp;
void set_acl_addr(void *addr)
{
acl_execp = (CMDFUNC) addr;
}
int aclcmd(char *str)
{
if (acl_execp)
return (*acl_execp)(str);
fprintf(stderr, "set_acl_addr() must be called first.\n");
return 0;
}
The interpreter address is passed to the library as follows:
local set_acl_addr = dl_find(hdll, "set_acl_addr");
dl_call(set_acl_addr, dl_builtin_addr("acl_exec"));
Related Topics