libexplain  1.4.D001
libexplain/buffer/serial_icounter_struct.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/serial.h>
00020 
00021 #include <libexplain/buffer/int.h>
00022 #include <libexplain/buffer/serial_icounter_struct.h>
00023 #include <libexplain/buffer/pointer.h>
00024 #include <libexplain/is_efault.h>
00025 
00026 
00027 #ifdef HAVE_LINUX_SERIAL_H
00028 
00029 void
00030 explain_buffer_serial_icounter_struct(explain_string_buffer_t *sb,
00031     const struct serial_icounter_struct *data)
00032 {
00033     if (explain_is_efault_pointer(data, sizeof(*data)))
00034     {
00035         explain_buffer_pointer(sb, data);
00036         return;
00037     }
00038 
00039     explain_string_buffer_puts(sb, "{ rx = ");
00040     explain_buffer_int(sb, data->rx);
00041     explain_string_buffer_puts(sb, ", tx = ");
00042     explain_buffer_int(sb, data->tx);
00043     if (data->cts)
00044     {
00045         explain_string_buffer_puts(sb, ", cts = ");
00046         explain_buffer_int(sb, data->cts);
00047     }
00048     if (data->dsr)
00049     {
00050         explain_string_buffer_puts(sb, ", dsr = ");
00051         explain_buffer_int(sb, data->dsr);
00052     }
00053     if (data->rng)
00054     {
00055         explain_string_buffer_puts(sb, ", rng = ");
00056         explain_buffer_int(sb, data->rng);
00057     }
00058     if (data->dcd)
00059     {
00060         explain_string_buffer_puts(sb, ", dcd = ");
00061         explain_buffer_int(sb, data->dcd);
00062     }
00063     if (data->frame)
00064     {
00065         explain_string_buffer_puts(sb, ", frame = ");
00066         explain_buffer_int(sb, data->frame);
00067     }
00068     if (data->overrun)
00069     {
00070         explain_string_buffer_puts(sb, ", overrun = ");
00071         explain_buffer_int(sb, data->overrun);
00072     }
00073     if (data->parity)
00074     {
00075         explain_string_buffer_puts(sb, ", parity = ");
00076         explain_buffer_int(sb, data->parity);
00077     }
00078     if (data->brk)
00079     {
00080         explain_string_buffer_puts(sb, ", brk = ");
00081         explain_buffer_int(sb, data->brk);
00082     }
00083     if (data->buf_overrun)
00084     {
00085         explain_string_buffer_puts(sb, ", buf_overrun = ");
00086         explain_buffer_int(sb, data->buf_overrun);
00087     }
00088     explain_string_buffer_puts(sb, " }");
00089 }
00090 
00091 #else
00092 
00093 void
00094 explain_buffer_serial_icounter_struct(explain_string_buffer_t *sb,
00095     const struct serial_icounter_struct *data)
00096 {
00097     explain_buffer_pointer(sb, data);
00098 }
00099 
00100 #endif
00101 
00102 
00103 /* vim: set ts=8 sw=4 et : */