All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Macros | Functions
Turbulence: general facilities, initialization, etc

Macros

#define abort_error(m,...)   do{turbulence_error (ctx, axl_true, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)
 
#define error(m,...)   do{turbulence_error (ctx, axl_false, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)
 
#define msg(m,...)   do{turbulence_msg (ctx, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)
 
#define msg2(m,...)   do{turbulence_msg2 (ctx, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)
 
#define tbc_access(m,...)   do{turbulence_access (ctx, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)
 
#define wrn(m,...)   do{turbulence_wrn (ctx, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)
 
#define wrn_sl(m,...)   do{turbulence_wrn_sl (ctx, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)
 

Functions

char * turbulence_base_dir (const char *path)
 
axl_bool turbulence_change_fd_owner (TurbulenceCtx *ctx, const char *file_name, const char *user, const char *group)
 
axl_bool turbulence_change_fd_perms (TurbulenceCtx *ctx, const char *file_name, const char *mode)
 
void turbulence_color_log_enable (TurbulenceCtx *ctx, int value)
 
axl_bool turbulence_create_dir (const char *path)
 
const char * turbulence_datadir (TurbulenceCtx *ctx)
 
void turbulence_exit (TurbulenceCtx *ctx, axl_bool free_ctx, axl_bool free_vortex_ctx)
 
axl_bool turbulence_file_is_fullpath (const char *file)
 
char * turbulence_file_name (const char *path)
 
axl_bool turbulence_file_test_v (const char *format, VortexFileTest test,...)
 
int turbulence_get_system_id (TurbulenceCtx *ctx, const char *value, axl_bool get_user)
 
axl_bool turbulence_init (TurbulenceCtx *ctx, VortexCtx *vortex_ctx, const char *config)
 
axl_bool turbulence_is_num (const char *value)
 
long turbulence_last_modification (const char *file)
 
void turbulence_log2_enable (TurbulenceCtx *ctx, int value)
 
axl_bool turbulence_log2_enabled (TurbulenceCtx *ctx)
 
void turbulence_log3_enable (TurbulenceCtx *ctx, int value)
 
axl_bool turbulence_log3_enabled (TurbulenceCtx *ctx)
 
void turbulence_log_enable (TurbulenceCtx *ctx, int value)
 
axl_bool turbulence_log_enabled (TurbulenceCtx *ctx)
 
void turbulence_reload_config (TurbulenceCtx *ctx, int value)
 
const char * turbulence_runtime_datadir (TurbulenceCtx *ctx)
 
const char * turbulence_runtime_tmpdir (TurbulenceCtx *ctx)
 
void turbulence_sleep (TurbulenceCtx *ctx, long microseconds)
 
const char * turbulence_sysconfdir (TurbulenceCtx *ctx)
 
axl_bool turbulence_unlink (const char *path)
 

Detailed Description

Macro Definition Documentation

