/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 1.3u-20000712-1502 (Alpha 3)
 * 
 * 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
 * changes to this file unless you know what you are doing--modify the SWIG 
 * interface file instead. 
 * ----------------------------------------------------------------------------- */

/***********************************************************************
 * common.swg
 *
 *     This file contains generic SWIG runtime support for pointer
 *     type checking as well as a few commonly used macros to control
 *     external linkage.
 *
 * Author : David Beazley (beazley@cs.uchicago.edu)
 *
 * Copyright (c) 1999-2000, The University of Chicago
 * 
 * This file may be freely redistributed without license or fee provided
 * this copyright message remains intact.
 ************************************************************************/

#include <string.h>

#if defined(_WIN32) || defined(__WIN32__)
#       if defined(_MSC_VER)
#               if defined(STATIC_LINKED)
#                       define SWIGEXPORT(a) a
#               else
#                       define SWIGEXPORT(a) __declspec(dllexport) a
#               endif
#       else
#               if defined(__BORLANDC__)
#                       define SWIGEXPORT(a) a _export
#               else
#                       define SWIGEXPORT(a) a
#       endif
#endif
#else
#       define SWIGEXPORT(a) a
#endif

#ifdef SWIG_GLOBAL
#define SWIGRUNTIME(a) SWIGEXPORT(a)
#else
#define SWIGRUNTIME(a) static a
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef struct swig_type_info {
  char  *name;                 
  void *(*converter)(void *);
  char  *str;
  struct swig_type_info  *next;
  struct swig_type_info  *prev;
} swig_type_info;

#ifdef SWIG_NOINCLUDE
SWIGEXPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *);
SWIGEXPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *);
SWIGEXPORT(void *) SWIG_TypeCast(swig_type_info *, void *);
#else

static swig_type_info *swig_type_list = 0;

/* Register a type mapping with the type-checking */
SWIGRUNTIME(swig_type_info *)
SWIG_TypeRegister(swig_type_info *ti)
{
  swig_type_info *tc, *head, *ret, *next;
  /* Check to see if this type has already been registered */
  tc = swig_type_list;
  while (tc) {
    if (strcmp(tc->name, ti->name) == 0) {
      /* Already exists in the table.  Just add additional types to the list */
      head = tc;
      next = tc->next;
      goto l1;
    }
    tc = tc->prev;
  }
  head = ti;
  next = 0;

  /* Place in list */
  ti->prev = swig_type_list;
  swig_type_list = ti;

  /* Build linked lists */
 l1:
  ret = head;
  tc = ti + 1;
  /* Patch up the rest of the links */
  while (tc->name) {
    head->next = tc;
    tc->prev = head;
    head = tc;
    tc++;
  }
  head->next = next;
  return ret;
}

/* Check the typename */
SWIGRUNTIME(swig_type_info *) 
SWIG_TypeCheck(char *c, swig_type_info *ty)
{
  swig_type_info *s;
  if (!ty) return 0;        /* Void pointer */
  s = ty->next;             /* First element always just a name */
  while (s) {
    if (strcmp(s->name,c) == 0) {
      if (s == ty->next) return s;
      /* Move s to the top of the linked list */
      s->prev->next = s->next;
      if (s->next) {
	s->next->prev = s->prev;
      }
      /* Insert s as second element in the list */
      s->next = ty->next;
      if (ty->next) ty->next->prev = s;
      ty->next = s;
      return s;
    }
    s = s->next;
  }
  return 0;
}

/* Cast a pointer (needed for C++ inheritance */
SWIGRUNTIME(void *) 
SWIG_TypeCast(swig_type_info *ty, void *ptr) 
{
  if ((!ty) || (!ty->converter)) return ptr;
  return (*ty->converter)(ptr);
}

/* Search for a swig_type_info structure */
SWIGRUNTIME(void *)
SWIG_TypeQuery(const char *name) {
  swig_type_info *ty = swig_type_list;
  while (ty) {
    if (ty->str && (strcmp(name,ty->str) == 0)) return ty;
    if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
    ty = ty->prev;
  }
  return 0;
}

#endif

#ifdef __cplusplus
}
#endif



/* -----------------------------------------------------------------------------
 * perl5.swg
 *
 * Perl5 runtime library
 * $Header: /home/newville/Codes/cvsroot/ifeffit/src/win32/ifeffit_wrap_pl.c,v 1.1 2001/10/05 17:07:01 newville Exp $
 * ----------------------------------------------------------------------------- */

#define SWIGPERL
#define SWIGPERL5
#ifdef __cplusplus
/* Needed on some windows machines---since MS plays funny
   games with the header files under C++ */
#include <math.h>
#include <stdlib.h>
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

/* Get rid of free and malloc defined by perl */
#undef free
#undef malloc

#include <string.h>
#ifdef __cplusplus
}
#endif

#ifdef PERL_OBJECT
#define MAGIC_PPERL  CPerlObj *pPerl = (CPerlObj *) this;
#define MAGIC_CAST   (int (CPerlObj::*)(SV *, MAGIC *))
#define SWIGCLASS_STATIC 
#else
#define MAGIC_PPERL
#define MAGIC_CAST
#define SWIGCLASS_STATIC static
#endif

