libexplain  1.4.D001
libexplain/iocontrol/vidioc_s_modulator.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - a library of system-call-specific strerror replacements
00003  * Copyright (C) 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/videodev2.h>
00022 #include <libexplain/ac/string.h>
00023 #include <libexplain/ac/sys/ioctl.h>
00024 
00025 #include <libexplain/buffer/einval.h>
00026 #include <libexplain/buffer/is_the_null_pointer.h>
00027 #include <libexplain/buffer/v4l2_modulator.h>
00028 #include <libexplain/iocontrol/generic.h>
00029 #include <libexplain/iocontrol/vidioc_s_modulator.h>
00030 #include <libexplain/is_efault.h>
00031 
00032 #ifdef VIDIOC_S_MODULATOR
00033 
00034 
00035 static void
00036 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb,
00037     int errnum, int fildes, int request, const void *data)
00038 {
00039     (void)p;
00040     (void)errnum;
00041     (void)fildes;
00042     (void)request;
00043     explain_buffer_v4l2_modulator(sb, data, 1);
00044 }
00045 
00046 
00047 static void
00048 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb,
00049     int errnum, int fildes, int request, const void *data)
00050 {
00051     switch (errnum)
00052     {
00053     case EINVAL:
00054         if (!data)
00055         {
00056             explain_buffer_is_the_null_pointer(sb, "data");
00057             return;
00058         }
00059 
00060         {
00061             const struct v4l2_modulator *arg;
00062 
00063             arg = data;
00064             if (!explain_is_efault_pointer(arg, sizeof(*arg)))
00065             {
00066                 struct v4l2_modulator qry;
00067 
00068                 memset(&qry, 0, sizeof(qry));
00069                 qry.index = arg->index;
00070                 if (ioctl(fildes, VIDIOC_G_MODULATOR, &qry) >= 0)
00071                 {
00072                     explain_buffer_einval_vague(sb, "data->txsubchans");
00073                     return;
00074                 }
00075                 if (errno == EINVAL)
00076                 {
00077                     explain_buffer_einval_vague(sb, "data->index");
00078                     return;
00079                 }
00080             }
00081 
00082             explain_buffer_einval_vague(sb, "data");
00083             return;
00084         }
00085 
00086     default:
00087         explain_iocontrol_generic_print_explanation
00088         (
00089             p,
00090             sb,
00091             errnum,
00092             fildes,
00093             request,
00094             data
00095         );
00096         break;
00097     }
00098 }
00099 
00100 
00101 const explain_iocontrol_t explain_iocontrol_vidioc_s_modulator =
00102 {
00103     "VIDIOC_S_MODULATOR", /* name */
00104     VIDIOC_S_MODULATOR, /* value */
00105     0, /* disambiguate */
00106     0, /* print_name */
00107     print_data,
00108     print_explanation,
00109     0, /* print_data_returned */
00110     sizeof(struct v4l2_modulator), /* data_size */
00111     "struct v4l2_modulator *", /* data_type */
00112     0, /* flags */
00113     __FILE__,
00114     __LINE__,
00115 };
00116 
00117 #else /* ndef VIDIOC_S_MODULATOR */
00118 
00119 const explain_iocontrol_t explain_iocontrol_vidioc_s_modulator =
00120 {
00121     0, /* name */
00122     0, /* value */
00123     0, /* disambiguate */
00124     0, /* print_name */
00125     0, /* print_data */
00126     0, /* print_explanation */
00127     0, /* print_data_returned */
00128     0, /* data_size */
00129     0, /* data_type */
00130     0, /* flags */
00131     __FILE__,
00132     __LINE__,
00133 };
00134 
00135 #endif /* VIDIOC_S_MODULATOR */
00136 
00137 /* vim: set ts=8 sw=4 et : */