*
* Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
* Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
*
* Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
* Copyright (C) 2012 Bert Vermeulen <bert@biot.com>
* be added to the Python sys.path, or NULL.
*
* @return SRD_OK upon success, a (negative) error code otherwise.
* be added to the Python sys.path, or NULL.
*
* @return SRD_OK upon success, a (negative) error code otherwise.
* @return SRD_OK upon success, a (negative) error code otherwise.
*/
SRD_API int srd_inst_option_set(struct srd_decoder_inst *di,
* @return SRD_OK upon success, a (negative) error code otherwise.
*/
SRD_API int srd_inst_option_set(struct srd_decoder_inst *di,
{
PyObject *py_dec_options, *py_dec_optkeys, *py_di_options, *py_optval;
PyObject *py_optlist, *py_classval;
Py_UNICODE *py_ustr;
{
PyObject *py_dec_options, *py_dec_optkeys, *py_di_options, *py_optval;
PyObject *py_optlist, *py_classval;
Py_UNICODE *py_ustr;
int num_optkeys, ret, size, i;
int num_optkeys, ret, size, i;
if (!PyObject_HasAttrString(di->decoder->py_dec, "options")) {
/* Decoder has no options. */
if (!PyObject_HasAttrString(di->decoder->py_dec, "options")) {
/* Decoder has no options. */
- if (!(py_optval = PyUnicode_FromString(value))) {
+ if (!g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
+ srd_err("Option '%s' requires a string value.", key);
+ goto err_out;
+ }
+ val_str = g_variant_get_string(value, NULL);
+ if (!(py_optval = PyUnicode_FromString(val_str))) {
- if (!(py_optval = PyLong_FromString(value, NULL, 0))) {
+ if (!g_variant_is_of_type(value, G_VARIANT_TYPE_INT64)) {
+ srd_err("Option '%s' requires an integer value.", key);
+ goto err_out;
+ }
+ val_int = g_variant_get_int64(value);
+ if (!(py_optval = PyLong_FromLong(val_int))) {
* @return SRD_OK upon success, a (negative) error code otherwise.
*/
SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di,
* @return SRD_OK upon success, a (negative) error code otherwise.
*/
SRD_API int srd_inst_probe_set_all(struct srd_decoder_inst *di,
int i, num_required_probes;
srd_dbg("set probes called for instance %s with list of %d probes",
int i, num_required_probes;
srd_dbg("set probes called for instance %s with list of %d probes",
- probenum_str = g_hash_table_lookup(new_probes, probe_id);
- if (!probenum_str) {
+ probe_val= g_hash_table_lookup(new_probes, probe_id);
+ if (!g_variant_is_of_type(probe_val, G_VARIANT_TYPE_INT32)) {
/* Probe name was specified without a value. */
srd_err("No probe number was specified for %s.",
/* Probe name was specified without a value. */
srd_err("No probe number was specified for %s.",
if (!(sl = g_slist_find_custom(di->decoder->probes, probe_id,
(GCompareFunc)compare_probe_id))) {
/* Fall back on optional probes. */
if (!(sl = g_slist_find_custom(di->decoder->opt_probes,
probe_id, (GCompareFunc) compare_probe_id))) {
srd_err("Protocol decoder %s has no probe "
if (!(sl = g_slist_find_custom(di->decoder->probes, probe_id,
(GCompareFunc)compare_probe_id))) {
/* Fall back on optional probes. */
if (!(sl = g_slist_find_custom(di->decoder->opt_probes,
probe_id, (GCompareFunc) compare_probe_id))) {
srd_err("Protocol decoder %s has no probe "
* NULL in case of failure.
*/
SRD_API struct srd_decoder_inst *srd_inst_new(const char *decoder_id,
* NULL in case of failure.
*/
SRD_API struct srd_decoder_inst *srd_inst_new(const char *decoder_id,
* @return SRD_OK upon success, a (negative) error code otherwise.
*/
SRD_API int srd_inst_stack(struct srd_decoder_inst *di_from,
* @return SRD_OK upon success, a (negative) error code otherwise.
*/
SRD_API int srd_inst_stack(struct srd_decoder_inst *di_from,
* @param obj The Python class instantiation.
*
* @return Pointer to struct srd_decoder_inst, or NULL if not found.
* @param obj The Python class instantiation.
*
* @return Pointer to struct srd_decoder_inst, or NULL if not found.
SRD_PRIV int srd_inst_start(struct srd_decoder_inst *di, PyObject *args)
{
PyObject *py_name, *py_res;
SRD_PRIV int srd_inst_start(struct srd_decoder_inst *di, PyObject *args)
{
PyObject *py_name, *py_res;
* @param inbuflen Length of the buffer. Must be > 0.
*
* @return SRD_OK upon success, a (negative) error code otherwise.
* @param inbuflen Length of the buffer. Must be > 0.
*
* @return SRD_OK upon success, a (negative) error code otherwise.
- const struct srd_decoder_inst *di,
- const uint8_t *inbuf, uint64_t inbuflen)
+ const struct srd_decoder_inst *di, const uint8_t *inbuf,
+ uint64_t inbuflen)
end_samplenum, logic))) {
srd_exception_catch("Protocol decoder instance %s: ",
di->inst_id);
end_samplenum, logic))) {
srd_exception_catch("Protocol decoder instance %s: ",
di->inst_id);
* @return SRD_OK upon success, a (negative) error code otherwise.
*/
SRD_API int srd_session_send(uint64_t start_samplenum, const uint8_t *inbuf,
* @return SRD_OK upon success, a (negative) error code otherwise.
*/
SRD_API int srd_session_send(uint64_t start_samplenum, const uint8_t *inbuf,
* @param cb_data Private data for the callback function. Can be NULL.
*/
SRD_API int srd_pd_output_callback_add(int output_type,
* @param cb_data Private data for the callback function. Can be NULL.
*/
SRD_API int srd_pd_output_callback_add(int output_type,
SRD_PRIV int srd_inst_pd_output_add(struct srd_decoder_inst *di,
int output_type, const char *proto_id)
{
SRD_PRIV int srd_inst_pd_output_add(struct srd_decoder_inst *di,
int output_type, const char *proto_id)
{