This section describes how to write functions to perform library intitalization and shutdown.
One library (.dll or .so file) for Sybase CEP Server may contain more than one UDF, more than one in-process adapter, or more than one server plugin. In some cases, you may want to have initialize() and shutdown() functions that apply to the entire library in addition to those that apply for a particular in-process adapter or plugin. These functions are called once when that the library is loaded or unloaded by Sybase CEP Server.
To implement this, write two functions with the following signatures:
Parameters: None.
Returns: Any one of the values in the C8LibraryResult enumeration:
C8_LIBRARY_INIT_ERROR: Initialize failed. The library will not be loaded. The c8_library_shutdown() function will be called if it is present.
C8_LIBRARY_INIT_OK: Initialize completed successfully.
C8_LIBRARY_INIT_OK_CAN_UNLOAD: The initialization completed successfully, and Sybase CEP Server may unload the library if there are no remaining references to it. For example, if the library is a UDF library, and if at some future time the server has unloaded all projects that call UDFs in this library, then it would be safe to unload this library.
Returns: Nothing.
These functions are purely optional. In your library, you can include either function, both functions, or neither function.
The function prototypes and the C8LibraryResult enumerations which defines the return codes such as C8_LIBRARY_INIT_ERROR are in the c8server.h file. This file is located in the "include" subdirectory of the Sybase CEP C/C++ SDK directory. If you installed to the default directory on Microsoft Windows, this will be:
C:\Program Files\SybaseC8\Server\sdk\c\include
If you installed to the default directory on a UNIX-like operating system, this will be:
/home/user/sybasec8/server/sdk/c/include