Beispiel #1
0
static PyObject *
nis_maps (PyObject *self, PyObject *args)
{
	nismaplist *maps;
	PyObject *list;

        if (!PyArg_NoArgs(args))
		return NULL;
	if ((maps = nis_maplist ()) == NULL)
		return NULL;
	if ((list = PyList_New(0)) == NULL)
		return NULL;
	for (maps = maps; maps; maps = maps->next) {
		PyObject *str = PyString_FromString(maps->map);
		if (!str || PyList_Append(list, str) < 0)
		{
			Py_DECREF(list);
			list = NULL;
			break;
		}
		Py_DECREF(str);
	}
	/* XXX Shouldn't we free the list of maps now? */
	return list;
}
Beispiel #2
0
static PyObject *
nis_maps (PyObject *self, PyObject *args, PyObject *kwdict)
{
	char *domain = NULL;
	nismaplist *maps;
	PyObject *list;
        int err;
	static char *kwlist[] = {"domain", NULL};

	if (!PyArg_ParseTupleAndKeywords(args, kwdict,
					 "|s:maps", kwlist, &domain))
		return NULL;
	if (!domain && ((err = yp_get_default_domain (&domain)) != 0)) {
		nis_error(err);
		return NULL;
	}

	if ((maps = nis_maplist (domain)) == NULL)
		return NULL;
	if ((list = PyList_New(0)) == NULL)
		return NULL;
	for (maps = maps; maps; maps = maps->next) {
		PyObject *str = PyUnicode_FromString(maps->map);
		if (!str || PyList_Append(list, str) < 0)
		{
			Py_DECREF(list);
			list = NULL;
			break;
		}
		Py_DECREF(str);
	}
	/* XXX Shouldn't we free the list of maps now? */
	return list;
}