#define abort_error (   m,
  ... 
)    do{turbulence_error (ctx, axl_true, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)

Drop an error msg to the console stderr without taking into consideration debug configuration.

To drop an error message use:

abort_error ("unable to open file: %s", file);
Parameters
mThe error message to output.

Referenced by turbulence_init(), and turbulence_run_config().

#define error (   m,
  ... 
)    do{turbulence_error (ctx, axl_false, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)
#define msg (   m,
  ... 
)    do{turbulence_msg (ctx, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)
#define msg2 (   m,
  ... 
)    do{turbulence_msg2 (ctx, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)

Drop a second level msg to the console stdout.

To drop a message use:

msg2 ("module loaded: %s", module);
Parameters
mThe console message to output.

Referenced by __turbulence_ppath_mask_items(), turbulence_ctx_wait(), turbulence_db_list_init(), turbulence_db_list_open(), turbulence_init(), and turbulence_run_load_modules_from_path().

#define tbc_access (   m,
  ... 
)    do{turbulence_access (ctx, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)

Reports an access message, a message that is sent to the access log file.

The message must contain access to the server information.

To drop a message use:

access ("module loaded: %s", module);
Parameters
mThe console message to output.
#define wrn (   m,
  ... 
)    do{turbulence_wrn (ctx, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)
#define wrn_sl (   m,
  ... 
)    do{turbulence_wrn_sl (ctx, __AXL_FILE__, __AXL_LINE__, m, ##__VA_ARGS__);}while(0)

Drops to the console stdout a warning, placing the content prefixed with the file and the line that caused the message, without introducing a new line.

To drop a message use:

wrn_sl ("module loaded: %s", module);
Parameters
mThe warning message to output.

Function Documentation

char * turbulence_base_dir ( const char *  path)

Allows to get the base dir associated to the provided path.

Parameters
pathThe path that is required to return its base part.
Returns
Returns the base dir associated to the function. You must deallocate the returning value with axl_free.
axl_bool turbulence_change_fd_owner ( TurbulenceCtx ctx,
const char *  file_name,
const char *  user,
const char *  group 
)

Allows to change the owner (user and group) of the socket's file associated.

Parameters
ctxThe Turbulence context.
file_nameThe file name path to change its owner.
userThe user string representing the user to change. If no user required to change, just pass empty string or NULL.
groupThe group string representing the group to change. If no group required to change, just pass empty string or NULL.
Returns
axl_true if the operation was completed, otherwise false is returned.

References turbulence_get_system_id().

axl_bool turbulence_change_fd_perms ( TurbulenceCtx ctx,
const char *  file_name,
const char *  mode 
)

Allows to change the permissions of the socket's file associated.

Parameters
ctxThe Turbulence context.
file_nameThe file name path to change perms.
modeThe mode to configure.
void turbulence_color_log_enable ( TurbulenceCtx ctx,
int  value 
)

Allows to configure if the console log produced is colorfied according to the status reported (red: (error,criticals), yellow: (warning), green: (info, debug).

Parameters
ctxThe turbulence context to configure.
valueThe value to configure. This function could take no effect on system where ansi values are not available.
axl_bool turbulence_create_dir ( const char *  path)

Creates the directory with the path provided.

Parameters
pathThe directory to create.
Returns
axl_true if the directory was created, otherwise axl_false is returned.

Referenced by turbulence_db_list_open().

const char * turbulence_datadir ( TurbulenceCtx ctx)

Allows to get the TBC_DATADIR path provided at compilation time.

This is configured when the libturbulence.{dll,so} is built, ensuring all pieces uses the same data dir value.

The TBC_DATADIR points to the base root directory where data files are located (mostly dtd files). Under unix system it is usually: /usr/share/turbulence. On windows system it is usually configured to: ../data.

Parameters
ctxThe turbulence ctx with the associated configuration where we are getting the sysconfdir. If NULL is provided, default value is returned.
Returns
The path currently configured by default or the value overrided on the configuration.
void turbulence_exit ( TurbulenceCtx ctx,
axl_bool  free_ctx,
axl_bool  free_vortex_ctx 
)

Performs all operations required to cleanup turbulence runtime execution (calling to all module cleanups).

References msg, turbulence_ctx_free(), turbulence_ctx_get_vortex_ctx(), turbulence_db_list_cleanup(), turbulence_loop_close(), and turbulence_module_notify_close().

axl_bool turbulence_file_is_fullpath ( const char *  file)

Allows to check if the provided file path is a full path (not releative).

The function is meant to be portable.

Parameters
fileThe file to check if it is a full path file name.
Returns
axl_true if the file is a full path, otherwise axl_false is returned.
char * turbulence_file_name ( const char *  path)

Allows to get the file name associated to the provided path.

Parameters
pathThe path that is required to return its base value.
Returns
Returns the base dir associated to the function. You msut deallocate the returning value with axl_free.

Referenced by turbulence_run_load_modules_from_path().

axl_bool turbulence_file_test_v ( const char *  format,
VortexFileTest  test,
  ... 
)

Provides the same functionality like vortex_support_file_test, but allowing to provide the file path as a printf like argument.

Parameters
formatThe path to be checked.
testThe test to be performed.
Returns
axl_true if all test returns axl_true. Otherwise axl_false is returned. Note that if format is NULL, the function will always return axl_false.

Referenced by turbulence_db_list_reload().

int turbulence_get_system_id ( TurbulenceCtx ctx,
const char *  value,
axl_bool  get_user 
)

Allows to get system user id or system group id from the provided string.

If the string already contains the user id or group id, the function returns its corresponding integet value. The function also checks if the value (that should represent a user or group in some way) is present on the current system. get_user parameter controls if the operation should perform a user lookup or a group lookup.

Parameters
ctxThe turbulence context.
valueThe user or group to get system id.
get_useraxl_true to signal the value to lookup user, otherwise axl_false to lookup for groups.
Returns
The function returns the user or group id or -1 if it fails.

References msg.

Referenced by turbulence_change_fd_owner().

axl_bool turbulence_init ( TurbulenceCtx ctx,
VortexCtx *  vortex_ctx,
const char *  config 
)

Starts turbulence execution, initializing all libraries required by the server application.

A call to turbulence_exit is required before exit.

References abort_error, msg, msg2, turbulence_ctx_set_vortex_ctx(), and turbulence_db_list_init().

axl_bool turbulence_is_num ( const char *  value)

Allows to check if the provided value contains a decimal number.

Parameters
valueThe decimal number to be checked.
Returns
axl_true in the case a decimal value is found otherwise axl_false is returned.
long turbulence_last_modification ( const char *  file)

Allows to get last modification date for the file provided.

Parameters
fileThe file to check for its modification time.
Returns
The last modification time for the file provided. The function return -1 if it fails.

Referenced by turbulence_db_list_flush(), turbulence_db_list_open(), and turbulence_db_list_reload().

void turbulence_log2_enable ( TurbulenceCtx ctx,
int  value 
)

Allows to activate the second level console log.

This level of debug automatically activates the previous one. Once activated it provides more information to the console.

Parameters
ctxThe turbulence context to configure.
valueThe value to configure.
axl_bool turbulence_log2_enabled ( TurbulenceCtx ctx)

Allows to check if the second level debug is activated (msg2 type).

Returns
axl_true if activated, otherwise axl_false is returned.
void turbulence_log3_enable ( TurbulenceCtx ctx,
int  value 
)

Allows to activate the third level console log.

This level of debug automatically activates the previous one. Once activated it provides more information to the console.

Parameters
ctxThe turbulence context to configure.
valueThe value to configure.
axl_bool turbulence_log3_enabled ( TurbulenceCtx ctx)

Allows to check if the third level debug is activated (msg2 with additional information).

Returns
axl_true if activated, otherwise axl_false is returned.
void turbulence_log_enable ( TurbulenceCtx ctx,
int  value 
)

Allows to activate the turbulence console log (by default disabled).

Parameters
ctxThe turbulence context to configure.
valueThe value to configure to enable/disable console log.
axl_bool turbulence_log_enabled ( TurbulenceCtx ctx)

Allows to check if the debug is activated (msg type).

Returns
axl_true if activated, otherwise axl_false is returned.
void turbulence_reload_config ( TurbulenceCtx ctx,
int  value 
)

Function that performs a reload operation for the current turbulence instance (represented by the provided TurbulenceCtx).

Parameters
ctxThe turbulence context representing a running instance that must reload.
valueThe signal number caught. This value is optional since reloading can be triggered not only by a signal received (i.e. SIGHUP).

References msg, and turbulence_module_notify_reload_conf().

Referenced by turbulence_signal_received().

const char * turbulence_runtime_datadir ( TurbulenceCtx ctx)

Allows to get the TBC_RUNTIME_DATADIR path provided at compilation time.

This is configured when the libturbulence.{dll,so} is built, ensuring all pieces uses the same runtime datadir value.

The TBC_RUNTIME_DATADIR points to the base directory where runtime data files are located (for example unix socket files).

Under unix system it is usually: /var/lib. On windows system it is usually configured to: ../run-time. Inside that directory is found a directory called "turbulence" where runtime content is found.

Parameters
ctxThe turbulence ctx with the associated configuration where we are getting the sysconfdir. If NULL is provided, default value is returned.
Returns
The path currently configured by default or the value overrided on the configuration.

Referenced by turbulence_support_get_backtrace().

const char * turbulence_runtime_tmpdir ( TurbulenceCtx ctx)

Allows to get current temporal directory.

Parameters
ctxThe turbulence ctx where the configuration will be checked.
Returns
The path to the temporal directory.

Referenced by turbulence_support_get_backtrace().

void turbulence_sleep ( TurbulenceCtx ctx,
long  microseconds 
)

Implements a portable subsecond thread sleep operation.

The caller will be blocked during the provide period.

Parameters
ctxThe context used during the operation.
microsecondsAmount of time to wait.
const char * turbulence_sysconfdir ( TurbulenceCtx ctx)

Allows to get the SYSCONFDIR path provided at compilation time.

This is configured when the libturbulence.{dll,so} is built, ensuring all pieces uses the same SYSCONFDIR value. See also turbulence_datadir.

The SYSCONFDIR points to the base root directory where all configuration is found. Under unix system it is usually: /etc. On windows system it is usually configured to: ../etc. Starting from that directory is found the rest of configurations:

  • etc/turbulence/turbulence.conf
  • etc/turbulence/sasl/sasl.conf
Parameters
ctxThe turbulence ctx with the associated configuration where we are getting the sysconfdir. If NULL is provided, default value is returned.
Returns
The path currently configured by default or the value overrided on the configuration.
axl_bool turbulence_unlink ( const char *  path)

Allows to remove the selected file pointed by the path provided.

Parameters
pathThe path to the file to be removed.
Returns
axl_true if the file was removed, otherwise axl_false is returned.