libsigrokdecode
 All Data Structures Files Functions Variables Typedefs Enumerator Macros
Functions
util.c File Reference
#include "sigrokdecode.h"
#include "sigrokdecode-internal.h"
#include "config.h"
Include dependency graph for util.c:

Go to the source code of this file.

Functions

SRD_PRIV int py_attr_as_str (const PyObject *py_obj, const char *attr, char **outstr)
 Get the value of a Python object's attribute, returned as a newly allocated char *. More...
 
SRD_PRIV int py_dictitem_as_str (const PyObject *py_obj, const char *key, char **outstr)
 Get the value of a Python dictionary item, returned as a newly allocated char *. More...
 
SRD_PRIV int py_str_as_str (const PyObject *py_str, char **outstr)
 Get the value of a Python unicode string object, returned as a newly allocated char *. More...
 
SRD_PRIV int py_strlist_to_char (const PyObject *py_strlist, char ***outstr)
 Convert a Python list of unicode strings to a NULL-terminated UTF8-encoded char * array. More...
 

Function Documentation

SRD_PRIV int py_attr_as_str ( const PyObject *  py_obj,
const char *  attr,
char **  outstr 
)

Get the value of a Python object's attribute, returned as a newly allocated char *.

Parameters
py_objThe object to probe.
attrName of the attribute to retrieve.
outstrptr to char * storage to be filled in.
Returns
SRD_OK upon success, a (negative) error code otherwise. The 'outstr' argument points to a malloc()ed string upon success.

Definition at line 36 of file util.c.

References py_str_as_str(), srd_dbg(), SRD_ERR_PYTHON, and srd_exception_catch().

Referenced by srd_decoder_load().

Here is the call graph for this function:

SRD_PRIV int py_dictitem_as_str ( const PyObject *  py_obj,
const char *  key,
char **  outstr 
)

Get the value of a Python dictionary item, returned as a newly allocated char *.

Parameters
py_objThe dictionary to probe.
keyKey of the item to retrieve.
outstrPointer to char * storage to be filled in.
Returns
SRD_OK upon success, a (negative) error code otherwise. The 'outstr' argument points to a malloc()ed string upon success.

Definition at line 77 of file util.c.

References py_str_as_str(), srd_dbg(), and SRD_ERR_PYTHON.

Here is the call graph for this function:

SRD_PRIV int py_str_as_str ( const PyObject *  py_str,
char **  outstr 
)

Get the value of a Python unicode string object, returned as a newly allocated char *.

Parameters
py_strThe unicode string object.
outstrptr to char * storage to be filled in.
Returns
SRD_OK upon success, a (negative) error code otherwise. The 'outstr' argument points to a malloc()ed string upon success.

Definition at line 115 of file util.c.

References srd_dbg(), SRD_ERR_MALLOC, SRD_ERR_PYTHON, srd_exception_catch(), and SRD_OK.

Referenced by py_attr_as_str(), py_dictitem_as_str(), srd_decoder_doc_get(), srd_decoder_searchpath_add(), srd_exception_catch(), and srd_inst_option_set().

Here is the call graph for this function:

SRD_PRIV int py_strlist_to_char ( const PyObject *  py_strlist,
char ***  outstr 
)

Convert a Python list of unicode strings to a NULL-terminated UTF8-encoded char * array.

The caller must g_free() each string when finished.

Parameters
py_strlistThe list object.
outstrptr to char ** storage to be filled in.
Returns
SRD_OK upon success, a (negative) error code otherwise. The 'outstr' argument points to a g_malloc()ed char** upon success.

Definition at line 169 of file util.c.

References srd_err(), SRD_ERR_MALLOC, SRD_ERR_PYTHON, and SRD_OK.

Referenced by srd_decoder_load().

Here is the call graph for this function: