libexplain  1.4.D001
libexplain/iocontrol/pppiocdetach.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 2010, 2011, 2013 Peter Miller
00004  * Written by Peter Miller <pmiller@opensource.org.au>
00005  *
00006  * This program is free software; you can redistribute it and/or modify it
00007  * under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 3 of the License, or (at your
00009  * option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00014  * License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00020 #include <libexplain/ac/errno.h>
00021 #include <libexplain/ac/linux/if_ppp.h>
00022 #include <libexplain/ac/stdint.h>
00023 #include <libexplain/ac/sys/ioctl.h>
00024 
00025 #include <libexplain/buffer/enxio.h>
00026 #include <libexplain/buffer/gettext.h>
00027 #include <libexplain/buffer/int.h>
00028 #include <libexplain/iocontrol/generic.h>
00029 #include <libexplain/iocontrol/pppiocdetach.h>
00030 
00031 #ifdef PPPIOCDETACH
00032 
00033 
00034 static void
00035 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb,
00036     int errnum, int fildes, int request, const void *data)
00037 {
00038     (void)p;
00039     (void)errnum;
00040     (void)fildes;
00041     (void)request;
00042     explain_buffer_int(sb, (intptr_t)data);
00043 }
00044 
00045 
00046 static void
00047 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb,
00048     int errnum, int fildes, int request, const void *data)
00049 {
00050     switch (errnum)
00051     {
00052     case EINVAL:
00053         /* FIXME: name *which* interface */
00054         explain_buffer_gettext
00055         (
00056             sb,
00057             /*
00058              * xgettext:  This error mesage is issued to explain an
00059              * EINVAL error returned form ioctl PPPIOCDETACH, in the
00060              * case where more than one process has the interface open.
00061              */
00062             i18n("too many processes have this PPP interface open")
00063         );
00064         break;
00065 
00066     case ENOTTY:
00067         explain_buffer_enxio_bad_unit(sb);
00068         break;
00069 
00070     default:
00071         explain_iocontrol_generic_print_explanation
00072         (
00073             p,
00074             sb,
00075             errnum,
00076             fildes,
00077             request,
00078             data
00079         );
00080         break;
00081     }
00082 }
00083 
00084 
00085 const explain_iocontrol_t explain_iocontrol_pppiocdetach =
00086 {
00087     "PPPIOCDETACH", /* name */
00088     PPPIOCDETACH, /* value */
00089     0, /* disambiguate */
00090     0, /* print_name */
00091     print_data,
00092     print_explanation,
00093     0, /* print_data_returned */
00094     NOT_A_POINTER, /* data_size */
00095     "intptr_t", /* data_type */
00096     0, /* flags */
00097     __FILE__,
00098     __LINE__,
00099 };
00100 
00101 #else /* ndef PPPIOCDETACH */
00102 
00103 const explain_iocontrol_t explain_iocontrol_pppiocdetach =
00104 {
00105     0, /* name */
00106     0, /* value */
00107     0, /* disambiguate */
00108     0, /* print_name */
00109     0, /* print_data */
00110     0, /* print_explanation */
00111     0, /* print_data_returned */
00112     0, /* data_size */
00113     0, /* data_type */
00114     0, /* flags */
00115     __FILE__,
00116     __LINE__,
00117 };
00118 
00119 #endif /* PPPIOCDETACH */
00120 
00121 
00122 /* vim: set ts=8 sw=4 et : */