Imported Upstream version 3.2.0
[debian/amanda] / perl / Amanda / Archive.c
index feec4de9a363671b4a03c12c22d15c95ef70a0ff..a77cc17b9b49ba63a48fe156500646c3f031fc42 100644 (file)
@@ -1,6 +1,6 @@
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.35
+ * Version 1.3.39
  * 
  * This file is not intended to be easily readable and contains a number of 
  * coding conventions designed to improve portability and efficiency. Do not make
  * 
  * This file is not intended to be easily readable and contains a number of 
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -8,8 +8,12 @@
  * interface file instead. 
  * ----------------------------------------------------------------------------- */
 
  * interface file instead. 
  * ----------------------------------------------------------------------------- */
 
+#include "../config/config.h"
+
+
 #define SWIGPERL
 #define SWIG_CASTRANK_MODE
 #define SWIGPERL
 #define SWIG_CASTRANK_MODE
+
 /* -----------------------------------------------------------------------------
  *  This section contains generic SWIG labels for method/variable
  *  declarations/attributes, and other compiler dependent labels.
 /* -----------------------------------------------------------------------------
  *  This section contains generic SWIG labels for method/variable
  *  declarations/attributes, and other compiler dependent labels.
 # endif
 #endif
 
 # endif
 #endif
 
+#ifndef SWIG_MSC_UNSUPPRESS_4505
+# if defined(_MSC_VER)
+#   pragma warning(disable : 4505) /* unreferenced local function has been removed */
+# endif 
+#endif
+
 #ifndef SWIGUNUSEDPARM
 # ifdef __cplusplus
 #   define SWIGUNUSEDPARM(p)
 #ifndef SWIGUNUSEDPARM
 # ifdef __cplusplus
 #   define SWIGUNUSEDPARM(p)
 /* -----------------------------------------------------------------------------
  * swigrun.swg
  *
 /* -----------------------------------------------------------------------------
  * swigrun.swg
  *
- * This file contains generic CAPI SWIG runtime support for pointer
+ * This file contains generic C API SWIG runtime support for pointer
  * type checking.
  * ----------------------------------------------------------------------------- */
 
  * type checking.
  * ----------------------------------------------------------------------------- */
 
 
 /*
   You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
 
 /*
   You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
-  creating a static or dynamic library from the swig runtime code.
-  In 99.9% of the cases, swig just needs to declare them as 'static'.
+  creating a static or dynamic library from the SWIG runtime code.
+  In 99.9% of the cases, SWIG just needs to declare them as 'static'.
   
   
-  But only do this if is strictly necessary, ie, if you have problems
-  with your compiler or so.
+  But only do this if strictly necessary, ie, if you have problems
+  with your compiler or suchlike.
 */
 
 #ifndef SWIGRUNTIME
 */
 
 #ifndef SWIGRUNTIME
 /* 
    Flags/methods for returning states.
    
 /* 
    Flags/methods for returning states.
    
-   The swig conversion methods, as ConvertPtr, return and integer 
+   The SWIG conversion methods, as ConvertPtr, return and integer 
    that tells if the conversion was successful or not. And if not,
    an error code can be returned (see swigerrors.swg for the codes).
    
    Use the following macros/flags to set or process the returning
    states.
    
    that tells if the conversion was successful or not. And if not,
    an error code can be returned (see swigerrors.swg for the codes).
    
    Use the following macros/flags to set or process the returning
    states.
    
-   In old swig versions, you usually write code as:
+   In old versions of SWIG, code such as the following was usually written:
 
      if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
        // success code
 
      if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
        // success code
        //fail code
      }
 
        //fail code
      }
 
-   Now you can be more explicit as:
+   Now you can be more explicit:
 
     int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
     if (SWIG_IsOK(res)) {
 
     int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
     if (SWIG_IsOK(res)) {
       // fail code
     }
 
       // fail code
     }
 
-   that seems to be the same, but now you can also do
+   which is the same really, but now you can also do
 
     Type *ptr;
     int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
 
     Type *ptr;
     int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
     
    I.e., now SWIG_ConvertPtr can return new objects and you can
    identify the case and take care of the deallocation. Of course that
     
    I.e., now SWIG_ConvertPtr can return new objects and you can
    identify the case and take care of the deallocation. Of course that
-   requires also to SWIG_ConvertPtr to return new result values, as
+   also requires SWIG_ConvertPtr to return new result values, such as
 
       int SWIG_ConvertPtr(obj, ptr,...) {         
         if (<obj is ok>) {                            
 
       int SWIG_ConvertPtr(obj, ptr,...) {         
         if (<obj is ok>) {                            
 
    Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
    more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
 
    Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
    more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
-   swig errors code.
+   SWIG errors code.
 
    Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
    allows to return the 'cast rank', for example, if you have this
 
    Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
    allows to return the 'cast rank', for example, if you have this
       fooi(1)   // cast rank '0'
 
    just use the SWIG_AddCast()/SWIG_CheckState()
       fooi(1)   // cast rank '0'
 
    just use the SWIG_AddCast()/SWIG_CheckState()
+*/
 
 
-
- */
 #define SWIG_OK                    (0) 
 #define SWIG_ERROR                 (-1)
 #define SWIG_IsOK(r)               (r >= 0)
 #define SWIG_OK                    (0) 
 #define SWIG_ERROR                 (-1)
 #define SWIG_IsOK(r)               (r >= 0)
 #define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
 #define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
 
 #define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
 #define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
 
-
 /* Cast-Rank Mode */
 #if defined(SWIG_CASTRANK_MODE)
 #  ifndef SWIG_TypeRank
 /* Cast-Rank Mode */
 #if defined(SWIG_CASTRANK_MODE)
 #  ifndef SWIG_TypeRank
@@ -290,8 +298,6 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
 #endif
 
 
 #endif
 
 
-
-
 #include <string.h>
 
 #ifdef __cplusplus
 #include <string.h>
 
 #ifdef __cplusplus
@@ -388,40 +394,58 @@ SWIG_TypeCompare(const char *nb, const char *tb) {
 }
 
 
 }
 
 
-/* think of this as a c++ template<> or a scheme macro */
-#define SWIG_TypeCheck_Template(comparison, ty)         \
-  if (ty) {                                             \
-    swig_cast_info *iter = ty->cast;                    \
-    while (iter) {                                      \
-      if (comparison) {                                 \
-        if (iter == ty->cast) return iter;              \
-        /* Move iter to the top of the linked list */   \
-        iter->prev->next = iter->next;                  \
-        if (iter->next)                                 \
-          iter->next->prev = iter->prev;                \
-        iter->next = ty->cast;                          \
-        iter->prev = 0;                                 \
-        if (ty->cast) ty->cast->prev = iter;            \
-        ty->cast = iter;                                \
-        return iter;                                    \
-      }                                                 \
-      iter = iter->next;                                \
-    }                                                   \
-  }                                                     \
-  return 0
-
 /*
   Check the typename
 */
 SWIGRUNTIME swig_cast_info *
 SWIG_TypeCheck(const char *c, swig_type_info *ty) {
 /*
   Check the typename
 */
 SWIGRUNTIME swig_cast_info *
 SWIG_TypeCheck(const char *c, swig_type_info *ty) {
-  SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
+  if (ty) {
+    swig_cast_info *iter = ty->cast;
+    while (iter) {
+      if (strcmp(iter->type->name, c) == 0) {
+        if (iter == ty->cast)
+          return iter;
+        /* Move iter to the top of the linked list */
+        iter->prev->next = iter->next;
+        if (iter->next)
+          iter->next->prev = iter->prev;
+        iter->next = ty->cast;
+        iter->prev = 0;
+        if (ty->cast) ty->cast->prev = iter;
+        ty->cast = iter;
+        return iter;
+      }
+      iter = iter->next;
+    }
+  }
+  return 0;
 }
 
 }
 
-/* Same as previous function, except strcmp is replaced with a pointer comparison */
+/* 
+  Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
+*/
 SWIGRUNTIME swig_cast_info *
 SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
-  SWIG_TypeCheck_Template(iter->type == from, into);
+SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
+  if (ty) {
+    swig_cast_info *iter = ty->cast;
+    while (iter) {
+      if (iter->type == from) {
+        if (iter == ty->cast)
+          return iter;
+        /* Move iter to the top of the linked list */
+        iter->prev->next = iter->next;
+        if (iter->next)
+          iter->next->prev = iter->prev;
+        iter->next = ty->cast;
+        iter->prev = 0;
+        if (ty->cast) ty->cast->prev = iter;
+        ty->cast = iter;
+        return iter;
+      }
+      iter = iter->next;
+    }
+  }
+  return 0;
 }
 
 /*
 }
 
 /*
@@ -1060,13 +1084,32 @@ SWIG_Perl_TypeProxyName(const swig_type_info *type) {
   }
 }
 
   }
 }
 
+/* Identical to SWIG_TypeCheck, except for strcmp comparison */
 SWIGRUNTIME swig_cast_info *
 SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) {
 SWIGRUNTIME swig_cast_info *
 SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) {
-  SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) 
-                           || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty);
+  if (ty) {
+    swig_cast_info *iter = ty->cast;
+    while (iter) {
+      if ( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) ||
+            (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0)) ) {
+        if (iter == ty->cast)
+          return iter;
+        /* Move iter to the top of the linked list */
+        iter->prev->next = iter->next;
+        if (iter->next)
+          iter->next->prev = iter->prev;
+        iter->next = ty->cast;
+        iter->prev = 0;
+        if (ty->cast) ty->cast->prev = iter;
+        ty->cast = iter;
+        return iter;
+      }
+      iter = iter->next;
+    }
+  }
+  return 0;
 }
 
 }
 
-
 /* Function for getting a pointer value */
 
 SWIGRUNTIME int
 /* Function for getting a pointer value */
 
 SWIGRUNTIME int
@@ -1414,6 +1457,12 @@ SWIG_Perl_SetModule(swig_module_info *module) {
 #ifdef open
   #undef open
 #endif
 #ifdef open
   #undef open
 #endif
+#ifdef readdir
+  #undef readdir
+#endif
+#ifdef bind
+  #undef bind
+#endif
 
 
 
 
 
 
@@ -1451,7 +1500,7 @@ static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0};
 #define SWIG_name   "Amanda::Archivec::boot_Amanda__Archive"
 #define SWIG_prefix "Amanda::Archivec::"
 
 #define SWIG_name   "Amanda::Archivec::boot_Amanda__Archive"
 #define SWIG_prefix "Amanda::Archivec::"
 
-#define SWIGVERSION 0x010335 
+#define SWIGVERSION 0x010339 
 #define SWIG_VERSION SWIGVERSION
 
 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -1487,6 +1536,8 @@ SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *);
 
 /* Support code (not directly available from perl) */
 
 
 /* Support code (not directly available from perl) */
 
+#define AMANDA_ARCHIVE_ERROR_DOMAIN "Amanda archive"
+
 /* A C object to contain all of the relevant callbacks and other state during a
  * read operation; this becomes the user_data during the read */
 typedef struct perl_read_data_s {
 /* A C object to contain all of the relevant callbacks and other state during a
  * read operation; this becomes the user_data during the read */
 typedef struct perl_read_data_s {
@@ -1651,16 +1702,6 @@ read_frag_cb(
     return TRUE;
 }
 
     return TRUE;
 }
 
-static void
-croak_gerror(GError **error)
-{
-    static char *errstr = NULL;
-    if (errstr) g_free(errstr);
-    errstr = g_strdup((*error)->message);
-    g_clear_error(error);
-    croak("Amanda archive: %s", errstr);
-}
-
 /* generic function to recognize when a string+len represents a number and
  * incidentally return the resulting value.  Note that this does not handle
  * negative numbers. */
 /* generic function to recognize when a string+len represents a number and
  * incidentally return the resulting value.  Note that this does not handle
  * negative numbers. */
@@ -1705,14 +1746,14 @@ amar_t *amar_new_(int fd, char *modestr) {
        return rv;
     }
 
        return rv;
     }
 
