libexplain  1.4.D001
libexplain/iocontrol/vidioc_g_dv_preset.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/pointer.h>
00025 #include <libexplain/buffer/v4l2_dv_preset.h>
00026 #include <libexplain/buffer/is_the_null_pointer.h>
00027 #include <libexplain/iocontrol/generic.h>
00028 #include <libexplain/iocontrol/vidioc_g_dv_preset.h>
00029 
00030 #ifdef VIDIOC_G_DV_PRESET
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     /* strange, this is _IORW, when it should be _IOR */
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         errnum = ENOTTY;
00060         /* Fall through... */
00061 
00062     default:
00063         explain_iocontrol_generic_print_explanation
00064         (
00065             p,
00066             sb,
00067             errnum,
00068             fildes,
00069             request,
00070             data
00071         );
00072         break;
00073     }
00074 }
00075 
00076 
00077 static void
00078 print_data_returned(const explain_iocontrol_t *p, explain_string_buffer_t *sb,
00079     int errnum, int fildes, int request, const void *data)
00080 {
00081     (void)p;
00082     (void)errnum;
00083     (void)fildes;
00084     (void)request;
00085     explain_buffer_v4l2_dv_preset(sb, data);
00086 }
00087 
00088 
00089 const explain_iocontrol_t explain_iocontrol_vidioc_g_dv_preset =
00090 {
00091     "VIDIOC_G_DV_PRESET", /* name */
00092     VIDIOC_G_DV_PRESET, /* value */
00093     0, /* disambiguate */
00094     0, /* print_name */
00095     print_data,
00096     print_explanation,
00097     print_data_returned,
00098     sizeof(struct v4l2_dv_preset), /* data_size */
00099     "struct v4l2_dv_preset *", /* data_type */
00100     0, /* flags */
00101     __FILE__,
00102     __LINE__,
00103 };
00104 
00105 #else /* ndef VIDIOC_G_DV_PRESET */
00106 
00107 const explain_iocontrol_t explain_iocontrol_vidioc_g_dv_preset =
00108 {
00109     0, /* name */
00110     0, /* value */
00111     0, /* disambiguate */
00112     0, /* print_name */
00113     0, /* print_data */
00114     0, /* print_explanation */
00115     0, /* print_data_returned */
00116     0, /* data_size */
00117     0, /* data_type */
00118     0, /* flags */
00119     __FILE__,
00120     __LINE__,
00121 };
00122 
00123 #endif /* VIDIOC_G_DV_PRESET */
00124 
00125 /* vim: set ts=8 sw=4 et : */