to_struct() now returns a boolean which is false if not all the elements of
authorTim Potter <tpot@samba.org>
Fri, 17 May 2002 02:24:06 +0000 (02:24 +0000)
committerTim Potter <tpot@samba.org>
Fri, 17 May 2002 02:24:06 +0000 (02:24 +0000)
the structure were present in the dictionary.

source/python/py_conv.c
source/python/py_conv.h

index 2dc12f348a789fc90bc074b07fb6fb03eca13f6e..c6f39515af16f453dd081bce4cc07e6a4ab61738 100644 (file)
@@ -78,7 +78,7 @@ PyObject *from_struct(void *s, struct pyconv *conv)
 
 /* Convert a Python dict to a structure */
 
-void to_struct(void *s, PyObject *dict, struct pyconv *conv)
+BOOL to_struct(void *s, PyObject *dict, struct pyconv *conv)
 {
        int i;
 
@@ -86,6 +86,9 @@ void to_struct(void *s, PyObject *dict, struct pyconv *conv)
                PyObject *obj;
                
                obj = PyDict_GetItemString(dict, conv[i].name);
+
+               if (!obj)
+                       return False;
                
                switch (conv[i].type) {
                case PY_UNISTR: {
@@ -123,4 +126,6 @@ void to_struct(void *s, PyObject *dict, struct pyconv *conv)
                        break;
                }
        }
+
+       return True;
 }
index 0de2d674de2eaa77525793da46560fc237ea0a1b..ed06b9a852af85648c8bf8d4ff3213426a002787 100644 (file)
@@ -30,7 +30,7 @@ struct pyconv {
 };
 
 PyObject *from_struct(void *s, struct pyconv *conv);
-void to_struct(void *s, PyObject *dict, struct pyconv *conv);
+BOOL to_struct(void *s, PyObject *dict, struct pyconv *conv);
 
 /* Another version of offsetof (-: */