PageRenderTime 52ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/libexplain-1.0.D001/libexplain/buffer/addrinfo_flags.c

#
C | 74 lines | 49 code | 8 blank | 17 comment | 0 complexity | 09ced18ae34aa39987471259ab97956d MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0
  1. /*
  2. * libexplain - Explain errno values returned by libc functions
  3. * Copyright (C) 2008, 2009 Peter Miller
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as
  7. * published by the Free Software Foundation; either version 3 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * This program 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 GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <libexplain/ac/netdb.h>
  19. #include <libexplain/buffer/addrinfo_flags.h>
  20. #include <libexplain/parse_bits.h>
  21. #include <libexplain/sizeof.h>
  22. static const explain_parse_bits_table_t table[] =
  23. {
  24. { "AI_PASSIVE", AI_PASSIVE },
  25. #ifdef AI_CANONNAME
  26. { "AI_CANONNAME", AI_CANONNAME },
  27. #endif
  28. #ifdef AI_NUMERICHOST
  29. { "AI_NUMERICHOST", AI_NUMERICHOST },
  30. #endif
  31. #ifdef AI_V4MAPPED
  32. { "AI_V4MAPPED", AI_V4MAPPED },
  33. #endif
  34. #ifdef AI_ALL
  35. { "AI_ALL", AI_ALL },
  36. #endif
  37. #ifdef AI_ADDRCONFIG
  38. { "AI_ADDRCONFIG", AI_ADDRCONFIG },
  39. #endif
  40. #ifdef AI_IDN
  41. { "AI_IDN", AI_IDN },
  42. #endif
  43. #ifdef AI_CANONIDN
  44. { "AI_CANONIDN", AI_CANONIDN },
  45. #endif
  46. #ifdef AI_IDN_ALLOW_UNASSIGNED
  47. { "AI_IDN_ALLOW_UNASSIGNED", AI_IDN_ALLOW_UNASSIGNED },
  48. #endif
  49. #ifdef AI_IDN_USE_STD3_ASCII_RULES
  50. { "AI_IDN_USE_STD3_ASCII_RULES", AI_IDN_USE_STD3_ASCII_RULES },
  51. #endif
  52. #ifdef AI_NUMERICSERV
  53. { "AI_NUMERICSERV", AI_NUMERICSERV },
  54. #endif
  55. };
  56. void
  57. explain_buffer_addrinfo_flags(explain_string_buffer_t *sb, int value)
  58. {
  59. explain_parse_bits_print(sb, value, table, SIZEOF(table));
  60. }
  61. int
  62. explain_parse_addrinfo_flags_or_die(const char *text,
  63. const char *caption)
  64. {
  65. return explain_parse_bits_or_die(text, table, SIZEOF(table), caption);
  66. }