libexplain  1.4.D001
libexplain/buffer/vt_mode.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/vt.h>
00020 
00021 #include <libexplain/buffer/int8.h>
00022 #include <libexplain/buffer/pointer.h>
00023 #include <libexplain/buffer/signal.h>
00024 #include <libexplain/buffer/vt_mode.h>
00025 #include <libexplain/is_efault.h>
00026 #include <libexplain/parse_bits.h>
00027 #include <libexplain/sizeof.h>
00028 
00029 
00030 #ifdef HAVE_LINUX_VT_H
00031 
00032 
00033 void
00034 explain_buffer_vt_mode_mode(explain_string_buffer_t *sb, int value)
00035 {
00036     static const explain_parse_bits_table_t table[] =
00037     {
00038         { "VT_AUTO", VT_AUTO },
00039         { "VT_PROCESS", VT_PROCESS },
00040         { "VT_ACKACQ", VT_ACKACQ },
00041     };
00042     explain_parse_bits_print_single(sb, value, table, SIZEOF(table));
00043 }
00044 
00045 
00046 void
00047 explain_buffer_vt_mode(explain_string_buffer_t *sb,
00048     const struct vt_mode *data)
00049 {
00050     if (explain_is_efault_pointer(data, sizeof(*data)))
00051     {
00052         explain_buffer_pointer(sb, data);
00053         return;
00054     }
00055 
00056     explain_string_buffer_puts(sb, "{ mode = ");
00057     explain_buffer_vt_mode_mode(sb, data->mode);
00058     if (data->waitv)
00059     {
00060         explain_string_buffer_puts(sb, ", waitv = ");
00061         explain_buffer_int8(sb, data->waitv);
00062     }
00063     if (data->relsig)
00064     {
00065         explain_string_buffer_puts(sb, ", relsig = ");
00066         explain_buffer_signal(sb, data->relsig);
00067     }
00068     if (data->acqsig)
00069     {
00070         explain_string_buffer_puts(sb, ", acqsig = ");
00071         explain_buffer_signal(sb, data->acqsig);
00072     }
00073     if (data->frsig)
00074     {
00075         explain_string_buffer_puts(sb, ", frsig = ");
00076         explain_buffer_signal(sb, data->frsig);
00077     }
00078     explain_string_buffer_puts(sb, " }");
00079 }
00080 
00081 #else
00082 
00083 void
00084 explain_buffer_vt_mode(explain_string_buffer_t *sb,
00085     const struct vt_mode *data)
00086 {
00087     explain_buffer_pointer(sb, data);
00088 }
00089 
00090 #endif
00091 
00092 
00093 /* vim: set ts=8 sw=4 et : */