MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / print_searchpaths

Function print_searchpaths

libsigrokdecode4DSL/srd.c:116–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116static int print_searchpaths(void)
117{
118 PyObject *py_paths, *py_path, *py_bytes;
119 PyGILState_STATE gstate;
120 GString *s;
121 GSList *l;
122 int i;
123
124 s = g_string_sized_new(500);
125 g_string_append(s, "Protocol decoder search paths:\n");
126 for (l = searchpaths; l; l = l->next)
127 g_string_append_printf(s, " - %s\n", (const char *)l->data);
128 s->str[s->len - 1] = '\0';
129 srd_dbg("%s", s->str);
130 g_string_free(s, TRUE);
131
132 gstate = PyGILState_Ensure();
133
134 py_paths = PySys_GetObject("path");
135 if (!py_paths)
136 goto err;
137
138 s = g_string_sized_new(500);
139 g_string_append(s, "Python system search paths:\n");
140 for (i = 0; i < PyList_Size(py_paths); i++) {
141 py_path = PyList_GetItem(py_paths, i);
142 py_bytes = PyUnicode_AsUTF8String(py_path);
143 g_string_append_printf(s, " - %s\n", PyBytes_AsString(py_bytes));
144 Py_DECREF(py_bytes);
145 }
146 s->str[s->len - 1] = '\0';
147 srd_dbg("%s", s->str);
148 g_string_free(s, TRUE);
149
150 PyGILState_Release(gstate);
151
152 return SRD_OK;
153
154err:
155 srd_err("Unable to query Python system search paths.");
156 PyGILState_Release(gstate);
157
158 return SRD_ERR_PYTHON;
159}
160
161/**
162 * Initialize libsigrokdecode.

Callers 1

srd_initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected