conf_data.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "putty.h"
  2. #define CONF_ENUM(name, ...) \
  3. static const ConfSaveEnumValue conf_enum_values_##name[] = { \
  4. __VA_ARGS__ \
  5. }; const ConfSaveEnumType conf_enum_##name = { \
  6. /*.values =*/ conf_enum_values_##name, \
  7. /*.nvalues =*/ lenof(conf_enum_values_##name), \
  8. };
  9. #define VALUE(eval, sval) { eval, sval, false }
  10. #define VALUE_OBSOLETE(eval, sval) { eval, sval, true }
  11. #include "conf-enums.h"
  12. bool conf_enum_map_to_storage(const ConfSaveEnumType *etype,
  13. int confval, int *storageval_out)
  14. {
  15. size_t i; // WINSCP
  16. for (i = 0; i < etype->nvalues; i++)
  17. if (!etype->values[i].obsolete &&
  18. etype->values[i].confval == confval) {
  19. *storageval_out = etype->values[i].storageval;
  20. return true;
  21. }
  22. return false;
  23. }
  24. bool conf_enum_map_from_storage(const ConfSaveEnumType *etype,
  25. int storageval, int *confval_out)
  26. {
  27. size_t i; // WINSCP
  28. for (i = 0; i < etype->nvalues; i++)
  29. if (etype->values[i].storageval == storageval) {
  30. *confval_out = etype->values[i].confval;
  31. return true;
  32. }
  33. return false;
  34. }
  35. #define CONF_OPTION(id, subkey_type, value_type, ...) \
  36. { CONF_TYPE_ ## subkey_type, CONF_TYPE_ ## value_type, __VA_ARGS__ },
  37. const ConfKeyInfo conf_key_info[] = {
  38. #include "conf.winscp.h"
  39. };