libexplain  1.4.D001
libexplain/iocontrol/siocsccgstat.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
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 3 of the License, or (at
00009  * your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License along
00017  * with this program. If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00020 #include <libexplain/ac/errno.h>
00021 #include <libexplain/ac/linux/scc.h>
00022 
00023 #include <libexplain/buffer/efault.h>
00024 #include <libexplain/buffer/pointer.h>
00025 #include <libexplain/buffer/scc_stat.h>
00026 #include <libexplain/iocontrol/generic.h>
00027 #include <libexplain/iocontrol/siocsccgstat.h>
00028 #include <libexplain/is_efault.h>
00029 
00030 #ifdef HAVE_LINUX_SCC_H
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_pointer(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 EFAULT:
00052         efault:
00053         explain_buffer_efault(sb, "data");
00054         break;
00055 
00056     case EINVAL:
00057         if (explain_is_efault_pointer(data, sizeof(struct scc_stat)))
00058             goto efault;
00059         /* Fall through... */
00060 
00061     default:
00062         explain_iocontrol_generic_print_explanation
00063         (
00064             p,
00065             sb,
00066             errnum,
00067             fildes,
00068             request,
00069             data
00070         );
00071         break;
00072     }
00073 }
00074 
00075 
00076 static void
00077 print_data_returned(const explain_iocontrol_t *p, explain_string_buffer_t *sb,
00078     int errnum, int fildes, int request, const void *data)
00079 {
00080     (void)p;
00081     (void)errnum;
00082     (void)fildes;
00083     (void)request;
00084     explain_buffer_scc_stat(sb, data);
00085 }
00086 
00087 
00088 const explain_iocontrol_t explain_iocontrol_siocsccgstat =
00089 {
00090     "SIOCSCCGSTAT", /* name */
00091     SIOCSCCGSTAT, /* value */
00092     explain_iocontrol_disambiguate_scc,
00093     0, /* print_name */
00094     print_data,
00095     print_explanation,
00096     print_data_returned,
00097     sizeof(struct scc_stat), /* data_size */
00098     "struct scc_stat *", /* data_type */
00099     IOCONTROL_FLAG_SIZE_DOES_NOT_AGREE, /* flags */
00100     __FILE__,
00101     __LINE__,
00102 };
00103 
00104 #else /* ndef SIOCSCCGSTAT */
00105 
00106 const explain_iocontrol_t explain_iocontrol_siocsccgstat =
00107 {
00108     0, /* name */
00109     0, /* value */
00110     0, /* disambiguate */
00111     0, /* print_name */
00112     0, /* print_data */
00113     0, /* print_explanation */
00114     0, /* print_data_returned */
00115     0, /* data_size */
00116     0, /* data_type */
00117     0, /* flags */
00118     __FILE__,
00119     __LINE__,
00120 };
00121 
00122 #endif /* SIOCSCCGSTAT */
00123 
00124 
00125 /* vim: set ts=8 sw=4 et : */