#if defined(WIN32) && defined(PERL_OBJECT) && !defined(PerlIO_exportFILE)
#define PerlIO_exportFILE(fh,fl) (FILE*)(fh)
#endif

/* Modifications for newer Perl 5.005 releases */

#if !defined(PERL_REVISION) || ((PERL_REVISION >= 5) && ((PERL_VERSION < 5) || ((PERL_VERSION == 5) && (PERL_SUBVERSION < 50))))
#ifndef PL_sv_yes
#define PL_sv_yes sv_yes
#endif
#ifndef PL_sv_undef
#define PL_sv_undef sv_undef
#endif
#ifndef PL_na
#define PL_na na
#endif
#endif

#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifdef SWIG_NOINCLUDE

#ifndef PERL_OBJECT
extern int SWIG_ConvertPtr(SV *, void **, swig_type_info *);
extern void SWIG_MakePtr(SV *, void *, swig_type_info *);
#else
extern int _SWIG_ConvertPtr(CPerlObj *, SV *, void **, swig_type_info *);
extern void _SWIG_MakePtr(CPerlObj *, SV *, void *, swig_type_info *);
#define SWIG_ConvertPtr(a,b,c) _SWIG_ConvertPtr(pPerl,a,b,c)
#define SWIG_MakePtr(a,b,c) _SWIG_MakePtr(pPerl,a,b,c)
#endif

#endif

/* Function for getting a pointer value */

#ifndef PERL_OBJECT
SWIGRUNTIME(int) 
SWIG_ConvertPtr(SV *sv, void **ptr, swig_type_info *_t)
#else
#define SWIG_ConvertPtr(a,b,c) _SWIG_GetConvert(pPerl,a,b,c)
SWIGRUNTIME(int)
_SWIG_ConvertPtr(CPerlObj *pPerl, SV *sv, void **ptr, swig_type_info *_t)
#endif
{
  char *_c;
  swig_type_info *tc;
  IV   tmp;

  /* If magical, apply more magic */
  if (SvGMAGICAL(sv))
    mg_get(sv);

  /* Check to see if this is an object */
  if (sv_isobject(sv)) {
    SV *tsv = (SV*) SvRV(sv);
    if ((SvTYPE(tsv) == SVt_PVHV)) {
      MAGIC *mg;
      if (SvMAGICAL(tsv)) {
	mg = mg_find(tsv,'P');
	if (mg) {
	  SV *rsv = mg->mg_obj;
	  if (sv_isobject(rsv)) {
	    tmp = SvIV((SV*)SvRV(rsv));
	  }
	}
      } else {
	return -1;
      }
    } else {
      tmp = SvIV((SV*)SvRV(sv));
    }
    if (!_t) {
      *(ptr) = (void *) tmp;
      return 0;
    }
  } else if (! SvOK(sv)) {            /* Check for undef */
    *(ptr) = (void *) 0;
    return 0;
  } else if (SvTYPE(sv) == SVt_RV) {  /* Check for NULL pointer */
    *(ptr) = (void *) 0;
    if (!SvROK(sv)) 
      return 0;
    else
      return -1;
  } else {                            /* Don't know what it is */
      *(ptr) = (void *) 0;
      return -1;
  }
  if (_t) {
    /* Now see if the types match */      
    _c = HvNAME(SvSTASH(SvRV(sv)));
    tc = SWIG_TypeCheck(_c,_t);
    if (!tc) {
      *ptr = (void *) tmp;
      return -1;
    }
    *ptr = SWIG_TypeCast(tc,(void *)tmp);
    return 0;
  }
  *ptr = (void *) tmp;
  return 0;
}
#ifndef PERL_OBJECT
SWIGRUNTIME(void) 
SWIG_MakePtr(SV *sv, void *ptr, swig_type_info *t)
#else
#define SWIG_MakePtr(a,b,c) _SWIG_MakePtr(pPerl,a,b,c)
SWIGRUNTIME(int *)
_SWIG_MakePtr(CPerlObj *pPerl, SV *sv, void *ptr, swig_type_info *t)
#endif
{
  sv_setref_pv(sv, t->name, ptr);
}

/* Magic variable code */
#ifndef PERL_OBJECT
#define swig_create_magic(s,a,b,c) _swig_create_magic(s,a,b,c)
static void _swig_create_magic(SV *sv, char *name, int (*set)(SV *, MAGIC *), int (*get)(SV *,MAGIC *)) {
#else
#define swig_create_magic(s,a,b,c) _swig_create_magic(pPerl,s,a,b,c)
static void _swig_create_magic(CPerlObj *pPerl, SV *sv, char *name, int (CPerlObj::*set)(SV *, MAGIC *), int (CPerlObj::*get)(SV *, MAGIC *)) {
#endif
  MAGIC *mg;
  sv_magic(sv,sv,'U',name,strlen(name));
  mg = mg_find(sv,'U');
  mg->mg_virtual = (MGVTBL *) malloc(sizeof(MGVTBL));
  mg->mg_virtual->svt_get = get;
  mg->mg_virtual->svt_set = set;
  mg->mg_virtual->svt_len = 0;
  mg->mg_virtual->svt_clear = 0;
  mg->mg_virtual->svt_free = 0;
}

#ifdef __cplusplus
}
#endif







