2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 static PyObject *py_get_predefined_key_by_name(PyObject *self, PyObject *args)
25 return Py_None; /* FIXME */
28 static PyObject *py_key_del_abs(PyObject *self, PyObject *args)
30 return Py_None; /* FIXME */
33 static PyMethodDef registry_methods[] = {
34 { "get_predefined_key_by_name", py_get_predefined_key_by_name, METH_VARARGS,
35 "S.get_predefined_key_by_name(name) -> key\n"
36 "Find a predefined key by name" },
37 { "key_del_abs", py_key_del_abs, METH_VARARGS, "S.key_del_abs(name) -> None\n"
38 "Delete a key by absolute path." },
39 { "get_predefined_key", py_get_predefined_key, METH_VARARGS, "S.get_predefined_key(hkey_id) -> key\n"
40 "Find a predefined key by id" },
41 { "diff_apply", py_diff_apply, METH_VARARGS, "S.diff_apply(filename) -> None\n"
42 "Apply the diff from the specified file" },
43 { "mount_hive", py_mount_hive, METH_VARARGS, "S.mount_hive(key, key_id, elements=None) -> None\n"
44 "Mount the specified key at the specified path." },
45 { "import_hive_key", py_import_hive_key, METH_VARARGS, "S.import_hive_key(hive, predef_key, elements=None) -> Key" },
49 PyTypeObject PyRegistry = {
50 .tp_name = "Registry",
51 .tp_methods = registry_methods,
52 .tp_new = registry_new,
55 static PyMethodDef hive_key_methods[] = {
56 { "del", hive_key_del, METH_VARARGS, "S.del(name) -> None\n"
58 { "flush", hive_key_flush, METH_VARARGS, "S.flush() -> None\n"
59 "Flush this key to disk" },
60 { "del_value", hive_key_del_value, METH_VARARGS, "S.del_value(name) -> None\n"
62 { "set_value", hive_key_set_value, METH_VARARGS, "S.set_value(name, type, data) -> None\n"
67 static PyObject *hive_open(PyTypeObject *type, PyObject *args, PyObject *kwargs)
73 PyTypeObject PyHiveKey = {
75 .tp_methods = hive_key_methods,
79 static PyObject *py_open_samba(PyObject *self, PyObject *args, PyObject *kwargs)
81 char *kwnames[] = { "lp_ctx", "session_info", };
82 struct registry_context *reg_ctx;
83 PyObject *py_lp_ctx, *py_session_info, *py_credentials;
84 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOO", kwnames,
85 &py_lp_ctx, &py_session_info, &py_credentials))
90 result = reg_open_samba(NULL, ®_ctx, py_event_context(),
91 lp_ctx, session_info, credentials);
92 if (!W_ERROR_IS_OK(result)) {
93 PyErr_SetWERROR(result);
102 static PyMethodDef py_registry_methods[] = {
103 { "open_samba", py_open_samba, METH_VARARGS|METH_KEYWORDS, "open_samba() -> reg" },
104 { "open_directory", py_open_directory, METH_VARARGS, "open_dir(location) -> key" },
105 { "create_directory", py_create_directory, METH_VARARGS, "create_dir(location) -> key" },
106 { "open_ldb_file", py_open_ldb_file, METH_VARARGS|METH_KEYWORDS, "open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key" },
107 { "str_regtype", py_str_regtype, METH_VARARGS, "str_regtype(int) -> str" },
108 { "get_predef_name", py_get_predef_name, METH_VARARGS, "get_predef_name(hkey) -> str" },
112 void initregistry(void)
116 m = PyInitModule3("registry", py_registry_methods, "Registry");
120 PyModule_AddObject(m, "HKEY_CLASSES_ROOT", PyInt_FromLong(HKEY_CLASSES_ROOT));
121 PyModule_AddObject(m, "HKEY_CURRENT_USER", PyInt_FromLong(HKEY_CURRENT_USER));
122 PyModule_AddObject(m, "HKEY_LOCAL_MACHINE", PyInt_FromLong(HKEY_LOCAL_MACHINE));
123 PyModule_AddObject(m, "HKEY_USERS", PyInt_FromLong(HKEY_USERS));
124 PyModule_AddObject(m, "HKEY_PERFORMANCE_DATA", PyInt_FromLong(HKEY_PERFORMANCE_DATA));
125 PyModule_AddObject(m, "HKEY_CURRENT_CONFIG", PyInt_FromLong(HKEY_CURRENT_CONFIG));
126 PyModule_AddObject(m, "HKEY_DYN_DATA", PyInt_FromLong(HKEY_DYN_DATA));
127 PyModule_AddObject(m, "HKEY_PERFORMANCE_TEXT", PyInt_FromLong(HKEY_PERFORMANCE_TEXT));
128 PyModule_AddObject(m, "HKEY_PERFORMANCE_NLSTEXT", PyInt_FromLong(HKEY_PERFORMANCE_NLSTEXT));