libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2008-2010, 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/unistd.h> 00020 00021 #include <libexplain/buffer/pathconf_name.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 #ifdef _PC_LINK_MAX 00029 { "_PC_LINK_MAX", _PC_LINK_MAX }, 00030 #endif 00031 #ifdef _PC_MAX_CANON 00032 { "_PC_MAX_CANON", _PC_MAX_CANON }, 00033 #endif 00034 #ifdef _PC_MAX_INPUT 00035 { "_PC_MAX_INPUT", _PC_MAX_INPUT }, 00036 #endif 00037 #ifdef _PC_NAME_MAX 00038 { "_PC_NAME_MAX", _PC_NAME_MAX }, 00039 #endif 00040 #ifdef _PC_PATH_MAX 00041 { "_PC_PATH_MAX", _PC_PATH_MAX }, 00042 #endif 00043 #ifdef _PC_PIPE_BUF 00044 { "_PC_PIPE_BUF", _PC_PIPE_BUF }, 00045 #endif 00046 #ifdef _PC_CHOWN_RESTRICTED 00047 { "_PC_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED }, 00048 #endif 00049 #ifdef _PC_NO_TRUNC 00050 { "_PC_NO_TRUNC", _PC_NO_TRUNC }, 00051 #endif 00052 #ifdef _PC_VDISABLE 00053 { "_PC_VDISABLE", _PC_VDISABLE }, 00054 #endif 00055 #ifdef _PC_SYNC_IO 00056 { "_PC_SYNC_IO", _PC_SYNC_IO }, 00057 #endif 00058 #ifdef _PC_ASYNC_IO 00059 { "_PC_ASYNC_IO", _PC_ASYNC_IO }, 00060 #endif 00061 #ifdef _PC_PRIO_IO 00062 { "_PC_PRIO_IO", _PC_PRIO_IO }, 00063 #endif 00064 #ifdef _PC_SOCK_MAXBUF 00065 { "_PC_SOCK_MAXBUF", _PC_SOCK_MAXBUF }, 00066 #endif 00067 #ifdef _PC_FILESIZEBITS 00068 { "_PC_FILESIZEBITS", _PC_FILESIZEBITS }, 00069 #endif 00070 #ifdef _PC_REC_INCR_XFER_SIZE 00071 { "_PC_REC_INCR_XFER_SIZE", _PC_REC_INCR_XFER_SIZE }, 00072 #endif 00073 #ifdef _PC_REC_MAX_XFER_SIZE 00074 { "_PC_REC_MAX_XFER_SIZE", _PC_REC_MAX_XFER_SIZE }, 00075 #endif 00076 #ifdef _PC_REC_MIN_XFER_SIZE 00077 { "_PC_REC_MIN_XFER_SIZE", _PC_REC_MIN_XFER_SIZE }, 00078 #endif 00079 #ifdef _PC_REC_XFER_ALIGN 00080 { "_PC_REC_XFER_ALIGN", _PC_REC_XFER_ALIGN }, 00081 #endif 00082 #ifdef _PC_ALLOC_SIZE_MIN 00083 { "_PC_ALLOC_SIZE_MIN", _PC_ALLOC_SIZE_MIN }, 00084 #endif 00085 #ifdef _PC_SYMLINK_MAX 00086 { "_PC_SYMLINK_MAX", _PC_SYMLINK_MAX }, 00087 #endif 00088 #ifdef _PC_2_SYMLINKS 00089 { "_PC_2_SYMLINKS", _PC_2_SYMLINKS }, 00090 #endif 00091 #ifdef _PC_MIN_HOLE_SIZE 00092 { "_PC_MIN_HOLE_SIZE", _PC_MIN_HOLE_SIZE }, 00093 #endif 00094 }; 00095 00096 00097 void 00098 explain_buffer_pathconf_name(explain_string_buffer_t *sb, int name) 00099 { 00100 explain_parse_bits_print_single(sb, name, table, SIZEOF(table)); 00101 } 00102 00103 00104 int 00105 explain_parse_pathconf_name_or_die(const char *text) 00106 { 00107 return explain_parse_bits_or_die(text, table, SIZEOF(table), 0); 00108 } 00109 00110 00111 int 00112 explain_valid_pathconf_name(int name) 00113 { 00114 return !!explain_parse_bits_find_by_value(name, table, SIZEOF(table)); 00115 } 00116 00117 00118 /* vim: set ts=8 sw=4 et : */