libexplain  1.4.D001
libexplain/iocontrol/vt_disallocate.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/gettext.h>
00026 #include <libexplain/iocontrol/generic.h>
00027 #include <libexplain/iocontrol/vt_disallocate.h>
00028 
00029 #ifdef VT_DISALLOCATE
00030 
00031 
00032 static void
00033 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, int
00034     errnum, int fildes, int request, const void *data)
00035 {
00036     switch (errnum)
00037     {
00038     case ENXIO:
00039         if ((intptr_t)data < 0 || (intptr_t)data > MAX_NR_CONSOLES)
00040         {
00041             explain_buffer_einval_out_of_range(sb, "data", 0, MAX_NR_CONSOLES);
00042             break;
00043         }
00044         goto generic;
00045 
00046     case EBUSY:
00047         explain_buffer_gettext
00048         (
00049             sb,
00050             /*
00051              * xgettext: this error message is used to explain an EBUSY error
00052              * returned by an ioctl VT_DISALLOCATE system call.
00053              */
00054             i18n("the virtual console is still in use")
00055         );
00056         break;
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_disallocate =
00075 {
00076     "VT_DISALLOCATE", /* name */
00077     VT_DISALLOCATE, /* value */
00078     0, /* disambiguate */
00079     0, /* print_name */
00080     explain_iocontrol_generic_print_data_long, /* print_data */
00081     print_explanation,
00082     0, /* print_data_returned */
00083     NOT_A_POINTER, /* data_size */
00084     "intptr_t", /* data_type */
00085     0, /* flags */
00086     __FILE__,
00087     __LINE__,
00088 };
00089 
00090 #else /* ndef VT_DISALLOCATE */
00091 
00092 const explain_iocontrol_t explain_iocontrol_vt_disallocate =
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_DISALLOCATE */
00109 
00110 
00111 /* vim: set ts=8 sw=4 et : */