Symisc UnQLite

An Embeddable NoSQL Database Engine



UnQLite C/C++ API Reference - Randomness inside foreign functions.

Syntax

unsigned int unqlite_context_random_num(unqlite_context *pCtx);

int unqlite_context_random_string(unqlite_context *pCtx,char *zBuf,int nBuflen);


Generate random number and/or string inside a foreign function.


Description


UnQLite is shipped with a high-quality pseudo-random number generator (PRNG). The PRNG is also used by the built-in rand() and rand_str() Jx9 functions. These interfaces allows host-applications to access the same PRNG for other purposes.


unqlite_context_random_num() returns a 32-bit unsigned integer between 0 and 0xFFFFFFFF.


unqlite_context_random_string() generate an English based alphabet string of length nBuflen (last argument).


Note that the generated string is not null terminated and the given buffer must be big enough to hold at least 3 bytes.


These interfaces accepts as their first argument a pointer to a unqlite_context which mean that they are designed to be invoked only from a foreign function.


These routines must be called from the same thread in which the application-defined function is running.


Parameters


pCtx

Foreign function Call Context.


Return value


Random generated number and/or string.


See also


Installing Foreign Functions.



Symisc Systems
Copyright © Symisc Systems