libexplain  1.4.D001
libexplain/buffer/line_discipline.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 2009, 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/sys/ioctl.h>
00020 
00021 #include <libexplain/buffer/line_discipline.h>
00022 #include <libexplain/buffer/pointer.h>
00023 #include <libexplain/parse_bits.h>
00024 #include <libexplain/is_efault.h>
00025 #include <libexplain/sizeof.h>
00026 #include <libexplain/string_buffer.h>
00027 
00028 
00029 #ifdef N_TTY
00030 
00031 void
00032 explain_buffer_line_discipline(explain_string_buffer_t *sb, int data)
00033 {
00034     static const explain_parse_bits_table_t table[] =
00035     {
00036         { "N_TTY", N_TTY },
00037         { "N_SLIP", N_SLIP },
00038         { "N_MOUSE", N_MOUSE },
00039         { "N_PPP", N_PPP },
00040         { "N_STRIP", N_STRIP },
00041         { "N_AX25", N_AX25 },
00042         { "N_X25", N_X25 },
00043         { "N_6PACK", N_6PACK },
00044         { "N_MASC", N_MASC },
00045         { "N_R3964", N_R3964 },
00046         { "N_PROFIBUS_FDL", N_PROFIBUS_FDL },
00047         { "N_IRDA", N_IRDA },
00048         { "N_SMSBLOCK", N_SMSBLOCK },
00049         { "N_HDLC", N_HDLC },
00050         { "N_SYNC_PPP", N_SYNC_PPP },
00051         { "N_HCI", N_HCI },
00052     };
00053 
00054     explain_parse_bits_print_single(sb, data, table, SIZEOF(table));
00055 }
00056 
00057 #else
00058 
00059 void
00060 explain_buffer_line_discipline(explain_string_buffer_t *sb, int data)
00061 {
00062     explain_string_buffer_printf(sb, "%d", data);
00063 }
00064 
00065 #endif
00066 
00067 
00068 void
00069 explain_buffer_line_discipline_star(explain_string_buffer_t *sb,
00070     const int *data)
00071 {
00072     if (explain_is_efault_pointer(data, sizeof(*data)))
00073         explain_buffer_pointer(sb, data);
00074     else
00075     {
00076         explain_string_buffer_puts(sb, "{ ");
00077         explain_buffer_line_discipline(sb, *data);
00078         explain_string_buffer_puts(sb, " }");
00079     }
00080 }
00081 
00082 
00083 /* vim: set ts=8 sw=4 et : */