libexplain
1.4.D001
|
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/videodev.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/iocontrol/generic.h> 00028 #include <libexplain/iocontrol/vidiocsync.h> 00029 #include <libexplain/is_efault.h> 00030 00031 #ifdef VIDIOCSYNC 00032 00033 00034 static void 00035 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00036 int errnum, int fildes, int request, const void *data) 00037 { 00038 switch (errnum) 00039 { 00040 case EINVAL: 00041 if (!data) 00042 { 00043 explain_buffer_is_the_null_pointer(sb, "data"); 00044 return; 00045 } 00046 00047 /* 00048 * framenum is probably out of range 00049 */ 00050 { 00051 const int *arg; 00052 00053 arg = data; 00054 if (!explain_is_efault_pointer(arg, sizeof(*arg))) 00055 { 00056 struct video_mbuf qry; 00057 00058 memset(&qry, 0, sizeof(qry)); 00059 if 00060 ( 00061 ioctl(fildes, VIDIOCGMBUF, &qry) >= 0 00062 && 00063 qry.frames > 0 00064 && 00065 (*arg < 0 || *arg >= qry.frames) 00066 ) 00067 { 00068 explain_buffer_einval_out_of_range 00069 ( 00070 sb, 00071 "data", 00072 0, 00073 qry.frames - 1 00074 ); 00075 return; 00076 } 00077 } 00078 } 00079 00080 explain_buffer_einval_vague(sb, "data"); 00081 break; 00082 00083 default: 00084 explain_iocontrol_generic_print_explanation 00085 ( 00086 p, 00087 sb, 00088 errnum, 00089 fildes, 00090 request, 00091 data 00092 ); 00093 break; 00094 } 00095 } 00096 00097 00098 const explain_iocontrol_t explain_iocontrol_vidiocsync = 00099 { 00100 "VIDIOCSYNC", /* name */ 00101 VIDIOCSYNC, /* value */ 00102 0, /* disambiguate */ 00103 0, /* print_name */ 00104 explain_iocontrol_generic_print_data_int_star, /* print_data */ 00105 print_explanation, 00106 0, /* print_data_returned */ 00107 sizeof(int), /* data_size */ 00108 "int *", /* data type */ 00109 0, /* flags */ 00110 __FILE__, 00111 __LINE__, 00112 }; 00113 00114 #else /* ndef VIDIOCSYNC */ 00115 00116 const explain_iocontrol_t explain_iocontrol_vidiocsync = 00117 { 00118 0, /* name */ 00119 0, /* value */ 00120 0, /* disambiguate */ 00121 0, /* print_name */ 00122 0, /* print_data */ 00123 0, /* print_explanation */ 00124 0, /* print_data_returned */ 00125 0, /* data_size */ 00126 0, /* data_type */ 00127 0, /* flags */ 00128 __FILE__, 00129 __LINE__, 00130 }; 00131 00132 #endif /* VIDIOCSYNC */ 00133 00134 /* vim: set ts=8 sw=4 et : */