* Return a protocol decoder's docstring. * * @param dec The loaded protocol decoder. * * @return A newly allocated buffer containing the protocol decoder's * documentation. The caller is responsible for free'ing the buffer. * * @since 0.1.0 */
| 941 | * @since 0.1.0 |
| 942 | */ |
| 943 | SRD_API char *srd_decoder_doc_get(const struct srd_decoder *dec) |
| 944 | { |
| 945 | PyObject *py_str; |
| 946 | char *doc; |
| 947 | PyGILState_STATE gstate; |
| 948 | |
| 949 | if (!srd_check_init()) |
| 950 | return NULL; |
| 951 | |
| 952 | if (!dec) |
| 953 | return NULL; |
| 954 | |
| 955 | gstate = PyGILState_Ensure(); |
| 956 | |
| 957 | if (!PyObject_HasAttrString(dec->py_mod, "__doc__")) |
| 958 | goto err; |
| 959 | |
| 960 | if (!(py_str = PyObject_GetAttrString(dec->py_mod, "__doc__"))) { |
| 961 | srd_exception_catch(NULL, "Failed to get docstring"); |
| 962 | goto err; |
| 963 | } |
| 964 | |
| 965 | doc = NULL; |
| 966 | if (py_str != Py_None) |
| 967 | py_str_as_str(py_str, &doc); |
| 968 | Py_DECREF(py_str); |
| 969 | |
| 970 | PyGILState_Release(gstate); |
| 971 | |
| 972 | return doc; |
| 973 | |
| 974 | err: |
| 975 | PyGILState_Release(gstate); |
| 976 | |
| 977 | return NULL; |
| 978 | } |
| 979 | |
| 980 | /** |
| 981 | * Unload the specified protocol decoder. |
nothing calls this directly
no test coverage detected