/*
 * This file was generated automatically by xsubpp version 1.9508 from the
 * contents of API.xs. Do not edit this file, edit API.xs instead.
 *
 *	ANY CHANGES MADE HERE WILL BE LOST!
 *
 */

#line 1 "API.xs"
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

/* $Id: API.xs,v 1.8 2003/03/18 07:05:23 whmoseley Exp $ */

#include <swish-e.h>

#ifndef newSVuv
#   define newSVuv(i) newSViv(i)
#endif

#ifndef call_pv
#   define call_pv(i,j) perl_call_pv(i,j)
#endif



#line 29 "API.c"
XS(XS_SWISH__API_new); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_new)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::new(CLASS, index_file_list)");
    SP -= items;
    {
	char *	CLASS = (char *)SvPV_nolen(ST(0));
	char *	index_file_list = (char *)SvPV_nolen(ST(1));
#line 33 "API.xs"
        SW_HANDLE handle;

#line 43 "API.c"
#line 36 "API.xs"
        SwishErrorsToStderr();
        handle = SwishInit( index_file_list );
        ST(0) = sv_newmortal();
        sv_setref_pv( ST(0), CLASS, (void *)handle );
        SwishSetRefPtr( handle, (void *)SvRV(ST(0)) );
        XSRETURN(1);
#line 51 "API.c"
	PUTBACK;
	return;
    }
}

XS(XS_SWISH__API_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_DESTROY)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::DESTROY(self)");
    {
	SW_HANDLE	self;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		self = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::DESTROY() -- self is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 50 "API.xs"
        SwishClose( self );
#line 74 "API.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_SWISH__API_IndexNames); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_IndexNames)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::IndexNames(self)");
    SP -= items;
    {
	SW_HANDLE	self;
#line 59 "API.xs"
        const char **index_name;

#line 91 "API.c"

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		self = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::SwishIndexNames() -- self is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 62 "API.xs"
        index_name = SwishIndexNames( self );
        while ( *index_name )
        {
            XPUSHs(sv_2mortal(newSVpv( (char *)*index_name ,0 )));
            index_name++;
        }
#line 106 "API.c"
	PUTBACK;
	return;
    }
}

XS(XS_SWISH__API_HeaderNames); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_HeaderNames)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::HeaderNames(self)");
    SP -= items;
    {
	SW_HANDLE	self;
#line 76 "API.xs"
        const char **name;

#line 124 "API.c"

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		self = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::SwishHeaderNames() -- self is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 79 "API.xs"
        name = SwishHeaderNames( self );
        while ( *name )
        {
            XPUSHs(sv_2mortal(newSVpv( (char *)*name ,0 )));
            name++;
        }
#line 139 "API.c"
	PUTBACK;
	return;
    }
}

XS(XS_SWISH__API_HeaderValue); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_HeaderValue)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: SWISH::API::HeaderValue(swish_handle, index_file, header_name)");
    SP -= items;
    {
	SW_HANDLE	swish_handle;
	char *	index_file = (char *)SvPV_nolen(ST(1));
	char *	header_name = (char *)SvPV_nolen(ST(2));
#line 95 "API.xs"
        SWISH_HEADER_TYPE  header_type;
        SWISH_HEADER_VALUE head_value;
        int i;

#line 161 "API.c"

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		swish_handle = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::SwishHeaderValue() -- swish_handle is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 100 "API.xs"
        head_value = SwishHeaderValue( swish_handle, index_file, header_name, &header_type );

        PUSHMARK(SP);
        XPUSHs((SV *)swish_handle);
        XPUSHs((SV *)&head_value);
        XPUSHs((SV *)&header_type);
        PUTBACK;
        i = call_pv( "SWISH::API::decode_header_value", G_ARRAY );
        SPAGAIN;
#line 179 "API.c"
	PUTBACK;
	return;
    }
}

