1 /* ----------------------------------------------------------------------------
2  * This file was automatically generated by SWIG (http://www.swig.org).
3  * Version 3.0.7
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 /* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
126 #if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
127 # define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
128 #endif
129 
130 /* Intel's compiler complains if a variable which was never initialised is
131  * cast to void, which is a common idiom which we use to indicate that we
132  * are aware a variable isn't used.  So we just silence that warning.
133  * See: https://github.com/swig/swig/issues/192 for more discussion.
134  */
135 #ifdef __INTEL_COMPILER
136 # pragma warning disable 592
137 #endif
138 
139 /* -----------------------------------------------------------------------------
140  * swigrun.swg
141  *
142  * This file contains generic C API SWIG runtime support for pointer
143  * type checking.
144  * ----------------------------------------------------------------------------- */
145 
146 /* This should only be incremented when either the layout of swig_type_info changes,
147    or for whatever reason, the runtime changes incompatibly */
148 #define SWIG_RUNTIME_VERSION "4"
149 
150 /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
151 #ifdef SWIG_TYPE_TABLE
152 # define SWIG_QUOTE_STRING(x) #x
153 # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
154 # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
155 #else
156 # define SWIG_TYPE_TABLE_NAME
157 #endif
158 
159 /*
160   You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
161   creating a static or dynamic library from the SWIG runtime code.
162   In 99.9% of the cases, SWIG just needs to declare them as 'static'.
163 
164   But only do this if strictly necessary, ie, if you have problems
165   with your compiler or suchlike.
166 */
167 
168 #ifndef SWIGRUNTIME
169 # define SWIGRUNTIME SWIGINTERN
170 #endif
171 
172 #ifndef SWIGRUNTIMEINLINE
173 # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
174 #endif
175 
176 /*  Generic buffer size */
177 #ifndef SWIG_BUFFER_SIZE
178 # define SWIG_BUFFER_SIZE 1024
179 #endif
180 
181 /* Flags for pointer conversions */
182 #define SWIG_POINTER_DISOWN        0x1
183 #define SWIG_CAST_NEW_MEMORY       0x2
184 
185 /* Flags for new pointer objects */
186 #define SWIG_POINTER_OWN           0x1
187 
188 
189 /*
190    Flags/methods for returning states.
191 
192    The SWIG conversion methods, as ConvertPtr, return an integer
193    that tells if the conversion was successful or not. And if not,
194    an error code can be returned (see swigerrors.swg for the codes).
195 
196    Use the following macros/flags to set or process the returning
197    states.
198 
199    In old versions of SWIG, code such as the following was usually written:
200 
201      if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
202        // success code
203      } else {
204        //fail code
205      }
206 
207    Now you can be more explicit:
208 
209     int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
210     if (SWIG_IsOK(res)) {
211       // success code
212     } else {
213       // fail code
214     }
215 
216    which is the same really, but now you can also do
217 
218     Type *ptr;
219     int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
220     if (SWIG_IsOK(res)) {
221       // success code
222       if (SWIG_IsNewObj(res) {
223         ...
224 	delete *ptr;
225       } else {
226         ...
227       }
228     } else {
229       // fail code
230     }
231 
232    I.e., now SWIG_ConvertPtr can return new objects and you can
233    identify the case and take care of the deallocation. Of course that
234    also requires SWIG_ConvertPtr to return new result values, such as
235 
236       int SWIG_ConvertPtr(obj, ptr,...) {
237         if (<obj is ok>) {
238           if (<need new object>) {
239             *ptr = <ptr to new allocated object>;
240             return SWIG_NEWOBJ;
241           } else {
242             *ptr = <ptr to old object>;
243             return SWIG_OLDOBJ;
244           }
245         } else {
246           return SWIG_BADOBJ;
247         }
248       }
249 
250    Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
251    more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
252    SWIG errors code.
253 
254    Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
255    allows to return the 'cast rank', for example, if you have this
256 
257        int food(double)
258        int fooi(int);
259 
260    and you call
261 
262       food(1)   // cast rank '1'  (1 -> 1.0)
263       fooi(1)   // cast rank '0'
264 
265    just use the SWIG_AddCast()/SWIG_CheckState()
266 */
267 
268 #define SWIG_OK                    (0)
269 #define SWIG_ERROR                 (-1)
270 #define SWIG_IsOK(r)               (r >= 0)
271 #define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)
272 
273 /* The CastRankLimit says how many bits are used for the cast rank */
274 #define SWIG_CASTRANKLIMIT         (1 << 8)
275 /* The NewMask denotes the object was created (using new/malloc) */
276 #define SWIG_NEWOBJMASK            (SWIG_CASTRANKLIMIT  << 1)
277 /* The TmpMask is for in/out typemaps that use temporal objects */
278 #define SWIG_TMPOBJMASK            (SWIG_NEWOBJMASK << 1)
279 /* Simple returning values */
280 #define SWIG_BADOBJ                (SWIG_ERROR)
281 #define SWIG_OLDOBJ                (SWIG_OK)
282 #define SWIG_NEWOBJ                (SWIG_OK | SWIG_NEWOBJMASK)
283 #define SWIG_TMPOBJ                (SWIG_OK | SWIG_TMPOBJMASK)
284 /* Check, add and del mask methods */
285 #define SWIG_AddNewMask(r)         (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
286 #define SWIG_DelNewMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
287 #define SWIG_IsNewObj(r)           (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
288 #define SWIG_AddTmpMask(r)         (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
289 #define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
290 #define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
291 
292 /* Cast-Rank Mode */
293 #if defined(SWIG_CASTRANK_MODE)
294 #  ifndef SWIG_TypeRank
295 #    define SWIG_TypeRank             unsigned long
296 #  endif
297 #  ifndef SWIG_MAXCASTRANK            /* Default cast allowed */
298 #    define SWIG_MAXCASTRANK          (2)
299 #  endif
300 #  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
301 #  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
SWIG_AddCast(int r)302 SWIGINTERNINLINE int SWIG_AddCast(int r) {
303   return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
304 }
SWIG_CheckState(int r)305 SWIGINTERNINLINE int SWIG_CheckState(int r) {
306   return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
307 }
308 #else /* no cast-rank mode */
309 #  define SWIG_AddCast(r) (r)
310 #  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
311 #endif
312 
313 
314 #include <string.h>
315 
316 #ifdef __cplusplus
317 extern "C" {
318 #endif
319 
320 typedef void *(*swig_converter_func)(void *, int *);
321 typedef struct swig_type_info *(*swig_dycast_func)(void **);
322 
323 /* Structure to store information on one type */
324 typedef struct swig_type_info {
325   const char             *name;			/* mangled name of this type */
326   const char             *str;			/* human readable name of this type */
327   swig_dycast_func        dcast;		/* dynamic cast function down a hierarchy */
328   struct swig_cast_info  *cast;			/* linked list of types that can cast into this type */
329   void                   *clientdata;		/* language specific type data */
330   int                    owndata;		/* flag if the structure owns the clientdata */
331 } swig_type_info;
332 
333 /* Structure to store a type and conversion function used for casting */
334 typedef struct swig_cast_info {
335   swig_type_info         *type;			/* pointer to type that is equivalent to this type */
336   swig_converter_func     converter;		/* function to cast the void pointers */
337   struct swig_cast_info  *next;			/* pointer to next cast in linked list */
338   struct swig_cast_info  *prev;			/* pointer to the previous cast */
339 } swig_cast_info;
340 
341 /* Structure used to store module information
342  * Each module generates one structure like this, and the runtime collects
343  * all of these structures and stores them in a circularly linked list.*/
344 typedef struct swig_module_info {
345   swig_type_info         **types;		/* Array of pointers to swig_type_info structures that are in this module */
346   size_t                 size;		        /* Number of types in this module */
347   struct swig_module_info *next;		/* Pointer to next element in circularly linked list */
348   swig_type_info         **type_initial;	/* Array of initially generated type structures */
349   swig_cast_info         **cast_initial;	/* Array of initially generated casting structures */
350   void                    *clientdata;		/* Language specific module data */
351 } swig_module_info;
352 
353 /*
354   Compare two type names skipping the space characters, therefore
355   "char*" == "char *" and "Class<int>" == "Class<int >", etc.
356 
357   Return 0 when the two name types are equivalent, as in
358   strncmp, but skipping ' '.
359 */
360 SWIGRUNTIME int
SWIG_TypeNameComp(const char * f1,const char * l1,const char * f2,const char * l2)361 SWIG_TypeNameComp(const char *f1, const char *l1,
362 		  const char *f2, const char *l2) {
363   for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
364     while ((*f1 == ' ') && (f1 != l1)) ++f1;
365     while ((*f2 == ' ') && (f2 != l2)) ++f2;
366     if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
367   }
368   return (int)((l1 - f1) - (l2 - f2));
369 }
370 
371 /*
372   Check type equivalence in a name list like <name1>|<name2>|...
373   Return 0 if equal, -1 if nb < tb, 1 if nb > tb
374 */
375 SWIGRUNTIME int
SWIG_TypeCmp(const char * nb,const char * tb)376 SWIG_TypeCmp(const char *nb, const char *tb) {
377   int equiv = 1;
378   const char* te = tb + strlen(tb);
379   const char* ne = nb;
380   while (equiv != 0 && *ne) {
381     for (nb = ne; *ne; ++ne) {
382       if (*ne == '|') break;
383     }
384     equiv = SWIG_TypeNameComp(nb, ne, tb, te);
385     if (*ne) ++ne;
386   }
387   return equiv;
388 }
389 
390 /*
391   Check type equivalence in a name list like <name1>|<name2>|...
392   Return 0 if not equal, 1 if equal
393 */
394 SWIGRUNTIME int
SWIG_TypeEquiv(const char * nb,const char * tb)395 SWIG_TypeEquiv(const char *nb, const char *tb) {
396   return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
397 }
398 
399 /*
400   Check the typename
401 */
402 SWIGRUNTIME swig_cast_info *
SWIG_TypeCheck(const char * c,swig_type_info * ty)403 SWIG_TypeCheck(const char *c, swig_type_info *ty) {
404   if (ty) {
405     swig_cast_info *iter = ty->cast;
406     while (iter) {
407       if (strcmp(iter->type->name, c) == 0) {
408         if (iter == ty->cast)
409           return iter;
410         /* Move iter to the top of the linked list */
411         iter->prev->next = iter->next;
412         if (iter->next)
413           iter->next->prev = iter->prev;
414         iter->next = ty->cast;
415         iter->prev = 0;
416         if (ty->cast) ty->cast->prev = iter;
417         ty->cast = iter;
418         return iter;
419       }
420       iter = iter->next;
421     }
422   }
423   return 0;
424 }
425 
426 /*
427   Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
428 */
429 SWIGRUNTIME swig_cast_info *
SWIG_TypeCheckStruct(swig_type_info * from,swig_type_info * ty)430 SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
431   if (ty) {
432     swig_cast_info *iter = ty->cast;
433     while (iter) {
434       if (iter->type == from) {
435         if (iter == ty->cast)
436           return iter;
437         /* Move iter to the top of the linked list */
438         iter->prev->next = iter->next;
439         if (iter->next)
440           iter->next->prev = iter->prev;
441         iter->next = ty->cast;
442         iter->prev = 0;
443         if (ty->cast) ty->cast->prev = iter;
444         ty->cast = iter;
445         return iter;
446       }
447       iter = iter->next;
448     }
449   }
450   return 0;
451 }
452 
453 /*
454   Cast a pointer up an inheritance hierarchy
455 */
456 SWIGRUNTIMEINLINE void *
SWIG_TypeCast(swig_cast_info * ty,void * ptr,int * newmemory)457 SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
458   return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
459 }
460 
461 /*
462    Dynamic pointer casting. Down an inheritance hierarchy
463 */
464 SWIGRUNTIME swig_type_info *
SWIG_TypeDynamicCast(swig_type_info * ty,void ** ptr)465 SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
466   swig_type_info *lastty = ty;
467   if (!ty || !ty->dcast) return ty;
468   while (ty && (ty->dcast)) {
469     ty = (*ty->dcast)(ptr);
470     if (ty) lastty = ty;
471   }
472   return lastty;
473 }
474 
475 /*
476   Return the name associated with this type
477 */
478 SWIGRUNTIMEINLINE const char *
SWIG_TypeName(const swig_type_info * ty)479 SWIG_TypeName(const swig_type_info *ty) {
480   return ty->name;
481 }
482 
483 /*
484   Return the pretty name associated with this type,
485   that is an unmangled type name in a form presentable to the user.
486 */
487 SWIGRUNTIME const char *
SWIG_TypePrettyName(const swig_type_info * type)488 SWIG_TypePrettyName(const swig_type_info *type) {
489   /* The "str" field contains the equivalent pretty names of the
490      type, separated by vertical-bar characters.  We choose
491      to print the last name, as it is often (?) the most
492      specific. */
493   if (!type) return NULL;
494   if (type->str != NULL) {
495     const char *last_name = type->str;
496     const char *s;
497     for (s = type->str; *s; s++)
498       if (*s == '|') last_name = s+1;
499     return last_name;
500   }
501   else
502     return type->name;
503 }
504 
505 /*
506    Set the clientdata field for a type
507 */
508 SWIGRUNTIME void
SWIG_TypeClientData(swig_type_info * ti,void * clientdata)509 SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
510   swig_cast_info *cast = ti->cast;
511   /* if (ti->clientdata == clientdata) return; */
512   ti->clientdata = clientdata;
513 
514   while (cast) {
515     if (!cast->converter) {
516       swig_type_info *tc = cast->type;
517       if (!tc->clientdata) {
518 	SWIG_TypeClientData(tc, clientdata);
519       }
520     }
521     cast = cast->next;
522   }
523 }
524 SWIGRUNTIME void
SWIG_TypeNewClientData(swig_type_info * ti,void * clientdata)525 SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
526   SWIG_TypeClientData(ti, clientdata);
527   ti->owndata = 1;
528 }
529 
530 /*
531   Search for a swig_type_info structure only by mangled name
532   Search is a O(log #types)
533 
534   We start searching at module start, and finish searching when start == end.
535   Note: if start == end at the beginning of the function, we go all the way around
536   the circular list.
537 */
538 SWIGRUNTIME swig_type_info *
SWIG_MangledTypeQueryModule(swig_module_info * start,swig_module_info * end,const char * name)539 SWIG_MangledTypeQueryModule(swig_module_info *start,
540                             swig_module_info *end,
541 		            const char *name) {
542   swig_module_info *iter = start;
543   do {
544     if (iter->size) {
545       size_t l = 0;
546       size_t r = iter->size - 1;
547       do {
548 	/* since l+r >= 0, we can (>> 1) instead (/ 2) */
549 	size_t i = (l + r) >> 1;
550 	const char *iname = iter->types[i]->name;
551 	if (iname) {
552 	  int compare = strcmp(name, iname);
553 	  if (compare == 0) {
554 	    return iter->types[i];
555 	  } else if (compare < 0) {
556 	    if (i) {
557 	      r = i - 1;
558 	    } else {
559 	      break;
560 	    }
561 	  } else if (compare > 0) {
562 	    l = i + 1;
563 	  }
564 	} else {
565 	  break; /* should never happen */
566 	}
567       } while (l <= r);
568     }
569     iter = iter->next;
570   } while (iter != end);
571   return 0;
572 }
573 
574 /*
575   Search for a swig_type_info structure for either a mangled name or a human readable name.
576   It first searches the mangled names of the types, which is a O(log #types)
577   If a type is not found it then searches the human readable names, which is O(#types).
578 
579   We start searching at module start, and finish searching when start == end.
580   Note: if start == end at the beginning of the function, we go all the way around
581   the circular list.
582 */
583 SWIGRUNTIME swig_type_info *
SWIG_TypeQueryModule(swig_module_info * start,swig_module_info * end,const char * name)584 SWIG_TypeQueryModule(swig_module_info *start,
585                      swig_module_info *end,
586 		     const char *name) {
587   /* STEP 1: Search the name field using binary search */
588   swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
589   if (ret) {
590     return ret;
591   } else {
592     /* STEP 2: If the type hasn't been found, do a complete search
593        of the str field (the human readable name) */
594     swig_module_info *iter = start;
595     do {
596       size_t i = 0;
597       for (; i < iter->size; ++i) {
598 	if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
599 	  return iter->types[i];
600       }
601       iter = iter->next;
602     } while (iter != end);
603   }
604 
605   /* neither found a match */
606   return 0;
607 }
608 
609 /*
610    Pack binary data into a string
611 */
612 SWIGRUNTIME char *
SWIG_PackData(char * c,void * ptr,size_t sz)613 SWIG_PackData(char *c, void *ptr, size_t sz) {
614   static const char hex[17] = "0123456789abcdef";
615   const unsigned char *u = (unsigned char *) ptr;
616   const unsigned char *eu =  u + sz;
617   for (; u != eu; ++u) {
618     unsigned char uu = *u;
619     *(c++) = hex[(uu & 0xf0) >> 4];
620     *(c++) = hex[uu & 0xf];
621   }
622   return c;
623 }
624 
625 /*
626    Unpack binary data from a string
627 */
628 SWIGRUNTIME const char *
SWIG_UnpackData(const char * c,void * ptr,size_t sz)629 SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
630   unsigned char *u = (unsigned char *) ptr;
631   const unsigned char *eu = u + sz;
632   for (; u != eu; ++u) {
633     char d = *(c++);
634     unsigned char uu;
635     if ((d >= '0') && (d <= '9'))
636       uu = ((d - '0') << 4);
637     else if ((d >= 'a') && (d <= 'f'))
638       uu = ((d - ('a'-10)) << 4);
639     else
640       return (char *) 0;
641     d = *(c++);
642     if ((d >= '0') && (d <= '9'))
643       uu |= (d - '0');
644     else if ((d >= 'a') && (d <= 'f'))
645       uu |= (d - ('a'-10));
646     else
647       return (char *) 0;
648     *u = uu;
649   }
650   return c;
651 }
652 
653 /*
654    Pack 'void *' into a string buffer.
655 */
656 SWIGRUNTIME char *
SWIG_PackVoidPtr(char * buff,void * ptr,const char * name,size_t bsz)657 SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
658   char *r = buff;
659   if ((2*sizeof(void *) + 2) > bsz) return 0;
660   *(r++) = '_';
661   r = SWIG_PackData(r,&ptr,sizeof(void *));
662   if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
663   strcpy(r,name);
664   return buff;
665 }
666 
667 SWIGRUNTIME const char *
SWIG_UnpackVoidPtr(const char * c,void ** ptr,const char * name)668 SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
669   if (*c != '_') {
670     if (strcmp(c,"NULL") == 0) {
671       *ptr = (void *) 0;
672       return name;
673     } else {
674       return 0;
675     }
676   }
677   return SWIG_UnpackData(++c,ptr,sizeof(void *));
678 }
679 
680 SWIGRUNTIME char *
SWIG_PackDataName(char * buff,void * ptr,size_t sz,const char * name,size_t bsz)681 SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
682   char *r = buff;
683   size_t lname = (name ? strlen(name) : 0);
684   if ((2*sz + 2 + lname) > bsz) return 0;
685   *(r++) = '_';
686   r = SWIG_PackData(r,ptr,sz);
687   if (lname) {
688     strncpy(r,name,lname+1);
689   } else {
690     *r = 0;
691   }
692   return buff;
693 }
694 
695 SWIGRUNTIME const char *
SWIG_UnpackDataName(const char * c,void * ptr,size_t sz,const char * name)696 SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
697   if (*c != '_') {
698     if (strcmp(c,"NULL") == 0) {
699       memset(ptr,0,sz);
700       return name;
701     } else {
702       return 0;
703     }
704   }
705   return SWIG_UnpackData(++c,ptr,sz);
706 }
707 
708 #ifdef __cplusplus
709 }
710 #endif
711 
712 /*  Errors in SWIG */
713 #define  SWIG_UnknownError    	   -1
714 #define  SWIG_IOError        	   -2
715 #define  SWIG_RuntimeError   	   -3
716 #define  SWIG_IndexError     	   -4
717 #define  SWIG_TypeError      	   -5
718 #define  SWIG_DivisionByZero 	   -6
719 #define  SWIG_OverflowError  	   -7
720 #define  SWIG_SyntaxError    	   -8
721 #define  SWIG_ValueError     	   -9
722 #define  SWIG_SystemError    	   -10
723 #define  SWIG_AttributeError 	   -11
724 #define  SWIG_MemoryError    	   -12
725 #define  SWIG_NullReferenceError   -13
726 
727 
728 
729 #ifdef __cplusplus
730 /* Needed on some windows machines---since MS plays funny games with the header files under C++ */
731 #include <math.h>
732 #include <stdlib.h>
733 extern "C" {
734 #endif
735 #include "EXTERN.h"
736 #include "perl.h"
737 #include "XSUB.h"
738 
739 /* Add in functionality missing in older versions of Perl. Much of this is based on Devel-PPPort on cpan. */
740 
741 /* Add PERL_REVISION, PERL_VERSION, PERL_SUBVERSION if missing */
742 #ifndef PERL_REVISION
743 #  if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION))
744 #    define PERL_PATCHLEVEL_H_IMPLICIT
745 #    include <patchlevel.h>
746 #  endif
747 #  if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL)))
748 #    include <could_not_find_Perl_patchlevel.h>
749 #  endif
750 #  ifndef PERL_REVISION
751 #    define PERL_REVISION       (5)
752 #    define PERL_VERSION        PATCHLEVEL
753 #    define PERL_SUBVERSION     SUBVERSION
754 #  endif
755 #endif
756 
757 #if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE)
758 #define PerlIO_exportFILE(fh,fl) (FILE*)(fh)
759 #endif
760 
761 #ifndef SvIOK_UV
762 # define SvIOK_UV(sv)       (SvIOK(sv) && (SvUVX(sv) == SvIVX(sv)))
763 #endif
764 
765 #ifndef SvUOK
766 # define SvUOK(sv)           SvIOK_UV(sv)
767 #endif
768 
769 #if ((PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5)))
770 #  define PL_sv_undef               sv_undef
771 #  define PL_na	                    na
772 #  define PL_errgv                  errgv
773 #  define PL_sv_no                  sv_no
774 #  define PL_sv_yes                 sv_yes
775 #  define PL_markstack_ptr          markstack_ptr
776 #endif
777 
778 #ifndef IVSIZE
779 #  ifdef LONGSIZE
780 #    define IVSIZE LONGSIZE
781 #  else
782 #    define IVSIZE 4 /* A bold guess, but the best we can make. */
783 #  endif
784 #endif
785 
786 #ifndef INT2PTR
787 #  if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
788 #    define PTRV                  UV
789 #    define INT2PTR(any,d)        (any)(d)
790 #  else
791 #    if PTRSIZE == LONGSIZE
792 #      define PTRV                unsigned long
793 #    else
794 #      define PTRV                unsigned
795 #    endif
796 #    define INT2PTR(any,d)        (any)(PTRV)(d)
797 #  endif
798 
799 #  define NUM2PTR(any,d)  (any)(PTRV)(d)
800 #  define PTR2IV(p)       INT2PTR(IV,p)
801 #  define PTR2UV(p)       INT2PTR(UV,p)
802 #  define PTR2NV(p)       NUM2PTR(NV,p)
803 
804 #  if PTRSIZE == LONGSIZE
805 #    define PTR2ul(p)     (unsigned long)(p)
806 #  else
807 #    define PTR2ul(p)     INT2PTR(unsigned long,p)
808 #  endif
809 #endif /* !INT2PTR */
810 
811 #ifndef SvPV_nolen
812 # define SvPV_nolen(x) SvPV(x,PL_na)
813 #endif
814 
815 #ifndef get_sv
816 #  define get_sv perl_get_sv
817 #endif
818 
819 #ifndef ERRSV
820 #  define ERRSV get_sv("@",FALSE)
821 #endif
822 
823 #ifndef pTHX_
824 #define pTHX_
825 #endif
826 
827 #include <string.h>
828 #ifdef __cplusplus
829 }
830 #endif
831 
832 /* -----------------------------------------------------------------------------
833  * error manipulation
834  * ----------------------------------------------------------------------------- */
835 
836 SWIGINTERN const char*
SWIG_Perl_ErrorType(int code)837 SWIG_Perl_ErrorType(int code) {
838   switch(code) {
839   case SWIG_MemoryError:
840     return "MemoryError";
841   case SWIG_IOError:
842     return "IOError";
843   case SWIG_RuntimeError:
844     return "RuntimeError";
845   case SWIG_IndexError:
846     return "IndexError";
847   case SWIG_TypeError:
848     return "TypeError";
849   case SWIG_DivisionByZero:
850     return "ZeroDivisionError";
851   case SWIG_OverflowError:
852     return "OverflowError";
853   case SWIG_SyntaxError:
854     return "SyntaxError";
855   case SWIG_ValueError:
856     return "ValueError";
857   case SWIG_SystemError:
858     return "SystemError";
859   case SWIG_AttributeError:
860     return "AttributeError";
861   default:
862     return "RuntimeError";
863   }
864 }
865 
866 
867 /* -----------------------------------------------------------------------------
868  * perlrun.swg
869  *
870  * This file contains the runtime support for Perl modules
871  * and includes code for managing global variables and pointer
872  * type checking.
873  * ----------------------------------------------------------------------------- */
874 
875 #ifdef PERL_OBJECT
876 #define SWIG_PERL_OBJECT_DECL CPerlObj *SWIGUNUSEDPARM(pPerl),
877 #define SWIG_PERL_OBJECT_CALL pPerl,
878 #else
879 #define SWIG_PERL_OBJECT_DECL
880 #define SWIG_PERL_OBJECT_CALL
881 #endif
882 
883 /* Common SWIG API */
884 
885 /* for raw pointers */
886 #define SWIG_ConvertPtr(obj, pp, type, flags)           SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags)
887 #define SWIG_ConvertPtrAndOwn(obj, pp, type, flags,own) SWIG_Perl_ConvertPtrAndOwn(SWIG_PERL_OBJECT_CALL obj, pp, type, flags, own)
888 #define SWIG_NewPointerObj(p, type, flags)              SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags)
889 #define swig_owntype                                    int
890 
891 /* for raw packed data */
892 #define SWIG_ConvertPacked(obj, p, s, type)             SWIG_Perl_ConvertPacked(SWIG_PERL_OBJECT_CALL obj, p, s, type)
893 #define SWIG_NewPackedObj(p, s, type)	                SWIG_Perl_NewPackedObj(SWIG_PERL_OBJECT_CALL p, s, type)
894 
895 /* for class or struct pointers */
896 #define SWIG_ConvertInstance(obj, pptr, type, flags)    SWIG_ConvertPtr(obj, pptr, type, flags)
897 #define SWIG_NewInstanceObj(ptr, type, flags)           SWIG_NewPointerObj(ptr, type, flags)
898 
899 /* for C or C++ function pointers */
900 #define SWIG_ConvertFunctionPtr(obj, pptr, type)        SWIG_ConvertPtr(obj, pptr, type, 0)
901 #define SWIG_NewFunctionPtrObj(ptr, type)               SWIG_NewPointerObj(ptr, type, 0)
902 
903 /* for C++ member pointers, ie, member methods */
904 #define SWIG_ConvertMember(obj, ptr, sz, ty)            SWIG_ConvertPacked(obj, ptr, sz, ty)
905 #define SWIG_NewMemberObj(ptr, sz, type)                SWIG_NewPackedObj(ptr, sz, type)
906 
907 
908 /* Runtime API */
909 
910 #define SWIG_GetModule(clientdata)                      SWIG_Perl_GetModule(clientdata)
911 #define SWIG_SetModule(clientdata, pointer)             SWIG_Perl_SetModule(pointer)
912 
913 
914 /* Error manipulation */
915 
916 #define SWIG_ErrorType(code)                            SWIG_Perl_ErrorType(code)
917 #define SWIG_Error(code, msg)            		sv_setpvf(get_sv("@", GV_ADD), "%s %s", SWIG_ErrorType(code), msg)
918 #define SWIG_fail                        		goto fail
919 
920 /* Perl-specific SWIG API */
921 
922 #define SWIG_MakePtr(sv, ptr, type, flags)              SWIG_Perl_MakePtr(SWIG_PERL_OBJECT_CALL sv, ptr, type, flags)
923 #define SWIG_MakePackedObj(sv, p, s, type)	        SWIG_Perl_MakePackedObj(SWIG_PERL_OBJECT_CALL sv, p, s, type)
924 #define SWIG_SetError(str)                              SWIG_Error(SWIG_RuntimeError, str)
925 
926 
927 #define SWIG_PERL_DECL_ARGS_1(arg1)                     (SWIG_PERL_OBJECT_DECL arg1)
928 #define SWIG_PERL_CALL_ARGS_1(arg1)                     (SWIG_PERL_OBJECT_CALL arg1)
929 #define SWIG_PERL_DECL_ARGS_2(arg1, arg2)               (SWIG_PERL_OBJECT_DECL arg1, arg2)
930 #define SWIG_PERL_CALL_ARGS_2(arg1, arg2)               (SWIG_PERL_OBJECT_CALL arg1, arg2)
931 
932 /* -----------------------------------------------------------------------------
933  * pointers/data manipulation
934  * ----------------------------------------------------------------------------- */
935 
936 /* For backward compatibility only */
937 #define SWIG_POINTER_EXCEPTION  0
938 
939 #ifdef __cplusplus
940 extern "C" {
941 #endif
942 
943 #define SWIG_OWNER   SWIG_POINTER_OWN
944 #define SWIG_SHADOW  SWIG_OWNER << 1
945 
946 #define SWIG_MAYBE_PERL_OBJECT SWIG_PERL_OBJECT_DECL
947 
948 /* SWIG Perl macros */
949 
950 /* Macro to declare an XS function */
951 #ifndef XSPROTO
952 #   define XSPROTO(name) void name(pTHX_ CV* cv)
953 #endif
954 
955 /* Macro to call an XS function */
956 #ifdef PERL_OBJECT
957 #  define SWIG_CALLXS(_name) _name(cv,pPerl)
958 #else
959 #  ifndef MULTIPLICITY
960 #    define SWIG_CALLXS(_name) _name(cv)
961 #  else
962 #    define SWIG_CALLXS(_name) _name(PERL_GET_THX, cv)
963 #  endif
964 #endif
965 
966 #ifdef PERL_OBJECT
967 #define MAGIC_PPERL  CPerlObj *pPerl = (CPerlObj *) this;
968 
969 #ifdef __cplusplus
970 extern "C" {
971 #endif
972 typedef int (CPerlObj::*SwigMagicFunc)(SV *, MAGIC *);
973 #ifdef __cplusplus
974 }
975 #endif
976 
977 #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
978 #define SWIGCLASS_STATIC
979 
980 #else /* PERL_OBJECT */
981 
982 #define MAGIC_PPERL
983 #define SWIGCLASS_STATIC static SWIGUNUSED
984 
985 #ifndef MULTIPLICITY
986 #define SWIG_MAGIC(a,b) (SV *a, MAGIC *b)
987 
988 #ifdef __cplusplus
989 extern "C" {
990 #endif
991 typedef int (*SwigMagicFunc)(SV *, MAGIC *);
992 #ifdef __cplusplus
993 }
994 #endif
995 
996 #else /* MULTIPLICITY */
997 
998 #define SWIG_MAGIC(a,b) (struct interpreter *interp, SV *a, MAGIC *b)
999 
1000 #ifdef __cplusplus
1001 extern "C" {
1002 #endif
1003 typedef int (*SwigMagicFunc)(struct interpreter *, SV *, MAGIC *);
1004 #ifdef __cplusplus
1005 }
1006 #endif
1007 
1008 #endif /* MULTIPLICITY */
1009 #endif /* PERL_OBJECT */
1010 
1011 #  ifdef PERL_OBJECT
1012 #    define SWIG_croak_null() SWIG_Perl_croak_null(pPerl)
SWIG_Perl_croak_null(CPerlObj * pPerl)1013 static void SWIG_Perl_croak_null(CPerlObj *pPerl)
1014 #  else
1015 static void SWIG_croak_null()
1016 #  endif
1017 {
1018   SV *err = get_sv("@", GV_ADD);
1019 #  if (PERL_VERSION < 6)
1020   croak("%_", err);
1021 #  else
1022   if (sv_isobject(err))
1023     croak(0);
1024   else
1025     croak("%s", SvPV_nolen(err));
1026 #  endif
1027 }
1028 
1029 
1030 /*
1031    Define how strict is the cast between strings and integers/doubles
1032    when overloading between these types occurs.
1033 
1034    The default is making it as strict as possible by using SWIG_AddCast
1035    when needed.
1036 
1037    You can use -DSWIG_PERL_NO_STRICT_STR2NUM at compilation time to
1038    disable the SWIG_AddCast, making the casting between string and
1039    numbers less strict.
1040 
1041    In the end, we try to solve the overloading between strings and
1042    numerical types in the more natural way, but if you can avoid it,
1043    well, avoid it using %rename, for example.
1044 */
1045 #ifndef SWIG_PERL_NO_STRICT_STR2NUM
1046 # ifndef SWIG_PERL_STRICT_STR2NUM
1047 #  define SWIG_PERL_STRICT_STR2NUM
1048 # endif
1049 #endif
1050 #ifdef SWIG_PERL_STRICT_STR2NUM
1051 /* string takes precedence */
1052 #define SWIG_Str2NumCast(x) SWIG_AddCast(x)
1053 #else
1054 /* number takes precedence */
1055 #define SWIG_Str2NumCast(x) x
1056 #endif
1057 
1058 
1059 
1060 #include <stdlib.h>
1061 
1062 SWIGRUNTIME const char *
SWIG_Perl_TypeProxyName(const swig_type_info * type)1063 SWIG_Perl_TypeProxyName(const swig_type_info *type) {
1064   if (!type) return NULL;
1065   if (type->clientdata != NULL) {
1066     return (const char*) type->clientdata;
1067   }
1068   else {
1069     return type->name;
1070   }
1071 }
1072 
1073 /* Identical to SWIG_TypeCheck, except for strcmp comparison */
1074 SWIGRUNTIME swig_cast_info *
SWIG_TypeProxyCheck(const char * c,swig_type_info * ty)1075 SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) {
1076   if (ty) {
1077     swig_cast_info *iter = ty->cast;
1078     while (iter) {
1079       if (strcmp(SWIG_Perl_TypeProxyName(iter->type), c) == 0) {
1080         if (iter == ty->cast)
1081           return iter;
1082         /* Move iter to the top of the linked list */
1083         iter->prev->next = iter->next;
1084         if (iter->next)
1085           iter->next->prev = iter->prev;
1086         iter->next = ty->cast;
1087         iter->prev = 0;
1088         if (ty->cast) ty->cast->prev = iter;
1089         ty->cast = iter;
1090         return iter;
1091       }
1092       iter = iter->next;
1093     }
1094   }
1095   return 0;
1096 }
1097 
1098 /* Function for getting a pointer value */
1099 
1100 SWIGRUNTIME int
SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV * sv,void ** ptr,swig_type_info * _t,int flags,int * own)1101 SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags, int *own) {
1102   swig_cast_info *tc;
1103   void *voidptr = (void *)0;
1104   SV *tsv = 0;
1105 
1106   if (own)
1107     *own = 0;
1108 
1109   /* If magical, apply more magic */
1110   if (SvGMAGICAL(sv))
1111     mg_get(sv);
1112 
1113   /* Check to see if this is an object */
1114   if (sv_isobject(sv)) {
1115     IV tmp = 0;
1116     tsv = (SV*) SvRV(sv);
1117     if ((SvTYPE(tsv) == SVt_PVHV)) {
1118       MAGIC *mg;
1119       if (SvMAGICAL(tsv)) {
1120         mg = mg_find(tsv,'P');
1121         if (mg) {
1122           sv = mg->mg_obj;
1123           if (sv_isobject(sv)) {
1124 	    tsv = (SV*)SvRV(sv);
1125             tmp = SvIV(tsv);
1126           }
1127         }
1128       } else {
1129         return SWIG_ERROR;
1130       }
1131     } else {
1132       tmp = SvIV(tsv);
1133     }
1134     voidptr = INT2PTR(void *,tmp);
1135   } else if (! SvOK(sv)) {            /* Check for undef */
1136     *(ptr) = (void *) 0;
1137     return SWIG_OK;
1138   } else if (SvTYPE(sv) == SVt_RV) {  /* Check for NULL pointer */
1139     if (!SvROK(sv)) {
1140       /* In Perl 5.12 and later, SVt_RV == SVt_IV, so sv could be a valid integer value.  */
1141       if (SvIOK(sv)) {
1142         return SWIG_ERROR;
1143       } else {
1144         /* NULL pointer (reference to undef). */
1145         *(ptr) = (void *) 0;
1146         return SWIG_OK;
1147       }
1148     } else {
1149       return SWIG_ERROR;
1150     }
1151   } else {                            /* Don't know what it is */
1152     return SWIG_ERROR;
1153   }
1154   if (_t) {
1155     /* Now see if the types match */
1156     char *_c = HvNAME(SvSTASH(SvRV(sv)));
1157     tc = SWIG_TypeProxyCheck(_c,_t);
1158 #ifdef SWIG_DIRECTORS
1159     if (!tc && !sv_derived_from(sv,SWIG_Perl_TypeProxyName(_t))) {
1160 #else
1161     if (!tc) {
1162 #endif
1163       return SWIG_ERROR;
1164     }
1165     {
1166       int newmemory = 0;
1167       *ptr = SWIG_TypeCast(tc,voidptr,&newmemory);
1168       if (newmemory == SWIG_CAST_NEW_MEMORY) {
1169         assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
1170         if (own)
1171           *own = *own | SWIG_CAST_NEW_MEMORY;
1172       }
1173     }
1174   } else {
1175     *ptr = voidptr;
1176   }
1177 
1178   /*
1179    *  DISOWN implementation: we need a perl guru to check this one.
1180    */
1181   if (tsv && (flags & SWIG_POINTER_DISOWN)) {
1182     /*
1183      *  almost copy paste code from below SWIG_POINTER_OWN setting
1184      */
1185     SV *obj = sv;
1186     HV *stash = SvSTASH(SvRV(obj));
1187     GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
1188     if (isGV(gv)) {
1189       HV *hv = GvHVn(gv);
1190       /*
1191        * To set ownership (see below), a newSViv(1) entry is added.
1192        * Hence, to remove ownership, we delete the entry.
1193        */
1194       if (hv_exists_ent(hv, obj, 0)) {
1195 	hv_delete_ent(hv, obj, 0, 0);
1196       }
1197     }
1198   }
1199   return SWIG_OK;
1200 }
1201 
1202 SWIGRUNTIME int
1203 SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) {
1204   return SWIG_Perl_ConvertPtrAndOwn(sv, ptr, _t, flags, 0);
1205 }
1206 
1207 SWIGRUNTIME void
1208 SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) {
1209   if (ptr && (flags & (SWIG_SHADOW | SWIG_POINTER_OWN))) {
1210     SV *self;
1211     SV *obj=newSV(0);
1212     HV *hash=newHV();
1213     HV *stash;
1214     sv_setref_pv(obj, SWIG_Perl_TypeProxyName(t), ptr);
1215     stash=SvSTASH(SvRV(obj));
1216     if (flags & SWIG_POINTER_OWN) {
1217       HV *hv;
1218       GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE);
1219       if (!isGV(gv))
1220         gv_init(gv, stash, "OWNER", 5, FALSE);
1221       hv=GvHVn(gv);
1222       hv_store_ent(hv, obj, newSViv(1), 0);
1223     }
1224     sv_magic((SV *)hash, (SV *)obj, 'P', Nullch, 0);
1225     SvREFCNT_dec(obj);
1226     self=newRV_noinc((SV *)hash);
1227     sv_setsv(sv, self);
1228     SvREFCNT_dec((SV *)self);
1229     sv_bless(sv, stash);
1230   }
1231   else {
1232     sv_setref_pv(sv, SWIG_Perl_TypeProxyName(t), ptr);
1233   }
1234 }
1235 
1236 SWIGRUNTIMEINLINE SV *
1237 SWIG_Perl_NewPointerObj(SWIG_MAYBE_PERL_OBJECT void *ptr, swig_type_info *t, int flags) {
1238   SV *result = sv_newmortal();
1239   SWIG_MakePtr(result, ptr, t, flags);
1240   return result;
1241 }
1242 
1243 SWIGRUNTIME void
1244 SWIG_Perl_MakePackedObj(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, int sz, swig_type_info *type) {
1245   char result[1024];
1246   char *r = result;
1247   if ((2*sz + 1 + strlen(SWIG_Perl_TypeProxyName(type))) > 1000) return;
1248   *(r++) = '_';
1249   r = SWIG_PackData(r,ptr,sz);
1250   strcpy(r,SWIG_Perl_TypeProxyName(type));
1251   sv_setpv(sv, result);
1252 }
1253 
1254 SWIGRUNTIME SV *
1255 SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info *type) {
1256   SV *result = sv_newmortal();
1257   SWIG_Perl_MakePackedObj(result, ptr, sz, type);
1258   return result;
1259 }
1260 
1261 /* Convert a packed value value */
1262 SWIGRUNTIME int
1263 SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) {
1264   swig_cast_info *tc;
1265   const char  *c = 0;
1266 
1267   if ((!obj) || (!SvOK(obj))) return SWIG_ERROR;
1268   c = SvPV_nolen(obj);
1269   /* Pointer values must start with leading underscore */
1270   if (*c != '_') return SWIG_ERROR;
1271   c++;
1272   c = SWIG_UnpackData(c,ptr,sz);
1273   if (ty) {
1274     tc = SWIG_TypeCheck(c,ty);
1275     if (!tc) return SWIG_ERROR;
1276   }
1277   return SWIG_OK;
1278 }
1279 
1280 
1281 /* Macros for low-level exception handling */
1282 #define SWIG_croak(x)    { SWIG_Error(SWIG_RuntimeError, x); SWIG_fail; }
1283 
1284 
1285 typedef XSPROTO(SwigPerlWrapper);
1286 typedef SwigPerlWrapper *SwigPerlWrapperPtr;
1287 
1288 /* Structure for command table */
1289 typedef struct {
1290   const char         *name;
1291   SwigPerlWrapperPtr  wrapper;
1292 } swig_command_info;
1293 
1294 /* Information for constant table */
1295 
1296 #define SWIG_INT     1
1297 #define SWIG_FLOAT   2
1298 #define SWIG_STRING  3
1299 #define SWIG_POINTER 4
1300 #define SWIG_BINARY  5
1301 
1302 /* Constant information structure */
1303 typedef struct swig_constant_info {
1304     int              type;
1305     const char      *name;
1306     long             lvalue;
1307     double           dvalue;
1308     void            *pvalue;
1309     swig_type_info **ptype;
1310 } swig_constant_info;
1311 
1312 
1313 /* Structure for variable table */
1314 typedef struct {
1315   const char   *name;
1316   SwigMagicFunc   set;
1317   SwigMagicFunc   get;
1318   swig_type_info  **type;
1319 } swig_variable_info;
1320 
1321 /* Magic variable code */
1322 #ifndef PERL_OBJECT
1323 # ifdef __cplusplus
1324 #  define swig_create_magic(s,a,b,c) _swig_create_magic(s,const_cast<char*>(a),b,c)
1325 # else
1326 #  define swig_create_magic(s,a,b,c) _swig_create_magic(s,(char*)(a),b,c)
1327 # endif
1328 # ifndef MULTIPLICITY
1329 SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *))
1330 # else
1331 SWIGRUNTIME void _swig_create_magic(SV *sv, char *name, int (*set)(struct interpreter*, SV *, MAGIC *), int (*get)(struct interpreter*, SV *,MAGIC *))
1332 # endif
1333 #else
1334 #  define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c)
1335 SWIGRUNTIME void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *))
1336 #endif
1337 {
1338   MAGIC *mg;
1339   sv_magic(sv,sv,'U',name,strlen(name));
1340   mg = mg_find(sv,'U');
1341   mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL));
1342   mg->mg_virtual->svt_get = (SwigMagicFunc) get;
1343   mg->mg_virtual->svt_set = (SwigMagicFunc) set;
1344   mg->mg_virtual->svt_len = 0;
1345   mg->mg_virtual->svt_clear = 0;
1346   mg->mg_virtual->svt_free = 0;
1347 }
1348 
1349 
1350 SWIGRUNTIME swig_module_info *
1351 SWIG_Perl_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
1352   static void *type_pointer = (void *)0;
1353   SV *pointer;
1354 
1355   /* first check if pointer already created */
1356   if (!type_pointer) {
1357     pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE | GV_ADDMULTI);
1358     if (pointer && SvOK(pointer)) {
1359       type_pointer = INT2PTR(swig_type_info **, SvIV(pointer));
1360     }
1361   }
1362 
1363   return (swig_module_info *) type_pointer;
1364 }
1365 
1366 SWIGRUNTIME void
1367 SWIG_Perl_SetModule(swig_module_info *module) {
1368   SV *pointer;
1369 
1370   /* create a new pointer */
1371   pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE | GV_ADDMULTI);
1372   sv_setiv(pointer, PTR2IV(module));
1373 }
1374 
1375 #ifdef __cplusplus
1376 }
1377 #endif
1378 
1379 /* Workaround perl5 global namespace pollution. Note that undefining library
1380  * functions like fopen will not solve the problem on all platforms as fopen
1381  * might be a macro on Windows but not necessarily on other operating systems. */
1382 #ifdef do_open
1383   #undef do_open
1384 #endif
1385 #ifdef do_close
1386   #undef do_close
1387 #endif
1388 #ifdef do_exec
1389   #undef do_exec
1390 #endif
1391 #ifdef scalar
1392   #undef scalar
1393 #endif
1394 #ifdef list
1395   #undef list
1396 #endif
1397 #ifdef apply
1398   #undef apply
1399 #endif
1400 #ifdef convert
1401   #undef convert
1402 #endif
1403 #ifdef Error
1404   #undef Error
1405 #endif
1406 #ifdef form
1407   #undef form
1408 #endif
1409 #ifdef vform
1410   #undef vform
1411 #endif
1412 #ifdef LABEL
1413   #undef LABEL
1414 #endif
1415 #ifdef METHOD
1416   #undef METHOD
1417 #endif
1418 #ifdef Move
1419   #undef Move
1420 #endif
1421 #ifdef yylex
1422   #undef yylex
1423 #endif
1424 #ifdef yyparse
1425   #undef yyparse
1426 #endif
1427 #ifdef yyerror
1428   #undef yyerror
1429 #endif
1430 #ifdef invert
1431   #undef invert
1432 #endif
1433 #ifdef ref
1434   #undef ref
1435 #endif
1436 #ifdef read
1437   #undef read
1438 #endif
1439 #ifdef write
1440   #undef write
1441 #endif
1442 #ifdef eof
1443   #undef eof
1444 #endif
1445 #ifdef close
1446   #undef close
1447 #endif
1448 #ifdef rewind
1449   #undef rewind
1450 #endif
1451 #ifdef free
1452   #undef free
1453 #endif
1454 #ifdef malloc
1455   #undef malloc
1456 #endif
1457 #ifdef calloc
1458   #undef calloc
1459 #endif
1460 #ifdef Stat
1461   #undef Stat
1462 #endif
1463 #ifdef check
1464   #undef check
1465 #endif
1466 #ifdef seekdir
1467   #undef seekdir
1468 #endif
1469 #ifdef open
1470   #undef open
1471 #endif
1472 #ifdef readdir
1473   #undef readdir
1474 #endif
1475 #ifdef bind
1476   #undef bind
1477 #endif
1478 #ifdef access
1479   #undef access
1480 #endif
1481 #ifdef stat
1482   #undef stat
1483 #endif
1484 #ifdef seed
1485   #undef seed
1486 #endif
1487 
1488 #ifdef bool
1489   /* Leave if macro is from C99 stdbool.h */
1490   #ifndef __bool_true_false_are_defined
1491 
1492   #endif
1493 #endif
1494 
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_amar_attr_t swig_types[0]
1510 #define SWIGTYPE_p_amar_file_t swig_types[1]
1511 #define SWIGTYPE_p_amar_t swig_types[2]
1512 #define SWIGTYPE_p_char swig_types[3]
1513 #define SWIGTYPE_p_double swig_types[4]
1514 #define SWIGTYPE_p_float swig_types[5]
1515 #define SWIGTYPE_p_gsize swig_types[6]
1516 #define SWIGTYPE_p_guint16 swig_types[7]
1517 #define SWIGTYPE_p_int swig_types[8]
1518 #define SWIGTYPE_p_off_t swig_types[9]
1519 #define SWIGTYPE_p_perl_read_data_t swig_types[10]
1520 #define SWIGTYPE_p_unsigned_char swig_types[11]
1521 static swig_type_info *swig_types[13];
1522 static swig_module_info swig_module = {swig_types, 12, 0, 0, 0, 0};
1523 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
1524 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
1525 
1526 /* -------- TYPES TABLE (END) -------- */
1527 
1528 #define SWIG_init    boot_Amanda__Archive
1529 
1530 #define SWIG_name   "Amanda::Archivec::boot_Amanda__Archive"
1531 #define SWIG_prefix "Amanda::Archivec::"
1532 
1533 #define SWIGVERSION 0x030007
1534 #define SWIG_VERSION SWIGVERSION
1535 
1536 
1537 #define SWIG_as_voidptr(a) (void *)((const void *)(a))
1538 #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
1539 
1540 
1541 #ifdef __cplusplus
1542 extern "C"
1543 #endif
1544 #ifndef PERL_OBJECT
1545 #ifndef MULTIPLICITY
1546 SWIGEXPORT void SWIG_init (CV* cv);
1547 #else
1548 SWIGEXPORT void SWIG_init (pTHXo_ CV* cv);
1549 #endif
1550 #else
1551 SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *);
1552 #endif
1553 
1554 
1555 #include "amglue.h"
1556 
1557 
1558 #include "amglue.h"
1559 
1560 
1561 #include "amglue.h"
1562 
1563 
1564 #include "amar.h"
1565 
1566 
1567 SWIGINTERNINLINE SV *
SWIG_PERL_DECL_ARGS_1(long value)1568 SWIG_From_long  SWIG_PERL_DECL_ARGS_1(long value)
1569 {
1570   SV *sv;
1571   if (value >= IV_MIN && value <= IV_MAX)
1572     sv = newSViv(value);
1573   else
1574     sv = newSVpvf("%ld", value);
1575   return sv_2mortal(sv);
1576 }
1577 
1578 
1579 SWIGINTERNINLINE SV *
SWIG_PERL_DECL_ARGS_1(int value)1580 SWIG_From_int  SWIG_PERL_DECL_ARGS_1(int value)
1581 {
1582   return SWIG_From_long  SWIG_PERL_CALL_ARGS_1(value);
1583 }
1584 
1585 
1586 /* Support code (not directly available from perl) */
1587 
1588 #define AMANDA_ARCHIVE_ERROR_DOMAIN "Amanda archive"
1589 
1590 /* A C object to contain all of the relevant callbacks and other state during a
1591  * read operation; this becomes the user_data during the read */
1592 typedef struct perl_read_data_s {
1593     SV *user_data;
1594     SV *file_start_sub;
1595     SV *file_finish_sub;
1596     SV *done_sub;
1597 
1598     amar_attr_handling_t *handling_array;
1599     amar_t *archive;
1600     GError *error;
1601 } perl_read_data_t;
1602 
1603 static gboolean
read_start_file_cb(gpointer user_data,guint16 filenum,gpointer filename,gsize filename_len,gboolean * ignore,gpointer * file_data)1604 read_start_file_cb(
1605 	gpointer user_data,
1606 	guint16  filenum,
1607 	gpointer filename,
1608 	gsize filename_len,
1609 	gboolean *ignore,
1610 	gpointer *file_data)
1611 {
1612     dSP;
1613     perl_read_data_t *dat = user_data;
1614     SV *rv = NULL;
1615     STRLEN len;
1616     int count;
1617 
1618     *file_data = NULL;
1619 
1620     g_assert(dat->file_start_sub != NULL);
1621 
1622     ENTER;
1623     SAVETMPS;
1624 
1625     PUSHMARK(SP);
1626     XPUSHs(dat->user_data);
1627     XPUSHs(sv_2mortal(newSViv(filenum)));
1628     XPUSHs(sv_2mortal(newSVpvn(filename, filename_len)));
1629     PUTBACK;
1630 
1631     count = call_sv(dat->file_start_sub, G_EVAL|G_SCALAR);
1632 
1633     SPAGAIN;
1634 
1635     if (count != 1)
1636 	croak("file_start_sub returned nothing");
1637 
1638     rv = POPs;
1639 
1640     /* if it's the string "IGNORE", then ignore it */
1641     if (SvPOK(rv)) {
1642 	static const char *ign = "IGNORE";
1643 	char *rvstr = SvPV(rv, len);
1644 	if (strlen(ign) == len && 0 == strncmp(ign, rvstr, len))
1645 	    *ignore = TRUE;
1646     }
1647 
1648     /* otherwise, keep the value */
1649     if (!*ignore)
1650 	*(SV **)(file_data) = SvREFCNT_inc(rv);
1651 
1652     PUTBACK;
1653     FREETMPS;
1654     LEAVE;
1655 
1656     if (SvTRUE(ERRSV)) {
1657 	if (dat && dat->archive) {
1658 	    amar_set_error(dat->archive, SvPV_nolen(ERRSV));
1659 	}
1660 	POPs;
1661 	return FALSE;
1662     }
1663     return TRUE;
1664 }
1665 
1666 static gboolean
read_finish_file_cb(gpointer user_data,guint16 filenum,gpointer * file_data,gboolean truncated)1667 read_finish_file_cb(
1668 	gpointer user_data,
1669 	guint16  filenum,
1670 	gpointer *file_data,
1671 	gboolean truncated)
1672 {
1673     dSP;
1674     perl_read_data_t *dat = user_data;
1675 
1676     g_assert(dat->file_finish_sub != NULL);
1677 
1678     ENTER;
1679     SAVETMPS;
1680 
1681     PUSHMARK(SP); XPUSHs(dat->user_data); XPUSHs(*(SV **)file_data);
1682     XPUSHs(sv_2mortal(newSViv(filenum)));
1683     XPUSHs(sv_2mortal(newSViv(truncated))); PUTBACK;
1684 
1685     call_sv(dat->file_finish_sub, G_EVAL|G_DISCARD);
1686 
1687     /* we're done with this file's file_data */
1688     SvREFCNT_dec(*(SV **)file_data);
1689 
1690     FREETMPS;
1691     LEAVE;
1692 
1693     if (SvTRUE(ERRSV)) {
1694 	if (dat && dat->archive) {
1695 	    amar_set_error(dat->archive, SvPV_nolen(ERRSV));
1696 	}
1697 	POPs;
1698 	return FALSE;
1699     }
1700     return TRUE;
1701 }
1702 
1703 static gboolean
read_done_cb(gpointer user_data,GError * error)1704 read_done_cb(
1705     gpointer  user_data,
1706     GError   *error)
1707 {
1708     dSP;
1709     perl_read_data_t *dat = user_data;
1710     gboolean rv = TRUE;
1711 
1712     g_assert(dat->done_sub != NULL);
1713 
1714     ENTER;
1715     SAVETMPS;
1716 
1717     PUSHMARK(SP);
1718     if (dat && dat->error && dat->error->message) {
1719 	XPUSHs(sv_2mortal(newSVpv(dat->error->message, 0)));
1720     } else if (error && error->message) {
1721 	XPUSHs(sv_2mortal(newSVpv(error->message, 0)));
1722     }
1723     PUTBACK;
1724 
1725     call_sv(dat->done_sub, G_EVAL|G_DISCARD);
1726 
1727     SPAGAIN;
1728 
1729     if (SvTRUE(ERRSV)) {
1730 	fprintf(stderr,"read_done failed: %s", SvPV_nolen(ERRSV));
1731 	POPs;
1732 	rv = FALSE;
1733     }
1734 
1735     PUTBACK;
1736     FREETMPS;
1737     LEAVE;
1738 
1739     return rv;
1740 }
1741 
1742 static gboolean
read_frag_cb(gpointer user_data,guint16 filenum,gpointer file_data,guint16 attrid,gpointer attrid_data,gpointer * attr_data,gpointer data,gsize size,gboolean eoa,gboolean truncated)1743 read_frag_cb(
1744 	gpointer user_data,
1745 	guint16  filenum,
1746 	gpointer file_data,
1747 	guint16  attrid,
1748 	gpointer attrid_data,
1749 	gpointer *attr_data,
1750 	gpointer data,
1751 	gsize size,
1752 	gboolean eoa,
1753 	gboolean truncated)
1754 {
1755     dSP;
1756     perl_read_data_t *dat = user_data;
1757     SV *rv;
1758     int count;
1759 
1760     if (!attrid_data)
1761 	return TRUE;
1762 
1763     ENTER;
1764     SAVETMPS;
1765 
1766     PUSHMARK(SP);
1767     XPUSHs(dat->user_data);
1768     XPUSHs(sv_2mortal(newSViv(filenum)));
1769     XPUSHs((SV *)file_data);
1770     XPUSHs(sv_2mortal(newSViv(attrid)));
1771     if (*attr_data)
1772         XPUSHs((SV *)(*attr_data));
1773     else
1774         XPUSHs(&PL_sv_undef);
1775     XPUSHs(sv_2mortal(newSVpvn(data, size)));
1776     XPUSHs(sv_2mortal(newSViv(eoa)));
1777     XPUSHs(sv_2mortal(newSViv(truncated)));
1778     PUTBACK;
1779 
1780     count = call_sv(attrid_data, G_EVAL|G_SCALAR);
1781 
1782     SPAGAIN;
1783 
1784     if (count != 1)
1785 	croak("fragment callback returned nothing");
1786 
1787     rv = POPs;
1788 
1789     if (eoa) {
1790         SvREFCNT_dec(*attr_data);
1791     } else {
1792         /* increment before decrement here, in case they're the same object */
1793         SvREFCNT_inc(rv);
1794         SvREFCNT_dec(*attr_data);
1795         *attr_data = rv;
1796     }
1797 
1798     FREETMPS;
1799     LEAVE;
1800 
1801     if (SvTRUE(ERRSV)) {
1802 	amar_set_error(dat->archive, SvPV_nolen(ERRSV));
1803 	POPs;
1804 	return FALSE;
1805     }
1806     return TRUE;
1807 }
1808 
1809 /* generic function to recognize when a string+len represents a number and
1810  * incidentally return the resulting value.  Note that this does not handle
1811  * negative numbers. */
1812 static gboolean
is_number(char * str,int len,int * result)1813 is_number(char *str, int len, int *result)
1814 {
1815     char *end = str+len;
1816     int r = 0;
1817 
1818     while (str < end) {
1819 	if (!g_ascii_isdigit(*str)) return FALSE;
1820 	r = r * 10 + (int)(*str - '0');
1821 	if (r < 0) {
1822 	    /* overflow */
1823 	    return FALSE;
1824 	}
1825 	str++;
1826     }
1827 
1828     *result = r;
1829     return TRUE;
1830 }
1831 
1832 
1833 
1834 
1835 /* Wrapper functions, mostly dealing with error handling */
1836 
amar_new_(int fd,char * modestr)1837 amar_t *amar_new_(int fd, char *modestr) {
1838     GError *error = NULL;
1839     amar_t *rv;
1840     int mode;
1841 
1842     if (strcmp(modestr, ">") == 0)
1843 	mode = O_WRONLY;
1844     else if (strcmp(modestr, "<") == 0)
1845 	mode = O_RDONLY;
1846     else
1847 	croak("mode must be '<' or '>'");
1848 
1849     if ((rv = amar_new(fd, mode, &error))) {
1850 	return rv;
1851     }
1852 
1853     croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
1854     return NULL;
1855 }
1856 
amar_size_(amar_t * archive)1857 off_t amar_size_(amar_t *archive) {
1858     return amar_size(archive);
1859 }
1860 
amar_close_(amar_t * arch)1861 void amar_close_(amar_t *arch) {
1862     GError *error = NULL;
1863     if (!amar_close(arch, &error))
1864 	croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
1865 }
1866 
1867 amar_file_t *
amar_new_file_(amar_t * arch,char * filename,gsize filename_len,off_t * want_position)1868 amar_new_file_(amar_t *arch, char *filename, gsize filename_len, off_t *want_position) {
1869     GError *error = NULL;
1870     amar_file_t *file;
1871     g_assert(arch != NULL);
1872 
1873     file = amar_new_file(arch, filename, filename_len, want_position, &error);
1874     if (file)
1875 	return file;
1876 
1877     croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
1878     return NULL;
1879 }
1880 
amar_file_size_(amar_file_t * file)1881 off_t amar_file_size_(amar_file_t *file) {
1882     return amar_file_size(file);
1883 }
1884 
amar_file_close_(amar_file_t * file)1885 void amar_file_close_(amar_file_t *file) {
1886     GError *error = NULL;
1887     if (!amar_file_close(file, &error))
1888 	croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
1889 }
1890 
1891 amar_attr_t *
amar_new_attr_(amar_file_t * file,guint16 attrid)1892 amar_new_attr_(amar_file_t *file, guint16 attrid) {
1893     GError *error = NULL;
1894     amar_attr_t *attr;
1895 
1896     g_assert(file != NULL);
1897 
1898     attr = amar_new_attr(file, attrid, &error);
1899     if (attr)
1900 	return attr;
1901 
1902     croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
1903     return NULL;
1904 }
1905 
amar_attr_size_(amar_attr_t * attr)1906 off_t amar_attr_size_(amar_attr_t *attr) {
1907     return amar_attr_size(attr);
1908 }
1909 
amar_attr_close_(amar_attr_t * attr)1910 void amar_attr_close_(amar_attr_t *attr) {
1911     GError *error = NULL;
1912     if (!amar_attr_close(attr, &error))
1913 	croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
1914 }
1915 
amar_attr_add_data_buffer_(amar_attr_t * attr,char * buffer,gsize size,gboolean eoa)1916 void amar_attr_add_data_buffer_(amar_attr_t *attr, char *buffer, gsize size, gboolean eoa) {
1917     GError *error = NULL;
1918     if (!amar_attr_add_data_buffer(attr, buffer, size, eoa, &error))
1919 	croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
1920 }
1921 
1922 off_t
amar_attr_add_data_fd_(amar_attr_t * attr,int fd,gboolean eoa)1923 amar_attr_add_data_fd_(amar_attr_t *attr, int fd, gboolean eoa) {
1924     GError *error = NULL;
1925     off_t rv = amar_attr_add_data_fd(attr, fd, eoa, &error);
1926     if (rv < 0)
1927 	croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
1928     return rv;
1929 }
1930 
1931 off_t
amar_attr_add_data_fd_in_thread_(amar_attr_t * attr,int fd,gboolean eoa)1932 amar_attr_add_data_fd_in_thread_(amar_attr_t *attr, int fd, gboolean eoa) {
1933     GError *error = NULL;
1934     off_t rv = amar_attr_add_data_fd_in_thread(attr, fd, eoa, &error);
1935     if (rv < 0)
1936 	croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
1937     return rv;
1938 }
1939 
1940 /* reading */
1941 
amar_read_(amar_t * archive,SV * params_hashref)1942 void amar_read_(amar_t *archive, SV *params_hashref) {
1943     perl_read_data_t *dat = g_new0(perl_read_data_t, 1);
1944     GError *error = NULL;
1945     gboolean success;
1946     HV *params;
1947     HE *param;
1948     I32 len;
1949     int maxhandlers;
1950     int hdl_idx;
1951 
1952     /* make sure we got a hashref */
1953     if (!SvROK(params_hashref) || SvTYPE(SvRV(params_hashref)) != SVt_PVHV)
1954 	croak("read() expects a single hashref");
1955     params = (HV *)SvRV(params_hashref);
1956     len = hv_iterinit(params);
1957 
1958     maxhandlers = hdl_idx = len;
1959     dat->handling_array = g_new0(amar_attr_handling_t, len+1);
1960 
1961     /* loop through the parameters */
1962     while ((param = hv_iternext(params))) {
1963 	I32 keylen;
1964 	char *key = hv_iterkey(param, &keylen);
1965 	int attrid;
1966 
1967 	/* if it's a number, it's handling information for an attrid */
1968 	if (is_number(key, keylen, &attrid)) {
1969 	    SV *val = hv_iterval(params, param);
1970 	    SV *coderef;
1971 	    UV bufsize = 0;
1972 	    int i;
1973 
1974 	    if (!SvROK(val)) goto croak_hdl;
1975 
1976 	    switch (SvTYPE(SvRV(val))) {
1977 		case SVt_PVCV:
1978 		    coderef = val;
1979 		    break;
1980 
1981 		case SVt_PVAV: {
1982 		    AV *arr = (AV *)SvRV(val);
1983 		    SV **svp;
1984 
1985 		    if (av_len(arr) != 1) /* av_len == largest index, not length */
1986 			goto croak_hdl;
1987 
1988 		    /* get the bufsize */
1989 		    svp = av_fetch(arr, 0, 0);
1990 		    if (!SvIOK(*svp))
1991 			goto croak_hdl;
1992 		    bufsize = SvUV(*svp);
1993 
1994 		    /* and the coderef */
1995 		    svp = av_fetch(arr, 1, 0);
1996 		    if (!SvROK(*svp) || SvTYPE(SvRV(*svp)) != SVt_PVCV)
1997 			goto croak_hdl;
1998 		    coderef = *svp;
1999 		    break;
2000 		}
2001 
2002 		default:
2003 		    goto croak_hdl;
2004 	    }
2005 
2006 	    /* fill in the handling array, putting attrid 0 at the end, and
2007 	     * filling in entries backward from there */
2008 	    i = (attrid == 0)? maxhandlers : --hdl_idx;
2009 	    dat->handling_array[i].attrid = attrid;
2010 	    dat->handling_array[i].min_size = bufsize;
2011 	    dat->handling_array[i].callback = read_frag_cb;
2012 	    dat->handling_array[i].attrid_data = coderef;
2013 	    SvREFCNT_inc(coderef);
2014 	    continue;
2015 
2016 	croak_hdl:
2017 	    croak("Expected CODEREF or [ MIN_SIZE, CODEREF ] for attrid %d", attrid);
2018 	}
2019 
2020 #define key_compare(key, val, keylen) \
2021     (keylen == sizeof(val)-1) && (0 == strncmp(key, val, keylen))
2022 
2023 	if (key_compare(key, "file_start", keylen)) {
2024 	    SV *val = hv_iterval(params, param);
2025 	    if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVCV)
2026 		croak("Expected a CODEREF for file_start");
2027 	    dat->file_start_sub = val;
2028 	    SvREFCNT_inc(val);
2029 	    continue;
2030 	}
2031 
2032 	if (key_compare(key, "file_finish", keylen)) {
2033 	    SV *val = hv_iterval(params, param);
2034 	    if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVCV)
2035 		croak("Expected a CODEREF for file_finish");
2036 	    dat->file_finish_sub = val;
2037 	    SvREFCNT_inc(val);
2038 	    continue;
2039 	}
2040 
2041 	if (key_compare(key, "done", keylen)) {
2042 	    SV *val = hv_iterval(params, param);
2043 	    if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVCV)
2044 		croak("Expected a CODEREF for done");
2045 	    dat->done_sub = val;
2046 	    SvREFCNT_inc(val);
2047 	    continue;
2048 	}
2049 
2050 	if (key_compare(key, "user_data", keylen)) {
2051 	    SV *val = hv_iterval(params, param);
2052 	    dat->user_data = val;
2053 	    SvREFCNT_inc(val);
2054 	    continue;
2055 	}
2056 #undef key_compare
2057 	croak("Invalid parameter named '%*s'", (int)keylen, key);
2058     }
2059 
2060     if (!dat->user_data)
2061 	dat->user_data = &PL_sv_undef;
2062 
2063     success = amar_read(archive, dat, dat->handling_array + hdl_idx,
2064 	dat->file_start_sub? read_start_file_cb : NULL,
2065 	dat->file_finish_sub? read_finish_file_cb : NULL,
2066 	dat->done_sub? read_done_cb : NULL,
2067 	&error);
2068 
2069     /* now unreference and free everything we referenced earlier */
2070     if (dat->file_start_sub)
2071 	SvREFCNT_dec(dat->file_start_sub);
2072     if (dat->file_finish_sub)
2073 	SvREFCNT_dec(dat->file_finish_sub);
2074     if (dat->done_sub)
2075 	SvREFCNT_dec(dat->done_sub);
2076     if (dat->user_data && dat->user_data != &PL_sv_undef)
2077 	SvREFCNT_dec(dat->user_data);
2078 
2079     for (hdl_idx = 0; hdl_idx <= maxhandlers; hdl_idx++) {
2080 	if (dat->handling_array[hdl_idx].attrid_data)
2081 	    SvREFCNT_dec(dat->handling_array[hdl_idx].attrid_data);
2082     }
2083 
2084     g_free(dat->handling_array);
2085     g_free(dat);
2086 
2087     /* if amar_read returned FALSE, then either we hit an internal
2088      * error, or one of the perl callbacks raised an exception, and $@
2089      * is still set */
2090     if (!success) {
2091 	if (error)
2092 	    croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
2093 	else
2094 	    croak(NULL);
2095     }
2096 }
2097 
amar_read_to_(amar_t * archive,guint16 filenum,guint16 attrid,int fd)2098 void amar_read_to_(
2099     amar_t   *archive,
2100     guint16   filenum,
2101     guint16   attrid,
2102     int       fd)
2103 {
2104     amar_read_to(archive, filenum, attrid, fd);
2105 }
2106 
amar_stop_read_(amar_t * archive)2107 void amar_stop_read_(
2108     amar_t   *archive)
2109 {
2110     amar_stop_read(archive);
2111 }
2112 
amar_start_read_(amar_t * archive)2113 void amar_start_read_(
2114     amar_t   *archive)
2115 {
2116     amar_start_read(archive);
2117 }
2118 
destroy_read_cb(perl_read_data_t * dat)2119 void destroy_read_cb(perl_read_data_t *dat)
2120 {
2121     if (dat->file_start_sub)
2122 	SvREFCNT_dec(dat->file_start_sub);
2123     if (dat->file_finish_sub)
2124 	SvREFCNT_dec(dat->file_finish_sub);
2125     if (dat->done_sub)
2126 	SvREFCNT_dec(dat->done_sub);
2127     if (dat->user_data && dat->user_data != &PL_sv_undef)
2128 	SvREFCNT_dec(dat->user_data);
2129 
2130 //    for (hdl_idx = 0; hdl_idx <= maxhandlers; hdl_idx++) {
2131 //	if (dat->handling_array[hdl_idx].attrid_data)
2132 //	    SvREFCNT_dec(dat->handling_array[hdl_idx].attrid_data);
2133 //    }
2134 
2135     g_free(dat->handling_array);
2136     g_free(dat);
2137 }
2138 
set_amar_read_cb_(amar_t * archive,SV * params_hashref)2139 perl_read_data_t *set_amar_read_cb_(amar_t *archive, SV *params_hashref)
2140 {
2141     perl_read_data_t *dat = g_new0(perl_read_data_t, 1);
2142     HV *params;
2143     HE *param;
2144     I32 len;
2145     int maxhandlers;
2146     int hdl_idx;
2147     dat->archive = archive;
2148 
2149     /* make sure we got a hashref */
2150     if (!SvROK(params_hashref) || SvTYPE(SvRV(params_hashref)) != SVt_PVHV)
2151 	croak("read() expects a single hashref");
2152     params = (HV *)SvRV(params_hashref);
2153     len = hv_iterinit(params);
2154 
2155     maxhandlers = hdl_idx = len;
2156     dat->handling_array = g_new0(amar_attr_handling_t, len+1);
2157 
2158     /* loop through the parameters */
2159     while ((param = hv_iternext(params))) {
2160 	I32 keylen;
2161 	char *key = hv_iterkey(param, &keylen);
2162 	int attrid;
2163 
2164 	/* if it's a number, it's handling information for an attrid */
2165 	if (is_number(key, keylen, &attrid)) {
2166 	    SV *val = hv_iterval(params, param);
2167 	    SV *coderef;
2168 	    UV bufsize = 0;
2169 	    int i;
2170 
2171 	    if (!SvROK(val)) goto croak_hdl;
2172 
2173 	    switch (SvTYPE(SvRV(val))) {
2174 		case SVt_PVCV:
2175 		    coderef = val;
2176 		    break;
2177 
2178 		case SVt_PVAV: {
2179 		    AV *arr = (AV *)SvRV(val);
2180 		    SV **svp;
2181 
2182 		    if (av_len(arr) != 1) /* av_len == largest index, not length */
2183 			goto croak_hdl;
2184 
2185 		    /* get the bufsize */
2186 		    svp = av_fetch(arr, 0, 0);
2187 		    if (!SvIOK(*svp))
2188 			goto croak_hdl;
2189 		    bufsize = SvUV(*svp);
2190 
2191 		    /* and the coderef */
2192 		    svp = av_fetch(arr, 1, 0);
2193 		    if (!SvROK(*svp) || SvTYPE(SvRV(*svp)) != SVt_PVCV)
2194 			goto croak_hdl;
2195 		    coderef = *svp;
2196 		    break;
2197 		}
2198 
2199 		default:
2200 		    goto croak_hdl;
2201 	    }
2202 
2203 	    /* fill in the handling array, putting attrid 0 at the end, and
2204 	     * filling in entries backward from there */
2205 	    i = (attrid == 0)? maxhandlers : --hdl_idx;
2206 	    dat->handling_array[i].attrid = attrid;
2207 	    dat->handling_array[i].min_size = bufsize;
2208 	    dat->handling_array[i].callback = read_frag_cb;
2209 	    dat->handling_array[i].attrid_data = coderef;
2210 	    SvREFCNT_inc(coderef);
2211 	    continue;
2212 
2213 	croak_hdl:
2214 	    croak("Expected CODEREF or [ MIN_SIZE, CODEREF ] for attrid %d", attrid);
2215 	}
2216 
2217 #define key_compare(key, val, keylen) \
2218     (keylen == sizeof(val)-1) && (0 == strncmp(key, val, keylen))
2219 
2220 	if (key_compare(key, "file_start", keylen)) {
2221 	    SV *val = hv_iterval(params, param);
2222 	    if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVCV)
2223 		croak("Expected a CODEREF for file_start");
2224 	    dat->file_start_sub = val;
2225 	    SvREFCNT_inc(val);
2226 	    continue;
2227 	}
2228 
2229 	if (key_compare(key, "file_finish", keylen)) {
2230 	    SV *val = hv_iterval(params, param);
2231 	    if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVCV)
2232 		croak("Expected a CODEREF for file_finish");
2233 	    dat->file_finish_sub = val;
2234 	    SvREFCNT_inc(val);
2235 	    continue;
2236 	}
2237 
2238 	if (key_compare(key, "done", keylen)) {
2239 	    SV *val = hv_iterval(params, param);
2240 	    if (!SvROK(val) || SvTYPE(SvRV(val)) != SVt_PVCV)
2241 		croak("Expected a CODEREF for file_finish");
2242 	    dat->done_sub = val;
2243 	    SvREFCNT_inc(val);
2244 	    continue;
2245 	}
2246 
2247 	if (key_compare(key, "user_data", keylen)) {
2248 	    SV *val = hv_iterval(params, param);
2249 	    dat->user_data = val;
2250 	    SvREFCNT_inc(val);
2251 	    continue;
2252 	}
2253 #undef key_compare
2254 	croak("Invalid parameter named '%*s'", (int)keylen, key);
2255     }
2256 
2257     if (!dat->user_data)
2258 	dat->user_data = &PL_sv_undef;
2259 
2260     set_amar_read_cb(archive, dat, dat->handling_array + hdl_idx,
2261 	dat->file_start_sub? read_start_file_cb : NULL,
2262 	dat->file_finish_sub? read_finish_file_cb : NULL,
2263 	dat->done_sub? read_done_cb : NULL,
2264 	&dat->error);
2265 
2266 
2267     if (dat->error)
2268 	croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &dat->error);
2269 
2270     return dat;
2271 }
2272 
2273 
2274 
2275 SWIGINTERN swig_type_info*
SWIG_pchar_descriptor(void)2276 SWIG_pchar_descriptor(void)
2277 {
2278   static int init = 0;
2279   static swig_type_info* info = 0;
2280   if (!init) {
2281     info = SWIG_TypeQuery("_p_char");
2282     init = 1;
2283   }
2284   return info;
2285 }
2286 
2287 
2288 SWIGINTERN int
SWIG_AsCharPtrAndSize(SV * obj,char ** cptr,size_t * psize,int * alloc)2289 SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
2290 {
2291   if (SvMAGICAL(obj)) {
2292      SV *tmp = sv_newmortal();
2293      SvSetSV(tmp, obj);
2294      obj = tmp;
2295   }
2296   if (SvPOK(obj)) {
2297     STRLEN len = 0;
2298     char *cstr = SvPV(obj, len);
2299     size_t size = len + 1;
2300     if (cptr)  {
2301       if (alloc) {
2302 	if (*alloc == SWIG_NEWOBJ) {
2303 	  *cptr = (char *)memcpy((char *)malloc((size)*sizeof(char)), cstr, sizeof(char)*(size));
2304 	} else {
2305 	  *cptr = cstr;
2306 	  *alloc = SWIG_OLDOBJ;
2307 	}
2308       }
2309     }
2310     if (psize) *psize = size;
2311     return SWIG_OK;
2312   } else {
2313     swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
2314     if (pchar_descriptor) {
2315       char* vptr = 0;
2316       if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) {
2317 	if (cptr) *cptr = vptr;
2318 	if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0;
2319 	if (alloc) *alloc = SWIG_OLDOBJ;
2320 	return SWIG_OK;
2321       }
2322     }
2323   }
2324   return SWIG_TypeError;
2325 }
2326 
2327 
2328 
2329 
2330 
2331 #include <limits.h>
2332 #if !defined(SWIG_NO_LLONG_MAX)
2333 # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
2334 #   define LLONG_MAX __LONG_LONG_MAX__
2335 #   define LLONG_MIN (-LLONG_MAX - 1LL)
2336 #   define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
2337 # endif
2338 #endif
2339 
2340 
2341 SWIGINTERN int
SWIG_PERL_DECL_ARGS_2(SV * obj,double * val)2342 SWIG_AsVal_double SWIG_PERL_DECL_ARGS_2(SV *obj, double *val)
2343 {
2344   if (SvNIOK(obj)) {
2345     if (val) *val = SvNV(obj);
2346     return SWIG_OK;
2347   } else if (SvIOK(obj)) {
2348     if (val) *val = (double) SvIV(obj);
2349     return SWIG_AddCast(SWIG_OK);
2350   } else {
2351     const char *nptr = SvPV_nolen(obj);
2352     if (nptr) {
2353       char *endptr;
2354       double v;
2355       errno = 0;
2356       v = strtod(nptr, &endptr);
2357       if (errno == ERANGE) {
2358 	errno = 0;
2359 	return SWIG_OverflowError;
2360       } else {
2361 	if (*endptr == '\0') {
2362 	  if (val) *val = v;
2363 	  return SWIG_Str2NumCast(SWIG_OK);
2364 	}
2365       }
2366     }
2367   }
2368   return SWIG_TypeError;
2369 }
2370 
2371 
2372 #include <float.h>
2373 
2374 
2375 #include <math.h>
2376 
2377 
2378 SWIGINTERNINLINE int
SWIG_CanCastAsInteger(double * d,double min,double max)2379 SWIG_CanCastAsInteger(double *d, double min, double max) {
2380   double x = *d;
2381   if ((min <= x && x <= max)) {
2382    double fx = floor(x);
2383    double cx = ceil(x);
2384    double rd =  ((x - fx) < 0.5) ? fx : cx; /* simple rint */
2385    if ((errno == EDOM) || (errno == ERANGE)) {
2386      errno = 0;
2387    } else {
2388      double summ, reps, diff;
2389      if (rd < x) {
2390        diff = x - rd;
2391      } else if (rd > x) {
2392        diff = rd - x;
2393      } else {
2394        return 1;
2395      }
2396      summ = rd + x;
2397      reps = diff/summ;
2398      if (reps < 8*DBL_EPSILON) {
2399        *d = rd;
2400        return 1;
2401      }
2402    }
2403   }
2404   return 0;
2405 }
2406 
2407 
2408 SWIGINTERN int
SWIG_PERL_DECL_ARGS_2(SV * obj,long * val)2409 SWIG_AsVal_long SWIG_PERL_DECL_ARGS_2(SV *obj, long* val)
2410 {
2411   if (SvUOK(obj)) {
2412     UV v = SvUV(obj);
2413     if (v <= LONG_MAX) {
2414       if (val) *val = v;
2415       return SWIG_OK;
2416     }
2417     return SWIG_OverflowError;
2418   } else if (SvIOK(obj)) {
2419     IV v = SvIV(obj);
2420     if (v >= LONG_MIN && v <= LONG_MAX) {
2421       if(val) *val = v;
2422       return SWIG_OK;
2423     }
2424     return SWIG_OverflowError;
2425   } else {
2426     int dispatch = 0;
2427     const char *nptr = SvPV_nolen(obj);
2428     if (nptr) {
2429       char *endptr;
2430       long v;
2431       errno = 0;
2432       v = strtol(nptr, &endptr,0);
2433       if (errno == ERANGE) {
2434 	errno = 0;
2435 	return SWIG_OverflowError;
2436       } else {
2437 	if (*endptr == '\0') {
2438 	  if (val) *val = v;
2439 	  return SWIG_Str2NumCast(SWIG_OK);
2440 	}
2441       }
2442     }
2443     if (!dispatch) {
2444       double d;
2445       int res = SWIG_AddCast(SWIG_AsVal_double SWIG_PERL_CALL_ARGS_2(obj,&d));
2446       if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) {
2447 	if (val) *val = (long)(d);
2448 	return res;
2449       }
2450     }
2451   }
2452   return SWIG_TypeError;
2453 }
2454 
2455 
2456 SWIGINTERN int
SWIG_PERL_DECL_ARGS_2(SV * obj,int * val)2457 SWIG_AsVal_int SWIG_PERL_DECL_ARGS_2(SV * obj, int *val)
2458 {
2459   long v;
2460   int res = SWIG_AsVal_long SWIG_PERL_CALL_ARGS_2(obj, &v);
2461   if (SWIG_IsOK(res)) {
2462     if ((v < INT_MIN || v > INT_MAX)) {
2463       return SWIG_OverflowError;
2464     } else {
2465       if (val) *val = (int)(v);
2466     }
2467   }
2468   return res;
2469 }
2470 
2471 #ifdef __cplusplus
2472 extern "C" {
2473 #endif
2474 
2475 #ifdef PERL_OBJECT
2476 #define MAGIC_CLASS _wrap_Amanda__Archive_var::
2477 class _wrap_Amanda__Archive_var : public CPerlObj {
2478 public:
2479 #else
2480 #define MAGIC_CLASS
2481 #endif
swig_magic_readonly(pTHX_ SV * SWIGUNUSEDPARM (sv),MAGIC * SWIGUNUSEDPARM (mg))2482 SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) {
2483     MAGIC_PPERL
2484     croak("Value is read-only.");
2485     return 0;
2486 }
2487 
2488 
2489 #ifdef PERL_OBJECT
2490 };
2491 #endif
2492 
2493 #ifdef __cplusplus
2494 }
2495 #endif
2496 
2497 #ifdef __cplusplus
2498 extern "C" {
2499 #endif
XS(_wrap_amar_new)2500 XS(_wrap_amar_new) {
2501   {
2502     int arg1 ;
2503     char *arg2 = (char *) 0 ;
2504     int res2 ;
2505     char *buf2 = 0 ;
2506     int alloc2 = 0 ;
2507     int argvi = 0;
2508     amar_t *result = 0 ;
2509     dXSARGS;
2510 
2511     if ((items < 2) || (items > 2)) {
2512       SWIG_croak("Usage: amar_new(fd,modestr);");
2513     }
2514     {
2515       IO *io = NULL;
2516       PerlIO *pio = NULL;
2517       int fd = -1;
2518 
2519       if (SvIOK(ST(0))) {
2520         /* plain old integer */
2521         arg1 = SvIV(ST(0));
2522       } else {
2523         /* try extracting as filehandle */
2524 
2525         /* note: sv_2io may call die() */
2526         io = sv_2io(ST(0));
2527         if (io) {
2528           pio = IoIFP(io);
2529         }
2530         if (pio) {
2531           fd = PerlIO_fileno(pio);
2532         }
2533         if (fd >= 0) {
2534           arg1 = fd;
2535         } else {
2536           SWIG_exception(SWIG_TypeError, "Expected integer file descriptor "
2537             "or file handle for argument 1");
2538         }
2539       }
2540     }
2541     res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
2542     if (!SWIG_IsOK(res2)) {
2543       SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "amar_new" "', argument " "2"" of type '" "char *""'");
2544     }
2545     arg2 = (char *)(buf2);
2546     result = (amar_t *)amar_new_(arg1,arg2);
2547     ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_amar_t, 0 | 0); argvi++ ;
2548 
2549     if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2550     XSRETURN(argvi);
2551   fail:
2552 
2553     if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2554     SWIG_croak_null();
2555   }
2556 }
2557 
2558 
XS(_wrap_amar_size)2559 XS(_wrap_amar_size) {
2560   {
2561     amar_t *arg1 = (amar_t *) 0 ;
2562     void *argp1 = 0 ;
2563     int res1 = 0 ;
2564     int argvi = 0;
2565     off_t result;
2566     dXSARGS;
2567 
2568     if ((items < 1) || (items > 1)) {
2569       SWIG_croak("Usage: amar_size(archive);");
2570     }
2571     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_t, 0 |  0 );
2572     if (!SWIG_IsOK(res1)) {
2573       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_size" "', argument " "1"" of type '" "amar_t *""'");
2574     }
2575     arg1 = (amar_t *)(argp1);
2576     result = amar_size_(arg1);
2577     {
2578       SV *for_stack;
2579       SP += argvi; PUTBACK;
2580       for_stack = sv_2mortal(amglue_newSVu64(result));
2581       SPAGAIN; SP -= argvi;
2582       ST(argvi) = for_stack;
2583       argvi++;
2584     }
2585 
2586     XSRETURN(argvi);
2587   fail:
2588 
2589     SWIG_croak_null();
2590   }
2591 }
2592 
2593 
XS(_wrap_amar_close)2594 XS(_wrap_amar_close) {
2595   {
2596     amar_t *arg1 = (amar_t *) 0 ;
2597     void *argp1 = 0 ;
2598     int res1 = 0 ;
2599     int argvi = 0;
2600     dXSARGS;
2601 
2602     if ((items < 1) || (items > 1)) {
2603       SWIG_croak("Usage: amar_close(arch);");
2604     }
2605     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_t, 0 |  0 );
2606     if (!SWIG_IsOK(res1)) {
2607       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_close" "', argument " "1"" of type '" "amar_t *""'");
2608     }
2609     arg1 = (amar_t *)(argp1);
2610     amar_close_(arg1);
2611     ST(argvi) = sv_newmortal();
2612 
2613     XSRETURN(argvi);
2614   fail:
2615 
2616     SWIG_croak_null();
2617   }
2618 }
2619 
2620 
XS(_wrap_amar_new_file)2621 XS(_wrap_amar_new_file) {
2622   {
2623     amar_t *arg1 = (amar_t *) 0 ;
2624     char *arg2 = (char *) 0 ;
2625     gsize arg3 ;
2626     off_t *arg4 = (off_t *) 0 ;
2627     void *argp1 = 0 ;
2628     int res1 = 0 ;
2629     int res2 ;
2630     char *buf2 = 0 ;
2631     size_t size2 = 0 ;
2632     int alloc2 = 0 ;
2633     off_t position4 ;
2634     int argvi = 0;
2635     SV * _saved[1] ;
2636     amar_file_t *result = 0 ;
2637     dXSARGS;
2638 
2639     if ((items < 3) || (items > 3)) {
2640       SWIG_croak("Usage: amar_new_file(arch,filename,filename_len,want_position);");
2641     }
2642     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_t, 0 |  0 );
2643     if (!SWIG_IsOK(res1)) {
2644       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_new_file" "', argument " "1"" of type '" "amar_t *""'");
2645     }
2646     arg1 = (amar_t *)(argp1);
2647     res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, &size2, &alloc2);
2648     if (!SWIG_IsOK(res2)) {
2649       SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "amar_new_file" "', argument " "2"" of type '" "char *""'");
2650     }
2651     arg2 = (char *)(buf2);
2652     arg3 = (gsize)(size2 - 1);
2653     {
2654       if (SvTRUE(ST(2))) {
2655         position4 = 0;
2656         arg4 = &position4;
2657       } else {
2658         arg4 = NULL;
2659       }
2660     }
2661     _saved[0] = ST(2);
2662     result = (amar_file_t *)amar_new_file_(arg1,arg2,arg3,arg4);
2663     ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_amar_file_t, 0 | 0); argvi++ ;
2664     {
2665       if (arg4) {
2666         SP += argvi; PUTBACK;
2667         ST(argvi) = sv_2mortal(amglue_newSVi64(*arg4));
2668         SPAGAIN; SP -= argvi; argvi++;
2669       }
2670     }
2671 
2672     if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2673 
2674     XSRETURN(argvi);
2675   fail:
2676 
2677     if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2678 
2679     SWIG_croak_null();
2680   }
2681 }
2682 
2683 
XS(_wrap_amar_file_size)2684 XS(_wrap_amar_file_size) {
2685   {
2686     amar_file_t *arg1 = (amar_file_t *) 0 ;
2687     void *argp1 = 0 ;
2688     int res1 = 0 ;
2689     int argvi = 0;
2690     off_t result;
2691     dXSARGS;
2692 
2693     if ((items < 1) || (items > 1)) {
2694       SWIG_croak("Usage: amar_file_size(file);");
2695     }
2696     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_file_t, 0 |  0 );
2697     if (!SWIG_IsOK(res1)) {
2698       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_file_size" "', argument " "1"" of type '" "amar_file_t *""'");
2699     }
2700     arg1 = (amar_file_t *)(argp1);
2701     result = amar_file_size_(arg1);
2702     {
2703       SV *for_stack;
2704       SP += argvi; PUTBACK;
2705       for_stack = sv_2mortal(amglue_newSVu64(result));
2706       SPAGAIN; SP -= argvi;
2707       ST(argvi) = for_stack;
2708       argvi++;
2709     }
2710 
2711     XSRETURN(argvi);
2712   fail:
2713 
2714     SWIG_croak_null();
2715   }
2716 }
2717 
2718 
XS(_wrap_amar_file_close)2719 XS(_wrap_amar_file_close) {
2720   {
2721     amar_file_t *arg1 = (amar_file_t *) 0 ;
2722     void *argp1 = 0 ;
2723     int res1 = 0 ;
2724     int argvi = 0;
2725     dXSARGS;
2726 
2727     if ((items < 1) || (items > 1)) {
2728       SWIG_croak("Usage: amar_file_close(file);");
2729     }
2730     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_file_t, 0 |  0 );
2731     if (!SWIG_IsOK(res1)) {
2732       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_file_close" "', argument " "1"" of type '" "amar_file_t *""'");
2733     }
2734     arg1 = (amar_file_t *)(argp1);
2735     amar_file_close_(arg1);
2736     ST(argvi) = sv_newmortal();
2737 
2738     XSRETURN(argvi);
2739   fail:
2740 
2741     SWIG_croak_null();
2742   }
2743 }
2744 
2745 
XS(_wrap_amar_new_attr)2746 XS(_wrap_amar_new_attr) {
2747   {
2748     amar_file_t *arg1 = (amar_file_t *) 0 ;
2749     guint16 arg2 ;
2750     void *argp1 = 0 ;
2751     int res1 = 0 ;
2752     int argvi = 0;
2753     amar_attr_t *result = 0 ;
2754     dXSARGS;
2755 
2756     if ((items < 2) || (items > 2)) {
2757       SWIG_croak("Usage: amar_new_attr(file,attrid);");
2758     }
2759     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_file_t, 0 |  0 );
2760     if (!SWIG_IsOK(res1)) {
2761       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_new_attr" "', argument " "1"" of type '" "amar_file_t *""'");
2762     }
2763     arg1 = (amar_file_t *)(argp1);
2764     {
2765       arg2 = amglue_SvU16(ST(1));
2766     }
2767     result = (amar_attr_t *)amar_new_attr_(arg1,arg2);
2768     ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_amar_attr_t, 0 | 0); argvi++ ;
2769 
2770     XSRETURN(argvi);
2771   fail:
2772 
2773     SWIG_croak_null();
2774   }
2775 }
2776 
2777 
XS(_wrap_amar_attr_size)2778 XS(_wrap_amar_attr_size) {
2779   {
2780     amar_attr_t *arg1 = (amar_attr_t *) 0 ;
2781     void *argp1 = 0 ;
2782     int res1 = 0 ;
2783     int argvi = 0;
2784     off_t result;
2785     dXSARGS;
2786 
2787     if ((items < 1) || (items > 1)) {
2788       SWIG_croak("Usage: amar_attr_size(attr);");
2789     }
2790     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_attr_t, 0 |  0 );
2791     if (!SWIG_IsOK(res1)) {
2792       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_attr_size" "', argument " "1"" of type '" "amar_attr_t *""'");
2793     }
2794     arg1 = (amar_attr_t *)(argp1);
2795     result = amar_attr_size_(arg1);
2796     {
2797       SV *for_stack;
2798       SP += argvi; PUTBACK;
2799       for_stack = sv_2mortal(amglue_newSVu64(result));
2800       SPAGAIN; SP -= argvi;
2801       ST(argvi) = for_stack;
2802       argvi++;
2803     }
2804 
2805     XSRETURN(argvi);
2806   fail:
2807 
2808     SWIG_croak_null();
2809   }
2810 }
2811 
2812 
XS(_wrap_amar_attr_close)2813 XS(_wrap_amar_attr_close) {
2814   {
2815     amar_attr_t *arg1 = (amar_attr_t *) 0 ;
2816     void *argp1 = 0 ;
2817     int res1 = 0 ;
2818     int argvi = 0;
2819     dXSARGS;
2820 
2821     if ((items < 1) || (items > 1)) {
2822       SWIG_croak("Usage: amar_attr_close(attr);");
2823     }
2824     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_attr_t, 0 |  0 );
2825     if (!SWIG_IsOK(res1)) {
2826       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_attr_close" "', argument " "1"" of type '" "amar_attr_t *""'");
2827     }
2828     arg1 = (amar_attr_t *)(argp1);
2829     amar_attr_close_(arg1);
2830     ST(argvi) = sv_newmortal();
2831 
2832     XSRETURN(argvi);
2833   fail:
2834 
2835     SWIG_croak_null();
2836   }
2837 }
2838 
2839 
XS(_wrap_amar_attr_add_data_buffer)2840 XS(_wrap_amar_attr_add_data_buffer) {
2841   {
2842     amar_attr_t *arg1 = (amar_attr_t *) 0 ;
2843     char *arg2 = (char *) 0 ;
2844     gsize arg3 ;
2845     gboolean arg4 ;
2846     void *argp1 = 0 ;
2847     int res1 = 0 ;
2848     int res2 ;
2849     char *buf2 = 0 ;
2850     size_t size2 = 0 ;
2851     int alloc2 = 0 ;
2852     int argvi = 0;
2853     dXSARGS;
2854 
2855     if ((items < 3) || (items > 3)) {
2856       SWIG_croak("Usage: amar_attr_add_data_buffer(attr,buffer,size,eoa);");
2857     }
2858     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_attr_t, 0 |  0 );
2859     if (!SWIG_IsOK(res1)) {
2860       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_attr_add_data_buffer" "', argument " "1"" of type '" "amar_attr_t *""'");
2861     }
2862     arg1 = (amar_attr_t *)(argp1);
2863     res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, &size2, &alloc2);
2864     if (!SWIG_IsOK(res2)) {
2865       SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "amar_attr_add_data_buffer" "', argument " "2"" of type '" "char *""'");
2866     }
2867     arg2 = (char *)(buf2);
2868     arg3 = (gsize)(size2 - 1);
2869     {
2870       arg4 = SvTRUE(ST(2));
2871     }
2872     amar_attr_add_data_buffer_(arg1,arg2,arg3,arg4);
2873     ST(argvi) = sv_newmortal();
2874 
2875     if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2876 
2877     XSRETURN(argvi);
2878   fail:
2879 
2880     if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2881 
2882     SWIG_croak_null();
2883   }
2884 }
2885 
2886 
XS(_wrap_amar_attr_add_data_fd)2887 XS(_wrap_amar_attr_add_data_fd) {
2888   {
2889     amar_attr_t *arg1 = (amar_attr_t *) 0 ;
2890     int arg2 ;
2891     gboolean arg3 ;
2892     void *argp1 = 0 ;
2893     int res1 = 0 ;
2894     int argvi = 0;
2895     off_t result;
2896     dXSARGS;
2897 
2898     if ((items < 3) || (items > 3)) {
2899       SWIG_croak("Usage: amar_attr_add_data_fd(attr,fd,eoa);");
2900     }
2901     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_attr_t, 0 |  0 );
2902     if (!SWIG_IsOK(res1)) {
2903       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_attr_add_data_fd" "', argument " "1"" of type '" "amar_attr_t *""'");
2904     }
2905     arg1 = (amar_attr_t *)(argp1);
2906     {
2907       IO *io = NULL;
2908       PerlIO *pio = NULL;
2909       int fd = -1;
2910 
2911       if (SvIOK(ST(1))) {
2912         /* plain old integer */
2913         arg2 = SvIV(ST(1));
2914       } else {
2915         /* try extracting as filehandle */
2916 
2917         /* note: sv_2io may call die() */
2918         io = sv_2io(ST(1));
2919         if (io) {
2920           pio = IoIFP(io);
2921         }
2922         if (pio) {
2923           fd = PerlIO_fileno(pio);
2924         }
2925         if (fd >= 0) {
2926           arg2 = fd;
2927         } else {
2928           SWIG_exception(SWIG_TypeError, "Expected integer file descriptor "
2929             "or file handle for argument 2");
2930         }
2931       }
2932     }
2933     {
2934       arg3 = SvTRUE(ST(2));
2935     }
2936     result = amar_attr_add_data_fd_(arg1,arg2,arg3);
2937     {
2938       SV *for_stack;
2939       SP += argvi; PUTBACK;
2940       for_stack = sv_2mortal(amglue_newSVu64(result));
2941       SPAGAIN; SP -= argvi;
2942       ST(argvi) = for_stack;
2943       argvi++;
2944     }
2945 
2946 
2947 
2948     XSRETURN(argvi);
2949   fail:
2950 
2951 
2952 
2953     SWIG_croak_null();
2954   }
2955 }
2956 
2957 
XS(_wrap_amar_attr_add_data_fd_in_thread)2958 XS(_wrap_amar_attr_add_data_fd_in_thread) {
2959   {
2960     amar_attr_t *arg1 = (amar_attr_t *) 0 ;
2961     int arg2 ;
2962     gboolean arg3 ;
2963     void *argp1 = 0 ;
2964     int res1 = 0 ;
2965     int argvi = 0;
2966     off_t result;
2967     dXSARGS;
2968 
2969     if ((items < 3) || (items > 3)) {
2970       SWIG_croak("Usage: amar_attr_add_data_fd_in_thread(attr,fd,eoa);");
2971     }
2972     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_attr_t, 0 |  0 );
2973     if (!SWIG_IsOK(res1)) {
2974       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_attr_add_data_fd_in_thread" "', argument " "1"" of type '" "amar_attr_t *""'");
2975     }
2976     arg1 = (amar_attr_t *)(argp1);
2977     {
2978       IO *io = NULL;
2979       PerlIO *pio = NULL;
2980       int fd = -1;
2981 
2982       if (SvIOK(ST(1))) {
2983         /* plain old integer */
2984         arg2 = SvIV(ST(1));
2985       } else {
2986         /* try extracting as filehandle */
2987 
2988         /* note: sv_2io may call die() */
2989         io = sv_2io(ST(1));
2990         if (io) {
2991           pio = IoIFP(io);
2992         }
2993         if (pio) {
2994           fd = PerlIO_fileno(pio);
2995         }
2996         if (fd >= 0) {
2997           arg2 = fd;
2998         } else {
2999           SWIG_exception(SWIG_TypeError, "Expected integer file descriptor "
3000             "or file handle for argument 2");
3001         }
3002       }
3003     }
3004     {
3005       arg3 = SvTRUE(ST(2));
3006     }
3007     result = amar_attr_add_data_fd_in_thread_(arg1,arg2,arg3);
3008     {
3009       SV *for_stack;
3010       SP += argvi; PUTBACK;
3011       for_stack = sv_2mortal(amglue_newSVu64(result));
3012       SPAGAIN; SP -= argvi;
3013       ST(argvi) = for_stack;
3014       argvi++;
3015     }
3016 
3017 
3018 
3019     XSRETURN(argvi);
3020   fail:
3021 
3022 
3023 
3024     SWIG_croak_null();
3025   }
3026 }
3027 
3028 
XS(_wrap_amar_read)3029 XS(_wrap_amar_read) {
3030   {
3031     amar_t *arg1 = (amar_t *) 0 ;
3032     SV *arg2 = (SV *) 0 ;
3033     void *argp1 = 0 ;
3034     int res1 = 0 ;
3035     int argvi = 0;
3036     dXSARGS;
3037 
3038     if ((items < 2) || (items > 2)) {
3039       SWIG_croak("Usage: amar_read(archive,params_hashref);");
3040     }
3041     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_t, 0 |  0 );
3042     if (!SWIG_IsOK(res1)) {
3043       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_read" "', argument " "1"" of type '" "amar_t *""'");
3044     }
3045     arg1 = (amar_t *)(argp1);
3046     arg2 = ST(1);
3047     amar_read_(arg1,arg2);
3048     ST(argvi) = sv_newmortal();
3049 
3050 
3051     XSRETURN(argvi);
3052   fail:
3053 
3054 
3055     SWIG_croak_null();
3056   }
3057 }
3058 
3059 
XS(_wrap_amar_read_to)3060 XS(_wrap_amar_read_to) {
3061   {
3062     amar_t *arg1 = (amar_t *) 0 ;
3063     guint16 arg2 ;
3064     guint16 arg3 ;
3065     int arg4 ;
3066     void *argp1 = 0 ;
3067     int res1 = 0 ;
3068     int argvi = 0;
3069     dXSARGS;
3070 
3071     if ((items < 4) || (items > 4)) {
3072       SWIG_croak("Usage: amar_read_to(archive,filenum,attrid,fd);");
3073     }
3074     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_t, 0 |  0 );
3075     if (!SWIG_IsOK(res1)) {
3076       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_read_to" "', argument " "1"" of type '" "amar_t *""'");
3077     }
3078     arg1 = (amar_t *)(argp1);
3079     {
3080       arg2 = amglue_SvU16(ST(1));
3081     }
3082     {
3083       arg3 = amglue_SvU16(ST(2));
3084     }
3085     {
3086       IO *io = NULL;
3087       PerlIO *pio = NULL;
3088       int fd = -1;
3089 
3090       if (SvIOK(ST(3))) {
3091         /* plain old integer */
3092         arg4 = SvIV(ST(3));
3093       } else {
3094         /* try extracting as filehandle */
3095 
3096         /* note: sv_2io may call die() */
3097         io = sv_2io(ST(3));
3098         if (io) {
3099           pio = IoIFP(io);
3100         }
3101         if (pio) {
3102           fd = PerlIO_fileno(pio);
3103         }
3104         if (fd >= 0) {
3105           arg4 = fd;
3106         } else {
3107           SWIG_exception(SWIG_TypeError, "Expected integer file descriptor "
3108             "or file handle for argument 4");
3109         }
3110       }
3111     }
3112     amar_read_to_(arg1,arg2,arg3,arg4);
3113     ST(argvi) = sv_newmortal();
3114 
3115 
3116     XSRETURN(argvi);
3117   fail:
3118 
3119 
3120     SWIG_croak_null();
3121   }
3122 }
3123 
3124 
XS(_wrap_amar_stop_read)3125 XS(_wrap_amar_stop_read) {
3126   {
3127     amar_t *arg1 = (amar_t *) 0 ;
3128     void *argp1 = 0 ;
3129     int res1 = 0 ;
3130     int argvi = 0;
3131     dXSARGS;
3132 
3133     if ((items < 1) || (items > 1)) {
3134       SWIG_croak("Usage: amar_stop_read(archive);");
3135     }
3136     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_t, 0 |  0 );
3137     if (!SWIG_IsOK(res1)) {
3138       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_stop_read" "', argument " "1"" of type '" "amar_t *""'");
3139     }
3140     arg1 = (amar_t *)(argp1);
3141     amar_stop_read_(arg1);
3142     ST(argvi) = sv_newmortal();
3143 
3144     XSRETURN(argvi);
3145   fail:
3146 
3147     SWIG_croak_null();
3148   }
3149 }
3150 
3151 
XS(_wrap_amar_start_read)3152 XS(_wrap_amar_start_read) {
3153   {
3154     amar_t *arg1 = (amar_t *) 0 ;
3155     void *argp1 = 0 ;
3156     int res1 = 0 ;
3157     int argvi = 0;
3158     dXSARGS;
3159 
3160     if ((items < 1) || (items > 1)) {
3161       SWIG_croak("Usage: amar_start_read(archive);");
3162     }
3163     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_t, 0 |  0 );
3164     if (!SWIG_IsOK(res1)) {
3165       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "amar_start_read" "', argument " "1"" of type '" "amar_t *""'");
3166     }
3167     arg1 = (amar_t *)(argp1);
3168     amar_start_read_(arg1);
3169     ST(argvi) = sv_newmortal();
3170 
3171     XSRETURN(argvi);
3172   fail:
3173 
3174     SWIG_croak_null();
3175   }
3176 }
3177 
3178 
XS(_wrap_destroy_read_cb)3179 XS(_wrap_destroy_read_cb) {
3180   {
3181     perl_read_data_t *arg1 = (perl_read_data_t *) 0 ;
3182     void *argp1 = 0 ;
3183     int res1 = 0 ;
3184     int argvi = 0;
3185     dXSARGS;
3186 
3187     if ((items < 1) || (items > 1)) {
3188       SWIG_croak("Usage: destroy_read_cb(dat);");
3189     }
3190     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_perl_read_data_t, 0 |  0 );
3191     if (!SWIG_IsOK(res1)) {
3192       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "destroy_read_cb" "', argument " "1"" of type '" "perl_read_data_t *""'");
3193     }
3194     arg1 = (perl_read_data_t *)(argp1);
3195     destroy_read_cb(arg1);
3196     ST(argvi) = sv_newmortal();
3197 
3198     XSRETURN(argvi);
3199   fail:
3200 
3201     SWIG_croak_null();
3202   }
3203 }
3204 
3205 
XS(_wrap_set_amar_read_cb)3206 XS(_wrap_set_amar_read_cb) {
3207   {
3208     amar_t *arg1 = (amar_t *) 0 ;
3209     SV *arg2 = (SV *) 0 ;
3210     void *argp1 = 0 ;
3211     int res1 = 0 ;
3212     int argvi = 0;
3213     perl_read_data_t *result = 0 ;
3214     dXSARGS;
3215 
3216     if ((items < 2) || (items > 2)) {
3217       SWIG_croak("Usage: set_amar_read_cb(archive,params_hashref);");
3218     }
3219     res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_amar_t, 0 |  0 );
3220     if (!SWIG_IsOK(res1)) {
3221       SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "set_amar_read_cb" "', argument " "1"" of type '" "amar_t *""'");
3222     }
3223     arg1 = (amar_t *)(argp1);
3224     arg2 = ST(1);
3225     result = (perl_read_data_t *)set_amar_read_cb_(arg1,arg2);
3226     ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_perl_read_data_t, 0 | 0); argvi++ ;
3227 
3228 
3229     XSRETURN(argvi);
3230   fail:
3231 
3232 
3233     SWIG_croak_null();
3234   }
3235 }
3236 
3237 
3238 
3239 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
3240 
3241 static swig_type_info _swigt__p_amar_attr_t = {"_p_amar_attr_t", "amar_attr_t *", 0, 0, (void*)0, 0};
3242 static swig_type_info _swigt__p_amar_file_t = {"_p_amar_file_t", "amar_file_t *", 0, 0, (void*)0, 0};
3243 static swig_type_info _swigt__p_amar_t = {"_p_amar_t", "amar_t *", 0, 0, (void*)0, 0};
3244 static swig_type_info _swigt__p_char = {"_p_char", "gchar *|char *", 0, 0, (void*)0, 0};
3245 static swig_type_info _swigt__p_double = {"_p_double", "double *|gdouble *", 0, 0, (void*)0, 0};
3246 static swig_type_info _swigt__p_float = {"_p_float", "float *|gfloat *", 0, 0, (void*)0, 0};
3247 static swig_type_info _swigt__p_gsize = {"_p_gsize", "gsize *", 0, 0, (void*)0, 0};
3248 static swig_type_info _swigt__p_guint16 = {"_p_guint16", "guint16 *", 0, 0, (void*)0, 0};
3249 static swig_type_info _swigt__p_int = {"_p_int", "amar_attr *|int *|gboolean *", 0, 0, (void*)0, 0};
3250 static swig_type_info _swigt__p_off_t = {"_p_off_t", "off_t *", 0, 0, (void*)0, 0};
3251 static swig_type_info _swigt__p_perl_read_data_t = {"_p_perl_read_data_t", "perl_read_data_t *", 0, 0, (void*)0, 0};
3252 static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "guchar *|unsigned char *", 0, 0, (void*)0, 0};
3253 
3254 static swig_type_info *swig_type_initial[] = {
3255   &_swigt__p_amar_attr_t,
3256   &_swigt__p_amar_file_t,
3257   &_swigt__p_amar_t,
3258   &_swigt__p_char,
3259   &_swigt__p_double,
3260   &_swigt__p_float,
3261   &_swigt__p_gsize,
3262   &_swigt__p_guint16,
3263   &_swigt__p_int,
3264   &_swigt__p_off_t,
3265   &_swigt__p_perl_read_data_t,
3266   &_swigt__p_unsigned_char,
3267 };
3268 
3269 static swig_cast_info _swigc__p_amar_attr_t[] = {  {&_swigt__p_amar_attr_t, 0, 0, 0},{0, 0, 0, 0}};
3270 static swig_cast_info _swigc__p_amar_file_t[] = {  {&_swigt__p_amar_file_t, 0, 0, 0},{0, 0, 0, 0}};
3271 static swig_cast_info _swigc__p_amar_t[] = {  {&_swigt__p_amar_t, 0, 0, 0},{0, 0, 0, 0}};
3272 static swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
3273 static swig_cast_info _swigc__p_double[] = {  {&_swigt__p_double, 0, 0, 0},{0, 0, 0, 0}};
3274 static swig_cast_info _swigc__p_float[] = {  {&_swigt__p_float, 0, 0, 0},{0, 0, 0, 0}};
3275 static swig_cast_info _swigc__p_gsize[] = {  {&_swigt__p_gsize, 0, 0, 0},{0, 0, 0, 0}};
3276 static swig_cast_info _swigc__p_guint16[] = {  {&_swigt__p_guint16, 0, 0, 0},{0, 0, 0, 0}};
3277 static swig_cast_info _swigc__p_int[] = {  {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
3278 static swig_cast_info _swigc__p_off_t[] = {  {&_swigt__p_off_t, 0, 0, 0},{0, 0, 0, 0}};
3279 static swig_cast_info _swigc__p_perl_read_data_t[] = {  {&_swigt__p_perl_read_data_t, 0, 0, 0},{0, 0, 0, 0}};
3280 static swig_cast_info _swigc__p_unsigned_char[] = {  {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
3281 
3282 static swig_cast_info *swig_cast_initial[] = {
3283   _swigc__p_amar_attr_t,
3284   _swigc__p_amar_file_t,
3285   _swigc__p_amar_t,
3286   _swigc__p_char,
3287   _swigc__p_double,
3288   _swigc__p_float,
3289   _swigc__p_gsize,
3290   _swigc__p_guint16,
3291   _swigc__p_int,
3292   _swigc__p_off_t,
3293   _swigc__p_perl_read_data_t,
3294   _swigc__p_unsigned_char,
3295 };
3296 
3297 
3298 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
3299 
3300 static swig_constant_info swig_constants[] = {
3301 {0,0,0,0,0,0}
3302 };
3303 #ifdef __cplusplus
3304 }
3305 #endif
3306 static swig_variable_info swig_variables[] = {
3307 {0,0,0,0}
3308 };
3309 static swig_command_info swig_commands[] = {
3310 {"Amanda::Archivec::amar_new", _wrap_amar_new},
3311 {"Amanda::Archivec::amar_size", _wrap_amar_size},
3312 {"Amanda::Archivec::amar_close", _wrap_amar_close},
3313 {"Amanda::Archivec::amar_new_file", _wrap_amar_new_file},
3314 {"Amanda::Archivec::amar_file_size", _wrap_amar_file_size},
3315 {"Amanda::Archivec::amar_file_close", _wrap_amar_file_close},
3316 {"Amanda::Archivec::amar_new_attr", _wrap_amar_new_attr},
3317 {"Amanda::Archivec::amar_attr_size", _wrap_amar_attr_size},
3318 {"Amanda::Archivec::amar_attr_close", _wrap_amar_attr_close},
3319 {"Amanda::Archivec::amar_attr_add_data_buffer", _wrap_amar_attr_add_data_buffer},
3320 {"Amanda::Archivec::amar_attr_add_data_fd", _wrap_amar_attr_add_data_fd},
3321 {"Amanda::Archivec::amar_attr_add_data_fd_in_thread", _wrap_amar_attr_add_data_fd_in_thread},
3322 {"Amanda::Archivec::amar_read", _wrap_amar_read},
3323 {"Amanda::Archivec::amar_read_to", _wrap_amar_read_to},
3324 {"Amanda::Archivec::amar_stop_read", _wrap_amar_stop_read},
3325 {"Amanda::Archivec::amar_start_read", _wrap_amar_start_read},
3326 {"Amanda::Archivec::destroy_read_cb", _wrap_destroy_read_cb},
3327 {"Amanda::Archivec::set_amar_read_cb", _wrap_set_amar_read_cb},
3328 {0,0}
3329 };
3330 /* -----------------------------------------------------------------------------
3331  * Type initialization:
3332  * This problem is tough by the requirement that no dynamic
3333  * memory is used. Also, since swig_type_info structures store pointers to
3334  * swig_cast_info structures and swig_cast_info structures store pointers back
3335  * to swig_type_info structures, we need some lookup code at initialization.
3336  * The idea is that swig generates all the structures that are needed.
3337  * The runtime then collects these partially filled structures.
3338  * The SWIG_InitializeModule function takes these initial arrays out of
3339  * swig_module, and does all the lookup, filling in the swig_module.types
3340  * array with the correct data and linking the correct swig_cast_info
3341  * structures together.
3342  *
3343  * The generated swig_type_info structures are assigned statically to an initial
3344  * array. We just loop through that array, and handle each type individually.
3345  * First we lookup if this type has been already loaded, and if so, use the
3346  * loaded structure instead of the generated one. Then we have to fill in the
3347  * cast linked list. The cast data is initially stored in something like a
3348  * two-dimensional array. Each row corresponds to a type (there are the same
3349  * number of rows as there are in the swig_type_initial array). Each entry in
3350  * a column is one of the swig_cast_info structures for that type.
3351  * The cast_initial array is actually an array of arrays, because each row has
3352  * a variable number of columns. So to actually build the cast linked list,
3353  * we find the array of casts associated with the type, and loop through it
3354  * adding the casts to the list. The one last trick we need to do is making
3355  * sure the type pointer in the swig_cast_info struct is correct.
3356  *
3357  * First off, we lookup the cast->type name to see if it is already loaded.
3358  * There are three cases to handle:
3359  *  1) If the cast->type has already been loaded AND the type we are adding
3360  *     casting info to has not been loaded (it is in this module), THEN we
3361  *     replace the cast->type pointer with the type pointer that has already
3362  *     been loaded.
3363  *  2) If BOTH types (the one we are adding casting info to, and the
3364  *     cast->type) are loaded, THEN the cast info has already been loaded by
3365  *     the previous module so we just ignore it.
3366  *  3) Finally, if cast->type has not already been loaded, then we add that
3367  *     swig_cast_info to the linked list (because the cast->type) pointer will
3368  *     be correct.
3369  * ----------------------------------------------------------------------------- */
3370 
3371 #ifdef __cplusplus
3372 extern "C" {
3373 #if 0
3374 } /* c-mode */
3375 #endif
3376 #endif
3377 
3378 #if 0
3379 #define SWIGRUNTIME_DEBUG
3380 #endif
3381 
3382 
3383 SWIGRUNTIME void
SWIG_InitializeModule(void * clientdata)3384 SWIG_InitializeModule(void *clientdata) {
3385   size_t i;
3386   swig_module_info *module_head, *iter;
3387   int init;
3388 
3389   /* check to see if the circular list has been setup, if not, set it up */
3390   if (swig_module.next==0) {
3391     /* Initialize the swig_module */
3392     swig_module.type_initial = swig_type_initial;
3393     swig_module.cast_initial = swig_cast_initial;
3394     swig_module.next = &swig_module;
3395     init = 1;
3396   } else {
3397     init = 0;
3398   }
3399 
3400   /* Try and load any already created modules */
3401   module_head = SWIG_GetModule(clientdata);
3402   if (!module_head) {
3403     /* This is the first module loaded for this interpreter */
3404     /* so set the swig module into the interpreter */
3405     SWIG_SetModule(clientdata, &swig_module);
3406   } else {
3407     /* the interpreter has loaded a SWIG module, but has it loaded this one? */
3408     iter=module_head;
3409     do {
3410       if (iter==&swig_module) {
3411         /* Our module is already in the list, so there's nothing more to do. */
3412         return;
3413       }
3414       iter=iter->next;
3415     } while (iter!= module_head);
3416 
3417     /* otherwise we must add our module into the list */
3418     swig_module.next = module_head->next;
3419     module_head->next = &swig_module;
3420   }
3421 
3422   /* When multiple interpreters are used, a module could have already been initialized in
3423        a different interpreter, but not yet have a pointer in this interpreter.
3424        In this case, we do not want to continue adding types... everything should be
3425        set up already */
3426   if (init == 0) return;
3427 
3428   /* Now work on filling in swig_module.types */
3429 #ifdef SWIGRUNTIME_DEBUG
3430   printf("SWIG_InitializeModule: size %d\n", swig_module.size);
3431 #endif
3432   for (i = 0; i < swig_module.size; ++i) {
3433     swig_type_info *type = 0;
3434     swig_type_info *ret;
3435     swig_cast_info *cast;
3436 
3437 #ifdef SWIGRUNTIME_DEBUG
3438     printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
3439 #endif
3440 
3441     /* if there is another module already loaded */
3442     if (swig_module.next != &swig_module) {
3443       type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
3444     }
3445     if (type) {
3446       /* Overwrite clientdata field */
3447 #ifdef SWIGRUNTIME_DEBUG
3448       printf("SWIG_InitializeModule: found type %s\n", type->name);
3449 #endif
3450       if (swig_module.type_initial[i]->clientdata) {
3451         type->clientdata = swig_module.type_initial[i]->clientdata;
3452 #ifdef SWIGRUNTIME_DEBUG
3453         printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
3454 #endif
3455       }
3456     } else {
3457       type = swig_module.type_initial[i];
3458     }
3459 
3460     /* Insert casting types */
3461     cast = swig_module.cast_initial[i];
3462     while (cast->type) {
3463       /* Don't need to add information already in the list */
3464       ret = 0;
3465 #ifdef SWIGRUNTIME_DEBUG
3466       printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
3467 #endif
3468       if (swig_module.next != &swig_module) {
3469         ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
3470 #ifdef SWIGRUNTIME_DEBUG
3471         if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
3472 #endif
3473       }
3474       if (ret) {
3475         if (type == swig_module.type_initial[i]) {
3476 #ifdef SWIGRUNTIME_DEBUG
3477           printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
3478 #endif
3479           cast->type = ret;
3480           ret = 0;
3481         } else {
3482           /* Check for casting already in the list */
3483           swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
3484 #ifdef SWIGRUNTIME_DEBUG
3485           if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
3486 #endif
3487           if (!ocast) ret = 0;
3488         }
3489       }
3490 
3491       if (!ret) {
3492 #ifdef SWIGRUNTIME_DEBUG
3493         printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
3494 #endif
3495         if (type->cast) {
3496           type->cast->prev = cast;
3497           cast->next = type->cast;
3498         }
3499         type->cast = cast;
3500       }
3501       cast++;
3502     }
3503     /* Set entry in modules->types array equal to the type */
3504     swig_module.types[i] = type;
3505   }
3506   swig_module.types[i] = 0;
3507 
3508 #ifdef SWIGRUNTIME_DEBUG
3509   printf("**** SWIG_InitializeModule: Cast List ******\n");
3510   for (i = 0; i < swig_module.size; ++i) {
3511     int j = 0;
3512     swig_cast_info *cast = swig_module.cast_initial[i];
3513     printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
3514     while (cast->type) {
3515       printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
3516       cast++;
3517       ++j;
3518     }
3519     printf("---- Total casts: %d\n",j);
3520   }
3521   printf("**** SWIG_InitializeModule: Cast List ******\n");
3522 #endif
3523 }
3524 
3525 /* This function will propagate the clientdata field of type to
3526 * any new swig_type_info structures that have been added into the list
3527 * of equivalent types.  It is like calling
3528 * SWIG_TypeClientData(type, clientdata) a second time.
3529 */
3530 SWIGRUNTIME void
SWIG_PropagateClientData(void)3531 SWIG_PropagateClientData(void) {
3532   size_t i;
3533   swig_cast_info *equiv;
3534   static int init_run = 0;
3535 
3536   if (init_run) return;
3537   init_run = 1;
3538 
3539   for (i = 0; i < swig_module.size; i++) {
3540     if (swig_module.types[i]->clientdata) {
3541       equiv = swig_module.types[i]->cast;
3542       while (equiv) {
3543         if (!equiv->converter) {
3544           if (equiv->type && !equiv->type->clientdata)
3545           SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
3546         }
3547         equiv = equiv->next;
3548       }
3549     }
3550   }
3551 }
3552 
3553 #ifdef __cplusplus
3554 #if 0
3555 {
3556   /* c-mode */
3557 #endif
3558 }
3559 #endif
3560 
3561 
3562 
3563 #if defined(__cplusplus) && ! defined(XSPROTO)
3564 extern "C"
3565 #endif
3566 
XS(SWIG_init)3567 XS(SWIG_init) {
3568   dXSARGS;
3569   int i;
3570 
3571   SWIG_InitializeModule(0);
3572 
3573   /* Install commands */
3574   for (i = 0; swig_commands[i].name; i++) {
3575     /* Casts only needed for Perl < 5.10. */
3576 #ifdef __cplusplus
3577     newXS(const_cast<char*>(swig_commands[i].name), swig_commands[i].wrapper, const_cast<char*>(__FILE__));
3578 #else
3579     newXS((char*)swig_commands[i].name, swig_commands[i].wrapper, (char*)__FILE__);
3580 #endif
3581   }
3582 
3583   /* Install variables */
3584   for (i = 0; swig_variables[i].name; i++) {
3585     SV *sv;
3586     sv = get_sv(swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI);
3587     if (swig_variables[i].type) {
3588       SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0);
3589     } else {
3590       sv_setiv(sv,(IV) 0);
3591     }
3592     swig_create_magic(sv, swig_variables[i].name, swig_variables[i].set, swig_variables[i].get);
3593   }
3594 
3595   /* Install constant */
3596   for (i = 0; swig_constants[i].type; i++) {
3597     SV *sv;
3598     sv = get_sv(swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI);
3599     switch(swig_constants[i].type) {
3600     case SWIG_INT:
3601       sv_setiv(sv, (IV) swig_constants[i].lvalue);
3602       break;
3603     case SWIG_FLOAT:
3604       sv_setnv(sv, (double) swig_constants[i].dvalue);
3605       break;
3606     case SWIG_STRING:
3607       sv_setpv(sv, (const char *) swig_constants[i].pvalue);
3608       break;
3609     case SWIG_POINTER:
3610       SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0);
3611       break;
3612     case SWIG_BINARY:
3613       SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype));
3614       break;
3615     default:
3616       break;
3617     }
3618     SvREADONLY_on(sv);
3619   }
3620 
3621   /*@SWIG:/usr/share/swig/3.0.7/perl5/perltypemaps.swg,65,%set_constant@*/ do {
3622     SV *sv = get_sv((char*) SWIG_prefix "AMAR_ATTR_FILENAME", TRUE | 0x2 | GV_ADDMULTI);
3623     sv_setsv(sv, SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(AMAR_ATTR_FILENAME)));
3624     SvREADONLY_on(sv);
3625   } while(0) /*@SWIG@*/;
3626   /*@SWIG:/usr/share/swig/3.0.7/perl5/perltypemaps.swg,65,%set_constant@*/ do {
3627     SV *sv = get_sv((char*) SWIG_prefix "AMAR_ATTR_EOF", TRUE | 0x2 | GV_ADDMULTI);
3628     sv_setsv(sv, SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(AMAR_ATTR_EOF)));
3629     SvREADONLY_on(sv);
3630   } while(0) /*@SWIG@*/;
3631   /*@SWIG:/usr/share/swig/3.0.7/perl5/perltypemaps.swg,65,%set_constant@*/ do {
3632     SV *sv = get_sv((char*) SWIG_prefix "AMAR_ATTR_GENERIC_DATA", TRUE | 0x2 | GV_ADDMULTI);
3633     sv_setsv(sv, SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(AMAR_ATTR_GENERIC_DATA)));
3634     SvREADONLY_on(sv);
3635   } while(0) /*@SWIG@*/;
3636   /*@SWIG:/usr/share/swig/3.0.7/perl5/perltypemaps.swg,65,%set_constant@*/ do {
3637     SV *sv = get_sv((char*) SWIG_prefix "AMAR_ATTR_RMAN_DATA", TRUE | 0x2 | GV_ADDMULTI);
3638     sv_setsv(sv, SWIG_From_int  SWIG_PERL_CALL_ARGS_1((int)(AMAR_ATTR_RMAN_DATA)));
3639     SvREADONLY_on(sv);
3640   } while(0) /*@SWIG@*/;
3641   ST(0) = &PL_sv_yes;
3642   XSRETURN(1);
3643 }
3644 
3645