libexplain
1.4.D001
|
00001 /* 00002 * libexplain - a library of system-call-specific strerror replacements 00003 * Copyright (C) 2011, 2013 Peter Miller 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU Lesser General Public License as 00007 * published by the Free Software Foundation; either version 3 of the 00008 * License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #include <libexplain/ac/linux/videodev2.h> 00020 00021 #include <libexplain/buffer/v4l2_clip.h> 00022 #include <libexplain/buffer/v4l2_rect.h> 00023 #include <libexplain/buffer/pointer.h> 00024 #include <libexplain/is_efault.h> 00025 00026 00027 #ifdef HAVE_LINUX_VIDEODEV2_H 00028 00029 void 00030 explain_buffer_v4l2_clip(explain_string_buffer_t *sb, 00031 const struct v4l2_clip *data) 00032 { 00033 if (explain_is_efault_pointer(data, sizeof(*data))) 00034 { 00035 explain_buffer_pointer(sb, data); 00036 return; 00037 } 00038 00039 explain_string_buffer_puts(sb, "{ c = "); 00040 explain_buffer_v4l2_rect(sb, &data->c); 00041 explain_string_buffer_puts(sb, ", next = "); 00042 explain_buffer_pointer(sb, data->next); 00043 explain_string_buffer_puts(sb, " }"); 00044 } 00045 00046 00047 void 00048 explain_buffer_v4l2_clip_list(explain_string_buffer_t *sb, 00049 const struct v4l2_clip *data, size_t data_size) 00050 { 00051 int first; 00052 00053 if (explain_is_efault_pointer(data, sizeof(*data)) || !data_size) 00054 { 00055 explain_buffer_pointer(sb, data); 00056 return; 00057 } 00058 00059 first = 1; 00060 explain_string_buffer_puts(sb, "{"); 00061 while (data && data_size > 0) 00062 { 00063 if (!first) 00064 { 00065 explain_string_buffer_puts(sb, ", "); 00066 first = 0; 00067 } 00068 explain_buffer_v4l2_rect(sb, &data->c); 00069 data = data->next; 00070 if (!data) 00071 break; 00072 --data_size; 00073 if (!data_size) 00074 break; 00075 if (explain_is_efault_pointer(data, sizeof(*data))) 00076 { 00077 explain_string_buffer_puts(sb, ", "); 00078 explain_buffer_pointer(sb, data); 00079 break; 00080 } 00081 } 00082 explain_string_buffer_puts(sb, " }"); 00083 } 00084 00085 #endif 00086 00087 /* vim: set ts=8 sw=4 et : */