XML Signatures

Sybase CEP software requires the description of the UDF to be in an XML file, which is put in the plugins directory of both the server and Studio.

The file name should have the extension ".udf" so the server and Studio can find the file. For each UDF, the file lists:

The Functions element of the XML file may describe an arbitrary number of functions. This allows for the grouping of related functions and/or library modules, and there may be an arbitrary number of function modules in a library. In the XML file, each function should be described inside its own "<Function> ... </Function>" element. For example:

<Functions>
<Function Name="MyFunc" 
         InitFunctionName="MyInit"
         ShutdownFunctionName="MyShutdown"
         Library="c8_udf_lib" 
         CclName="MyFunc"
         IsAggregator="false">
 ...
 <Input>
    <Parameter Name="var1"  Type="C8Float"/>
    ...
 </Input>
 <Output>
    <Parameter Type="C8Long"/>
 </Output>
</Function>
<Function Name="bar" ...>
...
</Function>
</Functions>

The initial function element is always named "Function" and has six attributes:

The Input element inside each Function element must contain a list of all input parameters. Only one Input element is permitted per function.

Each Parameter element inside the Input element includes two attributes: the parameter "Name" and "Type". The Name is arbitrary, but for clarity it should reflect the parameter usage. The Name attribute is used for error reporting if there is a type mismatch for any parameters at runtime.

The "Type" parameter specifies the data type of the input parameter. If you are writing your UDF in C/C++, the types available map directly into C base types via these typedefs:

typedef int C8Bool;        /* CCL "BOOLEAN" type */
typedef int32 C8Int;       /* CCL "INTEGER" type */
typedef double C8Float;    /* CCL "FLOAT" type. Note that 
                       * CCL FLOAT is NOT C "float"; 
                       * it's C "double". 
                       */
typedef char* C8CharPtr;   /* CCL "STRING" type */
typedef char C8Char;
typedef int64 C8Long;      /* CCL "LONG" type */
typedef int64 C8Timestamp; /* CCL "TIMESTAMP" type */
typedef int64 C8Interval;  /* CCL "INTERVAL type */
typedef void *C8BlobPtr;   /* CCL "BLOB" type */
typedef void C8Blob;       /* CCL "BLOB" type */

For example, if the first input parameter has a CCL data type of FLOAT, then you would specify C8Float in the .udf file. Only the above typedef names are supported in the "Type" attribute. Throughout the C code for your UDF, you should use the typedef'd names (for example, "C8Float") rather than the underlying C types (for example, "double"). The Sybase CEP software uses strong type checking to help ensure correctness of data at runtime.

The "output" element of the sample XML file contains only a single "Parameter" field and describes the function output in the same manner as input parameters. The "Name" attribute is optional. It is not currently possible to return more than a single value from a user defined function.