libexplain  1.4.D001
libexplain/iocontrol/vt_resize.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 it
00006  * under the terms of the GNU Lesser General Public License as published by
00007  * the Free Software Foundation; either version 3 of the License, or (at your
00008  * option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,but WITHOUT
00011  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00013  * 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 #include <libexplain/ac/errno.h>
00021 #include <libexplain/ac/linux/vt.h>
00022 
00023 #include <libexplain/buffer/eperm.h>
00024 #include <libexplain/buffer/vt_sizes.h>
00025 #include <libexplain/capability.h>
00026 #include <libexplain/iocontrol/generic.h>
00027 #include <libexplain/iocontrol/vt_resize.h>
00028 
00029 #ifdef VT_RESIZE
00030 
00031 
00032 static void
00033 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, int
00034     errnum, int fildes, int request, const void *data)
00035 {
00036     (void)p;
00037     (void)errnum;
00038     (void)fildes;
00039     (void)request;
00040     explain_buffer_vt_sizes(sb, data);
00041 }
00042 
00043 
00044 static void
00045 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, int
00046     errnum, int fildes, int request, const void *data)
00047 {
00048     switch (errnum)
00049     {
00050     case EPERM:
00051         if (!explain_capability_sys_tty_config())
00052         {
00053             explain_buffer_eperm_sys_tty_config(sb, "ioctl VT_RESIZE");
00054             break;
00055         }
00056         goto generic;
00057 
00058     default:
00059         generic:
00060         explain_iocontrol_generic_print_explanation
00061         (
00062             p,
00063             sb,
00064             errnum,
00065             fildes,
00066             request,
00067             data
00068         );
00069         break;
00070     }
00071 }
00072 
00073 
00074 const explain_iocontrol_t explain_iocontrol_vt_resize =
00075 {
00076     "VT_RESIZE", /* name */
00077     VT_RESIZE, /* value */
00078     0, /* disambiguate */
00079     0, /* print_name */
00080     print_data,
00081     print_explanation,
00082     0, /* print_data_returned */
00083     sizeof(struct vt_sizes), /* data_size */
00084     "struct vt_sizes *", /* data_type */
00085     IOCONTROL_FLAG_SIZE_DOES_NOT_AGREE, /* flags */
00086     __FILE__,
00087     __LINE__,
00088 };
00089 
00090 #else /* ndef VT_RESIZE */
00091 
00092 const explain_iocontrol_t explain_iocontrol_vt_resize =
00093 {
00094     0, /* name */
00095     0, /* value */
00096     0, /* disambiguate */
00097     0, /* print_name */
00098     0, /* print_data */
00099     0, /* print_explanation */
00100     0, /* print_data_returned */
00101     0, /* data_size */
00102     0, /* data_type */
00103     0, /* flags */
00104     __FILE__,
00105     __LINE__,
00106 };
00107 
00108 #endif /* VT_RESIZE */
00109 
00110 
00111 /* vim: set ts=8 sw=4 et : */