Gammu internals  1.38.0
cfg.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <gammu-config.h>
#include <gammu-inifile.h>
#include "coding/coding.h"
#include "../../helper/string.h"
Include dependency graph for cfg.c:

Go to the source code of this file.

Functions

GSM_Error INI_ReadFile (const char *FileName, gboolean Unicode, INI_Section **result)
 
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)
 
unsigned char * INI_GetValue (INI_Section *cfg, const unsigned char *section, const unsigned char *key, const gboolean Unicode)
 
INI_EntryINI_FindLastSectionEntry (INI_Section *file_info, const unsigned char *section, const gboolean Unicode)
 
void INI_Free_Entries (INI_Entry *entry)
 
void INI_Free (INI_Section *head)
 
gboolean GSM_StringToBool (const char *value)
 

Function Documentation

§ INI_Free_Entries()

void INI_Free_Entries ( INI_Entry entry)

Definition at line 437 of file cfg.c.

References _INI_Entry::EntryName, _INI_Entry::EntryValue, and _INI_Entry::Next.

Referenced by INI_Free().

438 {
439  INI_Entry *cur = entry, *next=NULL;
440 
441  if (cur == NULL) return;
442  while (cur != NULL) {
443  next = cur->Next;
444  free(cur->EntryName);
445  cur->EntryName=NULL;
446  free(cur->EntryValue);
447  cur->EntryValue=NULL;
448  free(cur);
449  cur=NULL;
450  cur=next;
451  }
452 }
unsigned char * EntryValue
Definition: gammu-inifile.h:44
Definition: gammu-inifile.h:41
unsigned char * EntryName
Definition: gammu-inifile.h:43
INI_Entry * Next
Definition: gammu-inifile.h:42

§ INI_GetBool()

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

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.

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