Add a setexpiry operation in samdb.py
[kai/samba.git] / source4 / lib / ldb / ldb_wrap.c
1 /* ----------------------------------------------------------------------------
2  * This file was automatically generated by SWIG (http://www.swig.org).
3  * Version 1.3.36
4  * 
5  * This file is not intended to be easily readable and contains a number of 
6  * coding conventions designed to improve portability and efficiency. Do not make
7  * changes to this file unless you know what you are doing--modify the SWIG 
8  * interface file instead. 
9  * ----------------------------------------------------------------------------- */
10
11 #define SWIGPYTHON
12 #define SWIG_PYTHON_NO_BUILD_NONE
13 /* -----------------------------------------------------------------------------
14  *  This section contains generic SWIG labels for method/variable
15  *  declarations/attributes, and other compiler dependent labels.
16  * ----------------------------------------------------------------------------- */
17
18 /* template workaround for compilers that cannot correctly implement the C++ standard */
19 #ifndef SWIGTEMPLATEDISAMBIGUATOR
20 # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
21 #  define SWIGTEMPLATEDISAMBIGUATOR template
22 # elif defined(__HP_aCC)
23 /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
24 /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
25 #  define SWIGTEMPLATEDISAMBIGUATOR template
26 # else
27 #  define SWIGTEMPLATEDISAMBIGUATOR
28 # endif
29 #endif
30
31 /* inline attribute */
32 #ifndef SWIGINLINE
33 # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
34 #   define SWIGINLINE inline
35 # else
36 #   define SWIGINLINE
37 # endif
38 #endif
39
40 /* attribute recognised by some compilers to avoid 'unused' warnings */
41 #ifndef SWIGUNUSED
42 # if defined(__GNUC__)
43 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
44 #     define SWIGUNUSED __attribute__ ((__unused__)) 
45 #   else
46 #     define SWIGUNUSED
47 #   endif
48 # elif defined(__ICC)
49 #   define SWIGUNUSED __attribute__ ((__unused__)) 
50 # else
51 #   define SWIGUNUSED 
52 # endif
53 #endif
54
55 #ifndef SWIG_MSC_UNSUPPRESS_4505
56 # if defined(_MSC_VER)
57 #   pragma warning(disable : 4505) /* unreferenced local function has been removed */
58 # endif 
59 #endif
60
61 #ifndef SWIGUNUSEDPARM
62 # ifdef __cplusplus
63 #   define SWIGUNUSEDPARM(p)
64 # else
65 #   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
66 # endif
67 #endif
68
69 /* internal SWIG method */
70 #ifndef SWIGINTERN
71 # define SWIGINTERN static SWIGUNUSED
72 #endif
73
74 /* internal inline SWIG method */
75 #ifndef SWIGINTERNINLINE
76 # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
77 #endif
78
79 /* exporting methods */
80 #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
81 #  ifndef GCC_HASCLASSVISIBILITY
82 #    define GCC_HASCLASSVISIBILITY
83 #  endif
84 #endif
85
86 #ifndef SWIGEXPORT
87 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
88 #   if defined(STATIC_LINKED)
89 #     define SWIGEXPORT
90 #   else
91 #     define SWIGEXPORT __declspec(dllexport)
92 #   endif
93 # else
94 #   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
95 #     define SWIGEXPORT __attribute__ ((visibility("default")))
96 #   else
97 #     define SWIGEXPORT
98 #   endif
99 # endif
100 #endif
101
102 /* calling conventions for Windows */
103 #ifndef SWIGSTDCALL
104 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
105 #   define SWIGSTDCALL __stdcall
106 # else
107 #   define SWIGSTDCALL
108 # endif 
109 #endif
110
111 /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
112 #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
113 # define _CRT_SECURE_NO_DEPRECATE
114 #endif
115
116 /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
117 #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
118 # define _SCL_SECURE_NO_DEPRECATE
119 #endif
120
121
122
123 /* Python.h has to appear first */
124 #include <Python.h>
125
126 /* -----------------------------------------------------------------------------
127  * swigrun.swg
128  *
129  * This file contains generic CAPI SWIG runtime support for pointer
130  * type checking.
131  * ----------------------------------------------------------------------------- */
132
133 /* This should only be incremented when either the layout of swig_type_info changes,
134    or for whatever reason, the runtime changes incompatibly */
135 #define SWIG_RUNTIME_VERSION "4"
136
137 /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
138 #ifdef SWIG_TYPE_TABLE
139 # define SWIG_QUOTE_STRING(x) #x
140 # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
141 # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
142 #else
143 # define SWIG_TYPE_TABLE_NAME
144 #endif
145
146 /*
147   You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
148   creating a static or dynamic library from the swig runtime code.
149   In 99.9% of the cases, swig just needs to declare them as 'static'.
150   
151   But only do this if is strictly necessary, ie, if you have problems
152   with your compiler or so.
153 */
154
155 #ifndef SWIGRUNTIME
156 # define SWIGRUNTIME SWIGINTERN
157 #endif
158
159 #ifndef SWIGRUNTIMEINLINE
160 # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
161 #endif
162
163 /*  Generic buffer size */
164 #ifndef SWIG_BUFFER_SIZE
165 # define SWIG_BUFFER_SIZE 1024
166 #endif
167
168 /* Flags for pointer conversions */
169 #define SWIG_POINTER_DISOWN        0x1
170 #define SWIG_CAST_NEW_MEMORY       0x2
171
172 /* Flags for new pointer objects */
173 #define SWIG_POINTER_OWN           0x1
174
175
176 /* 
177    Flags/methods for returning states.
178    
179    The swig conversion methods, as ConvertPtr, return and integer 
180    that tells if the conversion was successful or not. And if not,
181    an error code can be returned (see swigerrors.swg for the codes).
182    
183    Use the following macros/flags to set or process the returning
184    states.
185    
186    In old swig versions, you usually write code as:
187
188      if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
189        // success code
190      } else {
191        //fail code
192      }
193
194    Now you can be more explicit as:
195
196     int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
197     if (SWIG_IsOK(res)) {
198       // success code
199     } else {
200       // fail code
201     }
202
203    that seems to be the same, but now you can also do
204
205     Type *ptr;
206     int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
207     if (SWIG_IsOK(res)) {
208       // success code
209       if (SWIG_IsNewObj(res) {
210         ...
211         delete *ptr;
212       } else {
213         ...
214       }
215     } else {
216       // fail code
217     }
218     
219    I.e., now SWIG_ConvertPtr can return new objects and you can
220    identify the case and take care of the deallocation. Of course that
221    requires also to SWIG_ConvertPtr to return new result values, as
222
223       int SWIG_ConvertPtr(obj, ptr,...) {         
224         if (<obj is ok>) {                             
225           if (<need new object>) {                     
226             *ptr = <ptr to new allocated object>; 
227             return SWIG_NEWOBJ;                
228           } else {                                     
229             *ptr = <ptr to old object>;        
230             return SWIG_OLDOBJ;                
231           }                                    
232         } else {                                       
233           return SWIG_BADOBJ;                  
234         }                                              
235       }
236
237    Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
238    more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
239    swig errors code.
240
241    Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
242    allows to return the 'cast rank', for example, if you have this
243
244        int food(double)
245        int fooi(int);
246
247    and you call
248  
249       food(1)   // cast rank '1'  (1 -> 1.0)
250       fooi(1)   // cast rank '0'
251
252    just use the SWIG_AddCast()/SWIG_CheckState()
253
254
255  */
256 #define SWIG_OK                    (0) 
257 #define SWIG_ERROR                 (-1)
258 #define SWIG_IsOK(r)               (r >= 0)
259 #define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)  
260
261 /* The CastRankLimit says how many bits are used for the cast rank */
262 #define SWIG_CASTRANKLIMIT         (1 << 8)
263 /* The NewMask denotes the object was created (using new/malloc) */
264 #define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
265 /* The TmpMask is for in/out typemaps that use temporal objects */
266 #define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
267 /* Simple returning values */
268 #define SWIG_BADOBJ                (SWIG_ERROR)
269 #define SWIG_OLDOBJ                (SWIG_OK)
270 #define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
271 #define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
272 /* Check, add and del mask methods */
273 #define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
274 #define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
275 #define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
276 #define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
277 #define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
278 #define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
279
280
281 /* Cast-Rank Mode */
282 #if defined(SWIG_CASTRANK_MODE)
283 #  ifndef SWIG_TypeRank
284 #    define SWIG_TypeRank             unsigned long
285 #  endif
286 #  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
287 #    define SWIG_MAXCASTRANK          (2)
288 #  endif
289 #  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
290 #  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
291 SWIGINTERNINLINE int SWIG_AddCast(int r) { 
292   return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
293 }
294 SWIGINTERNINLINE int SWIG_CheckState(int r) { 
295   return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 
296 }
297 #else /* no cast-rank mode */
298 #  define SWIG_AddCast
299 #  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
300 #endif
301
302
303
304
305 #include <string.h>
306
307 #ifdef __cplusplus
308 extern "C" {
309 #endif
310
311 typedef void *(*swig_converter_func)(void *, int *);
312 typedef struct swig_type_info *(*swig_dycast_func)(void **);
313
314 /* Structure to store information on one type */
315 typedef struct swig_type_info {
316   const char             *name;                 /* mangled name of this type */
317   const char             *str;                  /* human readable name of this type */
318   swig_dycast_func        dcast;                /* dynamic cast function down a hierarchy */
319   struct swig_cast_info  *cast;                 /* linked list of types that can cast into this type */
320   void                   *clientdata;           /* language specific type data */
321   int                    owndata;               /* flag if the structure owns the clientdata */
322 } swig_type_info;
323
324 /* Structure to store a type and conversion function used for casting */
325 typedef struct swig_cast_info {
326   swig_type_info         *type;                 /* pointer to type that is equivalent to this type */
327   swig_converter_func     converter;            /* function to cast the void pointers */
328   struct swig_cast_info  *next;                 /* pointer to next cast in linked list */
329   struct swig_cast_info  *prev;                 /* pointer to the previous cast */
330 } swig_cast_info;
331
332 /* Structure used to store module information
333  * Each module generates one structure like this, and the runtime collects
334  * all of these structures and stores them in a circularly linked list.*/
335 typedef struct swig_module_info {
336   swig_type_info         **types;               /* Array of pointers to swig_type_info structures that are in this module */
337   size_t                 size;                  /* Number of types in this module */
338   struct swig_module_info *next;                /* Pointer to next element in circularly linked list */
339   swig_type_info         **type_initial;        /* Array of initially generated type structures */
340   swig_cast_info         **cast_initial;        /* Array of initially generated casting structures */
341   void                    *clientdata;          /* Language specific module data */
342 } swig_module_info;
343
344 /* 
345   Compare two type names skipping the space characters, therefore
346   "char*" == "char *" and "Class<int>" == "Class<int >", etc.
347
348   Return 0 when the two name types are equivalent, as in
349   strncmp, but skipping ' '.
350 */
351 SWIGRUNTIME int
352 SWIG_TypeNameComp(const char *f1, const char *l1,
353                   const char *f2, const char *l2) {
354   for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
355     while ((*f1 == ' ') && (f1 != l1)) ++f1;
356     while ((*f2 == ' ') && (f2 != l2)) ++f2;
357     if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
358   }
359   return (int)((l1 - f1) - (l2 - f2));
360 }
361
362 /*
363   Check type equivalence in a name list like <name1>|<name2>|...
364   Return 0 if not equal, 1 if equal
365 */
366 SWIGRUNTIME int
367 SWIG_TypeEquiv(const char *nb, const char *tb) {
368   int equiv = 0;
369   const char* te = tb + strlen(tb);
370   const char* ne = nb;
371   while (!equiv && *ne) {
372     for (nb = ne; *ne; ++ne) {
373       if (*ne == '|') break;
374     }
375     equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
376     if (*ne) ++ne;
377   }
378   return equiv;
379 }
380
381 /*
382   Check type equivalence in a name list like <name1>|<name2>|...
383   Return 0 if equal, -1 if nb < tb, 1 if nb > tb
384 */
385 SWIGRUNTIME int
386 SWIG_TypeCompare(const char *nb, const char *tb) {
387   int equiv = 0;
388   const char* te = tb + strlen(tb);
389   const char* ne = nb;
390   while (!equiv && *ne) {
391     for (nb = ne; *ne; ++ne) {
392       if (*ne == '|') break;
393     }
394     equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
395     if (*ne) ++ne;
396   }
397   return equiv;
398 }
399
400
401 /* think of this as a c++ template<> or a scheme macro */
402 #define SWIG_TypeCheck_Template(comparison, ty)         \
403   if (ty) {                                             \
404     swig_cast_info *iter = ty->cast;                    \
405     while (iter) {                                      \
406       if (comparison) {                                 \
407         if (iter == ty->cast) return iter;              \
408         /* Move iter to the top of the linked list */   \
409         iter->prev->next = iter->next;                  \
410         if (iter->next)                                 \
411           iter->next->prev = iter->prev;                \
412         iter->next = ty->cast;                          \
413         iter->prev = 0;                                 \
414         if (ty->cast) ty->cast->prev = iter;            \
415         ty->cast = iter;                                \
416         return iter;                                    \
417       }                                                 \
418       iter = iter->next;                                \
419     }                                                   \
420   }                                                     \
421   return 0
422
423 /*
424   Check the typename
425 */
426 SWIGRUNTIME swig_cast_info *
427 SWIG_TypeCheck(const char *c, swig_type_info *ty) {
428   SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
429 }
430
431 /* Same as previous function, except strcmp is replaced with a pointer comparison */
432 SWIGRUNTIME swig_cast_info *
433 SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
434   SWIG_TypeCheck_Template(iter->type == from, into);
435 }
436
437 /*
438   Cast a pointer up an inheritance hierarchy
439 */
440 SWIGRUNTIMEINLINE void *
441 SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
442   return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
443 }
444
445 /* 
446    Dynamic pointer casting. Down an inheritance hierarchy
447 */
448 SWIGRUNTIME swig_type_info *
449 SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
450   swig_type_info *lastty = ty;
451   if (!ty || !ty->dcast) return ty;
452   while (ty && (ty->dcast)) {
453     ty = (*ty->dcast)(ptr);
454     if (ty) lastty = ty;
455   }
456   return lastty;
457 }
458
459 /*
460   Return the name associated with this type
461 */
462 SWIGRUNTIMEINLINE const char *
463 SWIG_TypeName(const swig_type_info *ty) {
464   return ty->name;
465 }
466
467 /*
468   Return the pretty name associated with this type,
469   that is an unmangled type name in a form presentable to the user.
470 */
471 SWIGRUNTIME const char *
472 SWIG_TypePrettyName(const swig_type_info *type) {
473   /* The "str" field contains the equivalent pretty names of the
474      type, separated by vertical-bar characters.  We choose
475      to print the last name, as it is often (?) the most
476      specific. */
477   if (!type) return NULL;
478   if (type->str != NULL) {
479     const char *last_name = type->str;
480     const char *s;
481     for (s = type->str; *s; s++)
482       if (*s == '|') last_name = s+1;
483     return last_name;
484   }
485   else
486     return type->name;
487 }
488
489 /* 
490    Set the clientdata field for a type
491 */
492 SWIGRUNTIME void
493 SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
494   swig_cast_info *cast = ti->cast;
495   /* if (ti->clientdata == clientdata) return; */
496   ti->clientdata = clientdata;
497   
498   while (cast) {
499     if (!cast->converter) {
500       swig_type_info *tc = cast->type;
501       if (!tc->clientdata) {
502         SWIG_TypeClientData(tc, clientdata);
503       }
504     }    
505     cast = cast->next;
506   }
507 }
508 SWIGRUNTIME void
509 SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
510   SWIG_TypeClientData(ti, clientdata);
511   ti->owndata = 1;
512 }
513   
514 /*
515   Search for a swig_type_info structure only by mangled name
516   Search is a O(log #types)
517   
518   We start searching at module start, and finish searching when start == end.  
519   Note: if start == end at the beginning of the function, we go all the way around
520   the circular list.
521 */
522 SWIGRUNTIME swig_type_info *
523 SWIG_MangledTypeQueryModule(swig_module_info *start, 
524                             swig_module_info *end, 
525                             const char *name) {
526   swig_module_info *iter = start;
527   do {
528     if (iter->size) {
529       register size_t l = 0;
530       register size_t r = iter->size - 1;
531       do {
532         /* since l+r >= 0, we can (>> 1) instead (/ 2) */
533         register size_t i = (l + r) >> 1; 
534         const char *iname = iter->types[i]->name;
535         if (iname) {
536           register int compare = strcmp(name, iname);
537           if (compare == 0) {       
538             return iter->types[i];
539           } else if (compare < 0) {
540             if (i) {
541               r = i - 1;
542             } else {
543               break;
544             }
545           } else if (compare > 0) {
546             l = i + 1;
547           }
548         } else {
549           break; /* should never happen */
550         }
551       } while (l <= r);
552     }
553     iter = iter->next;
554   } while (iter != end);
555   return 0;
556 }
557
558 /*
559   Search for a swig_type_info structure for either a mangled name or a human readable name.
560   It first searches the mangled names of the types, which is a O(log #types)
561   If a type is not found it then searches the human readable names, which is O(#types).
562   
563   We start searching at module start, and finish searching when start == end.  
564   Note: if start == end at the beginning of the function, we go all the way around
565   the circular list.
566 */
567 SWIGRUNTIME swig_type_info *
568 SWIG_TypeQueryModule(swig_module_info *start, 
569                      swig_module_info *end, 
570                      const char *name) {
571   /* STEP 1: Search the name field using binary search */
572   swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
573   if (ret) {
574     return ret;
575   } else {
576     /* STEP 2: If the type hasn't been found, do a complete search
577        of the str field (the human readable name) */
578     swig_module_info *iter = start;
579     do {
580       register size_t i = 0;
581       for (; i < iter->size; ++i) {
582         if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
583           return iter->types[i];
584       }
585       iter = iter->next;
586     } while (iter != end);
587   }
588   
589   /* neither found a match */
590   return 0;
591 }
592
593 /* 
594    Pack binary data into a string
595 */
596 SWIGRUNTIME char *
597 SWIG_PackData(char *c, void *ptr, size_t sz) {
598   static const char hex[17] = "0123456789abcdef";
599   register const unsigned char *u = (unsigned char *) ptr;
600   register const unsigned char *eu =  u + sz;
601   for (; u != eu; ++u) {
602     register unsigned char uu = *u;
603     *(c++) = hex[(uu & 0xf0) >> 4];
604     *(c++) = hex[uu & 0xf];
605   }
606   return c;
607 }
608
609 /* 
610    Unpack binary data from a string
611 */
612 SWIGRUNTIME const char *
613 SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
614   register unsigned char *u = (unsigned char *) ptr;
615   register const unsigned char *eu = u + sz;
616   for (; u != eu; ++u) {
617     register char d = *(c++);
618     register unsigned char uu;
619     if ((d >= '0') && (d <= '9'))
620       uu = ((d - '0') << 4);
621     else if ((d >= 'a') && (d <= 'f'))
622       uu = ((d - ('a'-10)) << 4);
623     else 
624       return (char *) 0;
625     d = *(c++);
626     if ((d >= '0') && (d <= '9'))
627       uu |= (d - '0');
628     else if ((d >= 'a') && (d <= 'f'))
629       uu |= (d - ('a'-10));
630     else 
631       return (char *) 0;
632     *u = uu;
633   }
634   return c;
635 }
636
637 /* 
638    Pack 'void *' into a string buffer.
639 */
640 SWIGRUNTIME char *
641 SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
642   char *r = buff;
643   if ((2*sizeof(void *) + 2) > bsz) return 0;
644   *(r++) = '_';
645   r = SWIG_PackData(r,&ptr,sizeof(void *));
646   if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
647   strcpy(r,name);
648   return buff;
649 }
650
651 SWIGRUNTIME const char *
652 SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
653   if (*c != '_') {
654     if (strcmp(c,"NULL") == 0) {
655       *ptr = (void *) 0;
656       return name;
657     } else {
658       return 0;
659     }
660   }
661   return SWIG_UnpackData(++c,ptr,sizeof(void *));
662 }
663
664 SWIGRUNTIME char *
665 SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
666   char *r = buff;
667   size_t lname = (name ? strlen(name) : 0);
668   if ((2*sz + 2 + lname) > bsz) return 0;
669   *(r++) = '_';
670   r = SWIG_PackData(r,ptr,sz);
671   if (lname) {
672     strncpy(r,name,lname+1);
673   } else {
674     *r = 0;
675   }
676   return buff;
677 }
678
679 SWIGRUNTIME const char *
680 SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
681   if (*c != '_') {
682     if (strcmp(c,"NULL") == 0) {
683       memset(ptr,0,sz);
684       return name;
685     } else {
686       return 0;
687     }
688   }
689   return SWIG_UnpackData(++c,ptr,sz);
690 }
691
692 #ifdef __cplusplus
693 }
694 #endif
695
696 /*  Errors in SWIG */
697 #define  SWIG_UnknownError         -1 
698 #define  SWIG_IOError              -2 
699 #define  SWIG_RuntimeError         -3 
700 #define  SWIG_IndexError           -4 
701 #define  SWIG_TypeError            -5 
702 #define  SWIG_DivisionByZero       -6 
703 #define  SWIG_OverflowError        -7 
704 #define  SWIG_SyntaxError          -8 
705 #define  SWIG_ValueError           -9 
706 #define  SWIG_SystemError          -10
707 #define  SWIG_AttributeError       -11
708 #define  SWIG_MemoryError          -12 
709 #define  SWIG_NullReferenceError   -13
710
711
712
713
714 /* Add PyOS_snprintf for old Pythons */
715 #if PY_VERSION_HEX < 0x02020000
716 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
717 #  define PyOS_snprintf _snprintf
718 # else
719 #  define PyOS_snprintf snprintf
720 # endif
721 #endif
722
723 /* A crude PyString_FromFormat implementation for old Pythons */
724 #if PY_VERSION_HEX < 0x02020000
725
726 #ifndef SWIG_PYBUFFER_SIZE
727 # define SWIG_PYBUFFER_SIZE 1024
728 #endif
729
730 static PyObject *
731 PyString_FromFormat(const char *fmt, ...) {
732   va_list ap;
733   char buf[SWIG_PYBUFFER_SIZE * 2];
734   int res;
735   va_start(ap, fmt);
736   res = vsnprintf(buf, sizeof(buf), fmt, ap);
737   va_end(ap);
738   return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
739 }
740 #endif
741
742 /* Add PyObject_Del for old Pythons */
743 #if PY_VERSION_HEX < 0x01060000
744 # define PyObject_Del(op) PyMem_DEL((op))
745 #endif
746 #ifndef PyObject_DEL
747 # define PyObject_DEL PyObject_Del
748 #endif
749
750 /* A crude PyExc_StopIteration exception for old Pythons */
751 #if PY_VERSION_HEX < 0x02020000
752 # ifndef PyExc_StopIteration
753 #  define PyExc_StopIteration PyExc_RuntimeError
754 # endif
755 # ifndef PyObject_GenericGetAttr
756 #  define PyObject_GenericGetAttr 0
757 # endif
758 #endif
759 /* Py_NotImplemented is defined in 2.1 and up. */
760 #if PY_VERSION_HEX < 0x02010000
761 # ifndef Py_NotImplemented
762 #  define Py_NotImplemented PyExc_RuntimeError
763 # endif
764 #endif
765
766
767 /* A crude PyString_AsStringAndSize implementation for old Pythons */
768 #if PY_VERSION_HEX < 0x02010000
769 # ifndef PyString_AsStringAndSize
770 #  define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
771 # endif
772 #endif
773
774 /* PySequence_Size for old Pythons */
775 #if PY_VERSION_HEX < 0x02000000
776 # ifndef PySequence_Size
777 #  define PySequence_Size PySequence_Length
778 # endif
779 #endif
780
781
782 /* PyBool_FromLong for old Pythons */
783 #if PY_VERSION_HEX < 0x02030000
784 static
785 PyObject *PyBool_FromLong(long ok)
786 {
787   PyObject *result = ok ? Py_True : Py_False;
788   Py_INCREF(result);
789   return result;
790 }
791 #endif
792
793 /* Py_ssize_t for old Pythons */
794 /* This code is as recommended by: */
795 /* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
796 #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
797 typedef int Py_ssize_t;
798 # define PY_SSIZE_T_MAX INT_MAX
799 # define PY_SSIZE_T_MIN INT_MIN
800 #endif
801
802 /* -----------------------------------------------------------------------------
803  * error manipulation
804  * ----------------------------------------------------------------------------- */
805
806 SWIGRUNTIME PyObject*
807 SWIG_Python_ErrorType(int code) {
808   PyObject* type = 0;
809   switch(code) {
810   case SWIG_MemoryError:
811     type = PyExc_MemoryError;
812     break;
813   case SWIG_IOError:
814     type = PyExc_IOError;
815     break;
816   case SWIG_RuntimeError:
817     type = PyExc_RuntimeError;
818     break;
819   case SWIG_IndexError:
820     type = PyExc_IndexError;
821     break;
822   case SWIG_TypeError:
823     type = PyExc_TypeError;
824     break;
825   case SWIG_DivisionByZero:
826     type = PyExc_ZeroDivisionError;
827     break;
828   case SWIG_OverflowError:
829     type = PyExc_OverflowError;
830     break;
831   case SWIG_SyntaxError:
832     type = PyExc_SyntaxError;
833     break;
834   case SWIG_ValueError:
835     type = PyExc_ValueError;
836     break;
837   case SWIG_SystemError:
838     type = PyExc_SystemError;
839     break;
840   case SWIG_AttributeError:
841     type = PyExc_AttributeError;
842     break;
843   default:
844     type = PyExc_RuntimeError;
845   }
846   return type;
847 }
848
849
850 SWIGRUNTIME void
851 SWIG_Python_AddErrorMsg(const char* mesg)
852 {
853   PyObject *type = 0;
854   PyObject *value = 0;
855   PyObject *traceback = 0;
856
857   if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
858   if (value) {
859     PyObject *old_str = PyObject_Str(value);
860     PyErr_Clear();
861     Py_XINCREF(type);
862     PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
863     Py_DECREF(old_str);
864     Py_DECREF(value);
865   } else {
866     PyErr_SetString(PyExc_RuntimeError, mesg);
867   }
868 }
869
870
871
872 #if defined(SWIG_PYTHON_NO_THREADS)
873 #  if defined(SWIG_PYTHON_THREADS)
874 #    undef SWIG_PYTHON_THREADS
875 #  endif
876 #endif
877 #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
878 #  if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
879 #    if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
880 #      define SWIG_PYTHON_USE_GIL
881 #    endif
882 #  endif
883 #  if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
884 #    ifndef SWIG_PYTHON_INITIALIZE_THREADS
885 #     define SWIG_PYTHON_INITIALIZE_THREADS  PyEval_InitThreads() 
886 #    endif
887 #    ifdef __cplusplus /* C++ code */
888        class SWIG_Python_Thread_Block {
889          bool status;
890          PyGILState_STATE state;
891        public:
892          void end() { if (status) { PyGILState_Release(state); status = false;} }
893          SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
894          ~SWIG_Python_Thread_Block() { end(); }
895        };
896        class SWIG_Python_Thread_Allow {
897          bool status;
898          PyThreadState *save;
899        public:
900          void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
901          SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
902          ~SWIG_Python_Thread_Allow() { end(); }
903        };
904 #      define SWIG_PYTHON_THREAD_BEGIN_BLOCK   SWIG_Python_Thread_Block _swig_thread_block
905 #      define SWIG_PYTHON_THREAD_END_BLOCK     _swig_thread_block.end()
906 #      define SWIG_PYTHON_THREAD_BEGIN_ALLOW   SWIG_Python_Thread_Allow _swig_thread_allow
907 #      define SWIG_PYTHON_THREAD_END_ALLOW     _swig_thread_allow.end()
908 #    else /* C code */
909 #      define SWIG_PYTHON_THREAD_BEGIN_BLOCK   PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
910 #      define SWIG_PYTHON_THREAD_END_BLOCK     PyGILState_Release(_swig_thread_block)
911 #      define SWIG_PYTHON_THREAD_BEGIN_ALLOW   PyThreadState *_swig_thread_allow = PyEval_SaveThread()
912 #      define SWIG_PYTHON_THREAD_END_ALLOW     PyEval_RestoreThread(_swig_thread_allow)
913 #    endif
914 #  else /* Old thread way, not implemented, user must provide it */
915 #    if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
916 #      define SWIG_PYTHON_INITIALIZE_THREADS
917 #    endif
918 #    if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
919 #      define SWIG_PYTHON_THREAD_BEGIN_BLOCK
920 #    endif
921 #    if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
922 #      define SWIG_PYTHON_THREAD_END_BLOCK
923 #    endif
924 #    if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
925 #      define SWIG_PYTHON_THREAD_BEGIN_ALLOW
926 #    endif
927 #    if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
928 #      define SWIG_PYTHON_THREAD_END_ALLOW
929 #    endif
930 #  endif
931 #else /* No thread support */
932 #  define SWIG_PYTHON_INITIALIZE_THREADS
933 #  define SWIG_PYTHON_THREAD_BEGIN_BLOCK
934 #  define SWIG_PYTHON_THREAD_END_BLOCK
935 #  define SWIG_PYTHON_THREAD_BEGIN_ALLOW
936 #  define SWIG_PYTHON_THREAD_END_ALLOW
937 #endif
938
939 /* -----------------------------------------------------------------------------
940  * Python API portion that goes into the runtime
941  * ----------------------------------------------------------------------------- */
942
943 #ifdef __cplusplus
944 extern "C" {
945 #if 0
946 } /* cc-mode */
947 #endif
948 #endif
949
950 /* -----------------------------------------------------------------------------
951  * Constant declarations
952  * ----------------------------------------------------------------------------- */
953
954 /* Constant Types */
955 #define SWIG_PY_POINTER 4
956 #define SWIG_PY_BINARY  5
957
958 /* Constant information structure */
959 typedef struct swig_const_info {
960   int type;
961   char *name;
962   long lvalue;
963   double dvalue;
964   void   *pvalue;
965   swig_type_info **ptype;
966 } swig_const_info;
967
968 #ifdef __cplusplus
969 #if 0
970 { /* cc-mode */
971 #endif
972 }
973 #endif
974
975
976 /* -----------------------------------------------------------------------------
977  * See the LICENSE file for information on copyright, usage and redistribution
978  * of SWIG, and the README file for authors - http://www.swig.org/release.html.
979  *
980  * pyrun.swg
981  *
982  * This file contains the runtime support for Python modules
983  * and includes code for managing global variables and pointer
984  * type checking.
985  *
986  * ----------------------------------------------------------------------------- */
987
988 /* Common SWIG API */
989
990 /* for raw pointers */
991 #define SWIG_Python_ConvertPtr(obj, pptr, type, flags)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
992 #define SWIG_ConvertPtr(obj, pptr, type, flags)         SWIG_Python_ConvertPtr(obj, pptr, type, flags)
993 #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
994 #define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(ptr, type, flags)
995 #define SWIG_CheckImplicit(ty)                          SWIG_Python_CheckImplicit(ty) 
996 #define SWIG_AcquirePtr(ptr, src)                       SWIG_Python_AcquirePtr(ptr, src)
997 #define swig_owntype                                    int
998
999 /* for raw packed data */
1000 #define SWIG_ConvertPacked(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
1001 #define SWIG_NewPackedObj(ptr, sz, type)                SWIG_Python_NewPackedObj(ptr, sz, type)
1002
1003 /* for class or struct pointers */
1004 #define SWIG_ConvertInstance(obj, pptr, type, flags)    SWIG_ConvertPtr(obj, pptr, type, flags)
1005 #define SWIG_NewInstanceObj(ptr, type, flags)           SWIG_NewPointerObj(ptr, type, flags)
1006
1007 /* for C or C++ function pointers */
1008 #define SWIG_ConvertFunctionPtr(obj, pptr, type)        SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
1009 #define SWIG_NewFunctionPtrObj(ptr, type)               SWIG_Python_NewPointerObj(ptr, type, 0)
1010
1011 /* for C++ member pointers, ie, member methods */
1012 #define SWIG_ConvertMember(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
1013 #define SWIG_NewMemberObj(ptr, sz, type)                SWIG_Python_NewPackedObj(ptr, sz, type)
1014
1015
1016 /* Runtime API */
1017
1018 #define SWIG_GetModule(clientdata)                      SWIG_Python_GetModule()
1019 #define SWIG_SetModule(clientdata, pointer)             SWIG_Python_SetModule(pointer)
1020 #define SWIG_NewClientData(obj)                         PySwigClientData_New(obj)
1021
1022 #define SWIG_SetErrorObj                                SWIG_Python_SetErrorObj                            
1023 #define SWIG_SetErrorMsg                                SWIG_Python_SetErrorMsg                            
1024 #define SWIG_ErrorType(code)                            SWIG_Python_ErrorType(code)                        
1025 #define SWIG_Error(code, msg)                           SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 
1026 #define SWIG_fail                                       goto fail                                          
1027
1028
1029 /* Runtime API implementation */
1030
1031 /* Error manipulation */
1032
1033 SWIGINTERN void 
1034 SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
1035   SWIG_PYTHON_THREAD_BEGIN_BLOCK; 
1036   PyErr_SetObject(errtype, obj);
1037   Py_DECREF(obj);
1038   SWIG_PYTHON_THREAD_END_BLOCK;
1039 }
1040
1041 SWIGINTERN void 
1042 SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
1043   SWIG_PYTHON_THREAD_BEGIN_BLOCK;
1044   PyErr_SetString(errtype, (char *) msg);
1045   SWIG_PYTHON_THREAD_END_BLOCK;
1046 }
1047
1048 #define SWIG_Python_Raise(obj, type, desc)  SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
1049
1050 /* Set a constant value */
1051
1052 SWIGINTERN void
1053 SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {   
1054   PyDict_SetItemString(d, (char*) name, obj);
1055   Py_DECREF(obj);                            
1056 }
1057
1058 /* Append a value to the result obj */
1059
1060 SWIGINTERN PyObject*
1061 SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
1062 #if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
1063   if (!result) {
1064     result = obj;
1065   } else if (result == Py_None) {
1066     Py_DECREF(result);
1067     result = obj;
1068   } else {
1069     if (!PyList_Check(result)) {
1070       PyObject *o2 = result;
1071       result = PyList_New(1);
1072       PyList_SetItem(result, 0, o2);
1073     }
1074     PyList_Append(result,obj);
1075     Py_DECREF(obj);
1076   }
1077   return result;
1078 #else
1079   PyObject*   o2;
1080   PyObject*   o3;
1081   if (!result) {
1082     result = obj;
1083   } else if (result == Py_None) {
1084     Py_DECREF(result);
1085     result = obj;
1086   } else {
1087     if (!PyTuple_Check(result)) {
1088       o2 = result;
1089       result = PyTuple_New(1);
1090       PyTuple_SET_ITEM(result, 0, o2);
1091     }
1092     o3 = PyTuple_New(1);
1093     PyTuple_SET_ITEM(o3, 0, obj);
1094     o2 = result;
1095     result = PySequence_Concat(o2, o3);
1096     Py_DECREF(o2);
1097     Py_DECREF(o3);
1098   }
1099   return result;
1100 #endif
1101 }
1102
1103 /* Unpack the argument tuple */
1104
1105 SWIGINTERN int
1106 SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
1107 {
1108   if (!args) {
1109     if (!min && !max) {
1110       return 1;
1111     } else {
1112       PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", 
1113                    name, (min == max ? "" : "at least "), (int)min);
1114       return 0;
1115     }
1116   }  
1117   if (!PyTuple_Check(args)) {
1118     PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
1119     return 0;
1120   } else {
1121     register Py_ssize_t l = PyTuple_GET_SIZE(args);
1122     if (l < min) {
1123       PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 
1124                    name, (min == max ? "" : "at least "), (int)min, (int)l);
1125       return 0;
1126     } else if (l > max) {
1127       PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 
1128                    name, (min == max ? "" : "at most "), (int)max, (int)l);
1129       return 0;
1130     } else {
1131       register int i;
1132       for (i = 0; i < l; ++i) {
1133         objs[i] = PyTuple_GET_ITEM(args, i);
1134       }
1135       for (; l < max; ++l) {
1136         objs[l] = 0;
1137       }
1138       return i + 1;
1139     }    
1140   }
1141 }
1142
1143 /* A functor is a function object with one single object argument */
1144 #if PY_VERSION_HEX >= 0x02020000
1145 #define SWIG_Python_CallFunctor(functor, obj)           PyObject_CallFunctionObjArgs(functor, obj, NULL);
1146 #else
1147 #define SWIG_Python_CallFunctor(functor, obj)           PyObject_CallFunction(functor, "O", obj);
1148 #endif
1149
1150 /*
1151   Helper for static pointer initialization for both C and C++ code, for example
1152   static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
1153 */
1154 #ifdef __cplusplus
1155 #define SWIG_STATIC_POINTER(var)  var
1156 #else
1157 #define SWIG_STATIC_POINTER(var)  var = 0; if (!var) var
1158 #endif
1159
1160 /* -----------------------------------------------------------------------------
1161  * Pointer declarations
1162  * ----------------------------------------------------------------------------- */
1163
1164 /* Flags for new pointer objects */
1165 #define SWIG_POINTER_NOSHADOW       (SWIG_POINTER_OWN      << 1)
1166 #define SWIG_POINTER_NEW            (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
1167
1168 #define SWIG_POINTER_IMPLICIT_CONV  (SWIG_POINTER_DISOWN   << 1)
1169
1170 #ifdef __cplusplus
1171 extern "C" {
1172 #if 0
1173 } /* cc-mode */
1174 #endif
1175 #endif
1176
1177 /*  How to access Py_None */
1178 #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
1179 #  ifndef SWIG_PYTHON_NO_BUILD_NONE
1180 #    ifndef SWIG_PYTHON_BUILD_NONE
1181 #      define SWIG_PYTHON_BUILD_NONE
1182 #    endif
1183 #  endif
1184 #endif
1185
1186 #ifdef SWIG_PYTHON_BUILD_NONE
1187 #  ifdef Py_None
1188 #   undef Py_None
1189 #   define Py_None SWIG_Py_None()
1190 #  endif
1191 SWIGRUNTIMEINLINE PyObject * 
1192 _SWIG_Py_None(void)
1193 {
1194   PyObject *none = Py_BuildValue((char*)"");
1195   Py_DECREF(none);
1196   return none;
1197 }
1198 SWIGRUNTIME PyObject * 
1199 SWIG_Py_None(void)
1200 {
1201   static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
1202   return none;
1203 }
1204 #endif
1205
1206 /* The python void return value */
1207
1208 SWIGRUNTIMEINLINE PyObject * 
1209 SWIG_Py_Void(void)
1210 {
1211   PyObject *none = Py_None;
1212   Py_INCREF(none);
1213   return none;
1214 }
1215
1216 /* PySwigClientData */
1217
1218 typedef struct {
1219   PyObject *klass;
1220   PyObject *newraw;
1221   PyObject *newargs;
1222   PyObject *destroy;
1223   int delargs;
1224   int implicitconv;
1225 } PySwigClientData;
1226
1227 SWIGRUNTIMEINLINE int 
1228 SWIG_Python_CheckImplicit(swig_type_info *ty)
1229 {
1230   PySwigClientData *data = (PySwigClientData *)ty->clientdata;
1231   return data ? data->implicitconv : 0;
1232 }
1233
1234 SWIGRUNTIMEINLINE PyObject *
1235 SWIG_Python_ExceptionType(swig_type_info *desc) {
1236   PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0;
1237   PyObject *klass = data ? data->klass : 0;
1238   return (klass ? klass : PyExc_RuntimeError);
1239 }
1240
1241
1242 SWIGRUNTIME PySwigClientData * 
1243 PySwigClientData_New(PyObject* obj)
1244 {
1245   if (!obj) {
1246     return 0;
1247   } else {
1248     PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData));
1249     /* the klass element */
1250     data->klass = obj;
1251     Py_INCREF(data->klass);
1252     /* the newraw method and newargs arguments used to create a new raw instance */
1253     if (PyClass_Check(obj)) {
1254       data->newraw = 0;
1255       data->newargs = obj;
1256       Py_INCREF(obj);
1257     } else {
1258 #if (PY_VERSION_HEX < 0x02020000)
1259       data->newraw = 0;
1260 #else
1261       data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
1262 #endif
1263       if (data->newraw) {
1264         Py_INCREF(data->newraw);
1265         data->newargs = PyTuple_New(1);
1266         PyTuple_SetItem(data->newargs, 0, obj);
1267       } else {
1268         data->newargs = obj;
1269       }
1270       Py_INCREF(data->newargs);
1271     }
1272     /* the destroy method, aka as the C++ delete method */
1273     data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
1274     if (PyErr_Occurred()) {
1275       PyErr_Clear();
1276       data->destroy = 0;
1277     }
1278     if (data->destroy) {
1279       int flags;
1280       Py_INCREF(data->destroy);
1281       flags = PyCFunction_GET_FLAGS(data->destroy);
1282 #ifdef METH_O
1283       data->delargs = !(flags & (METH_O));
1284 #else
1285       data->delargs = 0;
1286 #endif
1287     } else {
1288       data->delargs = 0;
1289     }
1290     data->implicitconv = 0;
1291     return data;
1292   }
1293 }
1294
1295 SWIGRUNTIME void 
1296 PySwigClientData_Del(PySwigClientData* data)
1297 {
1298   Py_XDECREF(data->newraw);
1299   Py_XDECREF(data->newargs);
1300   Py_XDECREF(data->destroy);
1301 }
1302
1303 /* =============== PySwigObject =====================*/
1304
1305 typedef struct {
1306   PyObject_HEAD
1307   void *ptr;
1308   swig_type_info *ty;
1309   int own;
1310   PyObject *next;
1311 } PySwigObject;
1312
1313 SWIGRUNTIME PyObject *
1314 PySwigObject_long(PySwigObject *v)
1315 {
1316   return PyLong_FromVoidPtr(v->ptr);
1317 }
1318
1319 SWIGRUNTIME PyObject *
1320 PySwigObject_format(const char* fmt, PySwigObject *v)
1321 {
1322   PyObject *res = NULL;
1323   PyObject *args = PyTuple_New(1);
1324   if (args) {
1325     if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) {
1326       PyObject *ofmt = PyString_FromString(fmt);
1327       if (ofmt) {
1328         res = PyString_Format(ofmt,args);
1329         Py_DECREF(ofmt);
1330       }
1331       Py_DECREF(args);
1332     }
1333   }
1334   return res;
1335 }
1336
1337 SWIGRUNTIME PyObject *
1338 PySwigObject_oct(PySwigObject *v)
1339 {
1340   return PySwigObject_format("%o",v);
1341 }
1342
1343 SWIGRUNTIME PyObject *
1344 PySwigObject_hex(PySwigObject *v)
1345 {
1346   return PySwigObject_format("%x",v);
1347 }
1348
1349 SWIGRUNTIME PyObject *
1350 #ifdef METH_NOARGS
1351 PySwigObject_repr(PySwigObject *v)
1352 #else
1353 PySwigObject_repr(PySwigObject *v, PyObject *args)
1354 #endif
1355 {
1356   const char *name = SWIG_TypePrettyName(v->ty);
1357   PyObject *hex = PySwigObject_hex(v);    
1358   PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex));
1359   Py_DECREF(hex);
1360   if (v->next) {
1361 #ifdef METH_NOARGS
1362     PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next);
1363 #else
1364     PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args);
1365 #endif
1366     PyString_ConcatAndDel(&repr,nrep);
1367   }
1368   return repr;  
1369 }
1370
1371 SWIGRUNTIME int
1372 PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
1373 {
1374 #ifdef METH_NOARGS
1375   PyObject *repr = PySwigObject_repr(v);
1376 #else
1377   PyObject *repr = PySwigObject_repr(v, NULL);
1378 #endif
1379   if (repr) {
1380     fputs(PyString_AsString(repr), fp);
1381     Py_DECREF(repr);
1382     return 0; 
1383   } else {
1384     return 1; 
1385   }
1386 }
1387
1388 SWIGRUNTIME PyObject *
1389 PySwigObject_str(PySwigObject *v)
1390 {
1391   char result[SWIG_BUFFER_SIZE];
1392   return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
1393     PyString_FromString(result) : 0;
1394 }
1395
1396 SWIGRUNTIME int
1397 PySwigObject_compare(PySwigObject *v, PySwigObject *w)
1398 {
1399   void *i = v->ptr;
1400   void *j = w->ptr;
1401   return (i < j) ? -1 : ((i > j) ? 1 : 0);
1402 }
1403
1404 SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
1405
1406 SWIGRUNTIME PyTypeObject*
1407 PySwigObject_type(void) {
1408   static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
1409   return type;
1410 }
1411
1412 SWIGRUNTIMEINLINE int
1413 PySwigObject_Check(PyObject *op) {
1414   return ((op)->ob_type == PySwigObject_type())
1415     || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
1416 }
1417
1418 SWIGRUNTIME PyObject *
1419 PySwigObject_New(void *ptr, swig_type_info *ty, int own);
1420
1421 SWIGRUNTIME void
1422 PySwigObject_dealloc(PyObject *v)
1423 {
1424   PySwigObject *sobj = (PySwigObject *) v;
1425   PyObject *next = sobj->next;
1426   if (sobj->own == SWIG_POINTER_OWN) {
1427     swig_type_info *ty = sobj->ty;
1428     PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
1429     PyObject *destroy = data ? data->destroy : 0;
1430     if (destroy) {
1431       /* destroy is always a VARARGS method */
1432       PyObject *res;
1433       if (data->delargs) {
1434         /* we need to create a temporal object to carry the destroy operation */
1435         PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
1436         res = SWIG_Python_CallFunctor(destroy, tmp);
1437         Py_DECREF(tmp);
1438       } else {
1439         PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
1440         PyObject *mself = PyCFunction_GET_SELF(destroy);
1441         res = ((*meth)(mself, v));
1442       }
1443       Py_XDECREF(res);
1444     } 
1445 #if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
1446     else {
1447       const char *name = SWIG_TypePrettyName(ty);
1448       printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
1449     }
1450 #endif
1451   } 
1452   Py_XDECREF(next);
1453   PyObject_DEL(v);
1454 }
1455
1456 SWIGRUNTIME PyObject* 
1457 PySwigObject_append(PyObject* v, PyObject* next)
1458 {
1459   PySwigObject *sobj = (PySwigObject *) v;
1460 #ifndef METH_O
1461   PyObject *tmp = 0;
1462   if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
1463   next = tmp;
1464 #endif
1465   if (!PySwigObject_Check(next)) {
1466     return NULL;
1467   }
1468   sobj->next = next;
1469   Py_INCREF(next);
1470   return SWIG_Py_Void();
1471 }
1472
1473 SWIGRUNTIME PyObject* 
1474 #ifdef METH_NOARGS
1475 PySwigObject_next(PyObject* v)
1476 #else
1477 PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
1478 #endif
1479 {
1480   PySwigObject *sobj = (PySwigObject *) v;
1481   if (sobj->next) {    
1482     Py_INCREF(sobj->next);
1483     return sobj->next;
1484   } else {
1485     return SWIG_Py_Void();
1486   }
1487 }
1488
1489 SWIGINTERN PyObject*
1490 #ifdef METH_NOARGS
1491 PySwigObject_disown(PyObject *v)
1492 #else
1493 PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
1494 #endif
1495 {
1496   PySwigObject *sobj = (PySwigObject *)v;
1497   sobj->own = 0;
1498   return SWIG_Py_Void();
1499 }
1500
1501 SWIGINTERN PyObject*
1502 #ifdef METH_NOARGS
1503 PySwigObject_acquire(PyObject *v)
1504 #else
1505 PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
1506 #endif
1507 {
1508   PySwigObject *sobj = (PySwigObject *)v;
1509   sobj->own = SWIG_POINTER_OWN;
1510   return SWIG_Py_Void();
1511 }
1512
1513 SWIGINTERN PyObject*
1514 PySwigObject_own(PyObject *v, PyObject *args)
1515 {
1516   PyObject *val = 0;
1517 #if (PY_VERSION_HEX < 0x02020000)
1518   if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
1519 #else
1520   if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) 
1521 #endif
1522     {
1523       return NULL;
1524     } 
1525   else
1526     {
1527       PySwigObject *sobj = (PySwigObject *)v;
1528       PyObject *obj = PyBool_FromLong(sobj->own);
1529       if (val) {
1530 #ifdef METH_NOARGS
1531         if (PyObject_IsTrue(val)) {
1532           PySwigObject_acquire(v);
1533         } else {
1534           PySwigObject_disown(v);
1535         }
1536 #else
1537         if (PyObject_IsTrue(val)) {
1538           PySwigObject_acquire(v,args);
1539         } else {
1540           PySwigObject_disown(v,args);
1541         }
1542 #endif
1543       } 
1544       return obj;
1545     }
1546 }
1547
1548 #ifdef METH_O
1549 static PyMethodDef
1550 swigobject_methods[] = {
1551   {(char *)"disown",  (PyCFunction)PySwigObject_disown,  METH_NOARGS,  (char *)"releases ownership of the pointer"},
1552   {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS,  (char *)"aquires ownership of the pointer"},
1553   {(char *)"own",     (PyCFunction)PySwigObject_own,     METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
1554   {(char *)"append",  (PyCFunction)PySwigObject_append,  METH_O,       (char *)"appends another 'this' object"},
1555   {(char *)"next",    (PyCFunction)PySwigObject_next,    METH_NOARGS,  (char *)"returns the next 'this' object"},
1556   {(char *)"__repr__",(PyCFunction)PySwigObject_repr,    METH_NOARGS,  (char *)"returns object representation"},
1557   {0, 0, 0, 0}  
1558 };
1559 #else
1560 static PyMethodDef
1561 swigobject_methods[] = {
1562   {(char *)"disown",  (PyCFunction)PySwigObject_disown,  METH_VARARGS,  (char *)"releases ownership of the pointer"},
1563   {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS,  (char *)"aquires ownership of the pointer"},
1564   {(char *)"own",     (PyCFunction)PySwigObject_own,     METH_VARARGS,  (char *)"returns/sets ownership of the pointer"},
1565   {(char *)"append",  (PyCFunction)PySwigObject_append,  METH_VARARGS,  (char *)"appends another 'this' object"},
1566   {(char *)"next",    (PyCFunction)PySwigObject_next,    METH_VARARGS,  (char *)"returns the next 'this' object"},
1567   {(char *)"__repr__",(PyCFunction)PySwigObject_repr,   METH_VARARGS,  (char *)"returns object representation"},
1568   {0, 0, 0, 0}  
1569 };
1570 #endif
1571
1572 #if PY_VERSION_HEX < 0x02020000
1573 SWIGINTERN PyObject *
1574 PySwigObject_getattr(PySwigObject *sobj,char *name)
1575 {
1576   return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
1577 }
1578 #endif
1579
1580 SWIGRUNTIME PyTypeObject*
1581 _PySwigObject_type(void) {
1582   static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
1583   
1584   static PyNumberMethods PySwigObject_as_number = {
1585     (binaryfunc)0, /*nb_add*/
1586     (binaryfunc)0, /*nb_subtract*/
1587     (binaryfunc)0, /*nb_multiply*/
1588     (binaryfunc)0, /*nb_divide*/
1589     (binaryfunc)0, /*nb_remainder*/
1590     (binaryfunc)0, /*nb_divmod*/
1591     (ternaryfunc)0,/*nb_power*/
1592     (unaryfunc)0,  /*nb_negative*/
1593     (unaryfunc)0,  /*nb_positive*/
1594     (unaryfunc)0,  /*nb_absolute*/
1595     (inquiry)0,    /*nb_nonzero*/
1596     0,             /*nb_invert*/
1597     0,             /*nb_lshift*/
1598     0,             /*nb_rshift*/
1599     0,             /*nb_and*/
1600     0,             /*nb_xor*/
1601     0,             /*nb_or*/
1602     (coercion)0,   /*nb_coerce*/
1603     (unaryfunc)PySwigObject_long, /*nb_int*/
1604     (unaryfunc)PySwigObject_long, /*nb_long*/
1605     (unaryfunc)0,                 /*nb_float*/
1606     (unaryfunc)PySwigObject_oct,  /*nb_oct*/
1607     (unaryfunc)PySwigObject_hex,  /*nb_hex*/
1608 #if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
1609     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
1610 #elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
1611     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
1612 #elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
1613     0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
1614 #endif
1615   };
1616
1617   static PyTypeObject pyswigobject_type;  
1618   static int type_init = 0;
1619   if (!type_init) {
1620     const PyTypeObject tmp
1621       = {
1622         PyObject_HEAD_INIT(NULL)
1623         0,                                  /* ob_size */
1624         (char *)"PySwigObject",             /* tp_name */
1625         sizeof(PySwigObject),               /* tp_basicsize */
1626         0,                                  /* tp_itemsize */
1627         (destructor)PySwigObject_dealloc,   /* tp_dealloc */
1628         (printfunc)PySwigObject_print,      /* tp_print */
1629 #if PY_VERSION_HEX < 0x02020000
1630         (getattrfunc)PySwigObject_getattr,  /* tp_getattr */ 
1631 #else
1632         (getattrfunc)0,                     /* tp_getattr */ 
1633 #endif
1634         (setattrfunc)0,                     /* tp_setattr */ 
1635         (cmpfunc)PySwigObject_compare,      /* tp_compare */ 
1636         (reprfunc)PySwigObject_repr,        /* tp_repr */    
1637         &PySwigObject_as_number,            /* tp_as_number */
1638         0,                                  /* tp_as_sequence */
1639         0,                                  /* tp_as_mapping */
1640         (hashfunc)0,                        /* tp_hash */
1641         (ternaryfunc)0,                     /* tp_call */
1642         (reprfunc)PySwigObject_str,         /* tp_str */
1643         PyObject_GenericGetAttr,            /* tp_getattro */
1644         0,                                  /* tp_setattro */
1645         0,                                  /* tp_as_buffer */
1646         Py_TPFLAGS_DEFAULT,                 /* tp_flags */
1647         swigobject_doc,                     /* tp_doc */        
1648         0,                                  /* tp_traverse */
1649         0,                                  /* tp_clear */
1650         0,                                  /* tp_richcompare */
1651         0,                                  /* tp_weaklistoffset */
1652 #if PY_VERSION_HEX >= 0x02020000
1653         0,                                  /* tp_iter */
1654         0,                                  /* tp_iternext */
1655         swigobject_methods,                 /* tp_methods */ 
1656         0,                                  /* tp_members */
1657         0,                                  /* tp_getset */             
1658         0,                                  /* tp_base */               
1659         0,                                  /* tp_dict */               
1660         0,                                  /* tp_descr_get */          
1661         0,                                  /* tp_descr_set */          
1662         0,                                  /* tp_dictoffset */         
1663         0,                                  /* tp_init */               
1664         0,                                  /* tp_alloc */              
1665         0,                                  /* tp_new */                
1666         0,                                  /* tp_free */          
1667         0,                                  /* tp_is_gc */  
1668         0,                                  /* tp_bases */   
1669         0,                                  /* tp_mro */
1670         0,                                  /* tp_cache */   
1671         0,                                  /* tp_subclasses */
1672         0,                                  /* tp_weaklist */
1673 #endif
1674 #if PY_VERSION_HEX >= 0x02030000
1675         0,                                  /* tp_del */
1676 #endif
1677 #ifdef COUNT_ALLOCS
1678         0,0,0,0                             /* tp_alloc -> tp_next */
1679 #endif
1680       };
1681     pyswigobject_type = tmp;
1682     pyswigobject_type.ob_type = &PyType_Type;
1683     type_init = 1;
1684   }
1685   return &pyswigobject_type;
1686 }
1687
1688 SWIGRUNTIME PyObject *
1689 PySwigObject_New(void *ptr, swig_type_info *ty, int own)
1690 {
1691   PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type());
1692   if (sobj) {
1693     sobj->ptr  = ptr;
1694     sobj->ty   = ty;
1695     sobj->own  = own;
1696     sobj->next = 0;
1697   }
1698   return (PyObject *)sobj;
1699 }
1700
1701 /* -----------------------------------------------------------------------------
1702  * Implements a simple Swig Packed type, and use it instead of string
1703  * ----------------------------------------------------------------------------- */
1704
1705 typedef struct {
1706   PyObject_HEAD
1707   void *pack;
1708   swig_type_info *ty;
1709   size_t size;
1710 } PySwigPacked;
1711
1712 SWIGRUNTIME int
1713 PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
1714 {
1715   char result[SWIG_BUFFER_SIZE];
1716   fputs("<Swig Packed ", fp); 
1717   if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
1718     fputs("at ", fp); 
1719     fputs(result, fp); 
1720   }
1721   fputs(v->ty->name,fp); 
1722   fputs(">", fp);
1723   return 0; 
1724 }
1725   
1726 SWIGRUNTIME PyObject *
1727 PySwigPacked_repr(PySwigPacked *v)
1728 {
1729   char result[SWIG_BUFFER_SIZE];
1730   if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
1731     return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
1732   } else {
1733     return PyString_FromFormat("<Swig Packed %s>", v->ty->name);
1734   }  
1735 }
1736
1737 SWIGRUNTIME PyObject *
1738 PySwigPacked_str(PySwigPacked *v)
1739 {
1740   char result[SWIG_BUFFER_SIZE];
1741   if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
1742     return PyString_FromFormat("%s%s", result, v->ty->name);
1743   } else {
1744     return PyString_FromString(v->ty->name);
1745   }  
1746 }
1747
1748 SWIGRUNTIME int
1749 PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
1750 {
1751   size_t i = v->size;
1752   size_t j = w->size;
1753   int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
1754   return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
1755 }
1756
1757 SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
1758
1759 SWIGRUNTIME PyTypeObject*
1760 PySwigPacked_type(void) {
1761   static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
1762   return type;
1763 }
1764
1765 SWIGRUNTIMEINLINE int
1766 PySwigPacked_Check(PyObject *op) {
1767   return ((op)->ob_type == _PySwigPacked_type()) 
1768     || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
1769 }
1770
1771 SWIGRUNTIME void
1772 PySwigPacked_dealloc(PyObject *v)
1773 {
1774   if (PySwigPacked_Check(v)) {
1775     PySwigPacked *sobj = (PySwigPacked *) v;
1776     free(sobj->pack);
1777   }
1778   PyObject_DEL(v);
1779 }
1780
1781 SWIGRUNTIME PyTypeObject*
1782 _PySwigPacked_type(void) {
1783   static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
1784   static PyTypeObject pyswigpacked_type;
1785   static int type_init = 0;  
1786   if (!type_init) {
1787     const PyTypeObject tmp
1788       = {
1789         PyObject_HEAD_INIT(NULL)
1790         0,                                  /* ob_size */       
1791         (char *)"PySwigPacked",             /* tp_name */       
1792         sizeof(PySwigPacked),               /* tp_basicsize */  
1793         0,                                  /* tp_itemsize */   
1794         (destructor)PySwigPacked_dealloc,   /* tp_dealloc */    
1795         (printfunc)PySwigPacked_print,      /* tp_print */      
1796         (getattrfunc)0,                     /* tp_getattr */    
1797         (setattrfunc)0,                     /* tp_setattr */    
1798         (cmpfunc)PySwigPacked_compare,      /* tp_compare */    
1799         (reprfunc)PySwigPacked_repr,        /* tp_repr */       
1800         0,                                  /* tp_as_number */  
1801         0,                                  /* tp_as_sequence */
1802         0,                                  /* tp_as_mapping */ 
1803         (hashfunc)0,                        /* tp_hash */       
1804         (ternaryfunc)0,                     /* tp_call */       
1805         (reprfunc)PySwigPacked_str,         /* tp_str */        
1806         PyObject_GenericGetAttr,            /* tp_getattro */
1807         0,                                  /* tp_setattro */
1808         0,                                  /* tp_as_buffer */
1809         Py_TPFLAGS_DEFAULT,                 /* tp_flags */
1810         swigpacked_doc,                     /* tp_doc */
1811         0,                                  /* tp_traverse */
1812         0,                                  /* tp_clear */
1813         0,                                  /* tp_richcompare */
1814         0,                                  /* tp_weaklistoffset */
1815 #if PY_VERSION_HEX >= 0x02020000
1816         0,                                  /* tp_iter */
1817         0,                                  /* tp_iternext */
1818         0,                                  /* tp_methods */ 
1819         0,                                  /* tp_members */
1820         0,                                  /* tp_getset */             
1821         0,                                  /* tp_base */               
1822         0,                                  /* tp_dict */               
1823         0,                                  /* tp_descr_get */          
1824         0,                                  /* tp_descr_set */          
1825         0,                                  /* tp_dictoffset */         
1826         0,                                  /* tp_init */               
1827         0,                                  /* tp_alloc */              
1828         0,                                  /* tp_new */                
1829         0,                                  /* tp_free */          
1830         0,                                  /* tp_is_gc */  
1831         0,                                  /* tp_bases */   
1832         0,                                  /* tp_mro */
1833         0,                                  /* tp_cache */   
1834         0,                                  /* tp_subclasses */
1835         0,                                  /* tp_weaklist */
1836 #endif
1837 #if PY_VERSION_HEX >= 0x02030000
1838         0,                                  /* tp_del */
1839 #endif
1840 #ifdef COUNT_ALLOCS
1841         0,0,0,0                             /* tp_alloc -> tp_next */
1842 #endif
1843       };
1844     pyswigpacked_type = tmp;
1845     pyswigpacked_type.ob_type = &PyType_Type;
1846     type_init = 1;
1847   }
1848   return &pyswigpacked_type;
1849 }
1850
1851 SWIGRUNTIME PyObject *
1852 PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
1853 {
1854   PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type());
1855   if (sobj) {
1856     void *pack = malloc(size);
1857     if (pack) {
1858       memcpy(pack, ptr, size);
1859       sobj->pack = pack;
1860       sobj->ty   = ty;
1861       sobj->size = size;
1862     } else {
1863       PyObject_DEL((PyObject *) sobj);
1864       sobj = 0;
1865     }
1866   }
1867   return (PyObject *) sobj;
1868 }
1869
1870 SWIGRUNTIME swig_type_info *
1871 PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
1872 {
1873   if (PySwigPacked_Check(obj)) {
1874     PySwigPacked *sobj = (PySwigPacked *)obj;
1875     if (sobj->size != size) return 0;
1876     memcpy(ptr, sobj->pack, size);
1877     return sobj->ty;
1878   } else {
1879     return 0;
1880   }
1881 }
1882
1883 /* -----------------------------------------------------------------------------
1884  * pointers/data manipulation
1885  * ----------------------------------------------------------------------------- */
1886
1887 SWIGRUNTIMEINLINE PyObject *
1888 _SWIG_This(void)
1889 {
1890   return PyString_FromString("this");
1891 }
1892
1893 SWIGRUNTIME PyObject *
1894 SWIG_This(void)
1895 {
1896   static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
1897   return swig_this;
1898 }
1899
1900 /* #define SWIG_PYTHON_SLOW_GETSET_THIS */
1901
1902 SWIGRUNTIME PySwigObject *
1903 SWIG_Python_GetSwigThis(PyObject *pyobj) 
1904 {
1905   if (PySwigObject_Check(pyobj)) {
1906     return (PySwigObject *) pyobj;
1907   } else {
1908     PyObject *obj = 0;
1909 #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
1910     if (PyInstance_Check(pyobj)) {
1911       obj = _PyInstance_Lookup(pyobj, SWIG_This());      
1912     } else {
1913       PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
1914       if (dictptr != NULL) {
1915         PyObject *dict = *dictptr;
1916         obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
1917       } else {
1918 #ifdef PyWeakref_CheckProxy
1919         if (PyWeakref_CheckProxy(pyobj)) {
1920           PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
1921           return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
1922         }
1923 #endif
1924         obj = PyObject_GetAttr(pyobj,SWIG_This());
1925         if (obj) {
1926           Py_DECREF(obj);
1927         } else {
1928           if (PyErr_Occurred()) PyErr_Clear();
1929           return 0;
1930         }
1931       }
1932     }
1933 #else
1934     obj = PyObject_GetAttr(pyobj,SWIG_This());
1935     if (obj) {
1936       Py_DECREF(obj);
1937     } else {
1938       if (PyErr_Occurred()) PyErr_Clear();
1939       return 0;
1940     }
1941 #endif
1942     if (obj && !PySwigObject_Check(obj)) {
1943       /* a PyObject is called 'this', try to get the 'real this'
1944          PySwigObject from it */ 
1945       return SWIG_Python_GetSwigThis(obj);
1946     }
1947     return (PySwigObject *)obj;
1948   }
1949 }
1950
1951 /* Acquire a pointer value */
1952
1953 SWIGRUNTIME int
1954 SWIG_Python_AcquirePtr(PyObject *obj, int own) {
1955   if (own == SWIG_POINTER_OWN) {
1956     PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
1957     if (sobj) {
1958       int oldown = sobj->own;
1959       sobj->own = own;
1960       return oldown;
1961     }
1962   }
1963   return 0;
1964 }
1965
1966 /* Convert a pointer value */
1967
1968 SWIGRUNTIME int
1969 SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
1970   if (!obj) return SWIG_ERROR;
1971   if (obj == Py_None) {
1972     if (ptr) *ptr = 0;
1973     return SWIG_OK;
1974   } else {
1975     PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
1976     if (own)
1977       *own = 0;
1978     while (sobj) {
1979       void *vptr = sobj->ptr;
1980       if (ty) {
1981         swig_type_info *to = sobj->ty;
1982         if (to == ty) {
1983           /* no type cast needed */
1984           if (ptr) *ptr = vptr;
1985           break;
1986         } else {
1987           swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
1988           if (!tc) {
1989             sobj = (PySwigObject *)sobj->next;
1990           } else {
1991             if (ptr) {
1992               int newmemory = 0;
1993               *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
1994               if (newmemory == SWIG_CAST_NEW_MEMORY) {
1995                 assert(own);
1996                 if (own)
1997                   *own = *own | SWIG_CAST_NEW_MEMORY;
1998               }
1999             }
2000             break;
2001           }
2002         }
2003       } else {
2004         if (ptr) *ptr = vptr;
2005         break;
2006       }
2007     }
2008     if (sobj) {
2009       if (own)
2010         *own = *own | sobj->own;
2011       if (flags & SWIG_POINTER_DISOWN) {
2012         sobj->own = 0;
2013       }
2014       return SWIG_OK;
2015     } else {
2016       int res = SWIG_ERROR;
2017       if (flags & SWIG_POINTER_IMPLICIT_CONV) {
2018         PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
2019         if (data && !data->implicitconv) {
2020           PyObject *klass = data->klass;
2021           if (klass) {
2022             PyObject *impconv;
2023             data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
2024             impconv = SWIG_Python_CallFunctor(klass, obj);
2025             data->implicitconv = 0;
2026             if (PyErr_Occurred()) {
2027               PyErr_Clear();
2028               impconv = 0;
2029             }
2030             if (impconv) {
2031               PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv);
2032               if (iobj) {
2033                 void *vptr;
2034                 res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
2035                 if (SWIG_IsOK(res)) {
2036                   if (ptr) {
2037                     *ptr = vptr;
2038                     /* transfer the ownership to 'ptr' */
2039                     iobj->own = 0;
2040                     res = SWIG_AddCast(res);
2041                     res = SWIG_AddNewMask(res);
2042                   } else {
2043                     res = SWIG_AddCast(res);                
2044                   }
2045                 }
2046               }
2047               Py_DECREF(impconv);
2048             }
2049           }
2050         }
2051       }
2052       return res;
2053     }
2054   }
2055 }
2056
2057 /* Convert a function ptr value */
2058
2059 SWIGRUNTIME int
2060 SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
2061   if (!PyCFunction_Check(obj)) {
2062     return SWIG_ConvertPtr(obj, ptr, ty, 0);
2063   } else {
2064     void *vptr = 0;
2065     
2066     /* here we get the method pointer for callbacks */
2067     const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
2068     const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
2069     if (desc) {
2070       desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
2071       if (!desc) return SWIG_ERROR;
2072     }
2073     if (ty) {
2074       swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
2075       if (tc) {
2076         int newmemory = 0;
2077         *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
2078         assert(!newmemory); /* newmemory handling not yet implemented */
2079       } else {
2080         return SWIG_ERROR;
2081       }
2082     } else {
2083       *ptr = vptr;
2084     }
2085     return SWIG_OK;
2086   }
2087 }
2088
2089 /* Convert a packed value value */
2090
2091 SWIGRUNTIME int
2092 SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
2093   swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz);
2094   if (!to) return SWIG_ERROR;
2095   if (ty) {
2096     if (to != ty) {
2097       /* check type cast? */
2098       swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
2099       if (!tc) return SWIG_ERROR;
2100     }
2101   }
2102   return SWIG_OK;
2103 }  
2104
2105 /* -----------------------------------------------------------------------------
2106  * Create a new pointer object
2107  * ----------------------------------------------------------------------------- */
2108
2109 /*
2110   Create a new instance object, whitout calling __init__, and set the
2111   'this' attribute.
2112 */
2113
2114 SWIGRUNTIME PyObject* 
2115 SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
2116 {
2117 #if (PY_VERSION_HEX >= 0x02020000)
2118   PyObject *inst = 0;
2119   PyObject *newraw = data->newraw;
2120   if (newraw) {
2121     inst = PyObject_Call(newraw, data->newargs, NULL);
2122     if (inst) {
2123 #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
2124       PyObject **dictptr = _PyObject_GetDictPtr(inst);
2125       if (dictptr != NULL) {
2126         PyObject *dict = *dictptr;
2127         if (dict == NULL) {
2128           dict = PyDict_New();
2129           *dictptr = dict;
2130           PyDict_SetItem(dict, SWIG_This(), swig_this);
2131         }
2132       }
2133 #else
2134       PyObject *key = SWIG_This();
2135       PyObject_SetAttr(inst, key, swig_this);
2136 #endif
2137     }
2138   } else {
2139     PyObject *dict = PyDict_New();
2140     PyDict_SetItem(dict, SWIG_This(), swig_this);
2141     inst = PyInstance_NewRaw(data->newargs, dict);
2142     Py_DECREF(dict);
2143   }
2144   return inst;
2145 #else
2146 #if (PY_VERSION_HEX >= 0x02010000)
2147   PyObject *inst;
2148   PyObject *dict = PyDict_New();
2149   PyDict_SetItem(dict, SWIG_This(), swig_this);
2150   inst = PyInstance_NewRaw(data->newargs, dict);
2151   Py_DECREF(dict);
2152   return (PyObject *) inst;
2153 #else
2154   PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
2155   if (inst == NULL) {
2156     return NULL;
2157   }
2158   inst->in_class = (PyClassObject *)data->newargs;
2159   Py_INCREF(inst->in_class);
2160   inst->in_dict = PyDict_New();
2161   if (inst->in_dict == NULL) {
2162     Py_DECREF(inst);
2163     return NULL;
2164   }
2165 #ifdef Py_TPFLAGS_HAVE_WEAKREFS
2166   inst->in_weakreflist = NULL;
2167 #endif
2168 #ifdef Py_TPFLAGS_GC
2169   PyObject_GC_Init(inst);
2170 #endif
2171   PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
2172   return (PyObject *) inst;
2173 #endif
2174 #endif
2175 }
2176
2177 SWIGRUNTIME void
2178 SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
2179 {
2180  PyObject *dict;
2181 #if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
2182  PyObject **dictptr = _PyObject_GetDictPtr(inst);
2183  if (dictptr != NULL) {
2184    dict = *dictptr;
2185    if (dict == NULL) {
2186      dict = PyDict_New();
2187      *dictptr = dict;
2188    }
2189    PyDict_SetItem(dict, SWIG_This(), swig_this);
2190    return;
2191  }
2192 #endif
2193  dict = PyObject_GetAttrString(inst, (char*)"__dict__");
2194  PyDict_SetItem(dict, SWIG_This(), swig_this);
2195  Py_DECREF(dict);
2196
2197
2198
2199 SWIGINTERN PyObject *
2200 SWIG_Python_InitShadowInstance(PyObject *args) {
2201   PyObject *obj[2];
2202   if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
2203     return NULL;
2204   } else {
2205     PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
2206     if (sthis) {
2207       PySwigObject_append((PyObject*) sthis, obj[1]);
2208     } else {
2209       SWIG_Python_SetSwigThis(obj[0], obj[1]);
2210     }
2211     return SWIG_Py_Void();
2212   }
2213 }
2214
2215 /* Create a new pointer object */
2216
2217 SWIGRUNTIME PyObject *
2218 SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
2219   if (!ptr) {
2220     return SWIG_Py_Void();
2221   } else {
2222     int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
2223     PyObject *robj = PySwigObject_New(ptr, type, own);
2224     PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0;
2225     if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
2226       PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
2227       if (inst) {
2228         Py_DECREF(robj);
2229         robj = inst;
2230       }
2231     }
2232     return robj;
2233   }
2234 }
2235
2236 /* Create a new packed object */
2237
2238 SWIGRUNTIMEINLINE PyObject *
2239 SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
2240   return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
2241 }
2242
2243 /* -----------------------------------------------------------------------------*
2244  *  Get type list 
2245  * -----------------------------------------------------------------------------*/
2246
2247 #ifdef SWIG_LINK_RUNTIME
2248 void *SWIG_ReturnGlobalTypeList(void *);
2249 #endif
2250
2251 SWIGRUNTIME swig_module_info *
2252 SWIG_Python_GetModule(void) {
2253   static void *type_pointer = (void *)0;
2254   /* first check if module already created */
2255   if (!type_pointer) {
2256 #ifdef SWIG_LINK_RUNTIME
2257     type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
2258 #else
2259     type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
2260                                     (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
2261     if (PyErr_Occurred()) {
2262       PyErr_Clear();
2263       type_pointer = (void *)0;
2264     }
2265 #endif
2266   }
2267   return (swig_module_info *) type_pointer;
2268 }
2269
2270 #if PY_MAJOR_VERSION < 2
2271 /* PyModule_AddObject function was introduced in Python 2.0.  The following function
2272    is copied out of Python/modsupport.c in python version 2.3.4 */
2273 SWIGINTERN int
2274 PyModule_AddObject(PyObject *m, char *name, PyObject *o)
2275 {
2276   PyObject *dict;
2277   if (!PyModule_Check(m)) {
2278     PyErr_SetString(PyExc_TypeError,
2279                     "PyModule_AddObject() needs module as first arg");
2280     return SWIG_ERROR;
2281   }
2282   if (!o) {
2283     PyErr_SetString(PyExc_TypeError,
2284                     "PyModule_AddObject() needs non-NULL value");
2285     return SWIG_ERROR;
2286   }
2287   
2288   dict = PyModule_GetDict(m);
2289   if (dict == NULL) {
2290     /* Internal error -- modules must have a dict! */
2291     PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
2292                  PyModule_GetName(m));
2293     return SWIG_ERROR;
2294   }
2295   if (PyDict_SetItemString(dict, name, o))
2296     return SWIG_ERROR;
2297   Py_DECREF(o);
2298   return SWIG_OK;
2299 }
2300 #endif
2301
2302 SWIGRUNTIME void
2303 SWIG_Python_DestroyModule(void *vptr)
2304 {
2305   swig_module_info *swig_module = (swig_module_info *) vptr;
2306   swig_type_info **types = swig_module->types;
2307   size_t i;
2308   for (i =0; i < swig_module->size; ++i) {
2309     swig_type_info *ty = types[i];
2310     if (ty->owndata) {
2311       PySwigClientData *data = (PySwigClientData *) ty->clientdata;
2312       if (data) PySwigClientData_Del(data);
2313     }
2314   }
2315   Py_DECREF(SWIG_This());
2316 }
2317
2318 SWIGRUNTIME void
2319 SWIG_Python_SetModule(swig_module_info *swig_module) {
2320   static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
2321
2322   PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
2323                                    swig_empty_runtime_method_table);
2324   PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
2325   if (pointer && module) {
2326     PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
2327   } else {
2328     Py_XDECREF(pointer);
2329   }
2330 }
2331
2332 /* The python cached type query */
2333 SWIGRUNTIME PyObject *
2334 SWIG_Python_TypeCache(void) {
2335   static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
2336   return cache;
2337 }
2338
2339 SWIGRUNTIME swig_type_info *
2340 SWIG_Python_TypeQuery(const char *type)
2341 {
2342   PyObject *cache = SWIG_Python_TypeCache();
2343   PyObject *key = PyString_FromString(type); 
2344   PyObject *obj = PyDict_GetItem(cache, key);
2345   swig_type_info *descriptor;
2346   if (obj) {
2347     descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
2348   } else {
2349     swig_module_info *swig_module = SWIG_Python_GetModule();
2350     descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
2351     if (descriptor) {
2352       obj = PyCObject_FromVoidPtr(descriptor, NULL);
2353       PyDict_SetItem(cache, key, obj);
2354       Py_DECREF(obj);
2355     }
2356   }
2357   Py_DECREF(key);
2358   return descriptor;
2359 }
2360
2361 /* 
2362    For backward compatibility only
2363 */
2364 #define SWIG_POINTER_EXCEPTION  0
2365 #define SWIG_arg_fail(arg)      SWIG_Python_ArgFail(arg)
2366 #define SWIG_MustGetPtr(p, type, argnum, flags)  SWIG_Python_MustGetPtr(p, type, argnum, flags)
2367
2368 SWIGRUNTIME int
2369 SWIG_Python_AddErrMesg(const char* mesg, int infront)
2370 {
2371   if (PyErr_Occurred()) {
2372     PyObject *type = 0;
2373     PyObject *value = 0;
2374     PyObject *traceback = 0;
2375     PyErr_Fetch(&type, &value, &traceback);
2376     if (value) {
2377       PyObject *old_str = PyObject_Str(value);
2378       Py_XINCREF(type);
2379       PyErr_Clear();
2380       if (infront) {
2381         PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
2382       } else {
2383         PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
2384       }
2385       Py_DECREF(old_str);
2386     }
2387     return 1;
2388   } else {
2389     return 0;
2390   }
2391 }
2392   
2393 SWIGRUNTIME int
2394 SWIG_Python_ArgFail(int argnum)
2395 {
2396   if (PyErr_Occurred()) {
2397     /* add information about failing argument */
2398     char mesg[256];
2399     PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
2400     return SWIG_Python_AddErrMesg(mesg, 1);
2401   } else {
2402     return 0;
2403   }
2404 }
2405
2406 SWIGRUNTIMEINLINE const char *
2407 PySwigObject_GetDesc(PyObject *self)
2408 {
2409   PySwigObject *v = (PySwigObject *)self;
2410   swig_type_info *ty = v ? v->ty : 0;
2411   return ty ? ty->str : (char*)"";
2412 }
2413
2414 SWIGRUNTIME void
2415 SWIG_Python_TypeError(const char *type, PyObject *obj)
2416 {
2417   if (type) {
2418 #if defined(SWIG_COBJECT_TYPES)
2419     if (obj && PySwigObject_Check(obj)) {
2420       const char *otype = (const char *) PySwigObject_GetDesc(obj);
2421       if (otype) {
2422         PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
2423                      type, otype);
2424         return;
2425       }
2426     } else 
2427 #endif      
2428     {
2429       const char *otype = (obj ? obj->ob_type->tp_name : 0); 
2430       if (otype) {
2431         PyObject *str = PyObject_Str(obj);
2432         const char *cstr = str ? PyString_AsString(str) : 0;
2433         if (cstr) {
2434           PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
2435                        type, otype, cstr);
2436         } else {
2437           PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
2438                        type, otype);
2439         }
2440         Py_XDECREF(str);
2441         return;
2442       }
2443     }   
2444     PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
2445   } else {
2446     PyErr_Format(PyExc_TypeError, "unexpected type is received");
2447   }
2448 }
2449
2450
2451 /* Convert a pointer value, signal an exception on a type mismatch */
2452 SWIGRUNTIME void *
2453 SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
2454   void *result;
2455   if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
2456     PyErr_Clear();
2457     if (flags & SWIG_POINTER_EXCEPTION) {
2458       SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
2459       SWIG_Python_ArgFail(argnum);
2460     }
2461   }
2462   return result;
2463 }
2464
2465
2466 #ifdef __cplusplus
2467 #if 0
2468 { /* cc-mode */
2469 #endif
2470 }
2471 #endif
2472
2473
2474
2475 #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) 
2476
2477 #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else 
2478
2479
2480
2481   #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) 
2482
2483
2484 /* -------- TYPES TABLE (BEGIN) -------- */
2485
2486 #define SWIGTYPE_p_TALLOC_CTX swig_types[0]
2487 #define SWIGTYPE_p_char swig_types[1]
2488 #define SWIGTYPE_p_f_p_void_enum_ldb_debug_level_p_q_const__char_va_list__void swig_types[2]
2489 #define SWIGTYPE_p_int swig_types[3]
2490 #define SWIGTYPE_p_ldb_context swig_types[4]
2491 #define SWIGTYPE_p_ldb_dn swig_types[5]
2492 #define SWIGTYPE_p_ldb_ldif swig_types[6]
2493 #define SWIGTYPE_p_ldb_message swig_types[7]
2494 #define SWIGTYPE_p_ldb_message_element swig_types[8]
2495 #define SWIGTYPE_p_ldb_module_ops swig_types[9]
2496 #define SWIGTYPE_p_ldb_result swig_types[10]
2497 #define SWIGTYPE_p_ldb_val swig_types[11]
2498 #define SWIGTYPE_p_long_long swig_types[12]
2499 #define SWIGTYPE_p_p_char swig_types[13]
2500 #define SWIGTYPE_p_p_ldb_control swig_types[14]
2501 #define SWIGTYPE_p_p_ldb_result swig_types[15]
2502 #define SWIGTYPE_p_short swig_types[16]
2503 #define SWIGTYPE_p_signed_char swig_types[17]
2504 #define SWIGTYPE_p_unsigned_char swig_types[18]
2505 #define SWIGTYPE_p_unsigned_int swig_types[19]
2506 #define SWIGTYPE_p_unsigned_long swig_types[20]
2507 #define SWIGTYPE_p_unsigned_long_long swig_types[21]
2508 #define SWIGTYPE_p_unsigned_short swig_types[22]
2509 #define SWIGTYPE_p_void swig_types[23]
2510 static swig_type_info *swig_types[25];
2511 static swig_module_info swig_module = {swig_types, 24, 0, 0, 0, 0};
2512 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
2513 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
2514
2515 /* -------- TYPES TABLE (END) -------- */
2516
2517 #if (PY_VERSION_HEX <= 0x02000000)
2518 # if !defined(SWIG_PYTHON_CLASSIC)
2519 #  error "This python version requires swig to be run with the '-classic' option"
2520 # endif
2521 #endif
2522 #if (PY_VERSION_HEX <= 0x02020000)
2523 # error "This python version requires swig to be run with the '-nomodern' option"
2524 #endif
2525 #if (PY_VERSION_HEX <= 0x02020000)
2526 # error "This python version requires swig to be run with the '-nomodernargs' option"
2527 #endif
2528 #ifndef METH_O
2529 # error "This python version requires swig to be run with the '-nofastunpack' option"
2530 #endif
2531 #ifdef SWIG_TypeQuery
2532 # undef SWIG_TypeQuery
2533 #endif
2534 #define SWIG_TypeQuery SWIG_Python_TypeQuery
2535
2536 /*-----------------------------------------------
2537               @(target):= _ldb.so
2538   ------------------------------------------------*/
2539 #define SWIG_init    init_ldb
2540
2541 #define SWIG_name    "_ldb"
2542
2543 #define SWIGVERSION 0x010336 
2544 #define SWIG_VERSION SWIGVERSION
2545
2546
2547 #define SWIG_as_voidptr(a) (void *)((const void *)(a)) 
2548 #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) 
2549
2550
2551
2552 #include <stdint.h>
2553 #include <stdbool.h>
2554 #include "talloc.h"
2555 #include "events.h"
2556 #include "ldb.h"
2557 #include "ldb_errors.h"
2558 #include "ldb_private.h"
2559
2560 typedef struct ldb_message ldb_msg;
2561 typedef struct ldb_context ldb;
2562 typedef struct ldb_dn ldb_dn;
2563 typedef struct ldb_ldif ldb_ldif;
2564 typedef struct ldb_message_element ldb_message_element;
2565 typedef int ldb_error;
2566 typedef int ldb_int_error;
2567
2568
2569
2570   #define SWIG_From_long   PyInt_FromLong 
2571
2572
2573 SWIGINTERNINLINE PyObject *
2574 SWIG_From_int  (int value)
2575 {    
2576   return SWIG_From_long  (value);
2577 }
2578
2579
2580 PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx, 
2581                                struct ldb_message_element *el, 
2582                                struct ldb_val *val)
2583 {
2584         const struct ldb_schema_attribute *a;
2585         struct ldb_val new_val;
2586         TALLOC_CTX *mem_ctx = talloc_new(NULL);
2587         PyObject *ret;
2588         
2589         new_val = *val;
2590         
2591         if (ldb_ctx != NULL) {        
2592                 a = ldb_schema_attribute_by_name(ldb_ctx, el->name);
2593         
2594                 if (a != NULL) {
2595                         if (a->syntax->ldif_write_fn(ldb_ctx, mem_ctx, val, &new_val) != 0) {
2596                                 talloc_free(mem_ctx);
2597                                 return NULL;
2598                         }
2599                 }
2600         } 
2601         
2602         ret = PyString_FromStringAndSize((const char *)new_val.data, new_val.length);
2603         
2604         talloc_free(mem_ctx);
2605         
2606         return ret;
2607 }
2608
2609
2610
2611 SWIGINTERN swig_type_info*
2612 SWIG_pchar_descriptor(void)
2613 {
2614   static int init = 0;
2615   static swig_type_info* info = 0;
2616   if (!init) {
2617     info = SWIG_TypeQuery("_p_char");
2618     init = 1;
2619   }
2620   return info;
2621 }
2622
2623
2624 SWIGINTERN int
2625 SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
2626 {
2627   if (PyString_Check(obj)) {
2628     char *cstr; Py_ssize_t len;
2629     PyString_AsStringAndSize(obj, &cstr, &len);
2630     if (cptr)  {
2631       if (alloc) {
2632         /* 
2633            In python the user should not be able to modify the inner
2634            string representation. To warranty that, if you define
2635            SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string
2636            buffer is always returned.
2637
2638            The default behavior is just to return the pointer value,
2639            so, be careful.
2640         */ 
2641 #if defined(SWIG_PYTHON_SAFE_CSTRINGS)
2642         if (*alloc != SWIG_OLDOBJ) 
2643 #else
2644         if (*alloc == SWIG_NEWOBJ) 
2645 #endif
2646           {
2647             *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1));
2648             *alloc = SWIG_NEWOBJ;
2649           }
2650         else {
2651           *cptr = cstr;
2652           *alloc = SWIG_OLDOBJ;
2653         }
2654       } else {
2655         *cptr = PyString_AsString(obj);
2656       }
2657     }
2658     if (psize) *psize = len + 1;
2659     return SWIG_OK;
2660   } else {
2661     swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
2662     if (pchar_descriptor) {
2663       void* vptr = 0;
2664       if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
2665         if (cptr) *cptr = (char *) vptr;
2666         if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
2667         if (alloc) *alloc = SWIG_OLDOBJ;
2668         return SWIG_OK;
2669       }
2670     }
2671   }
2672   return SWIG_TypeError;
2673 }
2674
2675
2676
2677
2678 SWIGINTERN ldb_dn *new_ldb_dn(ldb *ldb_ctx,char const *str){
2679             ldb_dn *ret = ldb_dn_new(ldb_ctx, ldb_ctx, str);
2680             /* ldb_dn_new() doesn't accept NULL as memory context, so 
2681                we do it this way... */
2682             talloc_steal(NULL, ret);
2683
2684             if (ret == NULL)
2685                 SWIG_exception(SWIG_ValueError, 
2686                                 "unable to parse dn string");
2687 fail:
2688             return ret;
2689         }
2690 SWIGINTERN void delete_ldb_dn(ldb_dn *self){ talloc_free(self); }
2691
2692 SWIGINTERNINLINE PyObject*
2693   SWIG_From_bool  (bool value)
2694 {
2695   return PyBool_FromLong(value ? 1 : 0);
2696 }
2697
2698
2699 SWIGINTERNINLINE PyObject *
2700 SWIG_FromCharPtrAndSize(const char* carray, size_t size)
2701 {
2702   if (carray) {
2703     if (size > INT_MAX) {
2704       swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
2705       return pchar_descriptor ? 
2706         SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void();
2707     } else {
2708       return PyString_FromStringAndSize(carray, (int)(size));
2709     }
2710   } else {
2711     return SWIG_Py_Void();
2712   }
2713 }
2714
2715
2716 SWIGINTERNINLINE PyObject * 
2717 SWIG_FromCharPtr(const char *cptr)
2718
2719   return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
2720 }
2721
2722 SWIGINTERN ldb_dn *ldb_dn_parent(ldb_dn *self){ return ldb_dn_get_parent(NULL, self); }
2723 SWIGINTERN char const *ldb_dn_canonical_str(ldb_dn *self){
2724             return ldb_dn_canonical_string(self, self);
2725         }
2726 SWIGINTERN char const *ldb_dn_canonical_ex_str(ldb_dn *self){
2727             return ldb_dn_canonical_ex_string(self, self);
2728         }
2729 SWIGINTERN char *ldb_dn___repr__(ldb_dn *self){
2730             char *dn = ldb_dn_get_linearized(self), *ret;
2731             asprintf(&ret, "Dn('%s')", dn);
2732             talloc_free(dn);
2733             return ret;
2734         }
2735 SWIGINTERN ldb_dn *ldb_dn___add__(ldb_dn *self,ldb_dn *other){
2736             ldb_dn *ret = ldb_dn_copy(NULL, self);
2737             ldb_dn_add_child(ret, other);
2738             return ret;
2739         }
2740
2741 struct ldb_context *ldb_context_from_py_object(PyObject *py_obj)
2742 {
2743         struct ldb_context *ldb_ctx;
2744     if (SWIG_ConvertPtr(py_obj, (void *)&ldb_ctx, SWIGTYPE_p_ldb_context, 0 |  0 ) < 0)
2745         return NULL;
2746     return ldb_ctx;
2747 }
2748
2749 int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object, 
2750                          struct ldb_context *ldb_ctx, ldb_dn **dn)
2751 {
2752     int ret;
2753     struct ldb_dn *odn;
2754     if (ldb_ctx != NULL && PyString_Check(object)) {
2755         odn = ldb_dn_new(mem_ctx, ldb_ctx, PyString_AsString(object));
2756         if (!odn) {
2757                 return SWIG_ERROR;
2758         }
2759         *dn = odn;
2760         return 0;
2761     }
2762     ret = SWIG_ConvertPtr(object, (void **)&odn, SWIGTYPE_p_ldb_dn, 
2763                            SWIG_POINTER_EXCEPTION);
2764     *dn = ldb_dn_copy(mem_ctx, odn);
2765     if (odn && !*dn) {
2766         return SWIG_ERROR;
2767     }
2768     return ret;
2769 }
2770
2771 ldb_message_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
2772                                                PyObject *set_obj, int flags,
2773                                                const char *attr_name)
2774 {
2775     struct ldb_message_element *me = talloc(mem_ctx, struct ldb_message_element);
2776     me->name = attr_name;
2777     me->flags = flags;
2778     if (PyString_Check(set_obj)) {
2779         me->num_values = 1;
2780         me->values = talloc_array(me, struct ldb_val, me->num_values);
2781         me->values[0].length = PyString_Size(set_obj);
2782         me->values[0].data = (uint8_t *)talloc_strdup(me->values, 
2783                                            PyString_AsString(set_obj));
2784     } else if (PySequence_Check(set_obj)) {
2785         int i;
2786         me->num_values = PySequence_Size(set_obj);
2787         me->values = talloc_array(me, struct ldb_val, me->num_values);
2788         for (i = 0; i < me->num_values; i++) {
2789             PyObject *obj = PySequence_GetItem(set_obj, i);
2790             me->values[i].length = PyString_Size(obj);
2791             me->values[i].data = (uint8_t *)PyString_AsString(obj);
2792         }
2793     } else {
2794         talloc_free(me);
2795         me = NULL;
2796     }
2797
2798     return me;
2799 }
2800
2801 PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx, 
2802                                  ldb_message_element *me)
2803 {
2804     int i;
2805     PyObject *result;
2806
2807     /* Python << 2.5 doesn't have PySet_New and PySet_Add. */
2808     result = PyList_New(me->num_values);
2809
2810     for (i = 0; i < me->num_values; i++) {
2811         PyList_SetItem(result, i,
2812             ldb_val_to_py_object(ldb_ctx, me, &me->values[i]));
2813     }
2814
2815     return result;
2816 }
2817
2818
2819 SWIGINTERN int ldb_message_element___cmp__(ldb_message_element *self,ldb_message_element *other){
2820             return ldb_msg_element_compare(self, other);
2821         }
2822 SWIGINTERN PyObject *ldb_message_element___iter__(ldb_message_element *self){
2823             return PyObject_GetIter(ldb_msg_element_to_set(NULL, self));
2824         }
2825 SWIGINTERN PyObject *ldb_message_element___set__(ldb_message_element *self){
2826             return ldb_msg_element_to_set(NULL, self);
2827         }
2828
2829 #include <limits.h>
2830 #if !defined(SWIG_NO_LLONG_MAX)
2831 # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
2832 #   define LLONG_MAX __LONG_LONG_MAX__
2833 #   define LLONG_MIN (-LLONG_MAX - 1LL)
2834 #   define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
2835 # endif
2836 #endif
2837
2838
2839 SWIGINTERN int
2840 SWIG_AsVal_double (PyObject *obj, double *val)
2841 {
2842   int res = SWIG_TypeError;
2843   if (PyFloat_Check(obj)) {
2844     if (val) *val = PyFloat_AsDouble(obj);
2845     return SWIG_OK;
2846   } else if (PyInt_Check(obj)) {
2847     if (val) *val = PyInt_AsLong(obj);
2848     return SWIG_OK;
2849   } else if (PyLong_Check(obj)) {
2850     double v = PyLong_AsDouble(obj);
2851     if (!PyErr_Occurred()) {
2852       if (val) *val = v;
2853       return SWIG_OK;
2854     } else {
2855       PyErr_Clear();
2856     }
2857   }
2858 #ifdef SWIG_PYTHON_CAST_MODE
2859   {
2860     int dispatch = 0;
2861     double d = PyFloat_AsDouble(obj);
2862     if (!PyErr_Occurred()) {
2863       if (val) *val = d;
2864       return SWIG_AddCast(SWIG_OK);
2865     } else {
2866       PyErr_Clear();
2867     }
2868     if (!dispatch) {
2869       long v = PyLong_AsLong(obj);
2870       if (!PyErr_Occurred()) {
2871         if (val) *val = v;
2872         return SWIG_AddCast(SWIG_AddCast(SWIG_OK));
2873       } else {
2874         PyErr_Clear();
2875       }
2876     }
2877   }
2878 #endif
2879   return res;
2880 }
2881
2882
2883 #include <float.h>
2884
2885
2886 #include <math.h>
2887
2888
2889 SWIGINTERNINLINE int
2890 SWIG_CanCastAsInteger(double *d, double min, double max) {
2891   double x = *d;
2892   if ((min <= x && x <= max)) {
2893    double fx = floor(x);
2894    double cx = ceil(x);
2895    double rd =  ((x - fx) < 0.5) ? fx : cx; /* simple rint */
2896    if ((errno == EDOM) || (errno == ERANGE)) {
2897      errno = 0;
2898    } else {
2899      double summ, reps, diff;
2900      if (rd < x) {
2901        diff = x - rd;
2902      } else if (rd > x) {
2903        diff = rd - x;
2904      } else {
2905        return 1;
2906      }
2907      summ = rd + x;
2908      reps = diff/summ;
2909      if (reps < 8*DBL_EPSILON) {
2910        *d = rd;
2911        return 1;
2912      }
2913    }
2914   }
2915   return 0;
2916 }
2917
2918
2919 SWIGINTERN int
2920 SWIG_AsVal_long (PyObject *obj, long* val)
2921 {
2922   if (PyInt_Check(obj)) {
2923     if (val) *val = PyInt_AsLong(obj);
2924     return SWIG_OK;
2925   } else if (PyLong_Check(obj)) {
2926     long v = PyLong_AsLong(obj);
2927     if (!PyErr_Occurred()) {
2928       if (val) *val = v;
2929       return SWIG_OK;
2930     } else {
2931       PyErr_Clear();
2932     }
2933   }
2934 #ifdef SWIG_PYTHON_CAST_MODE
2935   {
2936     int dispatch = 0;
2937     long v = PyInt_AsLong(obj);
2938     if (!PyErr_Occurred()) {
2939       if (val) *val = v;
2940       return SWIG_AddCast(SWIG_OK);
2941     } else {
2942       PyErr_Clear();
2943     }
2944     if (!dispatch) {
2945       double d;
2946       int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
2947       if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
2948         if (val) *val = (long)(d);
2949         return res;
2950       }
2951     }
2952   }
2953 #endif
2954   return SWIG_TypeError;
2955 }
2956
2957
2958 SWIGINTERN int
2959 SWIG_AsVal_int (PyObject * obj, int *val)
2960 {
2961   long v;
2962   int res = SWIG_AsVal_long (obj, &v);
2963   if (SWIG_IsOK(res)) {
2964     if ((v < INT_MIN || v > INT_MAX)) {
2965       return SWIG_OverflowError;
2966     } else {
2967       if (val) *val = (int)(v);
2968     }
2969   }  
2970   return res;
2971 }
2972
2973 SWIGINTERN ldb_message_element *new_ldb_message_element(PyObject *set_obj,int flags,char const *name){
2974             return ldb_msg_element_from_pyobject(NULL, set_obj, flags, name);
2975         }
2976 SWIGINTERN int ldb_message_element___len__(ldb_message_element *self){
2977             return self->num_values;
2978         }
2979 SWIGINTERN PyObject *ldb_message_element_get(ldb_message_element *self,int i){
2980             if (i < 0 || i >= self->num_values)
2981                 return Py_None;
2982
2983             return ldb_val_to_py_object(NULL, self, &self->values[i]);
2984         }
2985 SWIGINTERN void delete_ldb_message_element(ldb_message_element *self){ talloc_free(self); }
2986
2987     PyObject *ldb_msg_list_elements(ldb_msg *msg)
2988     {
2989         int i, j = 0;
2990         PyObject *obj = PyList_New(msg->num_elements+(msg->dn != NULL?1:0));
2991         if (msg->dn != NULL) {
2992             PyList_SetItem(obj, j, PyString_FromString("dn"));
2993             j++;
2994         }
2995         for (i = 0; i < msg->num_elements; i++) {
2996             PyList_SetItem(obj, j, PyString_FromString(msg->elements[i].name));
2997             j++;
2998         }
2999         return obj;
3000     }
3001
3002 SWIGINTERN ldb_msg *new_ldb_msg(ldb_dn *dn){ 
3003             ldb_msg *ret = ldb_msg_new(NULL); 
3004             ret->dn = talloc_reference(ret, dn);
3005             return ret;
3006         }
3007 SWIGINTERN void delete_ldb_msg(ldb_msg *self){ talloc_free(self); }
3008 SWIGINTERN void ldb_msg___setitem____SWIG_0(ldb_msg *self,char const *attr_name,ldb_message_element *val){
3009             struct ldb_message_element *el;
3010             
3011             ldb_msg_remove_attr(self, attr_name);
3012
3013             el = talloc(self, struct ldb_message_element);
3014             el->name = talloc_strdup(el, attr_name);
3015             el->num_values = val->num_values;
3016             el->values = talloc_reference(el, val->values);
3017
3018             ldb_msg_add(self, el, val->flags);
3019         }
3020 SWIGINTERN void ldb_msg___setitem____SWIG_1(ldb_msg *self,char const *attr_name,PyObject *val){
3021             struct ldb_message_element *el = ldb_msg_element_from_pyobject(NULL,
3022                                                 val, 0, attr_name);
3023             talloc_steal(self, el);
3024             ldb_msg_remove_attr(self, attr_name);
3025             ldb_msg_add(self, el, el->flags);
3026         }
3027 SWIGINTERN unsigned int ldb_msg___len__(ldb_msg *self){ return self->num_elements; }
3028
3029 SWIGINTERNINLINE PyObject* 
3030 SWIG_From_unsigned_SS_long  (unsigned long value)
3031 {
3032   return (value > LONG_MAX) ?
3033     PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); 
3034 }
3035
3036
3037 SWIGINTERNINLINE PyObject *
3038 SWIG_From_unsigned_SS_int  (unsigned int value)
3039 {    
3040   return SWIG_From_unsigned_SS_long  (value);
3041 }
3042
3043 SWIGINTERN PyObject *ldb_msg_keys(ldb_msg *self){
3044             return ldb_msg_list_elements(self);
3045         }
3046 SWIGINTERN PyObject *ldb_msg___iter__(ldb_msg *self){
3047             return PyObject_GetIter(ldb_msg_list_elements(self));
3048         }
3049
3050 static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3, 0);
3051
3052 static void py_ldb_debug(void *context, enum ldb_debug_level level, const char *fmt, va_list ap)
3053 {
3054     char *text;
3055     PyObject *fn = context;
3056
3057     vasprintf(&text, fmt, ap);
3058     PyObject_CallFunction(fn, (char *)"(i,s)", level, text);
3059     free(text);
3060 }
3061
3062
3063     static PyObject *ldb_ldif_to_pyobject(ldb_ldif *ldif)
3064     {
3065         if (ldif == NULL) {
3066             return Py_None;
3067         } else {
3068             return Py_BuildValue((char *)"(iO)", ldif->changetype, 
3069                    SWIG_NewPointerObj(ldif->msg, SWIGTYPE_p_ldb_message, 0));
3070         }
3071     }
3072
3073
3074 PyObject *PyExc_LdbError;
3075
3076 SWIGINTERN ldb *new_ldb(){ 
3077             return ldb_init(NULL, event_context_init(NULL)); 
3078         }
3079
3080 SWIGINTERN int
3081 SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) 
3082 {
3083   if (PyInt_Check(obj)) {
3084     long v = PyInt_AsLong(obj);
3085     if (v >= 0) {
3086       if (val) *val = v;
3087       return SWIG_OK;
3088     } else {
3089       return SWIG_OverflowError;
3090     }
3091   } else if (PyLong_Check(obj)) {
3092     unsigned long v = PyLong_AsUnsignedLong(obj);
3093     if (!PyErr_Occurred()) {
3094       if (val) *val = v;
3095       return SWIG_OK;
3096     } else {
3097       PyErr_Clear();
3098     }
3099   }
3100 #ifdef SWIG_PYTHON_CAST_MODE
3101   {
3102     int dispatch = 0;
3103     unsigned long v = PyLong_AsUnsignedLong(obj);
3104     if (!PyErr_Occurred()) {
3105       if (val) *val = v;
3106       return SWIG_AddCast(SWIG_OK);
3107     } else {
3108       PyErr_Clear();
3109     }
3110     if (!dispatch) {
3111       double d;
3112       int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d));
3113       if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
3114         if (val) *val = (unsigned long)(d);
3115         return res;
3116       }
3117     }
3118   }
3119 #endif
3120   return SWIG_TypeError;
3121 }
3122
3123
3124 SWIGINTERN int
3125 SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val)
3126 {
3127   unsigned long v;
3128   int res = SWIG_AsVal_unsigned_SS_long (obj, &v);
3129   if (SWIG_IsOK(res)) {
3130     if ((v > UINT_MAX)) {
3131       return SWIG_OverflowError;
3132     } else {
3133       if (val) *val = (unsigned int)(v);
3134     }
3135   }  
3136   return res;
3137 }
3138
3139 SWIGINTERN void delete_ldb(ldb *self){ talloc_free(self); }
3140 SWIGINTERN ldb_error ldb_search_ex(ldb *self,TALLOC_CTX *mem_ctx,ldb_dn *base,enum ldb_scope scope,char const *expression,char const *const *attrs,struct ldb_control **controls,struct ldb_result **OUT){
3141             int ret;
3142             struct ldb_result *res;
3143             struct ldb_request *req;
3144             res = talloc_zero(mem_ctx, struct ldb_result);
3145             if (!res) {
3146                 return 1;
3147             }
3148
3149             ret = ldb_build_search_req(&req, self, mem_ctx,
3150                            base?base:ldb_get_default_basedn(self),
3151                            scope,
3152                            expression,
3153                            attrs,
3154                            controls,
3155                            res,
3156                            ldb_search_default_callback);
3157
3158             if (ret != 0) {
3159                 talloc_free(res);
3160                 return ret;
3161             }
3162
3163             ldb_set_timeout(self, req, 0); /* use default timeout */
3164                 
3165             ret = ldb_request(self, req);
3166                 
3167             if (ret == 0) {
3168                 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
3169             }
3170
3171             talloc_free(req);
3172
3173             *OUT = res;
3174             return ret;
3175         }
3176 SWIGINTERN PyObject *ldb_schema_format_value(ldb *self,char const *element_name,PyObject *val){
3177                 const struct ldb_schema_attribute *a;
3178                 struct ldb_val old_val;
3179                 struct ldb_val new_val;
3180                 TALLOC_CTX *mem_ctx = talloc_new(NULL);
3181                 PyObject *ret;
3182                 
3183                 old_val.data = PyString_AsString(val);
3184                 old_val.length = PyString_Size(val);
3185                 
3186                 a = ldb_schema_attribute_by_name(self, element_name);
3187         
3188                 if (a == NULL) {
3189                         return Py_None;
3190                 }
3191                 
3192                 if (a->syntax->ldif_write_fn(self, mem_ctx, &old_val, &new_val) != 0) {
3193                         talloc_free(mem_ctx);
3194                         return Py_None;
3195                  }
3196         
3197                 ret = PyString_FromStringAndSize((const char *)new_val.data, new_val.length);
3198                 
3199                 talloc_free(mem_ctx);
3200                 
3201                 return ret;
3202         }
3203 SWIGINTERN ldb_error ldb___contains__(ldb *self,ldb_dn *dn,struct ldb_result **result_as_bool){
3204             return ldb_search(self, dn, LDB_SCOPE_BASE, NULL, NULL, 
3205                              result_as_bool);
3206         }
3207 SWIGINTERN PyObject *ldb_parse_ldif(ldb *self,char const *s){
3208             PyObject *list = PyList_New(0);
3209             struct ldb_ldif *ldif;
3210             while ((ldif = ldb_ldif_read_string(self, &s)) != NULL) {
3211                 PyList_Append(list, ldb_ldif_to_pyobject(ldif));
3212             }
3213             return PyObject_GetIter(list);
3214         }
3215 SWIGINTERN char *ldb___repr__(ldb *self){
3216             char *ret;
3217             asprintf(&ret, "<ldb connection at 0x%x>", ret); 
3218             return ret;
3219         }
3220
3221 static char *timestring(time_t t)
3222 {
3223     char *tresult = ldb_timestring(NULL, t);
3224     char *result = strdup(tresult);
3225     talloc_free(tresult);
3226     return result; 
3227 }
3228
3229 #ifdef __cplusplus
3230 extern "C" {
3231 #endif
3232 SWIGINTERN PyObject *_wrap_ldb_val_to_py_object(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
3233   PyObject *resultobj = 0;
3234   struct ldb_context *arg1 = (struct ldb_context *) 0 ;
3235   struct ldb_message_element *arg2 = (struct ldb_message_element *) 0 ;
3236   struct ldb_val *arg3 = (struct ldb_val *) 0 ;
3237   void *argp1 = 0 ;
3238   int res1 = 0 ;
3239   void *argp2 = 0 ;
3240   int res2 = 0 ;
3241   void *argp3 = 0 ;
3242   int res3 = 0 ;
3243   PyObject * obj0 = 0 ;
3244   PyObject * obj1 = 0 ;
3245   PyObject * obj2 = 0 ;
3246   char *  kwnames[] = {
3247     (char *) "ldb_ctx",(char *) "el",(char *) "val", NULL 
3248   };
3249   PyObject *result = 0 ;
3250   
3251   if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:ldb_val_to_py_object",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
3252   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 |  0 );
3253   if (!SWIG_IsOK(res1)) {
3254     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_val_to_py_object" "', argument " "1"" of type '" "struct ldb_context *""'"); 
3255   }
3256   arg1 = (struct ldb_context *)(argp1);
3257   res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message_element, 0 |  0 );
3258   if (!SWIG_IsOK(res2)) {
3259     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_val_to_py_object" "', argument " "2"" of type '" "struct ldb_message_element *""'"); 
3260   }
3261   arg2 = (struct ldb_message_element *)(argp2);
3262   res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_ldb_val, 0 |  0 );
3263   if (!SWIG_IsOK(res3)) {
3264     SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ldb_val_to_py_object" "', argument " "3"" of type '" "struct ldb_val *""'"); 
3265   }
3266   arg3 = (struct ldb_val *)(argp3);
3267   if (arg1 == NULL)
3268   SWIG_exception(SWIG_ValueError, 
3269     "ldb context must be non-NULL");
3270   result = (PyObject *)ldb_val_to_py_object(arg1,arg2,arg3);
3271   resultobj = result;
3272   return resultobj;
3273 fail:
3274   return NULL;
3275 }
3276
3277
3278 SWIGINTERN PyObject *_wrap_new_Dn(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
3279   PyObject *resultobj = 0;
3280   ldb *arg1 = (ldb *) 0 ;
3281   char *arg2 = (char *) 0 ;
3282   void *argp1 = 0 ;
3283   int res1 = 0 ;
3284   int res2 ;
3285   char *buf2 = 0 ;
3286   int alloc2 = 0 ;
3287   PyObject * obj0 = 0 ;
3288   PyObject * obj1 = 0 ;
3289   char *  kwnames[] = {
3290     (char *) "ldb_ctx",(char *) "str", NULL 
3291   };
3292   ldb_dn *result = 0 ;
3293   
3294   if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:new_Dn",kwnames,&obj0,&obj1)) SWIG_fail;
3295   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 |  0 );
3296   if (!SWIG_IsOK(res1)) {
3297     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Dn" "', argument " "1"" of type '" "ldb *""'"); 
3298   }
3299   arg1 = (ldb *)(argp1);
3300   res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
3301   if (!SWIG_IsOK(res2)) {
3302     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Dn" "', argument " "2"" of type '" "char const *""'");
3303   }
3304   arg2 = (char *)(buf2);
3305   if (arg1 == NULL)
3306   SWIG_exception(SWIG_ValueError, 
3307     "ldb context must be non-NULL");
3308   result = (ldb_dn *)new_ldb_dn(arg1,(char const *)arg2);
3309   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_dn, SWIG_POINTER_NEW |  0 );
3310   if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3311   return resultobj;
3312 fail:
3313   if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3314   return NULL;
3315 }
3316
3317
3318 SWIGINTERN PyObject *_wrap_delete_Dn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
3319   PyObject *resultobj = 0;
3320   ldb_dn *arg1 = (ldb_dn *) 0 ;
3321   void *argp1 = 0 ;
3322   int res1 = 0 ;
3323   PyObject *swig_obj[1] ;
3324   
3325   if (!args) SWIG_fail;
3326   swig_obj[0] = args;
3327   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_dn, SWIG_POINTER_DISOWN |  0 );
3328   if (!SWIG_IsOK(res1)) {
3329     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Dn" "', argument " "1"" of type '" "ldb_dn *""'"); 
3330   }
3331   arg1 = (ldb_dn *)(argp1);
3332   delete_ldb_dn(arg1);
3333   resultobj = SWIG_Py_Void();
3334   return resultobj;
3335 fail:
3336   return NULL;
3337 }
3338
3339
3340 SWIGINTERN PyObject *_wrap_Dn_validate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
3341   PyObject *resultobj = 0;
3342   ldb_dn *arg1 = (ldb_dn *) 0 ;
3343   void *argp1 = 0 ;
3344   int res1 = 0 ;
3345   PyObject *swig_obj[1] ;
3346   bool result;
3347   
3348   if (!args) SWIG_fail;
3349   swig_obj[0] = args;
3350   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_dn, 0 |  0 );
3351   if (!SWIG_IsOK(res1)) {
3352     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dn_validate" "', argument " "1"" of type '" "ldb_dn *""'"); 
3353   }
3354   arg1 = (ldb_dn *)(argp1);
3355   result = (bool)ldb_dn_validate(arg1);
3356   resultobj = SWIG_From_bool((bool)(result));
3357   return resultobj;
3358 fail:
3359   return NULL;
3360 }
3361
3362
3363 SWIGINTERN PyObject *_wrap_Dn_get_casefold(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
3364   PyObject *resultobj = 0;
3365   ldb_dn *arg1 = (ldb_dn *) 0 ;
3366   void *argp1 = 0 ;
3367   int res1 = 0 ;
3368   PyObject *swig_obj[1] ;
3369   char *result = 0 ;
3370   
3371   if (!args) SWIG_fail;
3372   swig_obj[0] = args;
3373   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_dn, 0 |  0 );
3374   if (!SWIG_IsOK(res1)) {
3375     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dn_get_casefold" "', argument " "1"" of type '" "ldb_dn *""'"); 
3376   }
3377   arg1 = (ldb_dn *)(argp1);
3378   result = (char *)ldb_dn_get_casefold(arg1);
3379   resultobj = SWIG_FromCharPtr((const char *)result);
3380   return resultobj;
3381 fail:
3382   return NULL;
3383 }
3384
3385
3386 SWIGINTERN PyObject *_wrap_Dn___str__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
3387   PyObject *resultobj = 0;
3388   ldb_dn *arg1 = (ldb_dn *) 0 ;
3389   void *argp1 = 0 ;
3390   int res1 = 0 ;
3391   PyObject *swig_obj[1] ;
3392   char *result = 0 ;
3393   
3394   if (!args) SWIG_fail;
3395   swig_obj[0] = args;
3396   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_dn, 0 |  0 );
3397   if (!SWIG_IsOK(res1)) {
3398     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dn___str__" "', argument " "1"" of type '" "ldb_dn *""'"); 
3399   }
3400   arg1 = (ldb_dn *)(argp1);
3401   result = (char *)ldb_dn_get_linearized(arg1);
3402   resultobj = SWIG_FromCharPtr((const char *)result);
3403   return resultobj;
3404 fail:
3405   return NULL;
3406 }
3407
3408
3409 SWIGINTERN PyObject *_wrap_Dn_parent(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
3410   PyObject *resultobj = 0;
3411   ldb_dn *arg1 = (ldb_dn *) 0 ;
3412   void *argp1 = 0 ;
3413   int res1 = 0 ;
3414   PyObject *swig_obj[1] ;
3415   ldb_dn *result = 0 ;
3416   
3417   if (!args) SWIG_fail;
3418   swig_obj[0] = args;
3419   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_dn, 0 |  0 );
3420   if (!SWIG_IsOK(res1)) {
3421     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dn_parent" "', argument " "1"" of type '" "ldb_dn *""'"); 
3422   }
3423   arg1 = (ldb_dn *)(argp1);
3424   result = (ldb_dn *)ldb_dn_parent(arg1);
3425   resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_dn, 0 |  0 );
3426   return resultobj;
3427 fail:
3428   return NULL;
3429 }
3430
3431
3432 SWIGINTERN PyObject *_wrap_Dn___cmp__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
3433   PyObject *resultobj = 0;
3434   ldb_dn *arg1 = (ldb_dn *) 0 ;
3435   ldb_dn *arg2 = (ldb_dn *) 0 ;
3436   void *argp1 = 0 ;
3437   int res1 = 0 ;
3438   void *argp2 = 0 ;
3439   int res2 = 0 ;
3440   PyObject * obj0 = 0 ;
3441   PyObject * obj1 = 0 ;
3442   char *  kwnames[] = {
3443     (char *) "self",(char *) "other", NULL 
3444   };
3445   int result;
3446   
3447   if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Dn___cmp__",kwnames,&obj0,&obj1)) SWIG_fail;
3448   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_dn, 0 |  0 );
3449   if (!SWIG_IsOK(res1)) {
3450     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dn___cmp__" "', argument " "1"" of type '" "ldb_dn *""'"); 
3451   }
3452   arg1 = (ldb_dn *)(argp1);
3453   res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_dn, 0 |  0 );
3454   if (!SWIG_IsOK(res2)) {
3455     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Dn___cmp__" "', argument " "2"" of type '" "ldb_dn *""'"); 
3456   }
3457   arg2 = (ldb_dn *)(argp2);
3458   result = (int)ldb_dn_compare(arg1,arg2);
3459   resultobj = SWIG_From_int((int)(result));
3460   return resultobj;
3461 fail:
3462   return NULL;
3463 }
3464
3465
3466 SWIGINTERN PyObject *_wrap_Dn_is_valid(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
3467   PyObject *resultobj = 0;
3468   ldb_dn *arg1 = (ldb_dn *) 0 ;
3469   void *argp1 = 0 ;
3470   int res1 = 0 ;
3471   PyObject *swig_obj[1] ;
3472   bool result;
3473   
3474   if (!args) SWIG_fail;
3475   swig_obj[0] = args;
3476   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_dn, 0 |  0 );
3477   if (!SWIG_IsOK(res1)) {
3478     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dn_is_valid" "', argument " "1"" of type '" "ldb_dn *""'"); 
3479   }
3480   arg1 = (ldb_dn *)(argp1);
3481   result = (bool)ldb_dn_is_valid(arg1);
3482   resultobj = SWIG_From_bool((bool)(result));
3483   return resultobj;
3484 fail:
3485   return NULL;
3486 }
3487
3488
3489 SWIGINTERN PyObject *_wrap_Dn_is_special(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
3490   PyObject *resultobj = 0;
3491   ldb_dn *arg1 = (ldb_dn *) 0 ;
3492   void *argp1 = 0 ;
3493   int res1 = 0 ;
3494   PyObject *swig_obj[1] ;
3495   bool result;
3496   
3497   if (!args) SWIG_fail;
3498   swig_obj[0] = args;
3499   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_dn, 0 |  0 );
3500   if (!SWIG_IsOK(res1)) {
3501     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dn_is_special" "', argument " "1"" of type '" "ldb_dn *""'"); 
3502   }
3503   arg1 = (ldb_dn *)(argp1);
3504   result = (bool)ldb_dn_is_special(arg1);
3505   resultobj = SWIG_From_bool((bool)(result));
3506   return resultobj;
3507 fail:
3508   return NULL;
3509 }
3510
3511
3512 SWIGINTERN PyObject *_wrap_Dn_is_null(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
3513   PyObject *resultobj = 0;
3514   ldb_dn *arg1 = (ldb_dn *) 0 ;
3515   void *argp1 = 0 ;
3516   int res1 = 0 ;
3517   PyObject *swig_obj[1] ;
3518   bool result;
3519   
3520   if (!args) SWIG_fail;
3521   swig_obj[0] = args;
3522   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_dn, 0 |  0 );
3523   if (!SWIG_IsOK(res1)) {
3524     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dn_is_null" "', argument " "1"" of type '" "ldb_dn *""'"); 
3525   }
3526   arg1 = (ldb_dn *)(argp1);
3527   result = (bool)ldb_dn_is_null(arg1);
3528   resultobj = SWIG_From_bool((bool)(result));
3529   return resultobj;
3530 fail:
3531   return NULL;
3532 }
3533
3534
3535 SWIGINTERN PyObject *_wrap_Dn_check_special(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
3536   PyObject *resultobj = 0;
3537   ldb_dn *arg1 = (ldb_dn *) 0 ;
3538   char *arg2 = (char *) 0 ;
3539   void *argp1 = 0 ;
3540   int res1 = 0 ;
3541   int res2 ;
3542   char *buf2 = 0 ;
3543   int alloc2 = 0 ;
3544   PyObject * obj0 = 0 ;
3545   PyObject * obj1 = 0 ;
3546   char *  kwnames[] = {
3547     (char *) "self",(char *) "name", NULL 
3548   };
3549   bool result;
3550   
3551   if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Dn_check_special",kwnames,&obj0,&obj1)) SWIG_fail;
3552   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_dn, 0 |  0 );
3553   if (!SWIG_IsOK(res1)) {
3554     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dn_check_special" "', argument " "1"" of type '" "ldb_dn *""'"); 
3555   }
3556   arg1 = (ldb_dn *)(argp1);
3557   res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
3558   if (!SWIG_IsOK(res2)) {
3559     SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Dn_check_special" "', argument " "2"" of type '" "char const *""'");
3560   }
3561   arg2 = (char *)(buf2);
3562   result = (bool)ldb_dn_check_special(arg1,(char const *)arg2);
3563   resultobj = SWIG_From_bool((bool)(result));
3564   if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3565   return resultobj;
3566 fail:
3567   if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
3568   return NULL;
3569 }
3570
3571
3572 SWIGINTERN PyObject *_wrap_Dn___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
3573   PyObject *resultobj = 0;
3574   ldb_dn *arg1 = (ldb_dn *) 0 ;
3575   void *argp1 = 0 ;
3576   int res1 = 0 ;
3577   PyObject *swig_obj[1] ;
3578   int result;
3579   
3580   if (!args) SWIG_fail;
3581   swig_obj[0] = args;
3582   res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_dn, 0 |  0 );