* Get the API version of the specified decoder. * * @param d The decoder to use. Must not be NULL. * * @return The API version of the decoder, or 0 upon errors. * * @private */
| 697 | * @private |
| 698 | */ |
| 699 | SRD_PRIV long srd_decoder_apiver(const struct srd_decoder *d) |
| 700 | { |
| 701 | PyObject *py_apiver; |
| 702 | long apiver; |
| 703 | PyGILState_STATE gstate; |
| 704 | |
| 705 | if (!d) |
| 706 | return 0; |
| 707 | |
| 708 | gstate = PyGILState_Ensure(); |
| 709 | |
| 710 | py_apiver = PyObject_GetAttrString(d->py_dec, "api_version"); |
| 711 | apiver = (py_apiver && PyLong_Check(py_apiver)) |
| 712 | ? PyLong_AsLong(py_apiver) : 0; |
| 713 | Py_XDECREF(py_apiver); |
| 714 | |
| 715 | PyGILState_Release(gstate); |
| 716 | |
| 717 | return apiver; |
| 718 | } |
| 719 | |
| 720 | /** |
| 721 | * Load a protocol decoder module into the embedded Python interpreter. |