return talloc_str;
}
+const char **pyrpc_string_array_from_PyList(TALLOC_CTX *mem_ctx, PyObject *list,
+ const char *debug_name)
+{
+ const char **ret = NULL;
+ Py_ssize_t i;
+
+ if (!PyList_Check(list)) {
+ PyErr_Format(PyExc_TypeError,
+ "%s is not a list.",
+ debug_name);
+ return NULL;
+ }
+
+ ret = talloc_zero_array(mem_ctx, const char *, PyList_Size(list)+1);
+ if (ret == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ for (i = 0; i < PyList_Size(list); i++) {
+ PyObject *item = PyList_GetItem(list, i);
+ ret[i] = pyrpc_PyStr_AsString(ret, item);
+ if (ret[i] == NULL) {
+ talloc_free(ret);
+ return NULL;
+ }
+ }
+
+ ret[i] = NULL;
+ return ret;
+}
+
+PyObject *pyrpc_string_array_to_PyList(const char **string_array,
+ const char *debug_name)
+{
+ PyObject *pylist = NULL;
+ Py_ssize_t i;
+ Py_ssize_t len;
+
+ if (string_array == NULL) {
+ PyErr_Format(PyExc_TypeError,
+ "%s should be a string_array instead of NULL.",
+ debug_name);
+ return NULL;
+ }
+
+ len = str_list_length(string_array);
+
+ pylist = PyList_New(len);
+ if (pylist == NULL) {
+ return NULL;
+ }
+
+ for (i = 0; i < len; i++) {
+ PyObject *item = NULL;
+ int ret;
+
+ item = PyStr_FromString(string_array[i]);
+ if (item == NULL) {
+ Py_DECREF(pylist);
+ return NULL;
+ }
+
+ ret = PyList_SetItem(pylist, i, item);
+ if (ret != 0) {
+ Py_DECREF(pylist);
+ return NULL;
+ }
+ }
+
+ return pylist;
+}
+
PyObject *pyrpc_import_union(PyTypeObject *type, TALLOC_CTX *mem_ctx, int level,
const void *in, const char *typename)
{
PyObject *PyString_FromStringOrNULL(const char *str);
const char *pyrpc_PyStr_AsString(TALLOC_CTX *mem_ctx, PyObject *value);
+const char **pyrpc_string_array_from_PyList(TALLOC_CTX *mem_ctx, PyObject *list,
+ const char *debug_name);
+PyObject *pyrpc_string_array_to_PyList(const char **string_array,
+ const char *debug_name);
+
PyObject *pyrpc_import_union(PyTypeObject *type, TALLOC_CTX *mem_ctx, int level,
const void *in, const char *typename);
void *pyrpc_export_union(PyTypeObject *type, TALLOC_CTX *mem_ctx, int level,