/* -------- TYPES TABLE (BEGIN) -------- */

#define  SWIGTYPE_p_float swig_types[0] 
#define  SWIGTYPE_p_double swig_types[1] 
#define  SWIGTYPE_p_char swig_types[2] 
#define  SWIGTYPE_p_p_char swig_types[3] 
#define  SWIGTYPE_p_long swig_types[4] 
#define  SWIGTYPE_p_void swig_types[5] 
#define  SWIGTYPE_p_int swig_types[6] 
#define  SWIGTYPE_p_short swig_types[7] 
static swig_type_info *swig_types[9];

/* -------- TYPES TABLE (END) -------- */

#define SWIG_init    boot_Ifeffit

#define SWIG_name   "Ifeffit::boot_Ifeffit"
#define SWIG_varinit "Ifeffit::var_Ifeffit_init();"
#ifdef __cplusplus
extern "C"
#endif
#ifndef PERL_OBJECT
SWIGEXPORT(void) SWIG_init (CV* cv);
#else
SWIGEXPORT(void) SWIG_init (CV *cv, CPerlObj *);
#endif

#include "ifeffit.h"

#include <ctype.h>

/* Types used by the library */
static swig_type_info *SWIG_POINTER_int_p = 0;
static swig_type_info *SWIG_POINTER_short_p =0;
static swig_type_info *SWIG_POINTER_long_p = 0;
static swig_type_info *SWIG_POINTER_float_p = 0;
static swig_type_info *SWIG_POINTER_double_p = 0;
static swig_type_info *SWIG_POINTER_char_p = 0;
static swig_type_info *SWIG_POINTER_char_pp = 0;
static swig_type_info *SWIG_POINTER_void_p = 0;


/* #ifdef WIN32
#undef isspace
#define isspace(c) (c == ' ')
#endif
*/

/*------------------------------------------------------------------
  ptrvalue(ptr,type = 0)

  Attempts to dereference a pointer value.  If type is given, it 
  will try to use that type.  Otherwise, this function will attempt
  to "guess" the proper datatype by checking against all of the 
  builtin C datatypes. 
  ------------------------------------------------------------------ */

#ifdef PERL_OBJECT
static SV *_ptrvalue(CPerlObj *pPerl,SV *_PTRVALUE, int index, char *type) {
#define ptrvalue(a,b,c) _ptrvalue(pPerl,a,b,c)
#else
static SV *_ptrvalue(SV *_PTRVALUE, int index, char *type) {
#define ptrvalue(a,b,c) _ptrvalue(a,b,c)
#endif

  void     *ptr;
  SV       *obj = 0;

  if (SWIG_ConvertPtr(_PTRVALUE, &ptr, 0) < 0) {
    croak("Type error it ptrvalue. Argument is not a valid pointer value.");
  } else {
    /* If no datatype was passed, try a few common datatypes first */
    if (!type) {

      /* No datatype was passed.   Type to figure out if it's a common one */
      
      if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_int_p) >= 0) {
	type = "int";
      } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_double_p) >= 0) {
	type = "double";
      } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_short_p) >= 0) {
	type = "short";
      } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_long_p) >= 0) {
	type = "long";
      } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_float_p) >= 0) {
	type = "float";
      } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_p) >= 0) {
	type = "char";
      } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_pp) >= 0) {
	type = "char *";
      } else {
	type = "unknown";
      }
    }
    
    if (!ptr) {
      croak("Unable to dereference NULL pointer.");
      return 0;
    }

    /* Now we have a datatype.  Try to figure out what to do about it */
    if (strcmp(type,"int") == 0) {
      obj = sv_newmortal();
      sv_setiv(obj,(IV) *(((int *) ptr) + index));
    } else if (strcmp(type,"double") == 0) {
      obj = sv_newmortal();
      sv_setnv(obj,(double) *(((double *) ptr)+index));
    } else if (strcmp(type,"short") == 0) {
      obj = sv_newmortal();
      sv_setiv(obj,(IV) *(((short *) ptr) + index));
    } else if (strcmp(type,"long") == 0) {
      obj = sv_newmortal();
      sv_setiv(obj,(IV) *(((long *) ptr) + index));
    } else if (strcmp(type,"float") == 0) {
      obj = sv_newmortal();
      sv_setnv(obj,(double) *(((float *) ptr)+index));
    } else if (strcmp(type,"char") == 0) {
      obj = sv_newmortal();
      sv_setpv(obj,((char *) ptr)+index);
    } else if (strcmp(type,"char *") == 0) {
      char *c = *(((char **) ptr)+index);
      obj = sv_newmortal();
      if (c) 
	sv_setpv(obj,c);
      else 
	sv_setpv(obj,"NULL");
    } else {
      croak("Unable to dereference unsupported datatype.");
      obj = 0;
    }
  }
  return obj;
}

