libexplain
1.4.D001
|
00001 /* 00002 * libexplain - Explain errno values returned by libc functions 00003 * Copyright (C) 2010, 2011, 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/scc.h> 00020 00021 #include <libexplain/buffer/int.h> 00022 #include <libexplain/buffer/pointer.h> 00023 #include <libexplain/buffer/scc_kiss_cmd.h> 00024 #include <libexplain/parse_bits.h> 00025 #include <libexplain/is_efault.h> 00026 00027 00028 #ifdef HAVE_LINUX_SCC_H 00029 00030 static void 00031 explain_buffer_scc_param(explain_string_buffer_t *sb, int value) 00032 { 00033 static const explain_parse_bits_table_t table[] = 00034 { 00035 { "PARAM_DATA", PARAM_DATA }, 00036 { "PARAM_TXDELAY", PARAM_TXDELAY }, 00037 { "PARAM_PERSIST", PARAM_PERSIST }, 00038 { "PARAM_SLOTTIME", PARAM_SLOTTIME }, 00039 { "PARAM_TXTAIL", PARAM_TXTAIL }, 00040 { "PARAM_FULLDUP", PARAM_FULLDUP }, 00041 { "PARAM_SOFTDCD", PARAM_SOFTDCD }, 00042 { "PARAM_MUTE", PARAM_MUTE }, 00043 { "PARAM_DTR", PARAM_DTR }, 00044 { "PARAM_RTS", PARAM_RTS }, 00045 { "PARAM_SPEED", PARAM_SPEED }, 00046 { "PARAM_ENDDELAY", PARAM_ENDDELAY }, 00047 { "PARAM_GROUP", PARAM_GROUP }, 00048 { "PARAM_IDLE", PARAM_IDLE }, 00049 { "PARAM_MIN", PARAM_MIN }, 00050 { "PARAM_MAXKEY", PARAM_MAXKEY }, 00051 { "PARAM_WAIT", PARAM_WAIT }, 00052 { "PARAM_MAXDEFER", PARAM_MAXDEFER }, 00053 { "PARAM_TX", PARAM_TX }, 00054 { "PARAM_HWEVENT", PARAM_HWEVENT }, 00055 { "PARAM_RETURN", PARAM_RETURN }, 00056 }; 00057 00058 explain_parse_bits_print_single(sb, value, table, SIZEOF(table)); 00059 } 00060 00061 00062 void 00063 explain_buffer_scc_kiss_cmd(explain_string_buffer_t *sb, 00064 const struct scc_kiss_cmd *data, int all) 00065 { 00066 if (explain_is_efault_pointer(data, sizeof(*data))) 00067 { 00068 explain_buffer_pointer(sb, data); 00069 return; 00070 } 00071 00072 explain_string_buffer_puts(sb, "{ command = "); 00073 explain_buffer_scc_param(sb, data->command); 00074 if (all) 00075 { 00076 explain_string_buffer_puts(sb, ", param = "); 00077 explain_buffer_uint(sb, data->param); 00078 } 00079 explain_string_buffer_puts(sb, " }"); 00080 } 00081 00082 #else 00083 00084 void 00085 explain_buffer_scc_kiss_cmd(explain_string_buffer_t *sb, 00086 const struct scc_kiss_cmd *data, int all) 00087 { 00088 (void)all; 00089 explain_buffer_pointer(sb, data); 00090 } 00091 00092 #endif 00093 00094 00095 /* vim: set ts=8 sw=4 et : */