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

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

#include "ppport.h"
#include "GenerateFunctions.h"

#define B_INPLACE 1
#define B_LFTOBR 2
#define B_SPTONBSP 4
#define B_LEAVEKNOWN 8

#define B_ESCAPEVAL 1
#define B_ADDNEWLINE 2
#define B_CLOSETAG 4

#line 27 "GenerateUtil.c"
XS(XS_HTML__GenerateUtil_escape_html); /* prototype to pass -Wmissing-prototypes */
XS(XS_HTML__GenerateUtil_escape_html)
{
    dXSARGS;
    if (items != 2)
	Perl_croak(aTHX_ "Usage: HTML::GenerateUtil::escape_html(str, mode)");
    {
	SV *	str = ST(0);
	int	mode = (int)SvIV(ST(1));
	SV *	RETVAL;
#line 24 "GenerateUtil.xs"
  int b_inplace, b_lftobr, b_sptonbsp, b_leaveknown;
  SV * newstr;

  /* Check it's a string */
  if (!SvOK(str)) {
    XSRETURN_UNDEF;
  }

  /* Get flags */
  b_inplace = mode & B_INPLACE;
  b_lftobr = mode & B_LFTOBR;
  b_sptonbsp = mode & B_SPTONBSP;
  b_leaveknown = mode & B_LEAVEKNOWN;
#line 52 "GenerateUtil.c"
#line 39 "GenerateUtil.xs"
  /* Call helper function */
  newstr = GF_escape_html(str, b_inplace, b_lftobr, b_sptonbsp, b_leaveknown);

  if (!newstr)
    XSRETURN_UNDEF;

  /* Increment reference count because RETVAL = does implicit sv_2mortal later */
  if (b_inplace)
    SvREFCNT_inc(newstr);

  RETVAL = newstr;
#line 65 "GenerateUtil.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}

XS(XS_HTML__GenerateUtil_generate_attributes); /* prototype to pass -Wmissing-prototypes */
XS(XS_HTML__GenerateUtil_generate_attributes)
{
    dXSARGS;
    if (items != 1)
	Perl_croak(aTHX_ "Usage: HTML::GenerateUtil::generate_attributes(attr)");
    {
	SV *	attr = ST(0);
	SV *	RETVAL;
#line 57 "GenerateUtil.xs"
  SV * attrstr;
  HV * attrhv;

  if (!SvOK(attr) || !SvROK(attr) || SvTYPE(SvRV(attr)) != SVt_PVHV) {
    XSRETURN_UNDEF;
  }

  attrhv = (HV *)SvRV(attr);
#line 90 "GenerateUtil.c"
#line 66 "GenerateUtil.xs"
  attrstr = GF_generate_attributes(attrhv);

  RETVAL = attrstr;
#line 95 "GenerateUtil.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}

XS(XS_HTML__GenerateUtil_generate_tag); /* prototype to pass -Wmissing-prototypes */
XS(XS_HTML__GenerateUtil_generate_tag)
{
    dXSARGS;
    if (items != 4)
	Perl_croak(aTHX_ "Usage: HTML::GenerateUtil::generate_tag(tag, attr, val, mode)");
    {
	SV *	tag = ST(0);
	SV *	attr = ST(1);
	SV *	val = ST(2);
	int	mode = (int)SvIV(ST(3));
	SV *	RETVAL;
#line 79 "GenerateUtil.xs"
  SV * tagstr;
  HV * attrhv = 0;
  int b_escapeval, b_addnewline, b_closetag;

  if (!SvOK(tag)) {
    XSRETURN_UNDEF;
  }
  if (SvOK(attr) && (!SvROK(attr) || (SvROK(attr) && SvTYPE(SvRV(attr)) != SVt_PVHV))) {
    XSRETURN_UNDEF;
  }
  if (!SvOK(val)) {
    val = 0;
  }

  attrhv = SvOK(attr) ? (HV *)SvRV(attr) : 0;

  /* Get flags */
  b_escapeval = mode & B_ESCAPEVAL;
  b_addnewline = mode & B_ADDNEWLINE;
  b_closetag = mode & B_CLOSETAG;
#line 135 "GenerateUtil.c"
#line 100 "GenerateUtil.xs"
  tagstr = GF_generate_tag(tag, attrhv, val, b_escapeval, b_addnewline, b_closetag);

  RETVAL = tagstr;
#line 140 "GenerateUtil.c"
	ST(0) = RETVAL;
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}

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

    XS_VERSION_BOOTCHECK ;

        newXS("HTML::GenerateUtil::escape_html", XS_HTML__GenerateUtil_escape_html, file);
        newXS("HTML::GenerateUtil::generate_attributes", XS_HTML__GenerateUtil_generate_attributes, file);
        newXS("HTML::GenerateUtil::generate_tag", XS_HTML__GenerateUtil_generate_tag, file);
    XSRETURN_YES;
}

