libexplain  1.4.D001
libexplain/iocontrol/vidioc_queryctrl.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/sys/ioctl.h>
00023 
00024 #include <libexplain/buffer/einval.h>
00025 #include <libexplain/buffer/enotsup.h>
00026 #include <libexplain/buffer/is_the_null_pointer.h>
00027 #include <libexplain/buffer/v4l2_queryctrl.h>
00028 #include <libexplain/iocontrol/generic.h>
00029 #include <libexplain/iocontrol/vidioc_queryctrl.h>
00030 
00031 #ifdef VIDIOC_QUERYCTRL
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)request;
00041     explain_buffer_v4l2_queryctrl(sb, data, 0, fildes);
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 EINVAL:
00052         if (!data)
00053         {
00054             explain_buffer_is_the_null_pointer(sb, "data");
00055             return;
00056         }
00057 
00058         switch (explain_v4l2_queryctrl_check_id(fildes, data))
00059         {
00060         case explain_v4l2_queryctrl_check_id_no_idea:
00061         default:
00062             goto best_guess;
00063 
00064         case explain_v4l2_queryctrl_check_id_notsup:
00065             explain_buffer_enotsup_device(sb, "data->id");
00066             break;
00067 
00068         case explain_v4l2_queryctrl_check_id_nosuch:
00069             best_guess:
00070             explain_buffer_einval_vague(sb, "data->id");
00071             break;
00072 
00073         case explain_v4l2_queryctrl_check_id_ok:
00074             explain_buffer_einval_vague(sb, "data");
00075             break;
00076         }
00077         break;
00078 
00079     default:
00080         explain_iocontrol_generic_print_explanation
00081         (
00082             p,
00083             sb,
00084             errnum,
00085             fildes,
00086             request,
00087             data
00088         );
00089         break;
00090     }
00091 }
00092 
00093 
00094 static void
00095 print_data_returned(const explain_iocontrol_t *p, explain_string_buffer_t *sb,
00096     int errnum, int fildes, int request, const void *data)
00097 {
00098     (void)p;
00099     (void)errnum;
00100     (void)request;
00101     explain_buffer_v4l2_queryctrl(sb, data, 1, fildes);
00102 }
00103 
00104 
00105 const explain_iocontrol_t explain_iocontrol_vidioc_queryctrl =
00106 {
00107     "VIDIOC_QUERYCTRL", /* name */
00108     VIDIOC_QUERYCTRL, /* value */
00109     0, /* disambiguate */
00110     0, /* print_name */
00111     print_data,
00112     print_explanation,
00113     print_data_returned,
00114     sizeof(struct v4l2_queryctrl), /* data_size */
00115     "struct v4l2_queryctrl *", /* data_type */
00116     0, /* flags */
00117     __FILE__,
00118     __LINE__,
00119 };
00120 
00121 #else /* ndef VIDIOC_QUERYCTRL */
00122 
00123 const explain_iocontrol_t explain_iocontrol_vidioc_queryctrl =
00124 {
00125     0, /* name */
00126     0, /* value */
00127     0, /* disambiguate */
00128     0, /* print_name */
00129     0, /* print_data */
00130     0, /* print_explanation */
00131     0, /* print_data_returned */
00132     0, /* data_size */
00133     0, /* data_type */
00134     0, /* flags */
00135     __FILE__,
00136     __LINE__,
00137 };
00138 
00139 #endif /* VIDIOC_QUERYCTRL */
00140 
00141 
00142 /* vim: set ts=8 sw=4 et : */