Gammu internals  1.38.0
gammu-inifile.h File Reference
#include <gammu-types.h>
#include <gammu-error.h>
Include dependency graph for gammu-inifile.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _INI_Entry
 
struct  _INI_Section
 

Typedefs

typedef struct _INI_Entry INI_Entry
 
typedef struct _INI_Section INI_Section
 

Functions

void INI_Free (INI_Section *head)
 
GSM_Error INI_ReadFile (const char *FileName, gboolean Unicode, INI_Section **result)
 
INI_EntryINI_FindLastSectionEntry (INI_Section *file_info, const unsigned char *section, const gboolean Unicode)
 
unsigned char * INI_GetValue (INI_Section *file_info, const unsigned char *section, const unsigned char *key, const gboolean Unicode)
 
int INI_GetInt (INI_Section *cfg, const unsigned char *section, const unsigned char *key, int fallback)
 
gboolean INI_GetBool (INI_Section *cfg, const unsigned char *section, const unsigned char *key, gboolean fallback)
 
gboolean GSM_StringToBool (const char *value)
 

Detailed Description

Author
Michal Čihař

INI files manipulation.

Definition in file gammu-inifile.h.

Function Documentation

§ INI_GetBool()

gboolean INI_GetBool ( INI_Section cfg,
const unsigned char *  section,
const unsigned char *  key,
gboolean  fallback 
)

Returns boolean value from configuration. The file is automatically handled as not unicode.

Parameters
cfgFile data as returned by INI_ReadFile.
sectionSection to scan.
keyName of key to read.
fallbackFallback value.
Returns
Key value or fallback in case of failure.

Returns integer value from configuration.

Definition at line 344 of file cfg.c.

References FALSE, GSM_StringToBool(), and INI_GetValue().

Referenced by GSM_ReadConfig().

345 {
346  char *str;
347  gboolean ret;
348 
349  str = (char *)INI_GetValue(cfg, section, key, FALSE);
350  if (str) {
351  ret = GSM_StringToBool(str);
352  if (ret == -1) {
353  return fallback;
354  }
355  return ret;
356  } else {
357  return fallback;
358  }
359 }
gboolean GSM_StringToBool(const char *value)
Definition: cfg.c:470
int gboolean
Definition: gammu-types.h:23
#define FALSE
Definition: gammu-types.h:25
unsigned char * INI_GetValue(INI_Section *cfg, const unsigned char *section, const unsigned char *key, const gboolean Unicode)
Definition: cfg.c:365

§ INI_GetInt()

int INI_GetInt ( INI_Section cfg,
const unsigned char *  section,
const unsigned char *  key,
int  fallback 
)

Returns integer value from configuration. The file is automatically handled as not unicode.

Parameters
cfgFile data as returned by INI_ReadFile.
sectionSection to scan.
keyName of key to read.
fallbackFallback value.
Returns
Key value or fallback in case of failure.

Returns integer value from configuration.

Definition at line 329 of file cfg.c.

References FALSE, and INI_GetValue().

330 {
331  char *str;
332 
333  str = (char *)INI_GetValue(cfg, section, key, FALSE);
334  if (str) {
335  return atoi(str);
336  } else {
337  return fallback;
338  }
339 }
#define FALSE
Definition: gammu-types.h:25
unsigned char * INI_GetValue(INI_Section *cfg, const unsigned char *section, const unsigned char *key, const gboolean Unicode)
Definition: cfg.c:365