1800253a9ada921396e2caeabbfe82f4bc81339c
[debian/amanda] / perl / Amanda / Tapelist.c
1 /* ----------------------------------------------------------------------------
2  * This file was automatically generated by SWIG (http://www.swig.org).
3  * Version 2.0.4
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 #include "../config/config.h"
12
13
14 #define SWIGPERL
15 #define SWIG_CASTRANK_MODE
16
17 /* -----------------------------------------------------------------------------
18  *  This section contains generic SWIG labels for method/variable
19  *  declarations/attributes, and other compiler dependent labels.
20  * ----------------------------------------------------------------------------- */
21
22 /* template workaround for compilers that cannot correctly implement the C++ standard */
23 #ifndef SWIGTEMPLATEDISAMBIGUATOR
24 # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
25 #  define SWIGTEMPLATEDISAMBIGUATOR template
26 # elif defined(__HP_aCC)
27 /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
28 /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
29 #  define SWIGTEMPLATEDISAMBIGUATOR template
30 # else
31 #  define SWIGTEMPLATEDISAMBIGUATOR
32 # endif
33 #endif
34
35 /* inline attribute */
36 #ifndef SWIGINLINE
37 # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
38 #   define SWIGINLINE inline
39 # else
40 #   define SWIGINLINE
41 # endif
42 #endif
43
44 /* attribute recognised by some compilers to avoid 'unused' warnings */
45 #ifndef SWIGUNUSED
46 # if defined(__GNUC__)
47 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
48 #     define SWIGUNUSED __attribute__ ((__unused__)) 
49 #   else
50 #     define SWIGUNUSED
51 #   endif
52 # elif defined(__ICC)
53 #   define SWIGUNUSED __attribute__ ((__unused__)) 
54 # else
55 #   define SWIGUNUSED 
56 # endif
57 #endif
58
59 #ifndef SWIG_MSC_UNSUPPRESS_4505
60 # if defined(_MSC_VER)
61 #   pragma warning(disable : 4505) /* unreferenced local function has been removed */
62 # endif 
63 #endif
64
65 #ifndef SWIGUNUSEDPARM
66 # ifdef __cplusplus
67 #   define SWIGUNUSEDPARM(p)
68 # else
69 #   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
70 # endif
71 #endif
72
73 /* internal SWIG method */
74 #ifndef SWIGINTERN
75 # define SWIGINTERN static SWIGUNUSED
76 #endif
77
78 /* internal inline SWIG method */
79 #ifndef SWIGINTERNINLINE
80 # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
81 #endif
82
83 /* exporting methods */
84 #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
85 #  ifndef GCC_HASCLASSVISIBILITY
86 #    define GCC_HASCLASSVISIBILITY
87 #  endif
88 #endif
89
90 #ifndef SWIGEXPORT
91 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
92 #   if defined(STATIC_LINKED)
93 #     define SWIGEXPORT
94 #   else
95 #     define SWIGEXPORT __declspec(dllexport)
96 #   endif
97 # else
98 #   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
99 #     define SWIGEXPORT __attribute__ ((visibility("default")))
100 #   else
101 #     define SWIGEXPORT
102 #   endif
103 # endif
104 #endif
105
106 /* calling conventions for Windows */
107 #ifndef SWIGSTDCALL
108 # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
109 #   define SWIGSTDCALL __stdcall
110 # else
111 #   define SWIGSTDCALL
112 # endif 
113 #endif
114
115 /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
116 #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
117 # define _CRT_SECURE_NO_DEPRECATE
118 #endif
119
120 /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
121 #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
122 # define _SCL_SECURE_NO_DEPRECATE
123 #endif
124
125
126 /* -----------------------------------------------------------------------------
127  * swigrun.swg
128  *
129  * This file contains generic C API 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 strictly necessary, ie, if you have problems
152   with your compiler or suchlike.
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 an 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 versions of SWIG, code such as the following was usually written:
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:
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    which is the same really, 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    also requires SWIG_ConvertPtr to return new result values, such 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 #define SWIG_OK                    (0) 
256 #define SWIG_ERROR                 (-1)
257 #define SWIG_IsOK(r)               (r >= 0)
258 #define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)  
259
260 /* The CastRankLimit says how many bits are used for the cast rank */
261 #define SWIG_CASTRANKLIMIT         (1 << 8)
262 /* The NewMask denotes the object was created (using new/malloc) */
263 #define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
264 /* The TmpMask is for in/out typemaps that use temporal objects */
265 #define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
266 /* Simple returning values */
267 #define SWIG_BADOBJ                (SWIG_ERROR)
268 #define SWIG_OLDOBJ                (SWIG_OK)
269 #define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
270 #define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
271 /* Check, add and del mask methods */
272 #define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
273 #define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
274 #define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
275 #define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
276 #define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
277 #define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
278
279 /* Cast-Rank Mode */
280 #if defined(SWIG_CASTRANK_MODE)
281 #  ifndef SWIG_TypeRank
282 #    define SWIG_TypeRank             unsigned long
283 #  endif
284 #  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
285 #    define SWIG_MAXCASTRANK          (2)
286 #  endif
287 #  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
288 #  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
289 SWIGINTERNINLINE int SWIG_AddCast(int r) { 
290   return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
291 }
292 SWIGINTERNINLINE int SWIG_CheckState(int r) { 
293   return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 
294 }
295 #else /* no cast-rank mode */
296 #  define SWIG_AddCast
297 #  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
298 #endif
299
300
301 #include <string.h>
302
303 #ifdef __cplusplus
304 extern "C" {
305 #endif
306
307 typedef void *(*swig_converter_func)(void *, int *);
308 typedef struct swig_type_info *(*swig_dycast_func)(void **);
309
310 /* Structure to store information on one type */
311 typedef struct swig_type_info {
312   const char             *name;                 /* mangled name of this type */
313   const char             *str;                  /* human readable name of this type */
314   swig_dycast_func        dcast;                /* dynamic cast function down a hierarchy */
315   struct swig_cast_info  *cast;                 /* linked list of types that can cast into this type */
316   void                   *clientdata;           /* language specific type data */
317   int                    owndata;               /* flag if the structure owns the clientdata */
318 } swig_type_info;
319
320 /* Structure to store a type and conversion function used for casting */
321 typedef struct swig_cast_info {
322   swig_type_info         *type;                 /* pointer to type that is equivalent to this type */
323   swig_converter_func     converter;            /* function to cast the void pointers */
324   struct swig_cast_info  *next;                 /* pointer to next cast in linked list */
325   struct swig_cast_info  *prev;                 /* pointer to the previous cast */
326 } swig_cast_info;
327
328 /* Structure used to store module information
329  * Each module generates one structure like this, and the runtime collects
330  * all of these structures and stores them in a circularly linked list.*/
331 typedef struct swig_module_info {
332   swig_type_info         **types;               /* Array of pointers to swig_type_info structures that are in this module */
333   size_t                 size;                  /* Number of types in this module */
334   struct swig_module_info *next;                /* Pointer to next element in circularly linked list */
335   swig_type_info         **type_initial;        /* Array of initially generated type structures */
336   swig_cast_info         **cast_initial;        /* Array of initially generated casting structures */
337   void                    *clientdata;          /* Language specific module data */
338 } swig_module_info;
339
340 /* 
341   Compare two type names skipping the space characters, therefore
342   "char*" == "char *" and "Class<int>" == "Class<int >", etc.
343
344   Return 0 when the two name types are equivalent, as in
345   strncmp, but skipping ' '.
346 */
347 SWIGRUNTIME int
348 SWIG_TypeNameComp(const char *f1, const char *l1,
349                   const char *f2, const char *l2) {
350   for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
351     while ((*f1 == ' ') && (f1 != l1)) ++f1;
352     while ((*f2 == ' ') && (f2 != l2)) ++f2;
353     if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
354   }
355   return (int)((l1 - f1) - (l2 - f2));
356 }
357
358 /*
359   Check type equivalence in a name list like <name1>|<name2>|...
360   Return 0 if not equal, 1 if equal
361 */
362 SWIGRUNTIME int
363 SWIG_TypeEquiv(const char *nb, const char *tb) {
364   int equiv = 0;
365   const char* te = tb + strlen(tb);
366   const char* ne = nb;
367   while (!equiv && *ne) {
368     for (nb = ne; *ne; ++ne) {
369       if (*ne == '|') break;
370     }
371     equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
372     if (*ne) ++ne;
373   }
374   return equiv;
375 }
376
377 /*
378   Check type equivalence in a name list like <name1>|<name2>|...
379   Return 0 if equal, -1 if nb < tb, 1 if nb > tb
380 */
381 SWIGRUNTIME int
382 SWIG_TypeCompare(const char *nb, const char *tb) {
383   int equiv = 0;
384   const char* te = tb + strlen(tb);
385   const char* ne = nb;
386   while (!equiv && *ne) {
387     for (nb = ne; *ne; ++ne) {
388       if (*ne == '|') break;
389     }
390     equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
391     if (*ne) ++ne;
392   }
393   return equiv;
394 }
395
396
397 /*
398   Check the typename
399 */
400 SWIGRUNTIME swig_cast_info *
401 SWIG_TypeCheck(const char *c, swig_type_info *ty) {
402   if (ty) {
403     swig_cast_info *iter = ty->cast;
404     while (iter) {
405       if (strcmp(iter->type->name, c) == 0) {
406         if (iter == ty->cast)
407           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 /* 
425   Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
426 */
427 SWIGRUNTIME swig_cast_info *
428 SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
429   if (ty) {
430     swig_cast_info *iter = ty->cast;
431     while (iter) {
432       if (iter->type == from) {
433         if (iter == ty->cast)
434           return iter;
435         /* Move iter to the top of the linked list */
436         iter->prev->next = iter->next;
437         if (iter->next)
438           iter->next->prev = iter->prev;
439         iter->next = ty->cast;
440         iter->prev = 0;
441         if (ty->cast) ty->cast->prev = iter;
442         ty->cast = iter;
443         return iter;
444       }
445       iter = iter->next;
446     }
447   }
448   return 0;
449 }
450
451 /*
452   Cast a pointer up an inheritance hierarchy
453 */
454 SWIGRUNTIMEINLINE void *
455 SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
456   return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
457 }
458
459 /* 
460    Dynamic pointer casting. Down an inheritance hierarchy
461 */
462 SWIGRUNTIME swig_type_info *
463 SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
464   swig_type_info *lastty = ty;
465   if (!ty || !ty->dcast) return ty;
466   while (ty && (ty->dcast)) {
467     ty = (*ty->dcast)(ptr);
468     if (ty) lastty = ty;
469   }
470   return lastty;
471 }
472
473 /*
474   Return the name associated with this type
475 */
476 SWIGRUNTIMEINLINE const char *
477 SWIG_TypeName(const swig_type_info *ty) {
478   return ty->name;
479 }
480
481 /*
482   Return the pretty name associated with this type,
483   that is an unmangled type name in a form presentable to the user.
484 */
485 SWIGRUNTIME const char *
486 SWIG_TypePrettyName(const swig_type_info *type) {
487   /* The "str" field contains the equivalent pretty names of the
488      type, separated by vertical-bar characters.  We choose
489      to print the last name, as it is often (?) the most
490      specific. */
491   if (!type) return NULL;
492   if (type->str != NULL) {
493     const char *last_name = type->str;
494     const char *s;
495     for (s = type->str; *s; s++)
496       if (*s == '|') last_name = s+1;
497     return last_name;
498   }
499   else
500     return type->name;
501 }
502
503 /* 
504    Set the clientdata field for a type
505 */
506 SWIGRUNTIME void
507 SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
508   swig_cast_info *cast = ti->cast;
509   /* if (ti->clientdata == clientdata) return; */
510   ti->clientdata = clientdata;
511   
512   while (cast) {
513     if (!cast->converter) {
514       swig_type_info *tc = cast->type;
515       if (!tc->clientdata) {
516         SWIG_TypeClientData(tc, clientdata);
517       }
518     }    
519     cast = cast->next;
520   }
521 }
522 SWIGRUNTIME void
523 SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
524   SWIG_TypeClientData(ti, clientdata);
525   ti->owndata = 1;
526 }
527   
528 /*
529   Search for a swig_type_info structure only by mangled name
530   Search is a O(log #types)
531   
532   We start searching at module start, and finish searching when start == end.  
533   Note: if start == end at the beginning of the function, we go all the way around
534   the circular list.
535 */
536 SWIGRUNTIME swig_type_info *
537 SWIG_MangledTypeQueryModule(swig_module_info *start, 
538                             swig_module_info *end, 
539                             const char *name) {
540   swig_module_info *iter = start;
541   do {
542     if (iter->size) {
543       register size_t l = 0;
544       register size_t r = iter->size - 1;
545       do {
546         /* since l+r >= 0, we can (>> 1) instead (/ 2) */
547         register size_t i = (l + r) >> 1; 
548         const char *iname = iter->types[i]->name;
549         if (iname) {
550           register int compare = strcmp(name, iname);
551           if (compare == 0) {       
552             return iter->types[i];
553           } else if (compare < 0) {
554             if (i) {
555               r = i - 1;
556             } else {
557               break;
558             }
559           } else if (compare > 0) {
560             l = i + 1;
561           }
562         } else {
563           break; /* should never happen */
564         }
565       } while (l <= r);
566     }
567     iter = iter->next;
568   } while (iter != end);
569   return 0;
570 }
571
572 /*
573   Search for a swig_type_info structure for either a mangled name or a human readable name.
574   It first searches the mangled names of the types, which is a O(log #types)
575   If a type is not found it then searches the human readable names, which is O(#types).
576   
577   We start searching at module start, and finish searching when start == end.  
578   Note: if start == end at the beginning of the function, we go all the way around
579   the circular list.
580 */
581 SWIGRUNTIME swig_type_info *
582 SWIG_TypeQueryModule(swig_module_info *start, 
583                      swig_module_info *end, 
584                      const char *name) {
585   /* STEP 1: Search the name field using binary search */
586   swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
587   if (ret) {
588     return ret;
589   } else {
590     /* STEP 2: If the type hasn't been found, do a complete search
591        of the str field (the human readable name) */
592     swig_module_info *iter = start;
593     do {
594       register size_t i = 0;
595       for (; i < iter->size; ++i) {
596         if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
597           return iter->types[i];
598       }
599       iter = iter->next;
600     } while (iter != end);
601   }
602   
603   /* neither found a match */
604   return 0;
605 }
606
607 /* 
608    Pack binary data into a string
609 */
610 SWIGRUNTIME char *
611 SWIG_PackData(char *c, void *ptr, size_t sz) {
612   static const char hex[17] = "0123456789abcdef";
613   register const unsigned char *u = (unsigned char *) ptr;
614   register const unsigned char *eu =  u + sz;
615   for (; u != eu; ++u) {
616     register unsigned char uu = *u;
617     *(c++) = hex[(uu & 0xf0) >> 4];
618     *(c++) = hex[uu & 0xf];
619   }
620   return c;
621 }
622
623 /* 
624    Unpack binary data from a string
625 */
626 SWIGRUNTIME const char *
627 SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
628   register unsigned char *u = (unsigned char *) ptr;
629   register const unsigned char *eu = u + sz;
630   for (; u != eu; ++u) {
631     register char d = *(c++);
632     register unsigned char uu;
633     if ((d >= '0') && (d <= '9'))
634       uu = ((d - '0') << 4);
635     else if ((d >= 'a') && (d <= 'f'))
636       uu = ((d - ('a'-10)) << 4);
637     else 
638       return (char *) 0;
639     d = *(c++);
640     if ((d >= '0') && (d <= '9'))
641       uu |= (d - '0');
642     else if ((d >= 'a') && (d <= 'f'))
643       uu |= (d - ('a'-10));
644     else 
645       return (char *) 0;
646     *u = uu;
647   }
648   return c;
649 }
650
651 /* 
652    Pack 'void *' into a string buffer.
653 */
654 SWIGRUNTIME char *
655 SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
656   char *r = buff;
657   if ((2*sizeof(void *) + 2) > bsz) return 0;
658   *(r++) = '_';
659   r = SWIG_PackData(r,&ptr,sizeof(void *));
660   if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
661   strcpy(r,name);
662   return buff;
663 }
664
665 SWIGRUNTIME const char *
666 SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
667   if (*c != '_') {
668     if (strcmp(c,"NULL") == 0) {
669       *ptr = (void *) 0;
670       return name;
671     } else {
672       return 0;
673     }
674   }
675   return SWIG_UnpackData(++c,ptr,sizeof(void *));
676 }
677
678 SWIGRUNTIME char *
679 SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
680   char *r = buff;
681   size_t lname = (name ? strlen(name) : 0);
682   if ((2*sz + 2 + lname) > bsz) return 0;
683   *(r++) = '_';
684   r = SWIG_PackData(r,ptr,sz);
685   if (lname) {
686     strncpy(r,name,lname+1);
687   } else {
688     *r = 0;
689   }
690   return buff;
691 }
692
693 SWIGRUNTIME const char *
694 SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
695   if (*c != '_') {
696     if (strcmp(c,"NULL") == 0) {
697       memset(ptr,0,sz);
698       return name;
699     } else {
700       return 0;
701     }
702   }
703   return SWIG_UnpackData(++c,ptr,sz);
704 }
705
706 #ifdef __cplusplus
707 }
708 #endif
709
710 /*  Errors in SWIG */
711 #define  SWIG_UnknownError         -1 
712 #define  SWIG_IOError              -2 
713 #define  SWIG_RuntimeError         -3 
714 #define  SWIG_IndexError           -4 
715 #define  SWIG_TypeError            -5 
716 #define  SWIG_DivisionByZero       -6 
717 #define  SWIG_OverflowError        -7 
718 #define  SWIG_SyntaxError          -8 
719 #define  SWIG_ValueError           -9 
720 #define  SWIG_SystemError          -10
721 #define  SWIG_AttributeError       -11
722 #define  SWIG_MemoryError          -12 
723 #define  SWIG_NullReferenceError   -13
724
725
726
727 #ifdef __cplusplus
728 /* Needed on some windows machines---since MS plays funny games with the header files under C++ */
729 #include <math.h>
730 #include <stdlib.h>
731 extern "C" {
732 #endif
733 #include "EXTERN.h"
734 #include "perl.h"
735 #include "XSUB.h"
736
737 /* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */
738
739 /* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */
740 #ifndef PERL_REVISION
741 #  if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION))
742 #    define PERL_PATCHLEVEL_H_IMPLICIT
743 #    include <patchlevel.h>
744 #  endif
745 #  if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL)))
746 #    include <could_not_find_Perl_patchlevel.h>
747 #  endif
748 #  ifndef PERL_REVISION
749 #    define PERL_REVISION       (5)
750 #    define PERL_VERSION        PATCHLEVEL
751 #    define PERL_SUBVERSION     SUBVERSION
752 #  endif
753 #endif
754
755 #if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE)
756 #define PerlIO_exportFILE(fh,fl) (FILE*)(fh)
757 #endif
758
759 #ifndef SvIOK_UV
760 # define SvIOK_UV(sv)       (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv)))
761 #endif
762
763 #ifndef SvUOK
764 # define SvUOK(sv)           SvIOK_UV(sv)
765 #endif
766
767 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5)))
768 #  define PL_sv_undef               sv_undef
769 #  define PL_na                     na
770 #  define PL_errgv                  errgv
771 #  define PL_sv_no                  sv_no
772 #  define PL_sv_yes                 sv_yes
773 #  define PL_markstack_ptr          markstack_ptr
774 #endif
775
776 #ifndef IVSIZE
777 #  ifdef LONGSIZE
778 #    define IVSIZE LONGSIZE
779 #  else
780 #    define IVSIZE 4 /* A bold guess, but the best we can make. */
781 #  endif
782 #endif
783
784 #ifndef INT2PTR
785 #  if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
786 #    define PTRV                  UV
787 #    define INT2PTR(any,d)        (any)(d)
788 #  else
789 #    if PTRSIZE == LONGSIZE
790 #      define PTRV                unsigned long
791 #    else
792 #      define PTRV                unsigned
793 #    endif
794 #    define INT2PTR(any,d)        (any)(PTRV)(d)
795 #  endif
796
797 #  define NUM2PTR(any,d)  (any)(PTRV)(d)
798 #  define PTR2IV(p)       INT2PTR(IV,p)
799 #  define PTR2UV(p)       INT2PTR(UV,p)
800 #  define PTR2NV(p)       NUM2PTR(NV,p)
801
802 #  if PTRSIZE == LONGSIZE
803 #    define PTR2ul(p)     (unsigned long)(p)
804 #  else
805 #    define PTR2ul(p)     INT2PTR(unsigned long,p)
806 #  endif
807 #endif /* !INT2PTR */
808
809 #ifndef SvPV_nolen
810 # define SvPV_nolen(x) SvPV(x,PL_na)
811 #endif
812
813 #ifndef get_sv
814 #  define get_sv perl_get_sv
815 #endif
816
817 #ifndef ERRSV
818 #  define ERRSV get_sv("@",FALSE)
819 #endif
820
821 #ifndef pTHX_
822 #define pTHX_
823 #endif   
824
825 #include <string.h>
826 #ifdef __cplusplus
827 }
828 #endif
829
830 /* -----------------------------------------------------------------------------
831  * error manipulation
832  * ----------------------------------------------------------------------------- */
833
834 SWIGINTERN const char*
835 SWIG_Perl_ErrorType(int code) {
836   const char* type = 0;
837   switch(code) {
838   case SWIG_MemoryError:
839     type = "MemoryError";
840     break;
841   case SWIG_IOError:
842     type = "IOError";
843     break;
844   case SWIG_RuntimeError:
845     type = "RuntimeError";
846     break;
847   case SWIG_IndexError:
848     type = "IndexError";
849     break;
850   case SWIG_TypeError:
851     type = "TypeError";
852     break;
853   case SWIG_DivisionByZero:
854     type = "ZeroDivisionError";
855     break;
856   case SWIG_OverflowError:
857     type = "OverflowError";
858     break;
859   case SWIG_SyntaxError:
860     type = "SyntaxError";
861     break;
862   case SWIG_ValueError:
863     type = "ValueError";
864     break;
865   case SWIG_SystemError:
866     type = "SystemError";
867     break;
868   case SWIG_AttributeError:
869     type = "AttributeError";
870     break;
871   default:
872     type = "RuntimeError";
873   }
874   return type;
875 }
876
877
878
879
880 /* -----------------------------------------------------------------------------
881  * perlrun.swg
882  *
883  * This file contains the runtime support for Perl modules
884  * and includes code for managing global variables and pointer
885  * type checking.
886  * ----------------------------------------------------------------------------- */
887
888 #ifdef PERL_OBJECT
889 #define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl),
890 #define SWIG_PERL_OBJECT_CALL pPerl,
891 #else
892 #define SWIG_PERL_OBJECT_DECL
893 #define SWIG_PERL_OBJECT_CALL
894 #endif
895
896 /* Common SWIG API */
897
898 /* for raw pointers */
899 #define SWIG_ConvertPtr(obj, pp, type, flags)           SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags)
900 #define SWIG_ConvertPtrAndOwn(obj, pp, type, flags,own) SWIG_Perl_ConvertPtrAndOwn(SWIG_PERL_OBJECT_CALL obj, pp, type, flags, own)
901 #define SWIG_NewPointerObj(p, type, flags)              SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags)
902
903 /* for raw packed data */
904 #define SWIG_ConvertPacked(obj, p, s, type)             SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type)
905 #define SWIG_NewPackedObj(p, s, type)                   SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type)
906
907 /* for class or struct pointers */
908 #define SWIG_ConvertInstance(obj, pptr, type, flags)    SWIG_ConvertPtr(obj, pptr, type, flags)
909 #define SWIG_NewInstanceObj(ptr, type, flags)           SWIG_NewPointerObj(ptr, type, flags)
910
911 /* for C or C++ function pointers */
912 #define SWIG_ConvertFunctionPtr(obj, pptr, type)        SWIG_ConvertPtr(obj, pptr, type, 0)
913 #define SWIG_NewFunctionPtrObj(ptr, type)               SWIG_NewPointerObj(ptr, type, 0)
914
915 /* for C++ member pointers, ie, member methods */
916 #define SWIG_ConvertMember(obj, ptr, sz, ty)            SWIG_ConvertPacked(obj, ptr, sz, ty)
917 #define SWIG_NewMemberObj(ptr, sz, type)                SWIG_NewPackedObj(ptr, sz, type)
918
919
920 /* Runtime API */
921
922 #define SWIG_GetModule(clientdata)                      SWIG_Perl_GetModule()
923 #define SWIG_SetModule(clientdata, pointer)             SWIG_Perl_SetModule(pointer)
924
925
926 /* Error manipulation */
927
928 #define SWIG_ErrorType(code)                            SWIG_Perl_ErrorType(code)               
929 #define SWIG_Error(code, msg)                           sv_setpvf(GvSV(PL_errgv),"%s %s\n", SWIG_ErrorType(code), msg)
930 #define SWIG_fail                                       goto fail                                                   
931
932 /* Perl-specific SWIG API */
933
934 #define SWIG_MakePtr(sv, ptr, type, flags)              SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags)
935 #define SWIG_MakePackedObj(sv, p, s, type)              SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type)
936 #define SWIG_SetError(str)                              SWIG_Error(SWIG_RuntimeError, str)
937
938
939 #define SWIG_PERL_DECL_ARGS_1(arg1)                     (SWIG_PERL_OBJECT_DECL arg1)
940 #define SWIG_PERL_CALL_ARGS_1(arg1)                     (SWIG_PERL_OBJECT_CALL arg1)
941 #define SWIG_PERL_DECL_ARGS_2(arg1, arg2)               (SWIG_PERL_OBJECT_DECL arg1, arg2)
942 #define SWIG_PERL_CALL_ARGS_2(arg1, arg2)               (SWIG_PERL_OBJECT_CALL arg1, arg2)
943
944 /* -----------------------------------------------------------------------------
945  * pointers/data manipulation
946  * ----------------------------------------------------------------------------- */
947
948 /* For backward compatibility only */
949 #define SWIG_POINTER_EXCEPTION  0
950
951 #ifdef __cplusplus
952 extern "C" {
953 #endif
954
955 #define SWIG_OWNER   SWIG_POINTER_OWN
956 #define SWIG_SHADOW  SWIG_OWNER << 1
957
958 #define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL
959
960 /* SWIG Perl macros */
961
962 /* Macro to declare an XS function */
963 #ifndef XSPROTO
964 #   define XSPROTO(name) void name(pTHX_ CV* cv)
965 #endif
966
967 /* Macro to call an XS function */
968 #ifdef PERL_OBJECT 
969 #  define SWIG_CALLXS(_name) _name(cv,pPerl) 
970 #else 
971 #  ifndef MULTIPLICITY 
972 #    define SWIG_CALLXS(_name) _name(cv) 
973 #  else 
974 #    define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv) 
975 #  endif 
976 #endif 
977
978 #ifdef PERL_OBJECT
979 #define MAGIC_PPERL  CPerlObj *pPerl = (CPerlObj *) this;
980
981 #ifdef __cplusplus
982 extern "C" {
983 #endif
984 typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *);
985 #ifdef __cplusplus
986 }
987 #endif
988
989 #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
990 #define SWIGCLASS_STATIC
991
992 #else /* PERL_OBJECT */
993
994 #define MAGIC_PPERL
995 #define SWIGCLASS_STATIC static SWIGUNUSED
996
997 #ifndef MULTIPLICITY
998 #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
999
1000 #ifdef __cplusplus
1001 extern "C" {
1002 #endif
1003 typedef int (*SwigMagicFunc)(SV *, MAGIC *);
1004 #ifdef __cplusplus
1005 }
1006 #endif
1007
1008 #else /* MULTIPLICITY */
1009
1010 #define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b)
1011
1012 #ifdef __cplusplus
1013 extern "C" {
1014 #endif
1015 typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *);
1016 #ifdef __cplusplus
1017 }
1018 #endif
1019
1020 #endif /* MULTIPLICITY */
1021 #endif /* PERL_OBJECT */
1022
1023 /* Workaround for bug in perl 5.6.x croak and earlier */
1024 #if (PERL_VERSION < 8)
1025 #  ifdef PERL_OBJECT
1026 #    define SWIG_croak_null() SWIG_Perl_croak_null(pPerl)
1027 static void SWIG_Perl_croak_null(CPerlObj *pPerl)
1028 #  else
1029 static void SWIG_croak_null()
1030 #  endif
1031 {
1032   SV *err=ERRSV;
1033 #  if (PERL_VERSION < 6)
1034   croak("%_", err);
1035 #  else
1036   if (SvOK(err) && !SvROK(err)) croak("%_", err);
1037   croak(Nullch);
1038 #  endif
1039 }
1040 #else
1041 #  define SWIG_croak_null() croak(Nullch)
1042 #endif
1043
1044
1045 /* 
1046    Define how strict is the cast between strings and integers/doubles
1047    when overloading between these types occurs.
1048    
1049    The default is making it as strict as possible by using SWIG_AddCast
1050    when needed.
1051    
1052    You can use -DSWIG_PERL_NO_STRICT_STR2NUM at compilation time to
1053    disable the SWIG_AddCast, making the casting between string and
1054    numbers less strict.
1055
1056    In the end, we try to solve the overloading between strings and
1057    numerical types in the more natural way, but if you can avoid it,
1058    well, avoid it using %rename, for example.
1059 */
1060 #ifndef SWIG_PERL_NO_STRICT_STR2NUM
1061 # ifndef SWIG_PERL_STRICT_STR2NUM
1062 #  define SWIG_PERL_STRICT_STR2NUM
1063 # endif
1064 #endif
1065 #ifdef SWIG_PERL_STRICT_STR2NUM
1066 /* string takes precedence */
1067 #define SWIG_Str2NumCast(x) SWIG_AddCast(x)  
1068 #else
1069 /* number takes precedence */
1070 #define SWIG_Str2NumCast(x) x
1071 #endif
1072
1073
1074
1075 #include <stdlib.h>
1076
1077 SWIGRUNTIME const char *
1078 SWIG_Perl_TypeProxyName(const swig_type_info *type) {
1079   if (!type) return NULL;
1080   if (type->clientdata != NULL) {
1081     return (const char*) type->clientdata;
1082   } 
1083   else {
1084     return type->name;
1085   }
1086 }
1087
1088 /* Identical to SWIG_TypeCheck, except for strcmp comparison */
1089 SWIGRUNTIME swig_cast_info *
1090 SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) {
1091   if (ty) {
1092     swig_cast_info *iter = ty->cast;
1093     while (iter) {
1094       if ( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) ||
1095             (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0)) ) {
1096         if (iter == ty->cast)
1097           return iter;
1098         /* Move iter to the top of the linked list */
1099         iter->prev->next = iter->next;
1100         if (iter->next)
1101           iter->next->prev = iter->prev;
1102         iter->next = ty->cast;
1103         iter->prev = 0;
1104         if (ty->cast) ty->cast->prev = iter;
1105         ty->cast = iter;
1106         return iter;
1107       }
1108       iter = iter->next;
1109     }
1110   }
1111   return 0;
1112 }
1113
1114 /* Function for getting a pointer value */
1115
1116 SWIGRUNTIME int
1117 SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags, int *own) {
1118   swig_cast_info *tc;
1119   void *voidptr = (void *)0;
1120   SV *tsv = 0;
1121
1122   if (own)
1123     *own = 0;
1124
1125   /* If magical, apply more magic */
1126   if (SvGMAGICAL(sv))
1127     mg_get(sv);
1128
1129   /* Check to see if this is an object */
1130   if (sv_isobject(sv)) {
1131     IV tmp = 0;
1132     tsv = (SV*) SvRV(sv);
1133     if ((SvTYPE(tsv) == SVt_PVHV)) {
1134       MAGIC *mg;
1135       if (SvMAGICAL(tsv)) {
1136         mg = mg_find(tsv,'P');
1137         if (mg) {
1138           sv = mg->mg_obj;
1139           if (sv_isobject(sv)) {
1140             tsv = (SV*)SvRV(sv);
1141             tmp = SvIV(tsv);
1142           }
1143         }
1144       } else {
1145         return SWIG_ERROR;
1146       }
1147     } else {
1148       tmp = SvIV(tsv);
1149     }
1150     voidptr = INT2PTR(void *,tmp);
1151   } else if (! SvOK(sv)) {            /* Check for undef */
1152     *(ptr) = (void *) 0;
1153     return SWIG_OK;
1154   } else if (SvTYPE(sv) == SVt_RV) {  /* Check for NULL pointer */
1155     if (!SvROK(sv)) {
1156       /* In Perl 5.12 and later, SVt_RV == SVt_IV, so sv could be a valid integer value.  */
1157       if (SvIOK(sv)) {
1158         return SWIG_ERROR;
1159       } else {
1160         /* NULL pointer (reference to undef). */
1161         *(ptr) = (void *) 0;
1162         return SWIG_OK;
1163       }
1164     } else {
1165       return SWIG_ERROR;
1166     }
1167   } else {                            /* Don't know what it is */
1168     return SWIG_ERROR;
1169   }
1170   if (_t) {
1171     /* Now see if the types match */
1172     char *_c = HvNAME(SvSTASH(SvRV(sv)));
1173     tc = SWIG_TypeProxyCheck(_c,_t);
1174     if (!tc) {
1175       return SWIG_ERROR;
1176     }
1177     {
1178       int newmemory = 0;
1179       *ptr = SWIG_TypeCast(tc,voidptr,&newmemory);
1180       if (newmemory == SWIG_CAST_NEW_MEMORY) {
1181         assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
1182         if (own)
1183           *own = *own | SWIG_CAST_NEW_MEMORY;
1184       }
1185     }
1186   } else {
1187     *ptr = voidptr;
1188   }
1189
1190   /* 
1191    *  DISOWN implementation: we need a perl guru to check this one.
1192    */
1193   if (tsv && (flags & SWIG_POINTER_DISOWN)) {
1194     /* 
1195      *  almost copy paste code from below SWIG_POINTER_OWN setting
1196      */
1197     SV *obj = sv;
1198     HV *stash = SvSTASH(SvRV(obj));
1199     GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
1200     if (isGV(gv)) {
1201       HV *hv = GvHVn(gv);
1202       /*
1203        * To set ownership (see below), a newSViv(1) entry is added. 
1204        * Hence, to remove ownership, we delete the entry.
1205        */
1206       if (hv_exists_ent(hv, obj, 0)) {
1207         hv_delete_ent(hv, obj, 0, 0);
1208       }
1209     }
1210   }
1211   return SWIG_OK;
1212 }
1213
1214 SWIGRUNTIME int
1215 SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) {
1216   return SWIG_Perl_ConvertPtrAndOwn(sv, ptr, _t, flags, 0);
1217 }
1218
1219 SWIGRUNTIME void
1220 SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) {
1221   if (ptr && (flags & (SWIG_SHADOW | SWIG_POINTER_OWN))) {
1222     SV *self;
1223     SV *obj=newSV(0);
1224     HV *hash=newHV();
1225     HV *stash;
1226     sv_setref_pv(obj, (char *) SWIG_Perl_TypeProxyName(t), ptr);
1227     stash=SvSTASH(SvRV(obj));
1228     if (flags & SWIG_POINTER_OWN) {
1229       HV *hv;
1230       GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
1231       if (!isGV(gv))
1232         gv_init(gv, stash, "OWNER", 5, FALSE);
1233       hv=GvHVn(gv);
1234       hv_store_ent(hv, obj, newSViv(1), 0);
1235     }
1236     sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0);
1237     SvREFCNT_dec(obj);
1238     self=newRV_noinc((SV *)hash);
1239     sv_setsv(sv, self);
1240     SvREFCNT_dec((SV *)self);
1241     sv_bless(sv, stash);
1242   }
1243   else {
1244     sv_setref_pv(sv, (char *) SWIG_Perl_TypeProxyName(t), ptr);
1245   }
1246 }
1247
1248 SWIGRUNTIMEINLINE SV *
1249 SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) {
1250   SV *result = sv_newmortal();
1251   SWIG_MakePtr(result, ptr, t, flags);
1252   return result;
1253 }
1254
1255 SWIGRUNTIME void
1256 SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) {
1257   char result[1024];
1258   char *r = result;
1259   if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return;
1260   *(r++) = '_';
1261   r = SWIG_PackData(r,ptr,sz);
1262   strcpy(r,SWIG_Perl_TypeProxyName(type));
1263   sv_setpv(sv, result);
1264 }
1265
1266 SWIGRUNTIME SV *
1267 SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) {
1268   SV *result = sv_newmortal();
1269   SWIG_Perl_MakePackedObj(result, ptr, sz, type);
1270   return result;
1271 }
1272
1273 /* Convert a packed value value */
1274 SWIGRUNTIME int
1275 SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) {
1276   swig_cast_info *tc;
1277   const char  *c = 0;
1278
1279   if ((!obj) || (!SvOK(obj))) return SWIG_ERROR;
1280   c = SvPV_nolen(obj);
1281   /* Pointer values must start with leading underscore */
1282   if (*c != '_') return SWIG_ERROR;
1283   c++;
1284   c = SWIG_UnpackData(c,ptr,sz);
1285   if (ty) {
1286     tc = SWIG_TypeCheck(c,ty);
1287     if (!tc) return SWIG_ERROR;
1288   }
1289   return SWIG_OK;
1290 }
1291
1292
1293 /* Macros for low-level exception handling */
1294 #define SWIG_croak(x)    { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; }
1295
1296
1297 typedef XSPROTO(SwigPerlWrapper);
1298 typedef SwigPerlWrapper *SwigPerlWrapperPtr;
1299
1300 /* Structure for command table */
1301 typedef struct {
1302   const char         *name;
1303   SwigPerlWrapperPtr  wrapper;
1304 } swig_command_info;
1305
1306 /* Information for constant table */
1307
1308 #define SWIG_INT     1
1309 #define SWIG_FLOAT   2
1310 #define SWIG_STRING  3
1311 #define SWIG_POINTER 4
1312 #define SWIG_BINARY  5
1313
1314 /* Constant information structure */
1315 typedef struct swig_constant_info {
1316     int              type;
1317     const char      *name;
1318     long             lvalue;
1319     double           dvalue;
1320     void            *pvalue;
1321     swig_type_info **ptype;
1322 } swig_constant_info;
1323
1324
1325 /* Structure for variable table */
1326 typedef struct {
1327   const char   *name;
1328   SwigMagicFunc   set;
1329   SwigMagicFunc   get;
1330   swig_type_info  **type;
1331 } swig_variable_info;
1332
1333 /* Magic variable code */
1334 #ifndef PERL_OBJECT
1335 #define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c)
1336   #ifndef MULTIPLICITY
1337      SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) 
1338   #else
1339      SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *)) 
1340   #endif
1341 #else
1342 #  define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c)
1343 SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) 
1344 #endif
1345 {
1346   MAGIC *mg;
1347   sv_magic(sv,sv,'U',(char *) name,strlen(name));
1348   mg = mg_find(sv,'U');
1349   mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL));
1350   mg->mg_virtual->svt_get = (SwigMagicFunc) get;
1351   mg->mg_virtual->svt_set = (SwigMagicFunc) set;
1352   mg->mg_virtual->svt_len = 0;
1353   mg->mg_virtual->svt_clear = 0;
1354   mg->mg_virtual->svt_free = 0;
1355 }
1356
1357
1358 SWIGRUNTIME swig_module_info *
1359 SWIG_Perl_GetModule(void) {
1360   static void *type_pointer = (void *)0;
1361   SV *pointer;
1362
1363   /* first check if pointer already created */
1364   if (!type_pointer) {
1365     pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE | GV_ADDMULTI);
1366     if (pointer && SvOK(pointer)) {
1367       type_pointer = INT2PTR(swig_type_info **, SvIV(pointer));
1368     }
1369   }
1370
1371   return (swig_module_info *) type_pointer;
1372 }
1373
1374 SWIGRUNTIME void
1375 SWIG_Perl_SetModule(swig_module_info *module) {
1376   SV *pointer;
1377
1378   /* create a new pointer */
1379   pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE | GV_ADDMULTI);
1380   sv_setiv(pointer, PTR2IV(module));
1381 }
1382
1383 #ifdef __cplusplus
1384 }
1385 #endif
1386
1387 /* Workaround perl5 global namespace pollution. Note that undefining library
1388  * functions like fopen will not solve the problem on all platforms as fopen
1389  * might be a macro on Windows but not necessarily on other operating systems. */
1390 #ifdef do_open
1391   #undef do_open
1392 #endif
1393 #ifdef do_close
1394   #undef do_close
1395 #endif
1396 #ifdef do_exec
1397   #undef do_exec
1398 #endif
1399 #ifdef scalar
1400   #undef scalar
1401 #endif
1402 #ifdef list
1403   #undef list
1404 #endif
1405 #ifdef apply
1406   #undef apply
1407 #endif
1408 #ifdef convert
1409   #undef convert
1410 #endif
1411 #ifdef Error
1412   #undef Error
1413 #endif
1414 #ifdef form
1415   #undef form
1416 #endif
1417 #ifdef vform
1418   #undef vform
1419 #endif
1420 #ifdef LABEL
1421   #undef LABEL
1422 #endif
1423 #ifdef METHOD
1424   #undef METHOD
1425 #endif
1426 #ifdef Move
1427   #undef Move
1428 #endif
1429 #ifdef yylex
1430   #undef yylex
1431 #endif
1432 #ifdef yyparse
1433   #undef yyparse
1434 #endif
1435 #ifdef yyerror
1436   #undef yyerror
1437 #endif
1438 #ifdef invert
1439   #undef invert
1440 #endif
1441 #ifdef ref
1442   #undef ref
1443 #endif
1444 #ifdef read
1445   #undef read
1446 #endif
1447 #ifdef write
1448   #undef write
1449 #endif
1450 #ifdef eof
1451   #undef eof
1452 #endif
1453 #ifdef bool
1454   #undef bool
1455 #endif
1456 #ifdef close
1457   #undef close
1458 #endif
1459 #ifdef rewind
1460   #undef rewind
1461 #endif
1462 #ifdef free
1463   #undef free
1464 #endif
1465 #ifdef malloc
1466   #undef malloc
1467 #endif
1468 #ifdef calloc
1469   #undef calloc
1470 #endif
1471 #ifdef Stat
1472   #undef Stat
1473 #endif
1474 #ifdef check
1475   #undef check
1476 #endif
1477 #ifdef seekdir
1478   #undef seekdir
1479 #endif
1480 #ifdef open
1481   #undef open
1482 #endif
1483 #ifdef readdir
1484   #undef readdir
1485 #endif
1486 #ifdef bind
1487   #undef bind
1488 #endif
1489 #ifdef access
1490   #undef access
1491 #endif
1492 #ifdef stat
1493   #undef stat
1494 #endif
1495
1496
1497
1498 #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) 
1499
1500 #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else 
1501
1502
1503
1504   #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) 
1505
1506
1507 /* -------- TYPES TABLE (BEGIN) -------- */
1508
1509 #define SWIGTYPE_p_char swig_types[0]
1510 #define SWIGTYPE_p_double swig_types[1]
1511 #define SWIGTYPE_p_float swig_types[2]
1512 #define SWIGTYPE_p_int swig_types[3]
1513 #define SWIGTYPE_p_unsigned_char swig_types[4]
1514 static swig_type_info *swig_types[6];
1515 static swig_module_info swig_module = {swig_types, 5, 0, 0, 0, 0};
1516 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
1517 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
1518
1519 /* -------- TYPES TABLE (END) -------- */
1520
1521 #define SWIG_init    boot_Amanda__Tapelist
1522
1523 #define SWIG_name   "Amanda::Tapelistc::boot_Amanda__Tapelist"
1524 #define SWIG_prefix "Amanda::Tapelistc::"
1525
1526 #define SWIGVERSION 0x020004 
1527 #define SWIG_VERSION SWIGVERSION
1528
1529
1530 #define SWIG_as_voidptr(a) (void *)((const void *)(a)) 
1531 #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) 
1532
1533
1534 #ifdef __cplusplus
1535 extern "C"
1536 #endif
1537 #ifndef PERL_OBJECT
1538 #ifndef MULTIPLICITY
1539 SWIGEXPORT void SWIG_init (CV* cv);
1540 #else
1541 SWIGEXPORT void SWIG_init (pTHXo_ CV* cv);
1542 #endif
1543 #else
1544 SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *);
1545 #endif
1546
1547
1548 #include "amglue.h"
1549
1550
1551 #include "amglue.h"
1552
1553
1554 #include "amglue.h"
1555
1556
1557 #include "tapefile.h"
1558
1559
1560 #include <limits.h>
1561 #if !defined(SWIG_NO_LLONG_MAX)
1562 # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
1563 #   define LLONG_MAX __LONG_LONG_MAX__
1564 #   define LLONG_MIN (-LLONG_MAX - 1LL)
1565 #   define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
1566 # endif
1567 #endif
1568
1569
1570 SWIGINTERN int
1571 SWIG_AsVal_double SWIG_PERL_DECL_ARGS_2(SV *obj, double *val)
1572 {
1573   if (SvNIOK(obj)) {
1574     if (val) *val = SvNV(obj);
1575     return SWIG_OK;
1576   } else if (SvIOK(obj)) {
1577     if (val) *val = (double) SvIV(obj);
1578     return SWIG_AddCast(SWIG_OK);
1579   } else {
1580     const char *nptr = SvPV_nolen(obj);
1581     if (nptr) {
1582       char *endptr;
1583       double v;
1584       errno = 0;
1585       v = strtod(nptr, &endptr);
1586       if (errno == ERANGE) {
1587         errno = 0;
1588         return SWIG_OverflowError;
1589       } else {
1590         if (*endptr == '\0') {
1591           if (val) *val = v;
1592           return SWIG_Str2NumCast(SWIG_OK);
1593         }
1594       }
1595     }
1596   }
1597   return SWIG_TypeError;
1598 }
1599
1600
1601 #include <float.h>
1602
1603
1604 #include <math.h>
1605
1606
1607 SWIGINTERNINLINE int
1608 SWIG_CanCastAsInteger(double *d, double min, double max) {
1609   double x = *d;
1610   if ((min <= x && x <= max)) {
1611    double fx = floor(x);
1612    double cx = ceil(x);
1613    double rd =  ((x - fx) < 0.5) ? fx : cx; /* simple rint */
1614    if ((errno == EDOM) || (errno == ERANGE)) {
1615      errno = 0;
1616    } else {
1617      double summ, reps, diff;
1618      if (rd < x) {
1619        diff = x - rd;
1620      } else if (rd > x) {
1621        diff = rd - x;
1622      } else {
1623        return 1;
1624      }
1625      summ = rd + x;
1626      reps = diff/summ;
1627      if (reps < 8*DBL_EPSILON) {
1628        *d = rd;
1629        return 1;
1630      }
1631    }
1632   }
1633   return 0;
1634 }
1635
1636
1637 SWIGINTERN int
1638 SWIG_AsVal_long SWIG_PERL_DECL_ARGS_2(SV *obj, long* val)
1639 {
1640   if (SvIOK(obj)) {
1641     if (val) *val = SvIV(obj);
1642     return SWIG_OK;
1643   } else {
1644     int dispatch = 0;
1645     const char *nptr = SvPV_nolen(obj);
1646     if (nptr) {
1647       char *endptr;
1648       long v;
1649       errno = 0;
1650       v = strtol(nptr, &endptr,0);
1651       if (errno == ERANGE) {
1652         errno = 0;
1653         return SWIG_OverflowError;
1654       } else {
1655         if (*endptr == '\0') {
1656           if (val) *val = v;
1657           return SWIG_Str2NumCast(SWIG_OK);
1658         }
1659       }
1660     }
1661     if (!dispatch) {
1662       double d;
1663       int res = SWIG_AddCast(SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(obj,&d));
1664       if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
1665         if (val) *val = (long)(d);
1666         return res;
1667       }
1668     }
1669   }
1670   return SWIG_TypeError;
1671 }
1672
1673
1674 SWIGINTERN int
1675 SWIG_AsVal_int SWIG_PERL_DECL_ARGS_2(SV * obj, int *val)
1676 {
1677   long v;
1678   int res = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(obj, &v);
1679   if (SWIG_IsOK(res)) {
1680     if ((v < INT_MIN || v > INT_MAX)) {
1681       return SWIG_OverflowError;
1682     } else {
1683       if (val) *val = (int)(v);
1684     }
1685   }  
1686   return res;
1687 }
1688
1689
1690 SWIGINTERNINLINE SV *
1691 SWIG_FromCharPtrAndSize(const char* carray, size_t size)
1692 {
1693   SV *obj = sv_newmortal();
1694   if (carray) {
1695     sv_setpvn(obj, carray, size);
1696   } else {
1697     sv_setsv(obj, &PL_sv_undef);
1698   }
1699   return obj;
1700 }
1701
1702
1703 SWIGINTERNINLINE SV * 
1704 SWIG_FromCharPtr(const char *cptr)
1705
1706   return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
1707 }
1708
1709
1710 SWIGINTERN swig_type_info*
1711 SWIG_pchar_descriptor(void)
1712 {
1713   static int init = 0;
1714   static swig_type_info* info = 0;
1715   if (!init) {
1716     info = SWIG_TypeQuery("_p_char");
1717     init = 1;
1718   }
1719   return info;
1720 }
1721
1722
1723 SWIGINTERN int
1724 SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
1725 {
1726   if (SvMAGICAL(obj)) {
1727      SV *tmp = sv_newmortal();
1728      SvSetSV(tmp, obj);
1729      obj = tmp;
1730   }
1731   if (SvPOK(obj)) {
1732     STRLEN len = 0;
1733     char *cstr = SvPV(obj, len); 
1734     size_t size = len + 1;
1735     if (cptr)  {
1736       if (alloc) {
1737         if (*alloc == SWIG_NEWOBJ) {
1738           *cptr = (char *)memcpy((char *)malloc((size)*sizeof(char)), cstr, sizeof(char)*(size));
1739         } else {
1740           *cptr = cstr;
1741           *alloc = SWIG_OLDOBJ;
1742         }
1743       }
1744     }
1745     if (psize) *psize = size;
1746     return SWIG_OK;
1747   } else {
1748     swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
1749     if (pchar_descriptor) {
1750       char* vptr = 0; 
1751       if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) {
1752         if (cptr) *cptr = vptr;
1753         if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0;
1754         if (alloc) *alloc = SWIG_OLDOBJ;
1755         return SWIG_OK;
1756       }
1757     }
1758   }
1759   return SWIG_TypeError;
1760 }
1761
1762
1763
1764
1765 #ifdef __cplusplus
1766 extern "C" {
1767 #endif
1768
1769 #ifdef PERL_OBJECT
1770 #define MAGIC_CLASS _wrap_Amanda__Tapelist_var::
1771 class _wrap_Amanda__Tapelist_var : public CPerlObj {
1772 public:
1773 #else
1774 #define MAGIC_CLASS
1775 #endif
1776 SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) {
1777     MAGIC_PPERL
1778     croak("Value is read-only.");
1779     return 0;
1780 }
1781
1782
1783 #ifdef PERL_OBJECT
1784 };
1785 #endif
1786
1787 #ifdef __cplusplus
1788 }
1789 #endif
1790
1791 #ifdef __cplusplus
1792 extern "C" {
1793 #endif
1794 XS(_wrap_get_last_reusable_tape_label) {
1795   {
1796     int arg1 ;
1797     int argvi = 0;
1798     char *result = 0 ;
1799     dXSARGS;
1800     
1801     if ((items < 1) || (items > 1)) {
1802       SWIG_croak("Usage: get_last_reusable_tape_label(skip);");
1803     }
1804     {
1805       if (sizeof(signed int) == 1) {
1806         arg1 = amglue_SvI8(ST(0));
1807       } else if (sizeof(signed int) == 2) {
1808         arg1 = amglue_SvI16(ST(0));
1809       } else if (sizeof(signed int) == 4) {
1810         arg1 = amglue_SvI32(ST(0));
1811       } else if (sizeof(signed int) == 8) {
1812         arg1 = amglue_SvI64(ST(0));
1813       } else {
1814         g_critical("Unexpected signed int >64 bits?"); /* should be optimized out unless sizeof(signed int) > 8 */
1815       }
1816     }
1817     result = (char *)get_last_reusable_tape_label(arg1);
1818     ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
1819     
1820     XSRETURN(argvi);
1821   fail:
1822     
1823     SWIG_croak_null();
1824   }
1825 }
1826
1827
1828 XS(_wrap_list_new_tapes) {
1829   {
1830     int arg1 ;
1831     int argvi = 0;
1832     char *result = 0 ;
1833     dXSARGS;
1834     
1835     if ((items < 1) || (items > 1)) {
1836       SWIG_croak("Usage: list_new_tapes(nb);");
1837     }
1838     {
1839       if (sizeof(signed int) == 1) {
1840         arg1 = amglue_SvI8(ST(0));
1841       } else if (sizeof(signed int) == 2) {
1842         arg1 = amglue_SvI16(ST(0));
1843       } else if (sizeof(signed int) == 4) {
1844         arg1 = amglue_SvI32(ST(0));
1845       } else if (sizeof(signed int) == 8) {
1846         arg1 = amglue_SvI64(ST(0));
1847       } else {
1848         g_critical("Unexpected signed int >64 bits?"); /* should be optimized out unless sizeof(signed int) > 8 */
1849       }
1850     }
1851     result = (char *)list_new_tapes(arg1);
1852     ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
1853     
1854     XSRETURN(argvi);
1855   fail:
1856     
1857     SWIG_croak_null();
1858   }
1859 }
1860
1861
1862 XS(_wrap_C_read_tapelist) {
1863   {
1864     char *arg1 = (char *) 0 ;
1865     int res1 ;
1866     char *buf1 = 0 ;
1867     int alloc1 = 0 ;
1868     int argvi = 0;
1869     int result;
1870     dXSARGS;
1871     
1872     if ((items < 1) || (items > 1)) {
1873       SWIG_croak("Usage: C_read_tapelist(tapefile);");
1874     }
1875     res1 = SWIG_AsCharPtrAndSize(ST(0), &buf1, NULL, &alloc1);
1876     if (!SWIG_IsOK(res1)) {
1877       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "C_read_tapelist" "', argument " "1"" of type '" "char *""'");
1878     }
1879     arg1 = (char *)(buf1);
1880     result = (int)read_tapelist(arg1);
1881     {
1882       SV *for_stack;
1883       SP += argvi; PUTBACK;
1884       for_stack = sv_2mortal(amglue_newSVi64(result));
1885       SPAGAIN; SP -= argvi;
1886       ST(argvi) = for_stack;
1887       argvi++;
1888     }
1889     if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
1890     XSRETURN(argvi);
1891   fail:
1892     if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
1893     SWIG_croak_null();
1894   }
1895 }
1896
1897
1898 XS(_wrap_C_clear_tapelist) {
1899   {
1900     int argvi = 0;
1901     dXSARGS;
1902     
1903     if ((items < 0) || (items > 0)) {
1904       SWIG_croak("Usage: C_clear_tapelist();");
1905     }
1906     clear_tapelist();
1907     ST(argvi) = sv_newmortal();
1908     XSRETURN(argvi);
1909   fail:
1910     SWIG_croak_null();
1911   }
1912 }
1913
1914
1915
1916 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
1917
1918 static swig_type_info _swigt__p_char = {"_p_char", "gchar *|char *", 0, 0, (void*)0, 0};
1919 static swig_type_info _swigt__p_double = {"_p_double", "double *|gdouble *", 0, 0, (void*)0, 0};
1920 static swig_type_info _swigt__p_float = {"_p_float", "float *|gfloat *", 0, 0, (void*)0, 0};
1921 static swig_type_info _swigt__p_int = {"_p_int", "int *|gboolean *", 0, 0, (void*)0, 0};
1922 static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "guchar *|unsigned char *", 0, 0, (void*)0, 0};
1923
1924 static swig_type_info *swig_type_initial[] = {
1925   &_swigt__p_char,
1926   &_swigt__p_double,
1927   &_swigt__p_float,
1928   &_swigt__p_int,
1929   &_swigt__p_unsigned_char,
1930 };
1931
1932 static swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
1933 static swig_cast_info _swigc__p_double[] = {  {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}};
1934 static swig_cast_info _swigc__p_float[] = {  {&_swigt__p_float, 0, 0, 0},{0, 0, 0, 0}};
1935 static swig_cast_info _swigc__p_int[] = {  {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
1936 static swig_cast_info _swigc__p_unsigned_char[] = {  {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
1937
1938 static swig_cast_info *swig_cast_initial[] = {
1939   _swigc__p_char,
1940   _swigc__p_double,
1941   _swigc__p_float,
1942   _swigc__p_int,
1943   _swigc__p_unsigned_char,
1944 };
1945
1946
1947 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
1948
1949 static swig_constant_info swig_constants[] = {
1950 {0,0,0,0,0,0}
1951 };
1952 #ifdef __cplusplus
1953 }
1954 #endif
1955 static swig_variable_info swig_variables[] = {
1956 {0,0,0,0}
1957 };
1958 static swig_command_info swig_commands[] = {
1959 {"Amanda::Tapelistc::get_last_reusable_tape_label", _wrap_get_last_reusable_tape_label},
1960 {"Amanda::Tapelistc::list_new_tapes", _wrap_list_new_tapes},
1961 {"Amanda::Tapelistc::C_read_tapelist", _wrap_C_read_tapelist},
1962 {"Amanda::Tapelistc::C_clear_tapelist", _wrap_C_clear_tapelist},
1963 {0,0}
1964 };
1965 /* -----------------------------------------------------------------------------
1966  * Type initialization:
1967  * This problem is tough by the requirement that no dynamic 
1968  * memory is used. Also, since swig_type_info structures store pointers to 
1969  * swig_cast_info structures and swig_cast_info structures store pointers back
1970  * to swig_type_info structures, we need some lookup code at initialization. 
1971  * The idea is that swig generates all the structures that are needed. 
1972  * The runtime then collects these partially filled structures. 
1973  * The SWIG_InitializeModule function takes these initial arrays out of 
1974  * swig_module, and does all the lookup, filling in the swig_module.types
1975  * array with the correct data and linking the correct swig_cast_info
1976  * structures together.
1977  *
1978  * The generated swig_type_info structures are assigned staticly to an initial 
1979  * array. We just loop through that array, and handle each type individually.
1980  * First we lookup if this type has been already loaded, and if so, use the
1981  * loaded structure instead of the generated one. Then we have to fill in the
1982  * cast linked list. The cast data is initially stored in something like a
1983  * two-dimensional array. Each row corresponds to a type (there are the same
1984  * number of rows as there are in the swig_type_initial array). Each entry in
1985  * a column is one of the swig_cast_info structures for that type.
1986  * The cast_initial array is actually an array of arrays, because each row has
1987  * a variable number of columns. So to actually build the cast linked list,
1988  * we find the array of casts associated with the type, and loop through it 
1989  * adding the casts to the list. The one last trick we need to do is making
1990  * sure the type pointer in the swig_cast_info struct is correct.
1991  *
1992  * First off, we lookup the cast->type name to see if it is already loaded. 
1993  * There are three cases to handle:
1994  *  1) If the cast->type has already been loaded AND the type we are adding
1995  *     casting info to has not been loaded (it is in this module), THEN we
1996  *     replace the cast->type pointer with the type pointer that has already
1997  *     been loaded.
1998  *  2) If BOTH types (the one we are adding casting info to, and the 
1999  *     cast->type) are loaded, THEN the cast info has already been loaded by
2000  *     the previous module so we just ignore it.
2001  *  3) Finally, if cast->type has not already been loaded, then we add that
2002  *     swig_cast_info to the linked list (because the cast->type) pointer will
2003  *     be correct.
2004  * ----------------------------------------------------------------------------- */
2005
2006 #ifdef __cplusplus
2007 extern "C" {
2008 #if 0
2009 } /* c-mode */
2010 #endif
2011 #endif
2012
2013 #if 0
2014 #define SWIGRUNTIME_DEBUG
2015 #endif
2016
2017
2018 SWIGRUNTIME void
2019 SWIG_InitializeModule(void *clientdata) {
2020   size_t i;
2021   swig_module_info *module_head, *iter;
2022   int found, init;
2023   
2024   clientdata = clientdata;
2025   
2026   /* check to see if the circular list has been setup, if not, set it up */
2027   if (swig_module.next==0) {
2028     /* Initialize the swig_module */
2029     swig_module.type_initial = swig_type_initial;
2030     swig_module.cast_initial = swig_cast_initial;
2031     swig_module.next = &swig_module;
2032     init = 1;
2033   } else {
2034     init = 0;
2035   }
2036   
2037   /* Try and load any already created modules */
2038   module_head = SWIG_GetModule(clientdata);
2039   if (!module_head) {
2040     /* This is the first module loaded for this interpreter */
2041     /* so set the swig module into the interpreter */
2042     SWIG_SetModule(clientdata, &swig_module);
2043     module_head = &swig_module;
2044   } else {
2045     /* the interpreter has loaded a SWIG module, but has it loaded this one? */
2046     found=0;
2047     iter=module_head;
2048     do {
2049       if (iter==&swig_module) {
2050         found=1;
2051         break;
2052       }
2053       iter=iter->next;
2054     } while (iter!= module_head);
2055     
2056     /* if the is found in the list, then all is done and we may leave */
2057     if (found) return;
2058     /* otherwise we must add out module into the list */
2059     swig_module.next = module_head->next;
2060     module_head->next = &swig_module;
2061   }
2062   
2063   /* When multiple interpeters are used, a module could have already been initialized in
2064        a different interpreter, but not yet have a pointer in this interpreter.
2065        In this case, we do not want to continue adding types... everything should be
2066        set up already */
2067   if (init == 0) return;
2068   
2069   /* Now work on filling in swig_module.types */
2070 #ifdef SWIGRUNTIME_DEBUG
2071   printf("SWIG_InitializeModule: size %d\n", swig_module.size);
2072 #endif
2073   for (i = 0; i < swig_module.size; ++i) {
2074     swig_type_info *type = 0;
2075     swig_type_info *ret;
2076     swig_cast_info *cast;
2077     
2078 #ifdef SWIGRUNTIME_DEBUG
2079     printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
2080 #endif
2081     
2082     /* if there is another module already loaded */
2083     if (swig_module.next != &swig_module) {
2084       type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
2085     }
2086     if (type) {
2087       /* Overwrite clientdata field */
2088 #ifdef SWIGRUNTIME_DEBUG
2089       printf("SWIG_InitializeModule: found type %s\n", type->name);
2090 #endif
2091       if (swig_module.type_initial[i]->clientdata) {
2092         type->clientdata = swig_module.type_initial[i]->clientdata;
2093 #ifdef SWIGRUNTIME_DEBUG
2094         printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
2095 #endif
2096       }
2097     } else {
2098       type = swig_module.type_initial[i];
2099     }
2100     
2101     /* Insert casting types */
2102     cast = swig_module.cast_initial[i];
2103     while (cast->type) {
2104       /* Don't need to add information already in the list */
2105       ret = 0;
2106 #ifdef SWIGRUNTIME_DEBUG
2107       printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
2108 #endif
2109       if (swig_module.next != &swig_module) {
2110         ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
2111 #ifdef SWIGRUNTIME_DEBUG
2112         if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
2113 #endif
2114       }
2115       if (ret) {
2116         if (type == swig_module.type_initial[i]) {
2117 #ifdef SWIGRUNTIME_DEBUG
2118           printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
2119 #endif
2120           cast->type = ret;
2121           ret = 0;
2122         } else {
2123           /* Check for casting already in the list */
2124           swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
2125 #ifdef SWIGRUNTIME_DEBUG
2126           if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
2127 #endif
2128           if (!ocast) ret = 0;
2129         }
2130       }
2131       
2132       if (!ret) {
2133 #ifdef SWIGRUNTIME_DEBUG
2134         printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
2135 #endif
2136         if (type->cast) {
2137           type->cast->prev = cast;
2138           cast->next = type->cast;
2139         }
2140         type->cast = cast;
2141       }
2142       cast++;
2143     }
2144     /* Set entry in modules->types array equal to the type */
2145     swig_module.types[i] = type;
2146   }
2147   swig_module.types[i] = 0;
2148   
2149 #ifdef SWIGRUNTIME_DEBUG
2150   printf("**** SWIG_InitializeModule: Cast List ******\n");
2151   for (i = 0; i < swig_module.size; ++i) {
2152     int j = 0;
2153     swig_cast_info *cast = swig_module.cast_initial[i];
2154     printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
2155     while (cast->type) {
2156       printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
2157       cast++;
2158       ++j;
2159     }
2160     printf("---- Total casts: %d\n",j);
2161   }
2162   printf("**** SWIG_InitializeModule: Cast List ******\n");
2163 #endif
2164 }
2165
2166 /* This function will propagate the clientdata field of type to
2167 * any new swig_type_info structures that have been added into the list
2168 * of equivalent types.  It is like calling
2169 * SWIG_TypeClientData(type, clientdata) a second time.
2170 */
2171 SWIGRUNTIME void
2172 SWIG_PropagateClientData(void) {
2173   size_t i;
2174   swig_cast_info *equiv;
2175   static int init_run = 0;
2176   
2177   if (init_run) return;
2178   init_run = 1;
2179   
2180   for (i = 0; i < swig_module.size; i++) {
2181     if (swig_module.types[i]->clientdata) {
2182       equiv = swig_module.types[i]->cast;
2183       while (equiv) {
2184         if (!equiv->converter) {
2185           if (equiv->type && !equiv->type->clientdata)
2186           SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
2187         }
2188         equiv = equiv->next;
2189       }
2190     }
2191   }
2192 }
2193
2194 #ifdef __cplusplus
2195 #if 0
2196 {
2197   /* c-mode */
2198 #endif
2199 }
2200 #endif
2201
2202
2203
2204 #ifdef __cplusplus
2205 extern "C"
2206 #endif
2207
2208 XS(SWIG_init) {
2209   dXSARGS;
2210   int i;
2211   
2212   SWIG_InitializeModule(0);
2213   
2214   /* Install commands */
2215   for (i = 0; swig_commands[i].name; i++) {
2216     newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__);
2217   }
2218   
2219   /* Install variables */
2220   for (i = 0; swig_variables[i].name; i++) {
2221     SV *sv;
2222     sv = get_sv((char*) swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI);
2223     if (swig_variables[i].type) {
2224       SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0);
2225     } else {
2226       sv_setiv(sv,(IV) 0);
2227     }
2228     swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); 
2229   }
2230   
2231   /* Install constant */
2232   for (i = 0; swig_constants[i].type; i++) {
2233     SV *sv;
2234     sv = get_sv((char*)swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI);
2235     switch(swig_constants[i].type) {
2236     case SWIG_INT:
2237       sv_setiv(sv, (IV) swig_constants[i].lvalue);
2238       break;
2239     case SWIG_FLOAT:
2240       sv_setnv(sv, (double) swig_constants[i].dvalue);
2241       break;
2242     case SWIG_STRING:
2243       sv_setpv(sv, (char *) swig_constants[i].pvalue);
2244       break;
2245     case SWIG_POINTER:
2246       SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0);
2247       break;
2248     case SWIG_BINARY:
2249       SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype));
2250       break;
2251     default:
2252       break;
2253     }
2254     SvREADONLY_on(sv);
2255   }
2256   
2257   ST(0) = &PL_sv_yes;
2258   XSRETURN(1);
2259 }
2260