libexplain  1.4.D001
libexplain/buffer/v4l2_sliced_vbi_service_set.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  *
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/pointer.h>
00022 #include <libexplain/buffer/v4l2_sliced_vbi_service_set.h>
00023 #include <libexplain/is_efault.h>
00024 #include <libexplain/parse_bits.h>
00025 
00026 
00027 #ifdef HAVE_LINUX_VIDEODEV2_H
00028 
00029 void
00030 explain_buffer_v4l2_sliced_vbi_service_set(explain_string_buffer_t *sb,
00031     int value)
00032 {
00033     static const explain_parse_bits_table_t table[] =
00034     {
00035         { "V4L2_SLICED_TELETEXT_B", V4L2_SLICED_TELETEXT_B },
00036         { "V4L2_SLICED_VPS", V4L2_SLICED_VPS },
00037         { "V4L2_SLICED_CAPTION_525", V4L2_SLICED_CAPTION_525 },
00038         { "V4L2_SLICED_WSS_625", V4L2_SLICED_WSS_625 },
00039         { "V4L2_SLICED_VBI_525", V4L2_SLICED_VBI_525 },
00040         { "V4L2_SLICED_VBI_625", V4L2_SLICED_VBI_625 },
00041     };
00042 
00043     explain_parse_bits_print(sb, value, table, SIZEOF(table));
00044 }
00045 
00046 
00047 void
00048 explain_buffer_v4l2_sliced_vbi_service_set_array(explain_string_buffer_t *sb,
00049     const uint16_t *data, size_t data_size)
00050 {
00051     size_t          j;
00052 
00053     if (explain_is_efault_pointer(data, data_size * sizeof(*data)))
00054     {
00055         explain_buffer_pointer(sb, data);
00056         return;
00057     }
00058 
00059     /* shorten the array on the right if there are zero values */
00060     while (data_size > 2 && data[data_size - 1] == 0)
00061         --data_size;
00062 
00063     explain_string_buffer_puts(sb, "{ ");
00064     for (j = 0; j < data_size; ++j)
00065     {
00066         if (j)
00067             explain_string_buffer_puts(sb, ", ");
00068         explain_buffer_v4l2_sliced_vbi_service_set(sb, data[j]);
00069     }
00070     explain_string_buffer_puts(sb, " }");
00071 }
00072 
00073 
00074 void
00075 explain_buffer_v4l2_sliced_vbi_service_set_array2(explain_string_buffer_t *sb,
00076     const uint16_t *data, size_t dim1_size, size_t dim2_size)
00077 {
00078     size_t          j;
00079 
00080     if (explain_is_efault_pointer(data, dim1_size * dim2_size * sizeof(*data)))
00081     {
00082         explain_buffer_pointer(sb, data);
00083         return;
00084     }
00085 
00086     explain_string_buffer_puts(sb, "{ ");
00087     for (j = 0; j < dim1_size; ++j)
00088     {
00089         if (j)
00090             explain_string_buffer_puts(sb, ", ");
00091         explain_buffer_v4l2_sliced_vbi_service_set_array(sb,
00092             data + j * dim2_size, dim2_size);
00093     }
00094     explain_string_buffer_puts(sb, " }");
00095 }
00096 
00097 #endif
00098 
00099 /* vim: set ts=8 sw=4 et : */