libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2008, 2009, 2013 Peter Miller 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as 00007 * published by the Free Software Foundation; either version 3 of the 00008 * License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #include <libexplain/ac/netdb.h> 00020 00021 #include <libexplain/buffer/addrinfo_flags.h> 00022 #include <libexplain/parse_bits.h> 00023 #include <libexplain/sizeof.h> 00024 00025 00026 static const explain_parse_bits_table_t table[] = 00027 { 00028 { "AI_PASSIVE", AI_PASSIVE }, 00029 #ifdef AI_CANONNAME 00030 { "AI_CANONNAME", AI_CANONNAME }, 00031 #endif 00032 #ifdef AI_NUMERICHOST 00033 { "AI_NUMERICHOST", AI_NUMERICHOST }, 00034 #endif 00035 #ifdef AI_V4MAPPED 00036 { "AI_V4MAPPED", AI_V4MAPPED }, 00037 #endif 00038 #ifdef AI_ALL 00039 { "AI_ALL", AI_ALL }, 00040 #endif 00041 #ifdef AI_ADDRCONFIG 00042 { "AI_ADDRCONFIG", AI_ADDRCONFIG }, 00043 #endif 00044 #ifdef AI_IDN 00045 { "AI_IDN", AI_IDN }, 00046 #endif 00047 #ifdef AI_CANONIDN 00048 { "AI_CANONIDN", AI_CANONIDN }, 00049 #endif 00050 #ifdef AI_IDN_ALLOW_UNASSIGNED 00051 { "AI_IDN_ALLOW_UNASSIGNED", AI_IDN_ALLOW_UNASSIGNED }, 00052 #endif 00053 #ifdef AI_IDN_USE_STD3_ASCII_RULES 00054 { "AI_IDN_USE_STD3_ASCII_RULES", AI_IDN_USE_STD3_ASCII_RULES }, 00055 #endif 00056 #ifdef AI_NUMERICSERV 00057 { "AI_NUMERICSERV", AI_NUMERICSERV }, 00058 #endif 00059 }; 00060 00061 00062 void 00063 explain_buffer_addrinfo_flags(explain_string_buffer_t *sb, int value) 00064 { 00065 explain_parse_bits_print(sb, value, table, SIZEOF(table)); 00066 } 00067 00068 00069 int 00070 explain_parse_addrinfo_flags_or_die(const char *text, 00071 const char *caption) 00072 { 00073 return explain_parse_bits_or_die(text, table, SIZEOF(table), caption); 00074 } 00075 00076 00077 /* vim: set ts=8 sw=4 et : */