iniutil.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * category: [config]
  3. * apply status:
  4. * edit status:
  5. * build status:
  6. * description: to read .ini format file
  7. * TODO: multi thread and multi process test.
  8. */
  9. #ifndef __LOGINI_H__
  10. #define __LOGINI_H__
  11. #pragma once
  12. #include "config.h"
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #include <stdarg.h>
  17. #include "array.h"
  18. /** return length of retval*/
  19. TOOLKIT_API int inifile_read_str_s(const char* section, const char* key, const char* defval, char* retval, int val_size, const char* file);
  20. /** please remember to FREE the returned char*-type value if not null*/
  21. TOOLKIT_API char *inifile_read_str(const char *file, const char *section, const char *key, const char *defval);
  22. TOOLKIT_API int inifile_read_int(const char *file, const char *section, const char *key, int defval);
  23. TOOLKIT_API array_header_t* inifile_read_section_all(const char *file);
  24. TOOLKIT_API array_header_t* inifile_read_section_key_all(const char *file, const char *section);
  25. TOOLKIT_API int inifile_format_readv(const char *file, const char *section, const char *key, const char *fmt, va_list arg);
  26. TOOLKIT_API int inifile_format_read(const char *file, const char *section, const char *key, const char *fmt, ...);
  27. /*0:suc, -1:failed*/
  28. TOOLKIT_API int inifile_write_str(const char *file, const char *section, const char *key, const char *value);
  29. TOOLKIT_API int inifile_write_int(const char *file, const char *section, const char *key, int value);
  30. TOOLKIT_API int inifile_format_writev(const char *file, const char *section, const char *key, const char *fmt, va_list arg);
  31. TOOLKIT_API int inifile_format_write(const char *file, const char *section, const char *key, const char *fmt, ...);
  32. #ifdef __cplusplus
  33. } // extern "C" {
  34. #endif
  35. #endif //__LOGINI_H__