Difference between revisions of "SDK Shared Library Functions"

From Lianjapedia
Jump to: navigation, search
m (1 revision)
(Blanked the page)
 
Line 1: Line 1:
'C' functions defined in shared libraries can be used on Linux.
 
  
==Defining the C functions==
 
The shared library must include the following four elements:
 
 
====The include file "lianja_api.h"====
 
 
<code lang="c">
 
#include "lianja_api.h"
 
</code>
 
 
====The API_SHARED_FUNCTION_TABLE structure====
 
Used to define the 'C' functions and objects included in the library:
 
 
 
<code lang="c">
 
// API function address table
 
static struct API_FUNCTION_ADDRESS_TABLE *api_function_address_table = NULL;
 
 
// Add all functions and objects  to this structure as follows:
 
// Name, C Function Name Type
 
//
 
// Make sure the last entry is NULL.
 
//
 
static struct API_SHARED_FUNCTION_TABLE api_function_table[7] = {
 
{"schar", "fnSamplesCharacter", API_FUNCTION},
 
{"stype", "fnSamplesType", API_FUNCTION},
 
{"slog", "fnSamplesLogical", API_FUNCTION},
 
{"snum", "fnSamplesNumeric", API_FUNCTION},
 
{"sopen", "fnSamplesOpen", API_FUNCTION},
 
{"myclass", "clsMyClass", API_CLASS},
 
{NULL, NULL, -1}
 
} ;
 
</code>
 
 
====The initAPI() function====
 
 
 
<code lang="c">
 
// This function is used to define function addresses for API calls.
 
int initAPI(struct API_FUNCTION_ADDRESS_TABLE *function_address_table)
 
{
 
    api_function_address_table = function_address_table;
 
    return 0;
 
}
 
</code>
 
 
====The getFunctions() function====
 
 
<code lang="c">
 
// This function is used to return the function names of the API.
 
struct API_SHARED_FUNCTION_TABLE *getFunctions(void)
 
{
 
return api_function_table;
 
}
 
</code>
 
 
==Using the 'C' functions and classes:==
 
 
Shared libraries are loaded using the SET LIBRARY TO <library> [ADDITIVE] command or the [[REQUIRE()]], [[REQUIRE_ONCE()]], [[INCLUDE()]] or [[INCLUDE_ONCE()]] functions.  By default library files are accessed from the directory defined by the DB_LIBDIR environment variable.
 
 
If full path information is specified, the shared library files can be loaded from other directories, e.g.
 
 
<code lang="recital">
 
// pdf.so is in the DB_LIBDIR directory
 
set library to pdf
 
   
 
//mylib.so is in /opt/lianja/myapplibs
 
set library to /opt/lianja/myapplibs/mylib
 
</code>
 
 
The function [[LOADLIBRARY()|LOADLIBRARY(<library>)]] can also be used to load additional shared libraries.  The name of the shared library file including the full path and file extension must be specified.
 
 
The [[SET LIBRARY|SET LIBRARY TO]] or [[RELEASE LIBRARY|RELEASE LIBRARY <library>]] commands are used to close all or specified shared libraries.
 
 
The [[LIST PROCEDURE]] and [[DISPLAY PROCEDURE]] commands include loaded shared library function names in their listings and the [[LIST CLASSES]] and [[DISPLAY CLASSES]] commands include loaded shared library class names in their listings.
 
 
Loaded shared library functions can be used in the same way as an internal function.  Loaded shared library classes can be used in the same way as system classes.
 
 
[[Category:Documentation]]
 
[[Category:SDK]]
 

Latest revision as of 00:19, 16 April 2013