libexplain  1.4.D001
libexplain/buffer/termios2.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/linux/termios.h>
00020 
00021 #include <libexplain/buffer/int.h>
00022 #include <libexplain/buffer/line_discipline.h>
00023 #include <libexplain/buffer/pointer.h>
00024 #include <libexplain/buffer/termio_cc.h>
00025 #include <libexplain/buffer/termio_cflag.h>
00026 #include <libexplain/buffer/termio_iflag.h>
00027 #include <libexplain/buffer/termio_lflag.h>
00028 #include <libexplain/buffer/termio_oflag.h>
00029 #include <libexplain/buffer/termios2.h>
00030 #include <libexplain/is_efault.h>
00031 
00032 
00033 #if defined(HAVE_LINUX_TERMIOS_H) && defined(TCGETS2)
00034 
00035 void
00036 explain_buffer_termios2(explain_string_buffer_t *sb,
00037     const struct termios2 *data)
00038 {
00039     if (explain_is_efault_pointer(data, sizeof(*data)))
00040     {
00041         explain_buffer_pointer(sb, data);
00042         return;
00043     }
00044 
00045     explain_string_buffer_puts(sb, "{ c_iflag = ");
00046     explain_buffer_termio_iflag(sb, data->c_iflag);
00047     explain_string_buffer_puts(sb, ", c_oflag = ");
00048     explain_buffer_termio_oflag(sb, data->c_oflag);
00049     explain_string_buffer_puts(sb, ", c_cflag = ");
00050     explain_buffer_termio_cflag(sb, data->c_cflag);
00051     explain_string_buffer_puts(sb, ", c_lflag = ");
00052     explain_buffer_termio_lflag(sb, data->c_lflag);
00053     explain_string_buffer_puts(sb, ", c_line = ");
00054     explain_buffer_line_discipline(sb, data->c_line);
00055     explain_string_buffer_puts(sb, ", c_cc = ");
00056     explain_buffer_termio_cc(sb, data->c_cc, sizeof(data->c_cc));
00057     explain_string_buffer_puts(sb, ", c_ispeed = ");
00058     explain_buffer_int(sb, data->c_ispeed);
00059     explain_string_buffer_puts(sb, ", c_ospeed = ");
00060     explain_buffer_int(sb, data->c_ospeed);
00061     explain_string_buffer_puts(sb, " }");
00062 }
00063 
00064 #else
00065 
00066 void
00067 explain_buffer_termios2(explain_string_buffer_t *sb,
00068     const struct termios2 *data)
00069 {
00070     explain_buffer_pointer(sb, data);
00071 }
00072 
00073 #endif
00074 
00075 
00076 /* vim: set ts=8 sw=4 et : */