readconf.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* readconf/include/readconf.h
  2. *
  3. * This file is part of readconf.
  4. *
  5. * readconf is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * readconf is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with readconf. If not, see <https://www.gnu.org/licenses/>
  17. */
  18. #ifndef __READCONF_H
  19. #define __READCONF_H
  20. #include <port.h>
  21. #include <do_op_set.h>
  22. #define READCONF_LINE_SPLIT '\n'
  23. /* also the size we will allocate for a buffer */
  24. #define READCONF_MAXLINESIZE 128
  25. #define READCONF_COMMENT '#'
  26. #define READCONF_EQUAL '='
  27. #define READCONF_WHITESPACE " \t\0"
  28. struct readconf_op {
  29. char *op;
  30. int oplen;
  31. int (* do_op) (void);
  32. };
  33. /* in that readconf.c */
  34. extern struct readconf_op ops[];
  35. extern char *line_buffer;
  36. extern int line_no;
  37. /* and here are readconf apis */
  38. int readconf_init(void);
  39. void *readconf_find_name_any(char *name, int *out_type);
  40. struct readconf_strconf *readconf_find_strname(char *name);
  41. struct readconf_uintconf *readconf_find_uintname(char *name);
  42. int do_op_set(void);
  43. char *skip_space(char *);
  44. int len_of(char *);
  45. #endif