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

#line 1 "KVIrc.xs"
#line 11 "KVIrc.c"
XS(XS_KVIrc_echo); /* prototype to pass -Wmissing-prototypes */
XS(XS_KVIrc_echo)
{
    dXSARGS;
    if (items < 1 || items > 3)
	Perl_croak(aTHX_ "Usage: KVIrc::echo(text, colorset = 0, windowid = 0)");
    {
	char *	text = (char *)SvPV_nolen(ST(0));
	int	colorset;
	char *	windowid;

	if (items < 2)
	    colorset = 0;
	else {
	    colorset = (int)SvIV(ST(1));
	}

	if (items < 3)
	    windowid = 0;
	else {
	    windowid = (char *)SvPV_nolen(ST(2));
	}
#line 8 "KVIrc.xs"
		if(g_pCurrentKvsContext && text)
		{
			KviWindow * pWnd;
			if(windowid)
			{
				pWnd = g_pApp->findWindow(windowid);
				if(!pWnd)pWnd = g_pCurrentKvsContext->window();
			} else {
				pWnd = g_pCurrentKvsContext->window();
			}
			pWnd->outputNoFmt(colorset,TQString::fromUtf8(text));
		}
#line 47 "KVIrc.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_KVIrc_say); /* prototype to pass -Wmissing-prototypes */
XS(XS_KVIrc_say)
{
    dXSARGS;
    if (items < 1 || items > 2)
	Perl_croak(aTHX_ "Usage: KVIrc::say(text, windowid = 0)");
    {
	char *	text = (char *)SvPV_nolen(ST(0));
	char *	windowid;

	if (items < 2)
	    windowid = 0;
	else {
	    windowid = (char *)SvPV_nolen(ST(1));
	}
#line 25 "KVIrc.xs"
		if(g_pCurrentKvsContext && text)
		{
			KviWindow * pWnd;
			if(windowid)
			{
				pWnd = g_pApp->findWindow(windowid);
				if(!pWnd)pWnd = g_pCurrentKvsContext->window();
			} else {
				pWnd = g_pCurrentKvsContext->window();
			}
			TQString tmp = TQString::fromUtf8(text);
			KviUserInput::parse(tmp,pWnd);
		}
#line 81 "KVIrc.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_KVIrc_warning); /* prototype to pass -Wmissing-prototypes */
XS(XS_KVIrc_warning)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: KVIrc::warning(text)");
    {
	char *	text = (char *)SvPV_nolen(ST(0));
#line 42 "KVIrc.xs"
		if((!g_bExecuteQuiet) && g_pCurrentKvsContext)
			g_pCurrentKvsContext->warning(text);
#line 97 "KVIrc.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_KVIrc_internalWarning); /* prototype to pass -Wmissing-prototypes */
XS(XS_KVIrc_internalWarning)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: KVIrc::internalWarning(text)");
    {
	char *	text = (char *)SvPV_nolen(ST(0));
#line 48 "KVIrc.xs"
		if(!g_bExecuteQuiet)
			g_lWarningList.append(TQString(text));
#line 113 "KVIrc.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_KVIrc_getLocal); /* prototype to pass -Wmissing-prototypes */
XS(XS_KVIrc_getLocal)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: KVIrc::getLocal(varname)");
    {
	char *	varname = (char *)SvPV_nolen(ST(0));
	char *	RETVAL;
	dXSTARG;
#line 55 "KVIrc.xs"
		TQString tmp;
		KviStr hack;
		if(g_pCurrentKvsContext)
		{
			KviKvsVariant * pVar = g_pCurrentKvsContext->localVariables()->find(varname);
			if(pVar)
			{
				pVar->asString(tmp);
				hack = tmp;
				RETVAL = hack.ptr();
			} else RETVAL = "";
		}
#line 141 "KVIrc.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_KVIrc_setLocal); /* prototype to pass -Wmissing-prototypes */
XS(XS_KVIrc_setLocal)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: KVIrc::setLocal(varname, value)");
    {
	char *	varname = (char *)SvPV_nolen(ST(0));
	char *	value = (char *)SvPV_nolen(ST(1));
#line 74 "KVIrc.xs"
		if(g_pCurrentKvsContext)
		{
			if(value && *value)
			{
				KviKvsVariant * pVar = g_pCurrentKvsContext->localVariables()->get(varname);
				pVar->setString(value);
			} else {
				g_pCurrentKvsContext->localVariables()->unset(varname);
			}
		}
#line 167 "KVIrc.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_KVIrc_getGlobal); /* prototype to pass -Wmissing-prototypes */
XS(XS_KVIrc_getGlobal)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: KVIrc::getGlobal(varname)");
    {
	char *	varname = (char *)SvPV_nolen(ST(0));
	char *	RETVAL;
	dXSTARG;
#line 88 "KVIrc.xs"
		TQString tmp;
		KviStr hack;
		if(g_pCurrentKvsContext)
		{
			KviKvsVariant * pVar = g_pCurrentKvsContext->globalVariables()->find(varname);
			if(pVar)
			{
				pVar->asString(tmp);
				hack = tmp;
				RETVAL = hack.ptr();
			} else RETVAL = "";
		}
#line 195 "KVIrc.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

XS(XS_KVIrc_setGlobal); /* prototype to pass -Wmissing-prototypes */
XS(XS_KVIrc_setGlobal)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: KVIrc::setGlobal(varname, value)");
    {
	char *	varname = (char *)SvPV_nolen(ST(0));
	char *	value = (char *)SvPV_nolen(ST(1));
#line 107 "KVIrc.xs"
		if(g_pCurrentKvsContext)
		{
			if(value && *value)
			{
				KviKvsVariant * pVar = g_pCurrentKvsContext->globalVariables()->get(varname);
				pVar->setString(value);
			} else {
				g_pCurrentKvsContext->localVariables()->unset(varname);
			}
		}
#line 221 "KVIrc.c"
    }
    XSRETURN_EMPTY;
}

XS(XS_KVIrc_eval); /* prototype to pass -Wmissing-prototypes */
XS(XS_KVIrc_eval)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: KVIrc::eval(code)");
    {
	char *	code = (char *)SvPV_nolen(ST(0));
	char *	RETVAL;
	dXSTARG;
#line 122 "KVIrc.xs"
		if(g_pCurrentKvsContext && code)
		{
			KviKvsVariant ret;
			if(KviKvsScript::run(TQString::fromUtf8(code),g_pCurrentKvsContext->window(),0,&ret))
			{
				TQString tmp;
				ret.asString(tmp);
				g_szLastReturnValue = tmp;
			} else {
				g_szLastReturnValue = "";
			}
			RETVAL = g_szLastReturnValue.ptr();
		} else {
			RETVAL = "";
		}
#line 252 "KVIrc.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}

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

        newXS("KVIrc::echo", XS_KVIrc_echo, file);
        newXS("KVIrc::say", XS_KVIrc_say, file);
        newXS("KVIrc::warning", XS_KVIrc_warning, file);
        newXS("KVIrc::internalWarning", XS_KVIrc_internalWarning, file);
        newXS("KVIrc::getLocal", XS_KVIrc_getLocal, file);
        newXS("KVIrc::setLocal", XS_KVIrc_setLocal, file);
        newXS("KVIrc::getGlobal", XS_KVIrc_getGlobal, file);
        newXS("KVIrc::setGlobal", XS_KVIrc_setGlobal, file);
        newXS("KVIrc::eval", XS_KVIrc_eval, file);
    XSRETURN_YES;
}