/*------------------------------------------------------------------
  ptrcreate(type,value = 0,numelements = 1)

  Attempts to create a new object of given type.  Type must be
  a basic C datatype.  Will not create complex objects.
  ------------------------------------------------------------------ */
#ifdef PERL_OBJECT
static SV *_ptrcreate(CPerlObj *pPerl, char *type, SV *value, int numelements) {
#define ptrcreate(a,b,c) _ptrcreate(pPerl,a,b,c)
#else
static SV *_ptrcreate(char *type, SV *value, int numelements) {
#define ptrcreate(a,b,c) _ptrcreate(a,b,c)
#endif

  void     *ptr;
  SV       *obj;
  int       sz;
  swig_type_info *cast = 0;

  /* Check the type string against a variety of possibilities */

  if (strcmp(type,"int") == 0) {
    sz = sizeof(int)*numelements;
    cast = SWIG_POINTER_int_p;
  } else if (strcmp(type,"short") == 0) {
    sz = sizeof(short)*numelements;
    cast = SWIG_POINTER_short_p;
  } else if (strcmp(type,"long") == 0) {
    sz = sizeof(long)*numelements;
    cast = SWIG_POINTER_long_p;
  } else if (strcmp(type,"double") == 0) {
    sz = sizeof(double)*numelements;
    cast = SWIG_POINTER_double_p;
  } else if (strcmp(type,"float") == 0) {
    sz = sizeof(float)*numelements;
    cast = SWIG_POINTER_float_p;
  } else if (strcmp(type,"char") == 0) {
    sz = sizeof(char)*numelements;
    cast = SWIG_POINTER_char_p;
  } else if (strcmp(type,"char *") == 0) {
    sz = sizeof(char *)*(numelements+1);
    cast = SWIG_POINTER_char_pp;
  } else if (strcmp(type,"void") == 0) {
    sz = numelements;
    cast = SWIG_POINTER_void_p;	
  } else {
    croak("Unable to create unknown datatype."); 
    return 0;
  }
   
  /* Create the new object */
  
  ptr = (void *) malloc(sz);
  if (!ptr) {
    croak("Out of memory in ptrcreate."); 
    return 0;
  }

  /* Now try to set its default value */

  if (value) {
    if (strcmp(type,"int") == 0) {
      int *ip,i,ivalue;
      ivalue = (int) SvIV(value);
      ip = (int *) ptr;
      for (i = 0; i < numelements; i++)
	ip[i] = ivalue;
    } else if (strcmp(type,"short") == 0) {
      short *ip,ivalue;
      int i;
      ivalue = (short) SvIV(value);
      ip = (short *) ptr;
      for (i = 0; i < numelements; i++)
	ip[i] = ivalue;
    } else if (strcmp(type,"long") == 0) {
      long *ip,ivalue;
      int i;
      ivalue = (long) SvIV(value);
      ip = (long *) ptr;
      for (i = 0; i < numelements; i++)
	ip[i] = ivalue;
    } else if (strcmp(type,"double") == 0) {
      double *ip,ivalue;
      int i;
      ivalue = (double) SvNV(value);
      ip = (double *) ptr;
      for (i = 0; i < numelements; i++)
	ip[i] = ivalue;
    } else if (strcmp(type,"float") == 0) {
      float *ip,ivalue;
      int i;
      ivalue = (float) SvNV(value);
      ip = (float *) ptr;
      for (i = 0; i < numelements; i++)
	ip[i] = ivalue;
    } else if (strcmp(type,"char") == 0) {
      char *ip,*ivalue;
      ivalue = (char *) SvPV(value,PL_na);
      ip = (char *) ptr;
      strncpy(ip,ivalue,numelements-1);
    } else if (strcmp(type,"char *") == 0) {
      char **ip, *ivalue;
      int  i;
      ivalue = (char *) SvPV(value,PL_na);
      ip = (char **) ptr;
      for (i = 0; i < numelements; i++) {
	if (ivalue) {
	  ip[i] = (char *) malloc(strlen(ivalue)+1);
	  strcpy(ip[i],ivalue);
	} else {
	  ip[i] = 0;
	}
      }
      ip[numelements] = 0;
    }
  } 
  /* Create the pointer value */
  

  obj = sv_newmortal();
  SWIG_MakePtr(obj,ptr,cast);
  return obj;
}

/*------------------------------------------------------------------
  ptrset(ptr,value,index = 0,type = 0)

  Attempts to set the value of a pointer variable.  If type is
  given, we will use that type.  Otherwise, we'll guess the datatype.
  ------------------------------------------------------------------ */

#ifdef PERL_OBJECT
static void _ptrset(CPerlObj *pPerl,SV *_PTRVALUE, SV *value, int index, char *type) {
#define ptrset(a,b,c,d) _ptrset(pPerl,a,b,c,d)
#else
static void _ptrset(SV *_PTRVALUE, SV *value, int index, char *type) {
#define ptrset(a,b,c,d) _ptrset(a,b,c,d)
#endif
  void     *ptr;
  SV       *obj;


  if (SWIG_ConvertPtr(_PTRVALUE, &ptr, 0) < 0) {
    croak("Type error it ptrvalue. Argument is not a valid pointer value.");
  } else {
    /* If no datatype was passed, try a few common datatypes first */
    if (!type) {
      /* No datatype was passed.   Type to figure out if it's a common one */
      if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_int_p) >= 0) {
	type = "int";
      } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_double_p) >= 0) {
	type = "double";
      } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_short_p) >= 0) {
	type = "short";
      } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_long_p) >= 0) {
	type = "long";
      } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_float_p) >= 0) {
	type = "float";
      } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_p) >= 0) {
	type = "char";
      } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_pp) >= 0) {
	type = "char *";
      } else {
	type = "unknown";
      }
    }
  }
  if (!ptr) {
    croak("Unable to set NULL pointer.");
    return;
  }
  
  /* Now we have a datatype.  Try to figure out what to do about it */
  if (strcmp(type,"int") == 0) {
    *(((int *) ptr)+index) = (int) SvIV(value);
  } else if (strcmp(type,"double") == 0) {
    *(((double *) ptr)+index) = (double) SvNV(value);
  } else if (strcmp(type,"short") == 0) {
    *(((short *) ptr)+index) = (short) SvIV(value);
  } else if (strcmp(type,"long") == 0) {
    *(((long *) ptr)+index) = (long) SvIV(value);
  } else if (strcmp(type,"float") == 0) {
    *(((float *) ptr)+index) = (float) SvNV(value);
  } else if (strcmp(type,"char") == 0) {
    char *c = SvPV(value,PL_na);
    strcpy(((char *) ptr)+index, c);
  } else if (strcmp(type,"char *") == 0) {
    char *c = SvPV(value,PL_na);
    char **ca = (char **) ptr;
    if (ca[index]) free(ca[index]);
    if (strcmp(c,"NULL") == 0) {
      ca[index] = 0;
    } else {
      ca[index] = (char *) malloc(strlen(c)+1);
      strcpy(ca[index],c);
    }
  } else {
    croak("Unable to set unsupported datatype.");
    return;
  }
}

