libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 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/linux/termios.h> 00020 00021 #include <libexplain/buffer/termio_cc.h> 00022 #include <libexplain/parse_bits.h> 00023 #include <libexplain/sizeof.h> 00024 00025 00026 static void 00027 char_name(explain_string_buffer_t *sb, int value) 00028 { 00029 static const explain_parse_bits_table_t table[] = 00030 { 00031 { "VINTR", VINTR }, 00032 { "VQUIT", VQUIT }, 00033 { "VERASE", VERASE }, 00034 { "VKILL", VKILL }, 00035 { "VEOF", VEOF }, 00036 #ifdef VTIME 00037 { "VTIME", VTIME }, 00038 #endif 00039 #ifdef VMIN 00040 { "VMIN", VMIN }, 00041 #endif 00042 #ifdef VSWTC 00043 { "VSWTC", VSWTC }, 00044 #endif 00045 #ifdef VSTART 00046 { "VSTART", VSTART }, 00047 #endif 00048 #ifdef VSTOP 00049 { "VSTOP", VSTOP }, 00050 #endif 00051 #ifdef VSUSP 00052 { "VSUSP", VSUSP }, 00053 #endif 00054 #ifdef VEOL 00055 { "VEOL", VEOL }, 00056 #endif 00057 #ifdef VREPRINT 00058 { "VREPRINT", VREPRINT }, 00059 #endif 00060 #ifdef VDISCARD 00061 { "VDISCARD", VDISCARD }, 00062 #endif 00063 #ifdef VWERASE 00064 { "VWERASE", VWERASE }, 00065 #endif 00066 #ifdef VLNEXT 00067 { "VLNEXT", VLNEXT }, 00068 #endif 00069 #ifdef VEOL2 00070 { "VEOL2", VEOL2 }, 00071 #endif 00072 }; 00073 00074 explain_parse_bits_print_single(sb, value, table, SIZEOF(table)); 00075 } 00076 00077 00078 void 00079 explain_buffer_termio_cc(explain_string_buffer_t *sb, const unsigned char *data, 00080 size_t data_size) 00081 { 00082 int first; 00083 size_t j; 00084 00085 explain_string_buffer_putc(sb, '{'); 00086 first = 1; 00087 for (j = 0; j < data_size; ++j) 00088 { 00089 unsigned char c; 00090 00091 c = data[j]; 00092 if (c) 00093 { 00094 if (!first) 00095 explain_string_buffer_puts(sb, ", "); 00096 char_name(sb, j); 00097 explain_string_buffer_puts(sb, " = "); 00098 explain_string_buffer_putc_quoted(sb, c); 00099 first = 0; 00100 } 00101 } 00102 explain_string_buffer_putc(sb, '}'); 00103 } 00104 00105 00106 /* vim: set ts=8 sw=4 et : */