libexplain  1.4.D001
libexplain/iocontrol/tiocshayesesp.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - Explain errno values returned by libc functions
00003  * Copyright (C) 2009-2011, 2013, 2014 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/sys/ioctl.h>
00022 #include <libexplain/ac/linux/hayesesp.h>
00023 
00024 #include <libexplain/buffer/ebusy.h>
00025 #include <libexplain/buffer/einval.h>
00026 #include <libexplain/buffer/gettext.h>
00027 #include <libexplain/buffer/hayes_esp_config.h>
00028 #include <libexplain/buffer/pointer.h>
00029 #include <libexplain/iocontrol/generic.h>
00030 #include <libexplain/iocontrol/tiocshayesesp.h>
00031 #include <libexplain/is_efault.h>
00032 
00033 
00034 #if defined(TIOCSHAYESESP) && defined(HAVE_LINUX_HAYESESP_H)
00035 
00036 static void
00037 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb,
00038     int errnum, int fildes, int request, const void *data)
00039 {
00040     (void)p;
00041     (void)errnum;
00042     (void)fildes;
00043     (void)request;
00044     explain_buffer_hayes_esp_config(sb, data);
00045 }
00046 
00047 
00048 static void
00049 print_explanation(const explain_iocontrol_t *p,
00050     explain_string_buffer_t *sb, int errnum, int fildes, int request,
00051     const void *data)
00052 {
00053     switch (errnum)
00054     {
00055     case EBUSY:
00056         explain_buffer_ebusy_fildes
00057         (
00058             sb,
00059             fildes,
00060             "fildes",
00061             "ioctl TIOCSHAYESESP"
00062         );
00063         break;
00064 
00065 #ifdef HAVE_LINUX_HAYESESP_H
00066     case EINVAL:
00067         {
00068             const struct hayes_esp_config *q;
00069 
00070             q = data;
00071             if (q->flow_on >= q->flow_off)
00072             {
00073                 explain_buffer_einval_value(sb, "data->flow_on", q->flow_on);
00074                 break;
00075             }
00076             if (q->rx_trigger < 1 || q->rx_trigger > 1023)
00077             {
00078                 explain_buffer_einval_value
00079                 (
00080                     sb,
00081                     "data->rx_trigger",
00082                     q->rx_trigger
00083                 );
00084                 break;
00085             }
00086             if (q->tx_trigger > 1023)
00087             {
00088                 explain_buffer_einval_value
00089                 (
00090                     sb,
00091                     "data->tx_trigger",
00092                     q->tx_trigger
00093                 );
00094                 break;
00095             }
00096             if (q->flow_off < 1 || q->flow_off > 1023)
00097             {
00098                 explain_buffer_einval_value
00099                 (
00100                     sb,
00101                     "data->flow_off",
00102                     q->flow_off
00103                 );
00104                 break;
00105             }
00106             if (q->flow_on < 1 || q->flow_on > 1023)
00107             {
00108                 explain_buffer_einval_value
00109                 (
00110                     sb,
00111                     "data->flow_on",
00112                     q->flow_on
00113                 );
00114                 break;
00115             }
00116             if (q->pio_threshold < 1 || q->pio_threshold > 1024)
00117             {
00118                 explain_buffer_einval_value
00119                 (
00120                     sb,
00121                     "data->pio_threshold",
00122                     q->pio_threshold
00123                 );
00124                 break;
00125             }
00126         }
00127         break;
00128 #endif
00129 
00130     default:
00131         explain_iocontrol_generic.print_explanation
00132         (
00133             p,
00134             sb,
00135             errnum,
00136             fildes,
00137             request,
00138             data
00139         );
00140         break;
00141     }
00142 }
00143 
00144 
00145 const explain_iocontrol_t explain_iocontrol_tiocshayesesp =
00146 {
00147     "TIOCSHAYESESP", /* name */
00148     TIOCSHAYESESP, /* value */
00149     0, /* disambiguate */
00150     0, /* print_name */
00151     print_data,
00152     print_explanation,
00153     0, /* print_data_returned */
00154     sizeof(struct hayes_esp_config), /* data_size */
00155     "struct hayes_esp_config *", /* data_type */
00156     0, /* flags */
00157     __FILE__,
00158     __LINE__,
00159 };
00160 
00161 #else
00162 
00163 const explain_iocontrol_t explain_iocontrol_tiocshayesesp =
00164 {
00165     0, /* name */
00166     0, /* value */
00167     0, /* disambiguate */
00168     0, /* print_name */
00169     0, /* print_data */
00170     0, /* print_explanation */
00171     0, /* print_data_returned */
00172     0, /* data_size */
00173     0, /* data_type */
00174     0, /* flags */
00175     __FILE__,
00176     __LINE__,
00177 };
00178 
00179 #endif
00180 
00181 
00182 /* vim: set ts=8 sw=4 et : */