IRCBot Plugin API  v5
Public Attributes | List of all members
API_config Struct Reference

#include <plugins.h>

Public Attributes

DS_CONFIG_SECTION *(* GetConfigSection )(DS_CONFIG_SECTION *parent, const char *name)
 
bool(* GetConfigSectionValueBuf )(DS_CONFIG_SECTION *section, const char *name, char *buf, size_t bufSize)
 
char *(* GetConfigSectionValue )(DS_CONFIG_SECTION *section, const char *name)
 
long(* GetConfigSectionLong )(DS_CONFIG_SECTION *section, const char *name)
 
double(* GetConfigSectionFloat )(DS_CONFIG_SECTION *section, const char *name)
 
bool(* IsConfigSectionValue )(DS_CONFIG_SECTION *section, const char *name)
 

Detailed Description

These functions give you access to the configuration in ircbot.conf.
As you probably know from your own dealings with ircbot.conf, the bot's configuration is based on hierarchical sections with values inside them.

Member Data Documentation

DS_CONFIG_SECTION*(* API_config::GetConfigSection)(DS_CONFIG_SECTION *parent, const char *name)

This function finds and returns a config section.
Example getting the AutoDJ section: DS_CONFIG_SECTION * sec = GetConfigSection(NULL, "AutoDJ");
Example getting the AutoDJ/Options section after getting AutoDJ above: DS_CONFIG_SECTION * options = GetConfigSection(sec, "Options");

Parameters
parentThe parent section to search in, NULL to search the root section.
nameThe name of the section to find
bool(* API_config::GetConfigSectionValueBuf)(DS_CONFIG_SECTION *section, const char *name, char *buf, size_t bufSize)

This function finds a section value and if it exists fills buf with it.
If the setion value is a number it will be converted to a string with snprintf

Parameters
sectionThe section to search in. This must not be NULL!
nameThe name of the value to find
bufThe buffer to store the value in
bufSizeThe size of buf
Returns
true if the value was found successfully, false otherwise
char*(* API_config::GetConfigSectionValue)(DS_CONFIG_SECTION *section, const char *name)

This function finds a string section value and if it exists returns a const pointer to the value.
The returned pointer should not be modified or free'd, it belongs to the configuration parser.
In the value is a number the function will return NULL

Parameters
sectionThe section to search in. This must not be NULL!
nameThe name of the value to find
Returns
A pointer to the string value if found successfully, NULL otherwise
long(* API_config::GetConfigSectionLong)(DS_CONFIG_SECTION *section, const char *name)

This function finds a numerical section value and if it exists returns the number.
In the value is a string it will be converted to a number with atol()

Parameters
sectionThe section to search in. This must not be NULL!
nameThe name of the value to find
Returns
The number if found, -1 otherwise. (note: if you have an option where -1 might be a valid setting you should use API_config::GetConfigSectionValueBuf or API_config::IsConfigSectionValue to make sure it actually exists)
double(* API_config::GetConfigSectionFloat)(DS_CONFIG_SECTION *section, const char *name)

This function finds a floating point section value and if it exists returns the number.
In the value is a string it will be converted to a number with atof()

Parameters
sectionThe section to search in. This must not be NULL!
nameThe name of the value to find
Returns
The number if found, -1 otherwise. (note: if you have an option where -1 might be a valid setting you should use API_config::GetConfigSectionValueBuf or API_config::IsConfigSectionValue to make sure it actually exists)
bool(* API_config::IsConfigSectionValue)(DS_CONFIG_SECTION *section, const char *name)

This function checks to see if a section value exists
In the value is a string it will be converted to a number with atof()

Parameters
sectionThe section to search in. This must not be NULL!
nameThe name of the value to find
Returns
true if the value was found, false otherwise.

The documentation for this struct was generated from the following file: