libexplain  1.4.D001
libexplain/buffer/console_font_op.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 2009, 2011, 2013, 2014 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/kd.h>
00020 
00021 #include <libexplain/buffer/console_font_op.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 
00027 
00028 #ifdef HAVE_LINUX_KD_H
00029 
00030 static void
00031 explain_buffer_kd_font_op(explain_string_buffer_t *sb, int value)
00032 {
00033     static const explain_parse_bits_table_t table[] =
00034     {
00035 #ifdef KD_FONT_OP_SET
00036         { "KD_FONT_OP_SET", KD_FONT_OP_SET },
00037 #endif
00038 #ifdef KD_FONT_OP_GET
00039         { "KD_FONT_OP_GET", KD_FONT_OP_GET },
00040 #endif
00041 #ifdef KD_FONT_OP_SET_DEFAULT
00042         { "KD_FONT_OP_SET_DEFAULT", KD_FONT_OP_SET_DEFAULT },
00043 #endif
00044 #ifdef KD_FONT_OP_COPY
00045         { "KD_FONT_OP_COPY", KD_FONT_OP_COPY },
00046 #endif
00047     };
00048 
00049     explain_parse_bits_print_single(sb, value, table, SIZEOF(table));
00050 }
00051 
00052 
00053 static void
00054 explain_buffer_kd_font_flag(explain_string_buffer_t *sb, int value)
00055 {
00056     static const explain_parse_bits_table_t table[] =
00057     {
00058 #ifdef KD_FONT_FLAG_DONT_RECALC
00059         { "KD_FONT_FLAG_DONT_RECALC", KD_FONT_FLAG_DONT_RECALC },
00060 #endif
00061     };
00062 
00063     explain_parse_bits_print(sb, value, table, SIZEOF(table));
00064 }
00065 
00066 #endif
00067 
00068 
00069 void
00070 explain_buffer_console_font_op(explain_string_buffer_t *sb,
00071     const struct console_font_op *value)
00072 {
00073 #ifdef HAVE_LINUX_KD_H
00074     if (explain_is_efault_pointer(value, sizeof(*value)))
00075         explain_buffer_pointer(sb, value);
00076     else
00077     {
00078         explain_string_buffer_puts(sb, "{ op = ");
00079         explain_buffer_kd_font_op(sb, value->op);
00080         explain_string_buffer_puts(sb, ", flags = ");
00081         explain_buffer_kd_font_flag(sb, value->flags);
00082         explain_string_buffer_printf
00083         (
00084             sb,
00085             ", width = %u, height = %u, charcount = %u, data = ",
00086             value->width,
00087             value->height,
00088             value->charcount
00089         );
00090         explain_buffer_pointer(sb, value->data);
00091         explain_string_buffer_puts(sb, " }");
00092     }
00093 #else
00094     explain_buffer_pointer(sb, value);
00095 #endif
00096 }
00097 
00098 
00099 /* vim: set ts=8 sw=4 et : */