Added a utility function to extract the info key from a dictionary.
authorTim Potter <tpot@samba.org>
Fri, 17 May 2002 02:25:37 +0000 (02:25 +0000)
committerTim Potter <tpot@samba.org>
Fri, 17 May 2002 02:25:37 +0000 (02:25 +0000)
source/python/py_common.c
source/python/py_common_proto.h

index 61eacced271ed9f972ab09036fe9d57cb95ce5a9..85305d027e9563f57db67a702c26505a8df75e9c 100644 (file)
@@ -197,3 +197,20 @@ struct cli_state *open_pipe_creds(char *server, PyObject *creds,
 
        return cli;
 }
+
+/* Return true if a dictionary contains a "level" key with an integer
+   value.  Set the value if so. */
+
+BOOL get_level_value(PyObject *dict, uint32 *level)
+{
+       PyObject *obj;
+
+       if (!(obj = PyDict_GetItemString(dict, "level")) ||
+           !PyInt_Check(obj))
+               return False;
+
+       if (level)
+               *level = PyInt_AsLong(obj);
+
+       return True;
+}
index dd823dd4c0384e2488bcdf1aecbfddd055cf6d62..992d444fa4d13d02865bd57b99a8601b9da51765 100644 (file)
@@ -14,6 +14,7 @@ PyObject *set_debuglevel(PyObject *self, PyObject *args);
 PyObject *py_setup_logging(PyObject *self, PyObject *args, PyObject *kw);
 struct cli_state *open_pipe_creds(char *server, PyObject *creds, 
                                  cli_pipe_fn *connect_fn, char **errstr);
+BOOL get_level_value(PyObject *dict, uint32 *level);
 
 /* The following definitions come from python/py_ntsec.c  */