config.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. Copyright (c) 2003-2006 by Juliusz Chroboczek
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #define CONFIG_INT 0
  20. #define CONFIG_OCTAL 1
  21. #define CONFIG_HEX 2
  22. #define CONFIG_TIME 3
  23. #define CONFIG_BOOLEAN 4
  24. #define CONFIG_TRISTATE 5
  25. #define CONFIG_TETRASTATE 6
  26. #define CONFIG_PENTASTATE 7
  27. #define CONFIG_FLOAT 8
  28. #define CONFIG_ATOM 9
  29. #define CONFIG_ATOM_LOWER 10
  30. #define CONFIG_PASSWORD 11
  31. #define CONFIG_INT_LIST 12
  32. #define CONFIG_ATOM_LIST 13
  33. #define CONFIG_ATOM_LIST_LOWER 14
  34. typedef struct _ConfigVariable {
  35. AtomPtr name;
  36. int type;
  37. union {
  38. int *i;
  39. float *f;
  40. struct _Atom **a;
  41. struct _AtomList **al;
  42. struct _IntList **il;
  43. } value;
  44. int (*setter)(struct _ConfigVariable*, void*);
  45. char *help;
  46. struct _ConfigVariable *next;
  47. } ConfigVariableRec, *ConfigVariablePtr;
  48. #define CONFIG_VARIABLE(name, type, help) \
  49. CONFIG_VARIABLE_SETTABLE(name, type, NULL, help)
  50. #define CONFIG_VARIABLE_SETTABLE(name, type, setter, help) \
  51. declareConfigVariable(internAtom(#name), type, &name, setter, help)
  52. void declareConfigVariable(AtomPtr name, int type, void *value,
  53. int (*setter)(ConfigVariablePtr, void*),
  54. char *help);
  55. void printConfigVariables(FILE *out, int html);
  56. int parseConfigLine(char *line, char *filename, int lineno, int set);
  57. int parseConfigFile(AtomPtr);
  58. int configIntSetter(ConfigVariablePtr, void*);
  59. int configFloatSetter(ConfigVariablePtr, void*);
  60. int configAtomSetter(ConfigVariablePtr, void*);