libexplain
1.4.D001
|
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/sys/ioctl.h> 00023 00024 #include <libexplain/buffer/enomem.h> 00025 #include <libexplain/buffer/gettext.h> 00026 #include <libexplain/buffer/int.h> 00027 #include <libexplain/iocontrol/generic.h> 00028 #include <libexplain/iocontrol/pppiocnewunit.h> 00029 00030 #ifdef PPPIOCNEWUNIT 00031 00032 00033 static void 00034 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00035 int errnum, int fildes, int request, const void *data) 00036 { 00037 (void)p; 00038 (void)errnum; 00039 (void)fildes; 00040 (void)request; 00041 explain_buffer_int_star(sb, data); 00042 } 00043 00044 00045 static void 00046 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00047 int errnum, int fildes, int request, const void *data) 00048 { 00049 switch (errnum) 00050 { 00051 case ENOMEM: 00052 explain_buffer_enomem_kernel(sb); 00053 break; 00054 00055 case EEXIST: 00056 case EIO: 00057 case EINVAL: 00058 /* FIXME: say exactly what interface name */ 00059 explain_buffer_gettext 00060 ( 00061 sb, 00062 /* 00063 * xgettext: This error message is issued to explain an 00064 * EEXIST error reported by an system call attempting to 00065 * create a new network interface. 00066 */ 00067 i18n("an interface of that name already exists") 00068 ); 00069 break; 00070 00071 default: 00072 explain_iocontrol_generic_print_explanation 00073 ( 00074 p, 00075 sb, 00076 errnum, 00077 fildes, 00078 request, 00079 data 00080 ); 00081 break; 00082 } 00083 } 00084 00085 00086 const explain_iocontrol_t explain_iocontrol_pppiocnewunit = 00087 { 00088 "PPPIOCNEWUNIT", /* name */ 00089 PPPIOCNEWUNIT, /* value */ 00090 0, /* disambiguate */ 00091 0, /* print_name */ 00092 print_data, 00093 print_explanation, 00094 print_data, /* print_data_returned */ 00095 sizeof(int), /* data_size */ 00096 "int *", /* data_type */ 00097 0, /* flags */ 00098 __FILE__, 00099 __LINE__, 00100 }; 00101 00102 #else /* ndef PPPIOCNEWUNIT */ 00103 00104 const explain_iocontrol_t explain_iocontrol_pppiocnewunit = 00105 { 00106 0, /* name */ 00107 0, /* value */ 00108 0, /* disambiguate */ 00109 0, /* print_name */ 00110 0, /* print_data */ 00111 0, /* print_explanation */ 00112 0, /* print_data_returned */ 00113 0, /* data_size */ 00114 0, /* data_type */ 00115 0, /* flags */ 00116 __FILE__, 00117 __LINE__, 00118 }; 00119 00120 #endif /* PPPIOCNEWUNIT */ 00121 00122 00123 /* vim: set ts=8 sw=4 et : */