libexplain  1.4.D001
libexplain/iocontrol/vt_waitactive.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 #include <libexplain/ac/stdint.h>
00023 
00024 #include <libexplain/buffer/einval.h>
00025 #include <libexplain/buffer/eperm.h>
00026 #include <libexplain/capability.h>
00027 #include <libexplain/iocontrol/generic.h>
00028 #include <libexplain/iocontrol/vt_waitactive.h>
00029 
00030 #ifdef VT_WAITACTIVE
00031 
00032 
00033 static void
00034 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, int
00035     errnum, int fildes, int request, const void *data)
00036 {
00037     switch (errnum)
00038     {
00039     case EPERM:
00040         if (!explain_capability_sys_tty_config())
00041         {
00042             explain_buffer_eperm_sys_tty_config(sb, "ioctl VT_WAITACTIVE");
00043             break;
00044         }
00045         goto generic;
00046 
00047     case ENXIO:
00048         {
00049             unsigned long arg = (intptr_t)data;
00050             if (arg <= 0 || arg > MAX_NR_CONSOLES)
00051             {
00052                 explain_buffer_einval_out_of_range
00053                 (
00054                     sb,
00055                     "data",
00056                     1,
00057                     MAX_NR_CONSOLES
00058                 );
00059                 break;
00060             }
00061         }
00062         goto generic;
00063 
00064     default:
00065         generic:
00066         explain_iocontrol_generic_print_explanation
00067         (
00068             p,
00069             sb,
00070             errnum,
00071             fildes,
00072             request,
00073             data
00074         );
00075         break;
00076     }
00077 }
00078 
00079 
00080 const explain_iocontrol_t explain_iocontrol_vt_waitactive =
00081 {
00082     "VT_WAITACTIVE", /* name */
00083     VT_WAITACTIVE, /* value */
00084     0, /* disambiguate */
00085     0, /* print_name */
00086     explain_iocontrol_generic_print_data_ulong, /* print_data */
00087     print_explanation,
00088     0, /* print_data_returned */
00089     NOT_A_POINTER, /* data_size */
00090     "intptr_t", /* data_type */
00091     0, /* flags */
00092     __FILE__,
00093     __LINE__,
00094 };
00095 
00096 #else /* ndef VT_WAITACTIVE */
00097 
00098 const explain_iocontrol_t explain_iocontrol_vt_waitactive =
00099 {
00100     0, /* name */
00101     0, /* value */
00102     0, /* disambiguate */
00103     0, /* print_name */
00104     0, /* print_data */
00105     0, /* print_explanation */
00106     0, /* print_data_returned */
00107     0, /* data_size */
00108     0, /* data_type */
00109     0, /* flags */
00110     __FILE__,
00111     __LINE__,
00112 };
00113 
00114 #endif /* VT_WAITACTIVE */
00115 
00116 
00117 /* vim: set ts=8 sw=4 et : */