/*------------------------------------------------------------------
  ptradd(ptr,offset)

  Adds a value to an existing pointer value.  Will do a type-dependent
  add for basic datatypes.  For other datatypes, will do a byte-add.
  ------------------------------------------------------------------ */

#ifdef PERL_OBJECT
static SV *_ptradd(CPerlObj *pPerl, SV *_PTRVALUE, int offset) {
#define ptradd(a,b) _ptradd(pPerl,a,b)
#else
static SV *_ptradd(SV *_PTRVALUE, int offset) {
#define ptradd(a,b) _ptradd(a,b)
#endif

  void *ptr,*junk;
  SV   *obj;
  swig_type_info *type;
  char *tname;

  /* Try to handle a few common datatypes first */

  if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_int_p) >= 0) {
    ptr = (void *) (((int *) ptr) + offset);
  } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_double_p) >= 0) {
    ptr = (void *) (((double *) ptr) + offset);
  } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_short_p) >= 0) {
    ptr = (void *) (((short *) ptr) + offset);
  } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_long_p) >= 0) {
    ptr = (void *) (((long *) ptr) + offset);
  } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_float_p) >= 0) {
    ptr = (void *) (((float *) ptr) + offset);
  } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,SWIG_POINTER_char_p) >= 0) {
    ptr = (void *) (((char *) ptr) + offset);
  } else if (SWIG_ConvertPtr(_PTRVALUE,&ptr,0) >= 0) {
    ptr = (void *) (((char *) ptr) + offset);
  } else {
    croak("Type error in ptradd. Argument is not a valid pointer value.");
    return 0;
  }
  printf("ptradd = %x\n", ptr);
  tname = HvNAME(SvSTASH(SvRV(_PTRVALUE)));
  obj = sv_newmortal();
  sv_setref_pv(obj,tname,ptr);
  return obj;
}

/*------------------------------------------------------------------
  ptrfree(ptr)

  Destroys a pointer value
  ------------------------------------------------------------------ */
