libexplain  1.4.D001
libexplain/iocontrol/vidioc_cropcap.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_cropcap.h>
00028 #include <libexplain/iocontrol/generic.h>
00029 #include <libexplain/iocontrol/vidioc_cropcap.h>
00030 
00031 #ifdef VIDIOC_CROPCAP
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)fildes;
00041     (void)request;
00042     explain_buffer_v4l2_cropcap(sb, data, 0);
00043 }
00044 
00045 
00046 static void
00047 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb,
00048     int errnum, int fildes, int request, const void *data)
00049 {
00050     switch (errnum)
00051     {
00052     case EINVAL:
00053         if (!data)
00054         {
00055             explain_buffer_is_the_null_pointer(sb, "data");
00056             return;
00057         }
00058 
00059         /*
00060          * Check the type (the Linux kernel always checks this first).
00061          */
00062         switch (explain_v4l2_cropcap_check_type(fildes, data))
00063         {
00064         case explain_v4l2_cropcap_check_type_no_idea:
00065         default:
00066             goto generic;
00067 
00068         case explain_v4l2_cropcap_check_type_notsup:
00069             explain_buffer_enotsup_device(sb, "data->type");
00070             return;
00071 
00072         case explain_v4l2_cropcap_check_type_nosuch:
00073             explain_buffer_einval_vague(sb, "data->type");
00074             return;
00075 
00076         case explain_v4l2_cropcap_check_type_ok:
00077             break;
00078         }
00079 
00080         /* no idea */
00081         goto generic;
00082 
00083     default:
00084         generic:
00085         explain_iocontrol_generic_print_explanation
00086         (
00087             p,
00088             sb,
00089             errnum,
00090             fildes,
00091             request,
00092             data
00093         );
00094         break;
00095     }
00096 }
00097 
00098 
00099 static void
00100 print_data_returned(const explain_iocontrol_t *p, explain_string_buffer_t *sb,
00101     int errnum, int fildes, int request, const void *data)
00102 {
00103     (void)p;
00104     (void)errnum;
00105     (void)fildes;
00106     (void)request;
00107     explain_buffer_v4l2_cropcap(sb, data, 1);
00108 }
00109 
00110 
00111 const explain_iocontrol_t explain_iocontrol_vidioc_cropcap =
00112 {
00113     "VIDIOC_CROPCAP", /* name */
00114     VIDIOC_CROPCAP, /* value */
00115     0, /* disambiguate */
00116     0, /* print_name */
00117     print_data,
00118     print_explanation,
00119     print_data_returned,
00120     sizeof(struct v4l2_cropcap), /* data_size */
00121     "struct v4l2_cropcap *", /* data_type */
00122     0, /* flags */
00123     __FILE__,
00124     __LINE__,
00125 };
00126 
00127 #else /* ndef VIDIOC_CROPCAP */
00128 
00129 const explain_iocontrol_t explain_iocontrol_vidioc_cropcap =
00130 {
00131     0, /* name */
00132     0, /* value */
00133     0, /* disambiguate */
00134     0, /* print_name */
00135     0, /* print_data */
00136     0, /* print_explanation */
00137     0, /* print_data_returned */
00138     0, /* data_size */
00139     0, /* data_type */
00140     0, /* flags */
00141     __FILE__,
00142     __LINE__,
00143 };
00144 
00145 #endif /* VIDIOC_CROPCAP */
00146 
00147 /* vim: set ts=8 sw=4 et : */