aboutsummaryrefslogtreecommitdiffstats
path: root/pb_decode.c
diff options
context:
space:
mode:
Diffstat (limited to 'pb_decode.c')
-rw-r--r--pb_decode.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/pb_decode.c b/pb_decode.c
index 63008dd5..df053314 100644
--- a/pb_decode.c
+++ b/pb_decode.c
@@ -7,14 +7,19 @@
#include "pb_decode.h"
#include <string.h>
-const pb_decoder_t PB_DECODERS[PB_LTYPES_COUNT] = {
- (pb_decoder_t)&pb_dec_varint,
- (pb_decoder_t)&pb_dec_svarint,
- (pb_decoder_t)&pb_dec_fixed,
+typedef bool (*pb_decoder_t)(pb_istream_t *stream, const pb_field_t *field, void *dest);
+
+/* --- Function pointers to field decoders ---
+ * Order in the array must match pb_action_t LTYPE numbering.
+ */
+static const pb_decoder_t PB_DECODERS[PB_LTYPES_COUNT] = {
+ &pb_dec_varint,
+ &pb_dec_svarint,
+ &pb_dec_fixed,
- (pb_decoder_t)&pb_dec_bytes,
- (pb_decoder_t)&pb_dec_string,
- (pb_decoder_t)&pb_dec_submessage
+ &pb_dec_bytes,
+ &pb_dec_string,
+ &pb_dec_submessage
};
/**************
@@ -108,33 +113,27 @@ bool pb_skip_string(pb_istream_t *stream)
* to just assume the correct type and fail safely on corrupt message.
*/
-enum wire_type_t {
- WT_VARINT = 0,
- WT_64BIT = 1,
- WT_STRING = 2,
- WT_32BIT = 5
-};
-
static bool skip(pb_istream_t *stream, int wire_type)
{
switch (wire_type)
{
- case WT_VARINT: return pb_skip_varint(stream);
- case WT_64BIT: return pb_read(stream, NULL, 8);
- case WT_STRING: return pb_skip_string(stream);
- case WT_32BIT: return pb_read(stream, NULL, 4);
+ case PB_WT_VARINT: return pb_skip_varint(stream);
+ case PB_WT_64BIT: return pb_read(stream, NULL, 8);
+ case PB_WT_STRING: return pb_skip_string(stream);
+ case PB_WT_32BIT: return pb_read(stream, NULL, 4);
default: return false;
}
}
-/* Read a raw value to buffer, for the purpose of passing it to callback.
- * Size is maximum size on call, and actual size on return. */
-static bool read_raw_value(pb_istream_t *stream, int wire_type, uint8_t *buf, size_t *size)
+/* Read a raw value to buffer, for the purpose of passing it to callback as
+ * a substream. Size is maximum size on call, and actual size on return.
+ */
+static bool read_raw_value(pb_istream_t *stream, pb_wire_type_t wire_type, uint8_t *buf, size_t *size)
{
size_t max_size = *size;
switch (wire_type)
{
- case WT_VARINT:
+ case PB_WT_VARINT:
*size = 0;
do
{
@@ -144,11 +143,11 @@ static bool read_raw_value(pb_istream_t *stream, int wire_type, uint8_t *buf, si
} while (*buf++ & 0x80);
return true;
- case WT_64BIT:
+ case PB_WT_64BIT:
*size = 8;
return pb_read(stream, buf, 8);
- case WT_32BIT:
+ case PB_WT_32BIT:
*size = 4;
return pb_read(stream, buf, 4);
@@ -239,7 +238,7 @@ bool decode_field(pb_istream_t *stream, int wire_type, pb_field_iterator_t *iter
return func(stream, iter->current, iter->pData);
case PB_HTYPE_ARRAY:
- if (wire_type == WT_STRING
+ if (wire_type == PB_WT_STRING
&& PB_LTYPE(iter->current->type) <= PB_LTYPE_LAST_PACKABLE)
{
/* Packed array */
@@ -270,7 +269,7 @@ bool decode_field(pb_istream_t *stream, int wire_type, pb_field_iterator_t *iter
}
case PB_HTYPE_CALLBACK:
- if (wire_type == WT_STRING)
+ if (wire_type == PB_WT_STRING)
{
pb_callback_t *pCallback = (pb_callback_t*)iter->pData;
pb_istream_t substream;
@@ -419,7 +418,7 @@ bool pb_dec_fixed(pb_istream_t *stream, const pb_field_t *field, void *dest)
#ifdef __BIG_ENDIAN__
uint8_t bytes[8] = {0};
bool status = pb_read(stream, bytes, field->data_size);
- uint8_t lebytes[8] = {bytes[7], bytes[6], bytes[5], bytes[4],
+ uint8_t bebytes[8] = {bytes[7], bytes[6], bytes[5], bytes[4],
bytes[3], bytes[2], bytes[1], bytes[0]};
endian_copy(dest, lebytes, field->data_size, 8);
return status;
@@ -428,7 +427,7 @@ bool pb_dec_fixed(pb_istream_t *stream, const pb_field_t *field, void *dest)
#endif
}
-bool pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, uint8_t *dest)
+bool pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest)
{
pb_bytes_array_t *x = (pb_bytes_array_t*)dest;
@@ -445,7 +444,7 @@ bool pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, uint8_t *dest)
return pb_read(stream, x->bytes, x->size);
}
-bool pb_dec_string(pb_istream_t *stream, const pb_field_t *field, uint8_t *dest)
+bool pb_dec_string(pb_istream_t *stream, const pb_field_t *field, void *dest)
{
uint32_t size;
bool status;
Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
DESCRIPTION = "Configurations for Audiomanager Plugins with Sound Manager"
HOMEPAGE = ""
LICENSE = "MPLv2"
SECTION = "multimedia"

LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
RDEPENDS_${PN} = "libxml2 zlib dbus-lib"

SRC_URI = " \
    file://amcp_dbus.conf \
    file://amrp_dbus.conf \
    file://configuration.xml \
    file://customtypes.xsd \
    file://soundmanager-dbus.conf \
"

FILES_${PN} = " \
    ${sysconfdir}/dbus-1/system.d/amcp_dbus.conf \
    ${sysconfdir}/dbus-1/system.d/amrp_dbus.conf \
    ${sysconfdir}/dbus-1/system.d/soundmanager-dbus.conf \
    ${sysconfdir}/audiomanager/control/configuration.xml \
    ${sysconfdir}/audiomanager/control/customtypes.xsd \
"

FILES_${PN}-dbg += " \
    /usr/lib/audiomanager/command/.debug \
    /usr/lib/audiomanager/routing/.debug \
"

do_install() {
    install -d ${D}${sysconfdir}/dbus-1/system.d
    install -m 644 ${WORKDIR}/amcp_dbus.conf ${D}${sysconfdir}/dbus-1/system.d/
    install -m 644 ${WORKDIR}/amrp_dbus.conf ${D}${sysconfdir}/dbus-1/system.d/
    install -m 644 ${WORKDIR}/soundmanager-dbus.conf ${D}${sysconfdir}/dbus-1/system.d/
    install -d ${D}${sysconfdir}/audiomanager/control
    install -m 644 ${WORKDIR}/configuration.xml ${D}${sysconfdir}/audiomanager/control/
    install -m 644 ${WORKDIR}/customtypes.xsd ${D}${sysconfdir}/audiomanager/control/
}

RPROVIDES_${PN} += "virtual/audiomanager-plugins-config"