XS(XS_SWISH__API_decode_header_value); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_decode_header_value)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: SWISH::API::decode_header_value(swish_handle, header_value, header_type)");
    SP -= items;
    {
	SV *	swish_handle = ST(0);
	SV *	header_value = ST(1);
	SV *	header_type = ST(2);
#line 119 "API.xs"
        const char **string_list;
        SWISH_HEADER_VALUE *head_value;

#line 200 "API.c"
#line 123 "API.xs"
        head_value = (SWISH_HEADER_VALUE *)header_value;

        switch ( *(SWISH_HEADER_TYPE *)header_type )
        {
            case SWISH_STRING:
                if ( head_value->string &&  head_value->string[0] )
                    XPUSHs(sv_2mortal(newSVpv( (char *)head_value->string,0 )));
                else
                    ST(0) = &PL_sv_undef;
                break;

            case SWISH_NUMBER:
                XPUSHs(sv_2mortal(newSVuv( head_value->number )));
                break;

            case SWISH_BOOL:
                // how about pushing &PL_sv_yes and &PL_sv_no or using boolSV()?
                XPUSHs(sv_2mortal(newSViv( head_value->boolean ? 1 : 0 )));
                break;

            case SWISH_LIST:
                string_list = head_value->string_list;

                if ( !string_list ) /* Don't think this can happen */
                    XSRETURN_EMPTY;


                while ( *string_list )
                {
                    XPUSHs(sv_2mortal(newSVpv( (char *)*string_list ,0 )));
                    string_list++;
                }
                break;

            case SWISH_HEADER_ERROR:
                SwishAbortLastError( (SW_HANDLE)swish_handle );
                break;

            default:
                croak(" Unknown header type '%d'\n", header_type );
        }
#line 243 "API.c"
	PUTBACK;
	return;
    }
}

XS(XS_SWISH__API_AbortLastError); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_AbortLastError)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::AbortLastError(self)");
    {
	SW_HANDLE	self;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		self = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::SwishAbortLastError() -- self is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	SwishAbortLastError(self);
    }
    XSRETURN_EMPTY;
}

XS(XS_SWISH__API_Error); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_Error)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::Error(self)");
    {
	SW_HANDLE	self;
	int	RETVAL;
	dXSTARG;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		self = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::SwishError() -- self is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	RETVAL = SwishError(self);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_SWISH__API_ErrorString); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_ErrorString)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::ErrorString(self)");
    {
	SW_HANDLE	self;
	char *	RETVAL;
	dXSTARG;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		self = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::SwishErrorString() -- self is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	RETVAL = SwishErrorString(self);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_SWISH__API_LastErrorMsg); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_LastErrorMsg)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::LastErrorMsg(self)");
    {
	SW_HANDLE	self;
	char *	RETVAL;
	dXSTARG;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		self = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::SwishLastErrorMsg() -- self is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	RETVAL = SwishLastErrorMsg(self);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_SWISH__API_CriticalError); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_CriticalError)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::CriticalError(self)");
    {
	SW_HANDLE	self;
	int	RETVAL;
	dXSTARG;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		self = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::SwishCriticalError() -- self is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	RETVAL = SwishCriticalError(self);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_SWISH__API_New_Search_Object); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_New_Search_Object)
{
    dXSARGS;
    if (items < 1 || items > 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::New_Search_Object(swish_handle, query = NULL)");
    {
	SW_HANDLE	swish_handle;
	char *	query;
#line 203 "API.xs"
        char * CLASS = "SWISH::API::Search";

#line 378 "API.c"
	SW_SEARCH	RETVAL;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		swish_handle = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::New_Search_Object() -- swish_handle is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	if (items < 2)
	    query = NULL;
	else {
	    query = (char *)SvPV_nolen(ST(1));
	}
#line 206 "API.xs"
	RETVAL = New_Search_Object( swish_handle, query );
        if ( RETVAL )
	    SvREFCNT_inc( (SV *)SwishSearch_parent( RETVAL ) );

#line 398 "API.c"
	ST(0) = sv_newmortal();
	sv_setref_pv( ST(0), CLASS, (void*)RETVAL );

    }
    XSRETURN(1);
}

XS(XS_SWISH__API_Query); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_Query)
{
    dXSARGS;
    if (items < 1 || items > 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::Query(swish_handle, query = NULL)");
    SP -= items;
    {
	SW_HANDLE	swish_handle;
	char *	query;
#line 222 "API.xs"
        char * CLASS = "SWISH::API::Results";
        SW_RESULTS results;

#line 420 "API.c"

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		swish_handle = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::SwishQuery() -- swish_handle is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	if (items < 2)
	    query = NULL;
	else {
	    query = (char *)SvPV_nolen(ST(1));
	}
#line 226 "API.xs"
	results = SwishQuery( swish_handle, query );
        if ( results )
        {
	    SvREFCNT_inc( (SV *)SwishResults_parent( results ) );
            ST(0) = sv_newmortal();
            sv_setref_pv( ST(0), CLASS, (void *)results );
            ResultsSetRefPtr( results, (void *)SvRV(ST(0)) );
            XSRETURN(1);
        }
#line 444 "API.c"
	PUTBACK;
	return;
    }
}

XS(XS_SWISH__API_WordsByLetter); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_WordsByLetter)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: SWISH::API::WordsByLetter(handle, filename, c)");
    SP -= items;
    {
	SW_HANDLE	handle;
	char *	filename = (char *)SvPV_nolen(ST(1));
	char	c = (char)*SvPV_nolen(ST(2));
#line 246 "API.xs"
         char *Words,*tmp;
         int c2;

#line 465 "API.c"

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		handle = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::SwishWordsByLetter() -- handle is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 251 "API.xs"
         if(c=='*')
         {
            for(c2=1;c2<256;c2++)
            {
               Words=(char *)SwishWordsByLetter(handle,filename,(unsigned char)c2);
               for(tmp=Words;tmp && tmp[0];tmp+=strlen(tmp)+1)
               {
                  XPUSHs(sv_2mortal(newSVpv(tmp,0)));
               }
            }
         } else {
            Words=(char *)SwishWordsByLetter(handle,filename,c);
            for(tmp=Words;tmp && tmp[0];tmp+=strlen(tmp)+1)
            {
               XPUSHs(sv_2mortal(newSVpv(tmp,0)));
            }
         }
#line 491 "API.c"
	PUTBACK;
	return;
    }
}

XS(XS_SWISH__API_StemWord); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API_StemWord)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::StemWord(handle, word)");
    {
	SW_HANDLE	handle;
	char *	word = (char *)SvPV_nolen(ST(1));
	char *	RETVAL;
	dXSTARG;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		handle = (SW_HANDLE)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::SwishStemWord() -- handle is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	RETVAL = SwishStemWord(handle, word);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_SWISH__API__Search_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Search_DESTROY)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::Search::DESTROY(search)");
    {
	SW_SEARCH	search;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		search = (SW_SEARCH)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Search::DESTROY() -- search is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 294 "API.xs"
        if ( search )
        {
            SV *parent = (SV *)SwishSearch_parent( search );
            Free_Search_Object( search );
	    SvREFCNT_dec( parent );
        }
#line 544 "API.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_SWISH__API__Search_SetQuery); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Search_SetQuery)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::Search::SetQuery(search, query)");
    {
	SW_SEARCH	search;
	char *	query = (char *)SvPV_nolen(ST(1));

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		search = (SW_SEARCH)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Search::SwishSetQuery() -- search is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	SwishSetQuery(search, query);
    }
    XSRETURN_EMPTY;
}

XS(XS_SWISH__API__Search_SetStructure); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Search_SetStructure)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::Search::SetStructure(search, structure)");
    {
	SW_SEARCH	search;
	int	structure = (int)SvIV(ST(1));

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		search = (SW_SEARCH)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Search::SwishSetStructure() -- search is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	SwishSetStructure(search, structure);
    }
    XSRETURN_EMPTY;
}

XS(XS_SWISH__API__Search_PhraseDelimiter); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Search_PhraseDelimiter)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::Search::PhraseDelimiter(search, delimiter)");
    {
	SW_SEARCH	search;
	char *	delimiter = (char *)SvPV_nolen(ST(1));

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		search = (SW_SEARCH)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Search::SwishPhraseDelimiter() -- search is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 320 "API.xs"
        SwishPhraseDelimiter(search, delimiter[0] );
#line 611 "API.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_SWISH__API__Search_SetSearchLimit); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Search_SetSearchLimit)
{
    dXSARGS;
    if (items != 4)
	Perl_croak(aTHX_ "Usage: SWISH::API::Search::SetSearchLimit(search, property, low, high)");
    {
	SW_SEARCH	search;
	char *	property = (char *)SvPV_nolen(ST(1));
	char *	low = (char *)SvPV_nolen(ST(2));
	char *	high = (char *)SvPV_nolen(ST(3));

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		search = (SW_SEARCH)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Search::SwishSetSearchLimit() -- search is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	SwishSetSearchLimit(search, property, low, high);
    }
    XSRETURN_EMPTY;
}

XS(XS_SWISH__API__Search_ResetSearchLimit); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Search_ResetSearchLimit)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::Search::ResetSearchLimit(search)");
    {
	SW_SEARCH	search;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		search = (SW_SEARCH)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Search::SwishResetSearchLimit() -- search is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	SwishResetSearchLimit(search);
    }
    XSRETURN_EMPTY;
}

XS(XS_SWISH__API__Search_SetSort); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Search_SetSort)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::Search::SetSort(search, sort_string)");
    {
	SW_SEARCH	search;
	char *	sort_string = (char *)SvPV_nolen(ST(1));

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		search = (SW_SEARCH)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Search::SwishSetSort() -- search is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	SwishSetSort(search, sort_string);
    }
    XSRETURN_EMPTY;
}

XS(XS_SWISH__API__Search_Execute); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Search_Execute)
{
    dXSARGS;
    if (items < 1 || items > 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::Search::Execute(search, query = NULL)");
    SP -= items;
    {
	SW_SEARCH	search;
	char *	query;
#line 350 "API.xs"
        char * CLASS = "SWISH::API::Results";
        SW_RESULTS results;

#line 697 "API.c"

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		search = (SW_SEARCH)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Search::SwishExecute() -- search is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	if (items < 2)
	    query = NULL;
	else {
	    query = (char *)SvPV_nolen(ST(1));
	}
#line 354 "API.xs"
        results = SwishExecute( search, query );
        {
	    SvREFCNT_inc( (SV *)SwishResults_parent( results ) );
            ST(0) = sv_newmortal();
            sv_setref_pv( ST(0), CLASS, (void *)results );
            ResultsSetRefPtr( results, (void *)SvRV(ST(0)) );
            XSRETURN(1);
        }
#line 720 "API.c"
	PUTBACK;
	return;
    }
}

XS(XS_SWISH__API__Results_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Results_DESTROY)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::Results::DESTROY(results)");
    {
	SW_RESULTS	results;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		results = (SW_RESULTS)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Results::DESTROY() -- results is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 381 "API.xs"
        if ( results )
    	{
            SV *parent = (SV *)SwishResults_parent( results );
            Free_Results_Object( results );
            SvREFCNT_dec( parent );
        } 
#line 748 "API.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_SWISH__API__Results_Hits); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Results_Hits)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::Results::Hits(self)");
    {
	SW_RESULTS	self;
	int	RETVAL;
	dXSTARG;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		self = (SW_RESULTS)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Results::SwishHits() -- self is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	RETVAL = SwishHits(self);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_SWISH__API__Results_SeekResult); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Results_SeekResult)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::Results::SeekResult(self, position)");
    {
	SW_RESULTS	self;
	int	position = (int)SvIV(ST(1));
	int	RETVAL;
	dXSTARG;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		self = (SW_RESULTS)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Results::SwishSeekResult() -- self is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	RETVAL = SwishSeekResult(self, position);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

XS(XS_SWISH__API__Results_NextResult); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Results_NextResult)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::Results::NextResult(results)");
    {
	SW_RESULTS	results;
#line 407 "API.xs"
        char * CLASS = "SWISH::API::Result";

#line 813 "API.c"
	SW_RESULT	RETVAL;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		results = (SW_RESULTS)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Results::SwishNextResult() -- results is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 410 "API.xs"
        RETVAL = SwishNextResult(results);
        if ( RETVAL )
            SvREFCNT_inc( (SV *)SwishResult_parent( RETVAL ));
#line 826 "API.c"
	ST(0) = sv_newmortal();
	sv_setref_pv( ST(0), CLASS, (void*)RETVAL );

    }
    XSRETURN(1);
}

XS(XS_SWISH__API__Results_RemovedStopwords); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Results_RemovedStopwords)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::Results::RemovedStopwords(results, index_name)");
    SP -= items;
    {
	SW_RESULTS	results;
	char *	index_name = (char *)SvPV_nolen(ST(1));
#line 424 "API.xs"
        SW_HANDLE swish_handle;
        SWISH_HEADER_TYPE  header_type;
        SWISH_HEADER_VALUE head_value;
        int i;

#line 850 "API.c"

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		results = (SW_RESULTS)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Results::SwishRemovedStopwords() -- results is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 430 "API.xs"
        swish_handle = SW_ResultsToSW_HANDLE( results );
        header_type = SWISH_LIST;
        head_value = SwishRemovedStopwords( results, index_name );

        PUSHMARK(SP);
        XPUSHs((SV *)swish_handle);
        XPUSHs((SV *)&head_value);
        XPUSHs((SV *)&header_type);
        PUTBACK;
        i = call_pv( "SWISH::API::decode_header_value", G_ARRAY );
        SPAGAIN;
#line 870 "API.c"
	PUTBACK;
	return;
    }
}

XS(XS_SWISH__API__Results_ParsedWords); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Results_ParsedWords)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::Results::ParsedWords(results, index_name)");
    SP -= items;
    {
	SW_RESULTS	results;
	char *	index_name = (char *)SvPV_nolen(ST(1));
#line 451 "API.xs"
        SW_HANDLE swish_handle;
        SWISH_HEADER_TYPE  header_type;
        SWISH_HEADER_VALUE head_value;
        int i;

#line 892 "API.c"

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		results = (SW_RESULTS)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Results::SwishParsedWords() -- results is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 457 "API.xs"
        swish_handle = SW_ResultsToSW_HANDLE( results );
        header_type = SWISH_LIST;
        head_value = SwishParsedWords( results, index_name );

        PUSHMARK(SP);
        XPUSHs((SV *)swish_handle);
        XPUSHs((SV *)&head_value);
        XPUSHs((SV *)&header_type);
        PUTBACK;
        i = call_pv( "SWISH::API::decode_header_value", G_ARRAY );
        SPAGAIN;
#line 912 "API.c"
	PUTBACK;
	return;
    }
}

XS(XS_SWISH__API__Result_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Result_DESTROY)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: SWISH::API::Result::DESTROY(result)");
    {
	SW_RESULT	result;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		result = (SW_RESULT)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Result::DESTROY() -- result is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 490 "API.xs"
        if ( result )
        {
            SV *parent = (SV *)SwishResult_parent(result);
            SvREFCNT_dec( parent );
        }
#line 939 "API.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_SWISH__API__Result_Property); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Result_Property)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::Result::Property(result, property)");
    SP -= items;
    {
	SW_RESULT	result;
	char *	property = (char *)SvPV_nolen(ST(1));
#line 502 "API.xs"
         PropValue *pv;


#line 958 "API.c"

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		result = (SW_RESULT)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Result::SwishProperty() -- result is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 506 "API.xs"
        pv = getResultPropValue( result, property, 0 );
        if ( !pv )
            XSRETURN_UNDEF;


        switch (pv->datatype)
        {
            case PROP_INTEGER:
                PUSHs(sv_2mortal(newSViv(pv->value.v_int)));
                break;

            case PROP_ULONG:
                PUSHs(sv_2mortal(newSViv(pv->value.v_ulong)));
                break;

            case PROP_STRING:
                PUSHs(sv_2mortal(newSVpv(pv->value.v_str,0)));
                break;

            case PROP_DATE:
                PUSHs(sv_2mortal(newSViv(pv->value.v_date)));
                break;

            default:
                croak("Unknown property data type '%d' for property '%s'\n", pv->datatype, property);
        }

        freeResultPropValue(pv);
#line 995 "API.c"
	PUTBACK;
	return;
    }
}

XS(XS_SWISH__API__Result_ResultPropertyStr); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Result_ResultPropertyStr)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::Result::ResultPropertyStr(result, pname)");
    {
	SW_RESULT	result;
	char *	pname = (char *)SvPV_nolen(ST(1));
	char *	RETVAL;
	dXSTARG;

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		result = (SW_RESULT)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Result::SwishResultPropertyStr() -- result is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};

	RETVAL = SwishResultPropertyStr(result, pname);
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_SWISH__API__Result_ResultIndexValue); /* prototype to pass -Wmissing-prototypes */
XS(XS_SWISH__API__Result_ResultIndexValue)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: SWISH::API::Result::ResultIndexValue(self, header_name)");
    SP -= items;
    {
	SW_RESULT	self;
	char *	header_name = (char *)SvPV_nolen(ST(1));
#line 550 "API.xs"
        SW_HANDLE swish_handle;
        SWISH_HEADER_TYPE  header_type;
        SWISH_HEADER_VALUE head_value;
        int i;

#line 1042 "API.c"

	if( sv_isobject(ST(0)) && (SvTYPE(SvRV(ST(0))) == SVt_PVMG) )
		self = (SW_RESULT)SvIV((SV*)SvRV( ST(0) ));
	else{
		warn( "SWISH::API::Result::SwishResultIndexValue() -- self is not a blessed SV reference" );
		XSRETURN_UNDEF;
	};
#line 556 "API.xs"
        swish_handle = SW_ResultToSW_HANDLE( self );
        head_value = SwishResultIndexValue( self, header_name, &header_type );

        PUSHMARK(SP);
        XPUSHs((SV *)swish_handle);
        XPUSHs((SV *)&head_value);
        XPUSHs((SV *)&header_type);
        PUTBACK;
        i = call_pv( "SWISH::API::decode_header_value", G_ARRAY );
        SPAGAIN;
#line 1061 "API.c"
	PUTBACK;
	return;
    }
}

#ifdef __cplusplus
extern "C"
#endif
XS(boot_SWISH__API); /* prototype to pass -Wmissing-prototypes */
XS(boot_SWISH__API)
{
    dXSARGS;
    char* file = __FILE__;

    XS_VERSION_BOOTCHECK ;

        newXS("SWISH::API::new", XS_SWISH__API_new, file);
        newXS("SWISH::API::DESTROY", XS_SWISH__API_DESTROY, file);
        newXS("SWISH::API::IndexNames", XS_SWISH__API_IndexNames, file);
        newXS("SWISH::API::HeaderNames", XS_SWISH__API_HeaderNames, file);
        newXS("SWISH::API::HeaderValue", XS_SWISH__API_HeaderValue, file);
        newXS("SWISH::API::decode_header_value", XS_SWISH__API_decode_header_value, file);
        newXS("SWISH::API::AbortLastError", XS_SWISH__API_AbortLastError, file);
        newXS("SWISH::API::Error", XS_SWISH__API_Error, file);
        newXS("SWISH::API::ErrorString", XS_SWISH__API_ErrorString, file);
        newXS("SWISH::API::LastErrorMsg", XS_SWISH__API_LastErrorMsg, file);
        newXS("SWISH::API::CriticalError", XS_SWISH__API_CriticalError, file);
        newXS("SWISH::API::New_Search_Object", XS_SWISH__API_New_Search_Object, file);
        newXS("SWISH::API::Query", XS_SWISH__API_Query, file);
        newXS("SWISH::API::WordsByLetter", XS_SWISH__API_WordsByLetter, file);
        newXS("SWISH::API::StemWord", XS_SWISH__API_StemWord, file);
        newXS("SWISH::API::Search::DESTROY", XS_SWISH__API__Search_DESTROY, file);
        newXS("SWISH::API::Search::SetQuery", XS_SWISH__API__Search_SetQuery, file);
        newXS("SWISH::API::Search::SetStructure", XS_SWISH__API__Search_SetStructure, file);
        newXS("SWISH::API::Search::PhraseDelimiter", XS_SWISH__API__Search_PhraseDelimiter, file);
        newXS("SWISH::API::Search::SetSearchLimit", XS_SWISH__API__Search_SetSearchLimit, file);
        newXS("SWISH::API::Search::ResetSearchLimit", XS_SWISH__API__Search_ResetSearchLimit, file);
        newXS("SWISH::API::Search::SetSort", XS_SWISH__API__Search_SetSort, file);
        newXS("SWISH::API::Search::Execute", XS_SWISH__API__Search_Execute, file);
        newXS("SWISH::API::Results::DESTROY", XS_SWISH__API__Results_DESTROY, file);
        newXS("SWISH::API::Results::Hits", XS_SWISH__API__Results_Hits, file);
        newXS("SWISH::API::Results::SeekResult", XS_SWISH__API__Results_SeekResult, file);
        newXS("SWISH::API::Results::NextResult", XS_SWISH__API__Results_NextResult, file);
        newXS("SWISH::API::Results::RemovedStopwords", XS_SWISH__API__Results_RemovedStopwords, file);
        newXS("SWISH::API::Results::ParsedWords", XS_SWISH__API__Results_ParsedWords, file);
        newXS("SWISH::API::Result::DESTROY", XS_SWISH__API__Result_DESTROY, file);
        newXS("SWISH::API::Result::Property", XS_SWISH__API__Result_Property, file);
        newXS("SWISH::API::Result::ResultPropertyStr", XS_SWISH__API__Result_ResultPropertyStr, file);
        newXS("SWISH::API::Result::ResultIndexValue", XS_SWISH__API__Result_ResultIndexValue, file);
    XSRETURN_YES;
}