#ifdef PERL_OBJECT
void _ptrfree(CPerlObj *pPerl, SV *_PTRVALUE) {
#define ptrfree(a) _ptrfree(pPerl, a)
#else
void _ptrfree(SV *_PTRVALUE) {
#define ptrfree(a) _ptrfree(a)
#endif

  void *ptr, *junk;

  if (SWIG_ConvertPtr(_PTRVALUE,&ptr,0) < 0) {
    croak("Type error in ptrfree. Argument is not a valid pointer value.");
    return;
  }

  /* Check to see if this pointer is a char ** */
  if (SWIG_ConvertPtr(_PTRVALUE,&junk,SWIG_POINTER_char_pp) >= 0) {
    char **c = (char **) ptr;
    if (c) {
      int i = 0;
      while (c[i]) {
	free(c[i]);
	i++;
      }
    }
  } 
  if (ptr)
    free((char *) ptr);
}

#ifdef PERL_OBJECT
#define MAGIC_CLASS _wrap_Ifeffit_var::
class _wrap_Ifeffit_var : public CPerlObj {
public:
#else
#define MAGIC_CLASS
#endif
SWIGCLASS_STATIC int swig_magic_readonly(SV *sv, MAGIC *mg) {
    MAGIC_PPERL
    sv = sv; mg = mg;
    croak("Value is read-only.");
    return 0;
}


#ifdef PERL_OBJECT
};
#endif

XS(_wrap_ptrvalue) {
    SV *arg0 ;
    int arg1 = 0 ;
    char *arg2 = 0 ;
    int argvi = 0;
    SV *result ;
    dXSARGS;
    
    if ((items < 1) || (items > 3)) 
    croak("Usage: ptrvalue(ptr,index,type);");
    {
        arg0 = ST(0);
    }
    if (items > 1) {
        arg1 = (int )SvIV(ST(1));
    }
    if (items > 2) {
        if (! SvOK((SV*) ST(2))) {
            arg2 = 0; 
        }
        else {
            arg2 = (char *) SvPV(ST(2),PL_na); 
        }
    }
    result = (SV *)ptrvalue(arg0,arg1,arg2);
    {
        ST(argvi) = result;
        argvi++;
    }
    XSRETURN(argvi);
}


XS(_wrap_ptrset) {
    SV *arg0 ;
    SV *arg1 ;
    int arg2 = 0 ;
    char *arg3 = 0 ;
    int argvi = 0;
    dXSARGS;
    
    if ((items < 2) || (items > 4)) 
    croak("Usage: ptrset(ptr,value,index,type);");
    {
        arg0 = ST(0);
    }
    {
        arg1 = ST(1);
    }
    if (items > 2) {
        arg2 = (int )SvIV(ST(2));
    }
    if (items > 3) {
        if (! SvOK((SV*) ST(3))) {
            arg3 = 0; 
        }
        else {
            arg3 = (char *) SvPV(ST(3),PL_na); 
        }
    }
    ptrset(arg0,arg1,arg2,arg3);
    XSRETURN(argvi);
}


XS(_wrap_ptrcreate) {
    char *arg0 ;
    SV *arg1 = 0 ;
    int arg2 = 1 ;
    int argvi = 0;
    SV *result ;
    dXSARGS;
    
    if ((items < 1) || (items > 3)) 
    croak("Usage: ptrcreate(type,value,nitems);");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    if (items > 1) {
        {
            arg1 = ST(1);
        }
    }
    if (items > 2) {
        arg2 = (int )SvIV(ST(2));
    }
    result = (SV *)ptrcreate(arg0,arg1,arg2);
    {
        ST(argvi) = result;
        argvi++;
    }
    XSRETURN(argvi);
}


XS(_wrap_ptrfree) {
    SV *arg0 ;
    int argvi = 0;
    dXSARGS;
    
    if ((items < 1) || (items > 1)) 
    croak("Usage: ptrfree(ptr);");
    {
        arg0 = ST(0);
    }
    ptrfree(arg0);
    XSRETURN(argvi);
}


XS(_wrap_ptradd) {
    SV *arg0 ;
    int arg1 ;
    int argvi = 0;
    SV *result ;
    dXSARGS;
    
    if ((items < 2) || (items > 2)) 
    croak("Usage: ptradd(ptr,offset);");
    {
        arg0 = ST(0);
    }
    arg1 = (int )SvIV(ST(1));
    result = (SV *)ptradd(arg0,arg1);
    {
        ST(argvi) = result;
        argvi++;
    }
    XSRETURN(argvi);
}


XS(_wrap_iff_exec) {
    char *arg0 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 1) || (items > 1)) 
    croak("Usage: iff_exec(char *);");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    result = (int )iff_exec(arg0);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_iff_get_string) {
    char *arg0 ;
    char *arg1 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 2) || (items > 2)) 
    croak("Usage: iff_get_string(char *,char *);");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    if (! SvOK((SV*) ST(1))) {
        arg1 = 0; 
    }
    else {
        arg1 = (char *) SvPV(ST(1),PL_na); 
    }
    result = (int )iff_get_string(arg0,arg1);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_iff_put_string) {
    char *arg0 ;
    char *arg1 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 2) || (items > 2)) 
    croak("Usage: iff_put_string(char *,char *);");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    if (! SvOK((SV*) ST(1))) {
        arg1 = 0; 
    }
    else {
        arg1 = (char *) SvPV(ST(1),PL_na); 
    }
    result = (int )iff_put_string(arg0,arg1);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_iff_get_scalar) {
    char *arg0 ;
    double *arg1 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 2) || (items > 2)) 
    croak("Usage: iff_get_scalar(char *,double *);");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    if (SWIG_ConvertPtr(ST(1),(void **) &arg1,SWIGTYPE_p_double) < 0) {
        croak("Type error in argument 2 of iff_get_scalar. Expected %s", SWIGTYPE_p_double->name);
        XSRETURN(1);
    }
    result = (int )iff_get_scalar(arg0,arg1);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_iff_put_scalar) {
    char *arg0 ;
    double *arg1 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 2) || (items > 2)) 
    croak("Usage: iff_put_scalar(char *,double *);");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    if (SWIG_ConvertPtr(ST(1),(void **) &arg1,SWIGTYPE_p_double) < 0) {
        croak("Type error in argument 2 of iff_put_scalar. Expected %s", SWIGTYPE_p_double->name);
        XSRETURN(1);
    }
    result = (int )iff_put_scalar(arg0,arg1);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_iff_get_array) {
    char *arg0 ;
    double *arg1 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 2) || (items > 2)) 
    croak("Usage: iff_get_array(char *,double *);");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    if (SWIG_ConvertPtr(ST(1),(void **) &arg1,SWIGTYPE_p_double) < 0) {
        croak("Type error in argument 2 of iff_get_array. Expected %s", SWIGTYPE_p_double->name);
        XSRETURN(1);
    }
    result = (int )iff_get_array(arg0,arg1);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_iff_put_array) {
    char *arg0 ;
    int *arg1 ;
    double *arg2 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 3) || (items > 3)) 
    croak("Usage: iff_put_array(char *,int *,double *);");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    if (SWIG_ConvertPtr(ST(1),(void **) &arg1,SWIGTYPE_p_int) < 0) {
        croak("Type error in argument 2 of iff_put_array. Expected %s", SWIGTYPE_p_int->name);
        XSRETURN(1);
    }
    if (SWIG_ConvertPtr(ST(2),(void **) &arg2,SWIGTYPE_p_double) < 0) {
        croak("Type error in argument 3 of iff_put_array. Expected %s", SWIGTYPE_p_double->name);
        XSRETURN(1);
    }
    result = (int )iff_put_array(arg0,arg1,arg2);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_iff_get_echo) {
    char *arg0 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 1) || (items > 1)) 
    croak("Usage: iff_get_echo(char *);");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    result = (int )iff_get_echo(arg0);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_IFFEXECF) {
    char *arg0 ;
    int arg1 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 2) || (items > 2)) 
    croak("Usage: IFFEXECF(char *,int );");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    arg1 = (int )SvIV(ST(1));
    result = (int )IFFEXECF(arg0,arg1);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_IFFGETSTR) {
    char *arg0 ;
    int arg1 ;
    char *arg2 ;
    int arg3 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 4) || (items > 4)) 
    croak("Usage: IFFGETSTR(char *,int ,char *,int );");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    arg1 = (int )SvIV(ST(1));
    if (! SvOK((SV*) ST(2))) {
        arg2 = 0; 
    }
    else {
        arg2 = (char *) SvPV(ST(2),PL_na); 
    }
    arg3 = (int )SvIV(ST(3));
    result = (int )IFFGETSTR(arg0,arg1,arg2,arg3);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_IFFGETSCA) {
    char *arg0 ;
    int arg1 ;
    double *arg2 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 3) || (items > 3)) 
    croak("Usage: IFFGETSCA(char *,int ,double *);");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    arg1 = (int )SvIV(ST(1));
    if (SWIG_ConvertPtr(ST(2),(void **) &arg2,SWIGTYPE_p_double) < 0) {
        croak("Type error in argument 3 of IFFGETSCA. Expected %s", SWIGTYPE_p_double->name);
        XSRETURN(1);
    }
    result = (int )IFFGETSCA(arg0,arg1,arg2);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_IFFGETARR) {
    char *arg0 ;
    int arg1 ;
    double *arg2 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 3) || (items > 3)) 
    croak("Usage: IFFGETARR(char *,int ,double *);");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    arg1 = (int )SvIV(ST(1));
    if (SWIG_ConvertPtr(ST(2),(void **) &arg2,SWIGTYPE_p_double) < 0) {
        croak("Type error in argument 3 of IFFGETARR. Expected %s", SWIGTYPE_p_double->name);
        XSRETURN(1);
    }
    result = (int )IFFGETARR(arg0,arg1,arg2);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_IFFPUTARR) {
    char *arg0 ;
    int arg1 ;
    int *arg2 ;
    double *arg3 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 4) || (items > 4)) 
    croak("Usage: IFFPUTARR(char *,int ,int *,double *);");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    arg1 = (int )SvIV(ST(1));
    if (SWIG_ConvertPtr(ST(2),(void **) &arg2,SWIGTYPE_p_int) < 0) {
        croak("Type error in argument 3 of IFFPUTARR. Expected %s", SWIGTYPE_p_int->name);
        XSRETURN(1);
    }
    if (SWIG_ConvertPtr(ST(3),(void **) &arg3,SWIGTYPE_p_double) < 0) {
        croak("Type error in argument 4 of IFFPUTARR. Expected %s", SWIGTYPE_p_double->name);
        XSRETURN(1);
    }
    result = (int )IFFPUTARR(arg0,arg1,arg2,arg3);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}


XS(_wrap_IFFGETECHO) {
    char *arg0 ;
    int arg1 ;
    int argvi = 0;
    int result ;
    dXSARGS;
    
    if ((items < 2) || (items > 2)) 
    croak("Usage: IFFGETECHO(char *,int );");
    if (! SvOK((SV*) ST(0))) {
        arg0 = 0; 
    }
    else {
        arg0 = (char *) SvPV(ST(0),PL_na); 
    }
    arg1 = (int )SvIV(ST(1));
    result = (int )IFFGETECHO(arg0,arg1);
    ST(argvi) = sv_newmortal();
    sv_setiv(ST(argvi++),(IV) result);
    XSRETURN(argvi);
}



/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */

static swig_type_info _swigt__p_float[] = {{"_p_float", 0, "float *"},{"_p_float"},{0}};
static swig_type_info _swigt__p_double[] = {{"_p_double", 0, "double *"},{"_p_double"},{0}};
static swig_type_info _swigt__p_char[] = {{"_p_char", 0, "char *"},{"_p_char"},{0}};
static swig_type_info _swigt__p_p_char[] = {{"_p_p_char", 0, "char **"},{"_p_p_char"},{0}};
static swig_type_info _swigt__p_long[] = {{"_p_long", 0, "long *"},{"_p_long"},{0}};
static swig_type_info _swigt__p_void[] = {{"_p_void", 0, "void *"},{"_p_void"},{0}};
static swig_type_info _swigt__p_int[] = {{"_p_int", 0, "int *"},{"_p_int"},{0}};
static swig_type_info _swigt__p_short[] = {{"_p_short", 0, "short *"},{"_p_short"},{0}};

static swig_type_info *swig_types_initial[] = {
_swigt__p_float, 
_swigt__p_double, 
_swigt__p_char, 
_swigt__p_p_char, 
_swigt__p_long, 
_swigt__p_void, 
_swigt__p_int, 
_swigt__p_short, 
0
};


/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */

XS(_wrap_perl5_Ifeffit_var_init) {
    dXSARGS;
    SV *sv;
    XSRETURN(1);
}
#ifdef __cplusplus
extern "C"
#endif
XS(SWIG_init) {
    dXSARGS;
    int i;
    char *file = __FILE__;
    for (i = 0; swig_types_initial[i]; i++) {
        swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
    }
    newXS("Ifeffit::var_Ifeffit_init", _wrap_perl5_Ifeffit_var_init, file);
    
    SWIG_POINTER_int_p = SWIG_TypeQuery("int *");
    SWIG_POINTER_short_p = SWIG_TypeQuery("short *");
    SWIG_POINTER_long_p = SWIG_TypeQuery("long *");
    SWIG_POINTER_float_p = SWIG_TypeQuery("float *");
    SWIG_POINTER_double_p = SWIG_TypeQuery("double *");
    SWIG_POINTER_char_p = SWIG_TypeQuery("char *");
    SWIG_POINTER_char_pp = SWIG_TypeQuery("char **");
    SWIG_POINTER_void_p = SWIG_TypeQuery("void *");
    newXS("Ifeffit::ptrvalue", _wrap_ptrvalue, file);
    newXS("Ifeffit::ptrset", _wrap_ptrset, file);
    newXS("Ifeffit::ptrcreate", _wrap_ptrcreate, file);
    newXS("Ifeffit::ptrfree", _wrap_ptrfree, file);
    newXS("Ifeffit::ptradd", _wrap_ptradd, file);
    newXS("Ifeffit::iff_exec", _wrap_iff_exec, file);
    newXS("Ifeffit::iff_get_string", _wrap_iff_get_string, file);
    newXS("Ifeffit::iff_put_string", _wrap_iff_put_string, file);
    newXS("Ifeffit::iff_get_scalar", _wrap_iff_get_scalar, file);
    newXS("Ifeffit::iff_put_scalar", _wrap_iff_put_scalar, file);
    newXS("Ifeffit::iff_get_array", _wrap_iff_get_array, file);
    newXS("Ifeffit::iff_put_array", _wrap_iff_put_array, file);
    newXS("Ifeffit::iff_get_echo", _wrap_iff_get_echo, file);
    newXS("Ifeffit::IFFEXECF", _wrap_IFFEXECF, file);
    newXS("Ifeffit::IFFGETSTR", _wrap_IFFGETSTR, file);
    newXS("Ifeffit::IFFGETSCA", _wrap_IFFGETSCA, file);
    newXS("Ifeffit::IFFGETARR", _wrap_IFFGETARR, file);
    newXS("Ifeffit::IFFPUTARR", _wrap_IFFPUTARR, file);
    newXS("Ifeffit::IFFGETECHO", _wrap_IFFGETECHO, file);
    ST(0) = &PL_sv_yes;
    XSRETURN(1);
}