-    croak_gerror(&error);
+    croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
     return NULL;
 }
 
 void amar_close_(amar_t *arch) {
     GError *error = NULL;
     if (!amar_close(arch, &error))
     return NULL;
 }
 
 void amar_close_(amar_t *arch) {
     GError *error = NULL;
     if (!amar_close(arch, &error))
-       croak_gerror(&error);
+       croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
 }
 
 amar_file_t *
 }
 
 amar_file_t *
@@ -1725,14 +1766,14 @@ amar_new_file_(amar_t *arch, char *filename, gsize filename_len, off_t *want_pos
     if (file)
        return file;
 
     if (file)
        return file;
 
-    croak_gerror(&error);
+    croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
     return NULL;
 }
 
 void amar_file_close_(amar_file_t *file) {
     GError *error = NULL;
     if (!amar_file_close(file, &error))
     return NULL;
 }
 
 void amar_file_close_(amar_file_t *file) {
     GError *error = NULL;
     if (!amar_file_close(file, &error))
-       croak_gerror(&error);
+       croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
 }
 
 amar_attr_t *
 }
 
 amar_attr_t *
@@ -1746,20 +1787,20 @@ amar_new_attr_(amar_file_t *file, guint16 attrid) {
     if (attr)
        return attr;
 
     if (attr)
        return attr;
 
-    croak_gerror(&error);
+    croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
     return NULL;
 }
 
 void amar_attr_close_(amar_attr_t *attr) {
     GError *error = NULL;
     if (!amar_attr_close(attr, &error))
     return NULL;
 }
 
 void amar_attr_close_(amar_attr_t *attr) {
     GError *error = NULL;
     if (!amar_attr_close(attr, &error))
-       croak_gerror(&error);
+       croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
 }
 
 void amar_attr_add_data_buffer_(amar_attr_t *attr, char *buffer, gsize size, gboolean eoa) {
     GError *error = NULL;
     if (!amar_attr_add_data_buffer(attr, buffer, size, eoa, &error))
 }
 
 void amar_attr_add_data_buffer_(amar_attr_t *attr, char *buffer, gsize size, gboolean eoa) {
     GError *error = NULL;
     if (!amar_attr_add_data_buffer(attr, buffer, size, eoa, &error))
-       croak_gerror(&error);
+       croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
 }
 
 size_t
 }
 
 size_t
@@ -1767,7 +1808,7 @@ amar_attr_add_data_fd_(amar_attr_t *attr, int fd, gboolean eoa) {
     GError *error = NULL;
     size_t rv = amar_attr_add_data_fd(attr, fd, eoa, &error);
     if (rv < 0)
     GError *error = NULL;
     size_t rv = amar_attr_add_data_fd(attr, fd, eoa, &error);
     if (rv < 0)
-       croak_gerror(&error);
+       croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
     return rv;
 }
 
     return rv;
 }
 
