コード例 #1
0
ファイル: zprop_common.c プロジェクト: BjoKaSH/zfs-osx
static zprop_desc_t *
zprop_get_proptable(zfs_type_t type)
{
	if (type == ZFS_TYPE_POOL)
		return (zpool_prop_get_table());
	else
		return (zfs_prop_get_table());
}
コード例 #2
0
static PyObject *
py_get_proptable(PyObject *self, PyObject *args)
{
	zprop_desc_t *t = zfs_prop_get_table();
	PyObject *d = PyDict_New();
	zfs_prop_t i;

	for (i = 0; i < ZFS_NUM_PROPS; i++) {
		zprop_desc_t *p = &t[i];
		PyObject *tuple;
		static const char *typetable[] =
		    {"number", "string", "index"};
		static const char *attrtable[] =
		    {"default", "readonly", "inherit", "onetime"};
		PyObject *indextable;

		if (p->pd_proptype == PROP_TYPE_INDEX) {
			const zprop_index_t *it = p->pd_table;
			indextable = PyDict_New();
			int j;
			for (j = 0; it[j].pi_name; j++) {
				PyDict_SetItemString(indextable,
				    it[j].pi_name,
				    Py_BuildValue("K", it[j].pi_value));
			}
		} else {
			Py_INCREF(Py_None);
			indextable = Py_None;
		}

		tuple = Py_BuildValue("sissKsissiiO",
		    p->pd_name, p->pd_propnum, typetable[p->pd_proptype],
		    p->pd_strdefault, p->pd_numdefault,
		    attrtable[p->pd_attr], p->pd_types,
		    p->pd_values, p->pd_colname,
		    p->pd_rightalign, p->pd_visible, indextable);
		PyDict_SetItemString(d, p->pd_name, tuple);
		Py_DECREF(tuple);
	}

	return (d);
}