Skip to content
Sudheer edited this page Mar 19, 2023 · 2 revisions

Class of of reusable generic methods methods for random number generation

Synopsis

local utils = require('service_utils.common.utils');

Methods

utils.get_rand_int()

DESCRIPTION:

Generate random integer of 4 bytes

PARAMETERS:

none

RETURN:

rand_int: integer

utils.get_rand_bytes(len);

DESCRIPTION:

Generates a random byte buffer of size given by input parameter len

PARAMETERS:

len: integer

RETURN:

buf: CDATA (hex_data_s_type*), hex_data_s_type is defined in lua_schema.core_utils and is used across service_utils as the representation of binary data buffer.

utils.os_name();

DESCRIPTION:

Returns the name of OS on which the program is being run (equivalent of uname)

PARAMETERS:

none

RETURN:

osname: string

utils.load_library(libname, [extension]);

DESCRIPTION:

Loads a lua module implmented as a dynamic library. It is expected that the loader function is of the format luaopen_

PARAMETERS:

libname: string extension: optional, string, in case of OSX dynamic libraries can be of extension dylib or so and in linux it is always so

RETURN:

lib: table, loaded module

Clone this wiki locally