@@ -1911,7 +1952,7 @@ void amar_read_(amar_t *archive, SV *params_hashref) {
      * is still set */
     if (!success) {
        if (error)
      * is still set */
     if (!success) {
        if (error)
-           croak_gerror(&error);
+           croak_gerror(AMANDA_ARCHIVE_ERROR_DOMAIN, &error);
        else
            croak(NULL);
     }
        else
            croak(NULL);
     }
@@ -1935,6 +1976,11 @@ SWIG_pchar_descriptor(void)
 SWIGINTERN int
 SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
 {
 SWIGINTERN int
 SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
 {
+  if (SvMAGICAL(obj)) {
+     SV *tmp = sv_newmortal();
+     SvSetSV(tmp, obj);
+     obj = tmp;
+  }
   if (SvPOK(obj)) {
     STRLEN len = 0;
     char *cstr = SvPV(obj, len); 
   if (SvPOK(obj)) {
     STRLEN len = 0;
     char *cstr = SvPV(obj, len); 
@@ -2102,8 +2148,8 @@ extern "C" {
 #endif
 
 #ifdef PERL_OBJECT
 #endif
 
 #ifdef PERL_OBJECT
-#define MAGIC_CLASS _wrap_Amanda::Archive_var::
-class _wrap_Amanda::Archive_var : public CPerlObj {
+#define MAGIC_CLASS _wrap_Amanda__Archive_var::
+class _wrap_Amanda__Archive_var : public CPerlObj {
 public:
 #else
 #define MAGIC_CLASS
 public:
 #else
 #define MAGIC_CLASS
@@ -2130,27 +2176,41 @@ XS(_wrap_amar_new) {
   {
     int arg1 ;
     char *arg2 = (char *) 0 ;
   {
     int arg1 ;
     char *arg2 = (char *) 0 ;
-    amar_t *result = 0 ;
     int res2 ;
     char *buf2 = 0 ;
     int alloc2 = 0 ;
     int argvi = 0;
     int res2 ;
     char *buf2 = 0 ;
     int alloc2 = 0 ;
     int argvi = 0;
+    amar_t *result = 0 ;
     dXSARGS;
     
     if ((items < 2) || (items > 2)) {
       SWIG_croak("Usage: amar_new(fd,modestr);");
     }
     {
     dXSARGS;
     
     if ((items < 2) || (items > 2)) {
       SWIG_croak("Usage: amar_new(fd,modestr);");
     }
     {
-      if (sizeof(signed int) == 1) {
-        arg1 = amglue_SvI8(ST(0));
-      } else if (sizeof(signed int) == 2) {
-        arg1 = amglue_SvI16(ST(0));
-      } else if (sizeof(signed int) == 4) {
-        arg1 = amglue_SvI32(ST(0));
-      } else if (sizeof(signed int) == 8) {
-        arg1 = amglue_SvI64(ST(0));
+      IO *io = NULL;
+      PerlIO *pio = NULL;
+      int fd = -1;
+      
+      if (SvIOK(ST(0))) {
+        /* plain old integer */
+        arg1 = SvIV(ST(0));
       } else {
       } else {
-        g_critical("Unexpected signed int >64 bits?"); /* should be optimized out unless sizeof(signed int) > 8 */
+        /* try extracting as filehandle */
+        
+        /* note: sv_2io may call die() */
+        io = sv_2io(ST(0));
+        if (io) {
+          pio = IoIFP(io);
+        }
+        if (pio) {
+          fd = PerlIO_fileno(pio);
+        }
+        if (fd >= 0) {
+          arg1 = fd;
+        } else {
+          SWIG_exception(SWIG_TypeError, "Expected integer file descriptor "
+            "or file handle for argument 1");
+        }
       }
     }
     res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
       }
     }
     res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
@@ -2188,7 +2248,7 @@ XS(_wrap_amar_close) {
     }
     arg1 = (amar_t *)(argp1);
     amar_close_(arg1);
     }
     arg1 = (amar_t *)(argp1);
     amar_close_(arg1);
-    
+    ST(argvi) = sv_newmortal();
     
     XSRETURN(argvi);
   fail:
     
     XSRETURN(argvi);
   fail:
@@ -2204,7 +2264,6 @@ XS(_wrap_amar_new_file) {
     char *arg2 = (char *) 0 ;
     gsize arg3 ;
     off_t *arg4 = (off_t *) 0 ;
     char *arg2 = (char *) 0 ;
     gsize arg3 ;
     off_t *arg4 = (off_t *) 0 ;
-    amar_file_t *result = 0 ;
     void *argp1 = 0 ;
     int res1 = 0 ;
     int res2 ;
     void *argp1 = 0 ;
     int res1 = 0 ;
     int res2 ;
@@ -2214,6 +2273,7 @@ XS(_wrap_amar_new_file) {
     off_t position4 ;
     int argvi = 0;
     SV * _saved[1] ;
     off_t position4 ;
     int argvi = 0;
     SV * _saved[1] ;
+    amar_file_t *result = 0 ;
     dXSARGS;
     
     if ((items < 3) || (items > 3)) {
     dXSARGS;
     
     if ((items < 3) || (items > 3)) {
@@ -2243,8 +2303,9 @@ XS(_wrap_amar_new_file) {
     ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_amar_file_t, 0 | 0); argvi++ ;
     {
       if (arg4) {
     ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_amar_file_t, 0 | 0); argvi++ ;
     {
       if (arg4) {
-        ST(argvi) = amglue_newSVi64(*arg4);
-        argvi++;
+        SP += argvi; PUTBACK;
+        ST(argvi) = sv_2mortal(amglue_newSVi64(*arg4));
+        SPAGAIN; SP -= argvi; argvi++;
       }
     }
     
       }
     }
     
@@ -2277,7 +2338,7 @@ XS(_wrap_amar_file_close) {
     }
     arg1 = (amar_file_t *)(argp1);
     amar_file_close_(arg1);
     }
     arg1 = (amar_file_t *)(argp1);
     amar_file_close_(arg1);
-    
+    ST(argvi) = sv_newmortal();
     
     XSRETURN(argvi);
   fail:
     
     XSRETURN(argvi);
   fail:
@@ -2291,10 +2352,10 @@ XS(_wrap_amar_new_attr) {
   {
     amar_file_t *arg1 = (amar_file_t *) 0 ;
     guint16 arg2 ;
   {
     amar_file_t *arg1 = (amar_file_t *) 0 ;
     guint16 arg2 ;
-    amar_attr_t *result = 0 ;
     void *argp1 = 0 ;
     int res1 = 0 ;
     int argvi = 0;
     void *argp1 = 0 ;
     int res1 = 0 ;
     int argvi = 0;
+    amar_attr_t *result = 0 ;
     dXSARGS;
     
     if ((items < 2) || (items > 2)) {
     dXSARGS;
     
     if ((items < 2) || (items > 2)) {
@@ -2336,7 +2397,7 @@ XS(_wrap_amar_attr_close) {
     }
     arg1 = (amar_attr_t *)(argp1);
     amar_attr_close_(arg1);
     }
     arg1 = (amar_attr_t *)(argp1);
     amar_attr_close_(arg1);
-    
+    ST(argvi) = sv_newmortal();
     
     XSRETURN(argvi);
   fail:
     
     XSRETURN(argvi);
   fail:
@@ -2376,20 +2437,10 @@ XS(_wrap_amar_attr_add_data_buffer) {
     arg2 = (char *)(buf2);
     arg3 = (gsize)(size2 - 1);
     {
     arg2 = (char *)(buf2);
     arg3 = (gsize)(size2 - 1);
     {
-      if (sizeof(signed int) == 1) {
-        arg4 = amglue_SvI8(ST(2));
-      } else if (sizeof(signed int) == 2) {
-        arg4 = amglue_SvI16(ST(2));
-      } else if (sizeof(signed int) == 4) {
-        arg4 = amglue_SvI32(ST(2));
-      } else if (sizeof(signed int) == 8) {
-        arg4 = amglue_SvI64(ST(2));
-      } else {
-        g_critical("Unexpected signed int >64 bits?"); /* should be optimized out unless sizeof(signed int) > 8 */
-      }
+      arg4 = SvTRUE(ST(2));
     }
     amar_attr_add_data_buffer_(arg1,arg2,arg3,arg4);
     }
     amar_attr_add_data_buffer_(arg1,arg2,arg3,arg4);
-    
+    ST(argvi) = sv_newmortal();
     
     if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
     
     
     if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
     
@@ -2408,10 +2459,10 @@ XS(_wrap_amar_attr_add_data_fd) {
     amar_attr_t *arg1 = (amar_attr_t *) 0 ;
     int arg2 ;
     gboolean arg3 ;
     amar_attr_t *arg1 = (amar_attr_t *) 0 ;
     int arg2 ;
     gboolean arg3 ;
-    size_t result;
     void *argp1 = 0 ;
     int res1 = 0 ;
     int argvi = 0;
     void *argp1 = 0 ;
     int res1 = 0 ;
     int argvi = 0;
+    size_t result;
     dXSARGS;
     
     if ((items < 3) || (items > 3)) {
     dXSARGS;
     
     if ((items < 3) || (items > 3)) {
@@ -2423,34 +2474,42 @@ XS(_wrap_amar_attr_add_data_fd) {
     }
     arg1 = (amar_attr_t *)(argp1);
     {
     }
     arg1 = (amar_attr_t *)(argp1);
     {
-      if (sizeof(signed int) == 1) {
-        arg2 = amglue_SvI8(ST(1));
-      } else if (sizeof(signed int) == 2) {
-        arg2 = amglue_SvI16(ST(1));
-      } else if (sizeof(signed int) == 4) {
-        arg2 = amglue_SvI32(ST(1));
-      } else if (sizeof(signed int) == 8) {
-        arg2 = amglue_SvI64(ST(1));
+      IO *io = NULL;
+      PerlIO *pio = NULL;
+      int fd = -1;
+      
+      if (SvIOK(ST(1))) {
+        /* plain old integer */
+        arg2 = SvIV(ST(1));
       } else {
       } else {
-        g_critical("Unexpected signed int >64 bits?"); /* should be optimized out unless sizeof(signed int) > 8 */
+        /* try extracting as filehandle */
+        
+        /* note: sv_2io may call die() */
+        io = sv_2io(ST(1));
+        if (io) {
+          pio = IoIFP(io);
+        }
+        if (pio) {
+          fd = PerlIO_fileno(pio);
+        }
+        if (fd >= 0) {
+          arg2 = fd;
+        } else {
+          SWIG_exception(SWIG_TypeError, "Expected integer file descriptor "
+            "or file handle for argument 2");
+        }
       }
     }
     {
       }
     }
     {
-      if (sizeof(signed int) == 1) {
-        arg3 = amglue_SvI8(ST(2));
-      } else if (sizeof(signed int) == 2) {
-        arg3 = amglue_SvI16(ST(2));
-      } else if (sizeof(signed int) == 4) {
-        arg3 = amglue_SvI32(ST(2));
-      } else if (sizeof(signed int) == 8) {
-        arg3 = amglue_SvI64(ST(2));
-      } else {
-        g_critical("Unexpected signed int >64 bits?"); /* should be optimized out unless sizeof(signed int) > 8 */
-      }
+      arg3 = SvTRUE(ST(2));
     }
     result = amar_attr_add_data_fd_(arg1,arg2,arg3);
     {
     }
     result = amar_attr_add_data_fd_(arg1,arg2,arg3);
     {
-      ST(argvi) = sv_2mortal(amglue_newSVu64(result));
+      SV *for_stack;
+      SP += argvi; PUTBACK;
+      for_stack = sv_2mortal(amglue_newSVu64(result));
+      SPAGAIN; SP -= argvi;
+      ST(argvi) = for_stack;
       argvi++;
     }
     
       argvi++;
     }
     
@@ -2485,7 +2544,7 @@ XS(_wrap_amar_read) {
     arg1 = (amar_t *)(argp1);
     arg2 = ST(1);
     amar_read_(arg1,arg2);
     arg1 = (amar_t *)(argp1);
     arg2 = ST(1);
     amar_read_(arg1,arg2);
-    
+    ST(argvi) = sv_newmortal();
     
     
     XSRETURN(argvi);
     
     
     XSRETURN(argvi);