You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

inifile.h 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. Library for inifile like data files.
  3. Copyright (C) 2006 Olaf Klein, o.b.klein@gpsbabel.org
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
  15. */
  16. #ifndef HAVE_INIFILE_H
  17. #define HAVE_INIFILE_H
  18. #include "defs.h"
  19. typedef struct inifile_s {
  20. int isecs; /* number of sections */
  21. queue secs; /* sections */
  22. uint8_t unicode:1;
  23. } inifile_t;
  24. /*
  25. inifile_init:
  26. reads inifile filename into memory
  27. myname represents the calling module
  28. */
  29. inifile_t* inifile_init(const char* filename, const char* myname);
  30. void inifile_done(inifile_t* inifile);
  31. int inifile_has_section(const inifile_t* inifile, const char* section);
  32. /*
  33. inifile_readstr:
  34. returns NULL if not found, otherwise a pointer to the value of key ...
  35. all key values are valid entities until "inifile_done"
  36. */
  37. char* inifile_readstr(const inifile_t* inifile, const char* section, const char* key);
  38. /*
  39. inifile_readint:
  40. on success the value is stored into "*value" and "inifile_readint" returns 1,
  41. otherwise inifile_readint returns 0
  42. */
  43. int inifile_readint(const inifile_t* inifile, const char* section, const char* key, int* value);
  44. /*
  45. inifile_readint_def:
  46. if found inifile_readint_def returns value of key, otherwise a default value "def"
  47. */
  48. int inifile_readint_def(const inifile_t* inifile, const char* section, const char* key, const int def);
  49. #endif