text:
#include "IltStringBroadcastFilter.h"

#include <string>

#include "joynr/serializer/Serializer.h"
#include "IltUtil.h"

INIT_LOGGER(IltStringBroadcastFilter);

IltStringBroadcastFilter::IltStringBroadcastFilter()
{
}

bool IltStringBroadcastFilter::filter(
        const std::string& stringOut,
        const std::vector<std::string>& stringArrayOut,
        const joynr::interlanguagetest::namedTypeCollection2::
                ExtendedTypeCollectionEnumerationInTypeCollection::Enum& enumerationOut,
        const joynr::interlanguagetest::namedTypeCollection1::StructWithStringArray&
                structWithStringArrayOut,
        const std::vector<joynr::interlanguagetest::namedTypeCollection1::StructWithStringArray>&
                structWithStringArrayArrayOut,
        const interlanguagetest::TestInterfaceBroadcastWithFilteringBroadcastFilterParameters&
                filterParameters)
{
    JOYNR_LOG_WARN(logger, "****************************************");
    JOYNR_LOG_WARN(logger, "* IltStringBroadcastFilter::filter called");
    JOYNR_LOG_WARN(logger, "****************************************");

    // check output parameter contents
    bool checkResult = true;

    if (!IltUtil::checkStringArray(stringArrayOut)) {
        JOYNR_LOG_WARN(
                logger, "IltStringBroadcastFilter::filter: stringArrayOut has invalid value");
        JOYNR_LOG_WARN(logger, "array size is {}", stringArrayOut.size());
        checkResult = false;
    }
    if (enumerationOut != joynr::interlanguagetest::namedTypeCollection2::
                                  ExtendedTypeCollectionEnumerationInTypeCollection::
                                          ENUM_2_VALUE_EXTENSION_FOR_TYPECOLLECTION) {
        JOYNR_LOG_WARN(
                logger, "IltStringBroadcastFilter::filter: enumerationOut has invalid value");
        checkResult = false;
    }
    if (!IltUtil::checkStructWithStringArray(structWithStringArrayOut)) {
        JOYNR_LOG_WARN(
                logger,
                "IltStringBroadcastFilter::filter: structWithStringArrayOut has invalid value");
        checkResult = false;
    }

    if (!IltUtil::checkStructWithStringArrayArray(structWithStringArrayArrayOut)) {
        JOYNR_LOG_WARN(logger,
                       "IltStringBroadcastFilter::filter: structWithStringArrayArrayOut "
                       "has invalid value");
        checkResult = false;
    }

    if (checkResult == false) {
        JOYNR_LOG_WARN(logger, "IltStringBroadcastFilter::filter: check of out args failed");
        return false;
    }

    // check filter parameter contents

    // variables to store deserialized values
    std::string stringOfInterest = filterParameters.getStringOfInterest();
    JOYNR_LOG_WARN(
            logger, "IltStringBroadcastFilter::filter: stringOfInterest = {}", stringOfInterest);
    JOYNR_LOG_WARN(logger, "IltStringBroadcastFilter::filter: stringOut = {}", stringOut);

    std::vector<std::string> stringArrayOfInterest;
    joynr::serializer::deserializeFromJson(
            stringArrayOfInterest, filterParameters.getStringArrayOfInterest());

    std::string enumerationOfInterestJson = filterParameters.getEnumerationOfInterest();
    std::string enumerationOfInterestLiteral =
            enumerationOfInterestJson.substr(1, enumerationOfInterestJson.size() - 2);
    joynr::interlanguagetest::namedTypeCollection2::
            ExtendedTypeCollectionEnumerationInTypeCollection::Enum enumerationOfInterest =
                    joynr::interlanguagetest::namedTypeCollection2::
                            ExtendedTypeCollectionEnumerationInTypeCollection::getEnum(
                                    enumerationOfInterestLiteral);

    try {
        using joynr::interlanguagetest::namedTypeCollection1::StructWithStringArray;

        StructWithStringArray structWithStringArrayOfInterest;
        joynr::serializer::deserializeFromJson(
                structWithStringArrayOfInterest,
                filterParameters.getStructWithStringArrayOfInterest());

        std::vector<joynr::interlanguagetest::namedTypeCollection1::StructWithStringArray>
                structWithStringArrayArrayOfInterest;
        joynr::serializer::deserializeFromJson(
                structWithStringArrayArrayOfInterest,
                filterParameters.getStructWithStringArrayArrayOfInterest());

        if (!IltUtil::checkStringArray(stringArrayOfInterest)) {
            return false;
        }
        if (enumerationOfInterest != joynr::interlanguagetest::namedTypeCollection2::
                                             ExtendedTypeCollectionEnumerationInTypeCollection::
                                                     ENUM_2_VALUE_EXTENSION_FOR_TYPECOLLECTION) {
            return false;
        }
        if (!IltUtil::checkStructWithStringArray(structWithStringArrayOfInterest)) {
            return false;
        }
        if (!IltUtil::checkStructWithStringArrayArray(structWithStringArrayArrayOfInterest)) {
            return false;
        }

    } catch (const std::invalid_argument& e) {
        JOYNR_LOG_ERROR(logger,
                        "could not deserialize StructWithStringArray from {} - error: {}",
                        filterParameters.getStructWithStringArrayOfInterest(),
                        e.what());
        return false;
    }

    // decision for publication is made base on stringOfInterest
    if (stringOut == stringOfInterest) {
        JOYNR_LOG_WARN(logger, "IltStringBroadcastFilter::filter: returns true");
        return true;
    } else {
        JOYNR_LOG_WARN(logger, "IltStringBroadcastFilter::filter: returns false");
        return false;
    }
}


text:
class Opendata::Agents::Nodes::Dataset::UrlResourceController < ApplicationController
  include Cms::NodeFilter::View
  include Opendata::UrlHelper
  include SS::AuthFilter

  before_action :accept_cors_request
  before_action :set_dataset
  before_action :deny

  private

  def set_dataset
    @dataset_path = @cur_main_path.sub(/\/url_resource\/.*/, ".html")

    @dataset = Opendata::Dataset.site(@cur_site).filename(@dataset_path).first
    raise "404" unless @dataset
  end

  def deny
    return if @dataset.public?

    user = get_user_by_session
    raise "404" unless user

    set_last_logged_in
  end

  def set_last_modified
    response.headers["Last-Modified"] = CGI::rfc1123_date(@dataset.updated.in_time_zone)
  end

  public

  def index
    redirect_to @dataset_path
  end

  def download
    @item = @dataset.url_resources.find_by id: params[:id]
    @item.dataset.inc downloaded: 1

    @cur_node.layout_id = nil
    send_file @item.file.path, type: @item.content_type, filename: @item.filename,
      disposition: :attachment, x_sendfile: true
  end

  def content
    @cur_node.layout_id = nil
    @item = @dataset.url_resources.find_by id: params[:id]
    raise "404" unless @item.tsv_present?

    @data = @item.parse_tsv
    head :ok unless @data
  end
end

redpajama_set_name: RedPajamaGithub


text:
namespace clang {
  class LangOptions;
  class Rewriter;
  class SourceManager;
  class Stmt;

/// RewriteBuffer - As code is rewritten, SourceBuffer's from the original
/// input with modifications get a new RewriteBuffer associated with them.  The
/// RewriteBuffer captures the modified text itself as well as information used
/// to map between SourceLocation's in the original input and offsets in the
/// RewriteBuffer.  For example, if text is inserted into the buffer, any
/// locations after the insertion point have to be mapped.
class RewriteBuffer {
  friend class Rewriter;
  /// Deltas - Keep track of all the deltas in the source code due to insertions
  /// and deletions.
  DeltaTree Deltas;
  RewriteRope Buffer;
public:
  typedef RewriteRope::const_iterator iterator;
  iterator begin() const { return Buffer.begin(); }
  iterator end() const { return Buffer.end(); }
  unsigned size() const { return Buffer.size(); }

  /// \brief Write to \p Stream the result of applying all changes to the
  /// original buffer.
  /// Note that it isn't safe to use this function to overwrite memory mapped
  /// files in-place (PR17960). Consider using a higher-level utility such as
  /// Rewriter::overwriteChangedFiles() instead.
  ///
  /// The original buffer is not actually changed.
  raw_ostream &write(raw_ostream &Stream) const;

  /// RemoveText - Remove the specified text.
  void RemoveText(unsigned OrigOffset, unsigned Size,
                  bool removeLineIfEmpty = false);

  /// InsertText - Insert some text at the specified point, where the offset in
  /// the buffer is specified relative to the original SourceBuffer.  The
  /// text is inserted after the specified location.
  ///
  void InsertText(unsigned OrigOffset, StringRef Str,
                  bool InsertAfter = true);

  /// InsertTextBefore - Insert some text before the specified point, where the
  /// offset in the buffer is specified relative to the original
  /// SourceBuffer. The text is inserted before the specified location.  This is
  /// method is the same as InsertText with "InsertAfter == false".
  void InsertTextBefore(unsigned OrigOffset, StringRef Str) {
    InsertText(OrigOffset, Str, false);
  }

  /// InsertTextAfter - Insert some text at the specified point, where the
  /// offset in the buffer is specified relative to the original SourceBuffer.
  /// The text is inserted after the specified location.
  void InsertTextAfter(unsigned OrigOffset, StringRef Str) {
    InsertText(OrigOffset, Str);
  }

  /// ReplaceText - This method replaces a range of characters in the input
  /// buffer with a new string.  This is effectively a combined "remove/insert"
  /// operation.
  void ReplaceText(unsigned OrigOffset, unsigned OrigLength,
                   StringRef NewStr);

private:  // Methods only usable by Rewriter.

  /// Initialize - Start this rewrite buffer out with a copy of the unmodified
  /// input buffer.
  void Initialize(const char *BufStart, const char *BufEnd) {
    Buffer.assign(BufStart, BufEnd);
  }

  /// getMappedOffset - Given an offset into the original SourceBuffer that this
  /// RewriteBuffer is based on, map it into the offset space of the
  /// RewriteBuffer.  If AfterInserts is true and if the OrigOffset indicates a
  /// position where text is inserted, the location returned will be after any
  /// inserted text at the position.
  unsigned getMappedOffset(unsigned OrigOffset,
                           bool AfterInserts = false) const{
    return Deltas.getDeltaAt(2*OrigOffset+AfterInserts)+OrigOffset;
  }

  /// AddInsertDelta - When an insertion is made at a position, this
  /// method is used to record that information.
  void AddInsertDelta(unsigned OrigOffset, int Change) {
    return Deltas.AddDelta(2*OrigOffset, Change);
  }

  /// AddReplaceDelta - When a replacement/deletion is made at a position, this
  /// method is used to record that information.
  void AddReplaceDelta(unsigned OrigOffset, int Change) {
    return Deltas.AddDelta(2*OrigOffset+1, Change);
  }
};

/// Rewriter - This is the main interface to the rewrite buffers.  Its primary
/// job is to dispatch high-level requests to the low-level RewriteBuffers that
/// are involved.
class Rewriter {
  SourceManager *SourceMgr;
  const LangOptions *LangOpts;
  std::map<FileID, RewriteBuffer> RewriteBuffers;
public:
  struct RewriteOptions {
    /// \brief Given a source range, true to include previous inserts at the
    /// beginning of the range as part of the range itself (true by default).
    bool IncludeInsertsAtBeginOfRange;
    /// \brief Given a source range, true to include previous inserts at the
    /// end of the range as part of the range itself (true by default).
    bool IncludeInsertsAtEndOfRange;
    /// \brief If true and removing some text leaves a blank line
    /// also remove the empty line (false by default).
    bool RemoveLineIfEmpty;

    RewriteOptions()
      : IncludeInsertsAtBeginOfRange(true),
        IncludeInsertsAtEndOfRange(true),
        RemoveLineIfEmpty(false) { }
  };

  typedef std::map<FileID, RewriteBuffer>::iterator buffer_iterator;
  typedef std::map<FileID, RewriteBuffer>::const_iterator const_buffer_iterator;

  explicit Rewriter(SourceManager &SM, const LangOptions &LO)
    : SourceMgr(&SM), LangOpts(&LO) {}
  explicit Rewriter() : SourceMgr(nullptr), LangOpts(nullptr) {}

  void setSourceMgr(SourceManager &SM, const LangOptions &LO) {
    SourceMgr = &SM;
    LangOpts = &LO;
  }
  SourceManager &getSourceMgr() const { return *SourceMgr; }
  const LangOptions &getLangOpts() const { return *LangOpts; }

  /// isRewritable - Return true if this location is a raw file location, which
  /// is rewritable.  Locations from macros, etc are not rewritable.
  static bool isRewritable(SourceLocation Loc) {
    return Loc.isFileID();
  }

  /// getRangeSize - Return the size in bytes of the specified range if they
  /// are in the same file.  If not, this returns -1.
  int getRangeSize(SourceRange Range,
                   RewriteOptions opts = RewriteOptions()) const;
  int getRangeSize(const CharSourceRange &Range,
                   RewriteOptions opts = RewriteOptions()) const;

  /// getRewrittenText - Return the rewritten form of the text in the specified
  /// range.  If the start or end of the range was unrewritable or if they are
  /// in different buffers, this returns an empty string.
  ///
  /// Note that this method is not particularly efficient.
  ///
  std::string getRewrittenText(SourceRange Range) const;

  /// InsertText - Insert the specified string at the specified location in the
  /// original buffer.  This method returns true (and does nothing) if the input
  /// location was not rewritable, false otherwise.
  ///
  /// \param indentNewLines if true new lines in the string are indented
  /// using the indentation of the source line in position \p Loc.
  bool InsertText(SourceLocation Loc, StringRef Str,
                  bool InsertAfter = true, bool indentNewLines = false);

  /// InsertTextAfter - Insert the specified string at the specified location in
  ///  the original buffer.  This method returns true (and does nothing) if
  ///  the input location was not rewritable, false otherwise.  Text is
  ///  inserted after any other text that has been previously inserted
  ///  at the some point (the default behavior for InsertText).
  bool InsertTextAfter(SourceLocation Loc, StringRef Str) {
    return InsertText(Loc, Str);
  }

  /// \brief Insert the specified string after the token in the
  /// specified location.
  bool InsertTextAfterToken(SourceLocation Loc, StringRef Str);

  /// InsertText - Insert the specified string at the specified location in the
  /// original buffer.  This method returns true (and does nothing) if the input
  /// location was not rewritable, false otherwise.  Text is
  /// inserted before any other text that has been previously inserted
  /// at the some point.
  bool InsertTextBefore(SourceLocation Loc, StringRef Str) {
    return InsertText(Loc, Str, false);
  }

  /// RemoveText - Remove the specified text region.
  bool RemoveText(SourceLocation Start, unsigned Length,
                  RewriteOptions opts = RewriteOptions());

  /// \brief Remove the specified text region.
  bool RemoveText(CharSourceRange range,
                  RewriteOptions opts = RewriteOptions()) {
    return RemoveText(range.getBegin(), getRangeSize(range, opts), opts);
  }

  /// \brief Remove the specified text region.
  bool RemoveText(SourceRange range, RewriteOptions opts = RewriteOptions()) {
    return RemoveText(range.getBegin(), getRangeSize(range, opts), opts);
  }

  /// ReplaceText - This method replaces a range of characters in the input
  /// buffer with a new string.  This is effectively a combined "remove/insert"
  /// operation.
  bool ReplaceText(SourceLocation Start, unsigned OrigLength,
                   StringRef NewStr);

  /// ReplaceText - This method replaces a range of characters in the input
  /// buffer with a new string.  This is effectively a combined "remove/insert"
  /// operation.
  bool ReplaceText(SourceRange range, StringRef NewStr) {
    return ReplaceText(range.getBegin(), getRangeSize(range), NewStr);
  }

  /// ReplaceText - This method replaces a range of characters in the input
  /// buffer with a new string.  This is effectively a combined "remove/insert"
  /// operation.
  bool ReplaceText(SourceRange range, SourceRange replacementRange);

  /// ReplaceStmt - This replaces a Stmt/Expr with another, using the pretty
  /// printer to generate the replacement code.  This returns true if the input
  /// could not be rewritten, or false if successful.
  bool ReplaceStmt(Stmt *From, Stmt *To);

  /// \brief Increase indentation for the lines between the given source range.
  /// To determine what the indentation should be, 'parentIndent' is used
  /// that should be at a source location with an indentation one degree
  /// lower than the given range.
  bool IncreaseIndentation(CharSourceRange range, SourceLocation parentIndent);
  bool IncreaseIndentation(SourceRange range, SourceLocation parentIndent) {
    return IncreaseIndentation(CharSourceRange::getTokenRange(range),
                               parentIndent);
  }

  /// ConvertToString converts statement 'From' to a string using the
  /// pretty printer.
  std::string ConvertToString(Stmt *From);

  /// getEditBuffer - This is like getRewriteBufferFor, but always returns a
  /// buffer, and allows you to write on it directly.  This is useful if you
  /// want efficient low-level access to apis for scribbling on one specific
  /// FileID's buffer.
  RewriteBuffer &getEditBuffer(FileID FID);

  /// getRewriteBufferFor - Return the rewrite buffer for the specified FileID.
  /// If no modification has been made to it, return null.
  const RewriteBuffer *getRewriteBufferFor(FileID FID) const {
    std::map<FileID, RewriteBuffer>::const_iterator I =
      RewriteBuffers.find(FID);
    return I == RewriteBuffers.end() ? nullptr : &I->second;
  }

  // Iterators over rewrite buffers.
  buffer_iterator buffer_begin() { return RewriteBuffers.begin(); }
  buffer_iterator buffer_end() { return RewriteBuffers.end(); }
  const_buffer_iterator buffer_begin() const { return RewriteBuffers.begin(); }
  const_buffer_iterator buffer_end() const { return RewriteBuffers.end(); }

  /// overwriteChangedFiles - Save all changed files to disk.
  ///
  /// Returns true if any files were not saved successfully.
  /// Outputs diagnostics via the source manager's diagnostic engine
  /// in case of an error.
  bool overwriteChangedFiles();

private:
  unsigned getLocationOffsetAndFileID(SourceLocation Loc, FileID &FID) const;
};

} // end namespace clang

#endif


text:
<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>sing后台管理平台</title>

    <link href="/Public/css/bootstrap.min.css" rel="stylesheet">

    <link href="/Public/css/sb-admin.css" rel="stylesheet">

    <link href="/Public/css/plugins/morris.css" rel="stylesheet">

    <link href="/Public/css/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="/Public/css/sing/common.css" />
    <link rel="stylesheet" href="/Public/css/party/bootstrap-switch.css" />
    <link rel="stylesheet" type="text/css" href="/Public/css/party/uploadify.css">

    <?php
 $navs = D("Menu")->getAdminMenus(); $username = getLoginUsername(); foreach($navs as $k=>$v) { if($v['c'] == 'admin' && $username != 'admin') { unset($navs[$k]); } } $index = 'index'; ?>

    singcms内容管理平台

       <?php echo getLoginUsername()?>

           个人中心

           退出

      <li <?php echo (getActive($index)); ?>>
         首页

      <?php if(is_array($navs)): $i = 0; $__LIST__ = $navs;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$navo): $mod = ($i % 2 );++$i;?><li <?php echo (getActive($navo["c"])); ?>>
        <a href="<?php echo (getAdminMenuUrl($navo)); ?>"> <?php echo ($navo["name"]); ?>

<?php endforeach; endif; else: echo "" ;endif; ?>

                        推荐位内容管理

            <button  id="button-add" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">添加 </button>

            <form action="/admin.php" method="get">

                        推荐位
                        <select class="form-control" name="position_id">
                            <?php if(is_array($positions)): foreach($positions as $key=>$position): ?><option value="<?php echo ($position["id"]); ?>"<?php if($position['id'] == $positionId): ?>selected="selected"<?php endif; ?> ><?php echo ($position["name"]); ?></option><?php endforeach; endif; ?>
                        </select>

                <input type="hidden" name="c" value="positioncontent"/>
                <input type="hidden" name="a" value="index"/>

                        <input class="form-control" name="title" type="text" value="<?php echo ($title); ?>" placeholder="文章标题" />

                  <button id="sub_data" type="submit" class="btn btn-primary"></button>

            </form>

                    <form id="singcms-listorder">

                            排序
                            id
                            标题
                            时间
                            封面图
                            状态
                            操作

                            <?php if(is_array($contents)): $i = 0; $__LIST__ = $contents;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>

                                <input size=4 type='text'  name='listorder[<?php echo ($vo["id"]); ?>]' value="<?php echo ($vo["listorder"]); ?>"/>
                                <?php echo ($vo["id"]); ?>
                                <?php echo ($vo["title"]); ?>
                                <?php echo (date("y-m-d H:i",$vo["create_time"])); ?>
                                <?php echo (isThumb($vo["thumb"])); ?>

                                    <span  attr-status="<?php if($vo['status'] == 1): ?>0<?php else: ?>1<?php endif; ?>"  attr-id="<?php echo ($vo["id"]); ?>" class="sing_cursor singcms-on-off" id="singcms-on-off" ><?php echo (status($vo["status"])); ?>

                                    <span class="sing_cursor glyphicon glyphicon-edit" aria-hidden="true" id="singcms-edit" attr-id="<?php echo ($vo["id"]); ?>" >
                                    <a href="javascript:void(0)" id="singcms-delete"  attr-id="<?php echo ($vo["id"]); ?>"  attr-message="删除">

<?php endforeach; endif; else: echo "" ;endif; ?>

                    </from>

                        <button  id="button-listorder" type="button" class="btn btn-primary dropdown-toggle" >更新排序</button>


text: Titanium App for TheMovieDatabase


text:
#define IN_LIBXML
#include "libxml.h"

#include <string.h>
#include <stdarg.h>
#include <libxml/parser.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlmemory.h>
#include <libxml/globals.h>

void XMLCDECL xmlGenericErrorDefaultFunc	(void *ctx ATTRIBUTE_UNUSED,
				 const char *msg,
				 ...) LIBXML_ATTR_FORMAT(2,3);

#define XML_GET_VAR_STR(msg, str) {				\
    int       size, prev_size = -1;				\
    int       chars;						\
    char      *larger;						\
    va_list   ap;						\
								\
    str = (char *) xmlMalloc(150);				\
    if (str != NULL) {						\
								\
    size = 150;							\
								\
    while (size < 64000) {					\
	va_start(ap, msg);					\
	chars = vsnprintf(str, size, msg, ap);			\
	va_end(ap);						\
	if ((chars > -1) && (chars < size)) {			\
	    if (prev_size == chars) {				\
		break;						\
	    } else {						\
		prev_size = chars;				\
	    }							\
	}							\
	if (chars > -1)						\
	    size += chars + 1;					\
	else							\
	    size += 100;					\
	if ((larger = (char *) xmlRealloc(str, size)) == NULL) {\
	    break;						\
	}							\
	str = larger;						\
    }}								\
}

/************************************************************************
 *									*
 *			Handling of out of context errors		*
 *									*
 ************************************************************************/

/**
 * xmlGenericErrorDefaultFunc:
 * @ctx:  an error context
 * @msg:  the message to display/transmit
 * @...:  extra parameters for the message display
 *
 * Default handler for out of context error messages.
 */
void XMLCDECL
xmlGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
    va_list args;

    if (xmlGenericErrorContext == NULL)
	xmlGenericErrorContext = (void *) stderr;

    va_start(args, msg);
    vfprintf((FILE *)xmlGenericErrorContext, msg, args);
    va_end(args);
}

/**
 * initGenericErrorDefaultFunc:
 * @handler:  the handler
 *
 * Set or reset (if NULL) the default handler for generic errors
 * to the builtin error function.
 */
void
initGenericErrorDefaultFunc(xmlGenericErrorFunc * handler)
{
    if (handler == NULL)
        xmlGenericError = xmlGenericErrorDefaultFunc;
    else
        xmlGenericError = (*handler);
}

/**
 * xmlSetGenericErrorFunc:
 * @ctx:  the new error handling context
 * @handler:  the new handler function
 *
 * Function to reset the handler and the error context for out of
 * context error messages.
 * This simply means that @handler will be called for subsequent
 * error messages while not parsing nor validating. And @ctx will
 * be passed as first argument to @handler
 * One can simply force messages to be emitted to another FILE * than
 * stderr by setting @ctx to this file handle and @handler to NULL.
 * For multi-threaded applications, this must be set separately for each thread.
 */
void
xmlSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
    xmlGenericErrorContext = ctx;
    if (handler != NULL)
	xmlGenericError = handler;
    else
	xmlGenericError = xmlGenericErrorDefaultFunc;
}

/**
 * xmlSetStructuredErrorFunc:
 * @ctx:  the new error handling context
 * @handler:  the new handler function
 *
 * Function to reset the handler and the error context for out of
 * context structured error messages.
 * This simply means that @handler will be called for subsequent
 * error messages while not parsing nor validating. And @ctx will
 * be passed as first argument to @handler
 * For multi-threaded applications, this must be set separately for each thread.
 */
void
xmlSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
    xmlStructuredErrorContext = ctx;
    xmlStructuredError = handler;
}

/************************************************************************
 *									*
 *			Handling of parsing errors			*
 *									*
 ************************************************************************/

/**
 * xmlParserPrintFileInfo:
 * @input:  an xmlParserInputPtr input
 *
 * Displays the associated file and line informations for the current input
 */

void
xmlParserPrintFileInfo(xmlParserInputPtr input) {
    if (input != NULL) {
	if (input->filename)
	    xmlGenericError(xmlGenericErrorContext,
		    "%s:%d: ", input->filename,
		    input->line);
	else
	    xmlGenericError(xmlGenericErrorContext,
		    "Entity: line %d: ", input->line);
    }
}

/**
 * xmlParserPrintFileContext:
 * @input:  an xmlParserInputPtr input
 *
 * Displays current context within the input content for error tracking
 */

static void
xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
		xmlGenericErrorFunc channel, void *data ) {
    const xmlChar *cur, *base;
    unsigned int n, col;	/* GCC warns if signed, because compared with sizeof() */
    xmlChar  content[81]; /* space for 80 chars + line terminator */
    xmlChar *ctnt;

    if ((input == NULL) || (input->cur == NULL))
        return;

    cur = input->cur;
    base = input->base;
    /* skip backwards over any end-of-lines */
    while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) {
	cur--;
    }
    n = 0;
    /* search backwards for beginning-of-line (to max buff size) */
    while ((n++ < (sizeof(content)-1)) && (cur > base) &&
	   (*(cur) != '\n') && (*(cur) != '\r'))
        cur--;
    if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
    /* calculate the error position in terms of the current position */
    col = input->cur - cur;
    /* search forward for end-of-line (to max buff size) */
    n = 0;
    ctnt = content;
    /* copy selected text to our buffer */
    while ((*cur != 0) && (*(cur) != '\n') &&
	   (*(cur) != '\r') && (n < sizeof(content)-1)) {
		*ctnt++ = *cur++;
	n++;
    }
    *ctnt = 0;
    /* print out the selected text */
    channel(data ,"%s\n", content);
    /* create blank line with problem pointer */
    n = 0;
    ctnt = content;
    /* (leave buffer space for pointer + line terminator) */
    while ((n<col) && (n++ < sizeof(content)-2) && (*ctnt != 0)) {
	if (*(ctnt) != '\t')
	    *(ctnt) = ' ';
	ctnt++;
    }
    *ctnt++ = '^';
    *ctnt = 0;
    channel(data ,"%s\n", content);
}

/**
 * xmlParserPrintFileContext:
 * @input:  an xmlParserInputPtr input
 *
 * Displays current context within the input content for error tracking
 */
void
xmlParserPrintFileContext(xmlParserInputPtr input) {
   xmlParserPrintFileContextInternal(input, xmlGenericError,
                                     xmlGenericErrorContext);
}

/**
 * xmlReportError:
 * @err: the error
 * @ctx: the parser context or NULL
 * @str: the formatted error message
 *
 * Report an erro with its context, replace the 4 old error/warning
 * routines.
 */
static void
xmlReportError(xmlErrorPtr err, xmlParserCtxtPtr ctxt, const char *str,
               xmlGenericErrorFunc channel, void *data)
{
    char *file = NULL;
    int line = 0;
    int code = -1;
    int domain;
    const xmlChar *name = NULL;
    xmlNodePtr node;
    xmlErrorLevel level;
    xmlParserInputPtr input = NULL;
    xmlParserInputPtr cur = NULL;

    if (err == NULL)
        return;

    if (channel == NULL) {
	channel = xmlGenericError;
	data = xmlGenericErrorContext;
    }
    file = err->file;
    line = err->line;
    code = err->code;
    domain = err->domain;
    level = err->level;
    node = err->node;

    if (code == XML_ERR_OK)
        return;

    if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
        name = node->name;

    /*
     * Maintain the compatibility with the legacy error handling
     */
    if (ctxt != NULL) {
        input = ctxt->input;
        if ((input != NULL) && (input->filename == NULL) &&
            (ctxt->inputNr > 1)) {
            cur = input;
            input = ctxt->inputTab[ctxt->inputNr - 2];
        }
        if (input != NULL) {
            if (input->filename)
                channel(data, "%s:%d: ", input->filename, input->line);
            else if ((line != 0) && (domain == XML_FROM_PARSER))
                channel(data, "Entity: line %d: ", input->line);
        }
    } else {
        if (file != NULL)
            channel(data, "%s:%d: ", file, line);
        else if ((line != 0) &&
	         ((domain == XML_FROM_PARSER) || (domain == XML_FROM_SCHEMASV)||
		  (domain == XML_FROM_SCHEMASP)||(domain == XML_FROM_DTD) ||
		  (domain == XML_FROM_RELAXNGP)||(domain == XML_FROM_RELAXNGV)))
            channel(data, "Entity: line %d: ", line);
    }
    if (name != NULL) {
        channel(data, "element %s: ", name);
    }
    switch (domain) {
        case XML_FROM_PARSER:
            channel(data, "parser ");
            break;
        case XML_FROM_NAMESPACE:
            channel(data, "namespace ");
            break;
        case XML_FROM_DTD:
        case XML_FROM_VALID:
            channel(data, "validity ");
            break;
        case XML_FROM_HTML:
            channel(data, "HTML parser ");
            break;
        case XML_FROM_MEMORY:
            channel(data, "memory ");
            break;
        case XML_FROM_OUTPUT:
            channel(data, "output ");
            break;
        case XML_FROM_IO:
            channel(data, "I/O ");
            break;
        case XML_FROM_XINCLUDE:
            channel(data, "XInclude ");
            break;
        case XML_FROM_XPATH:
            channel(data, "XPath ");
            break;
        case XML_FROM_XPOINTER:
            channel(data, "parser ");
            break;
        case XML_FROM_REGEXP:
            channel(data, "regexp ");
            break;
        case XML_FROM_MODULE:
            channel(data, "module ");
            break;
        case XML_FROM_SCHEMASV:
            channel(data, "Schemas validity ");
            break;
        case XML_FROM_SCHEMASP:
            channel(data, "Schemas parser ");
            break;
        case XML_FROM_RELAXNGP:
            channel(data, "Relax-NG parser ");
            break;
        case XML_FROM_RELAXNGV:
            channel(data, "Relax-NG validity ");
            break;
        case XML_FROM_CATALOG:
            channel(data, "Catalog ");
            break;
        case XML_FROM_C14N:
            channel(data, "C14N ");
            break;
        case XML_FROM_XSLT:
            channel(data, "XSLT ");
            break;
        case XML_FROM_I18N:
            channel(data, "encoding ");
            break;
        case XML_FROM_SCHEMATRONV:
            channel(data, "schematron ");
            break;
        case XML_FROM_BUFFER:
            channel(data, "internal buffer ");
            break;
        case XML_FROM_URI:
            channel(data, "URI ");
            break;
        default:
            break;
    }
    switch (level) {
        case XML_ERR_NONE:
            channel(data, ": ");
            break;
        case XML_ERR_WARNING:
            channel(data, "warning : ");
            break;
        case XML_ERR_ERROR:
            channel(data, "error : ");
            break;
        case XML_ERR_FATAL:
            channel(data, "error : ");
            break;
    }
    if (str != NULL) {
        int len;
	len = xmlStrlen((const xmlChar *)str);
	if ((len > 0) && (str[len - 1] != '\n'))
	    channel(data, "%s\n", str);
	else
	    channel(data, "%s", str);
    } else {
        channel(data, "%s\n", "out of memory error");
    }

    if (ctxt != NULL) {
        xmlParserPrintFileContextInternal(input, channel, data);
        if (cur != NULL) {
            if (cur->filename)
                channel(data, "%s:%d: \n", cur->filename, cur->line);
            else if ((line != 0) && (domain == XML_FROM_PARSER))
                channel(data, "Entity: line %d: \n", cur->line);
            xmlParserPrintFileContextInternal(cur, channel, data);
        }
    }
    if ((domain == XML_FROM_XPATH) && (err->str1 != NULL) &&
        (err->int1 < 100) &&
	(err->int1 < xmlStrlen((const xmlChar *)err->str1))) {
	xmlChar buf[150];
	int i;

	channel(data, "%s\n", err->str1);
	for (i=0;i < err->int1;i++)
	     buf[i] = ' ';
	buf[i++] = '^';
	buf[i] = 0;
	channel(data, "%s\n", buf);
    }
}

/**
 * __xmlRaiseError:
 * @schannel: the structured callback channel
 * @channel: the old callback channel
 * @data: the callback data
 * @ctx: the parser context or NULL
 * @ctx: the parser context or NULL
 * @domain: the domain for the error
 * @code: the code for the error
 * @level: the xmlErrorLevel for the error
 * @file: the file source of the error (or NULL)
 * @line: the line of the error or 0 if N/A
 * @str1: extra string info
 * @str2: extra string info
 * @str3: extra string info
 * @int1: extra int info
 * @col: column number of the error or 0 if N/A
 * @msg:  the message to display/transmit
 * @...:  extra parameters for the message display
 *
 * Update the appropriate global or contextual error structure,
 * then forward the error message down the parser or generic
 * error callback handler
 */
void XMLCDECL
__xmlRaiseError(xmlStructuredErrorFunc schannel,
              xmlGenericErrorFunc channel, void *data, void *ctx,
              void *nod, int domain, int code, xmlErrorLevel level,
              const char *file, int line, const char *str1,
              const char *str2, const char *str3, int int1, int col,
	      const char *msg, ...)
{
    xmlParserCtxtPtr ctxt = NULL;
    xmlNodePtr node = (xmlNodePtr) nod;
    char *str = NULL;
    xmlParserInputPtr input = NULL;
    xmlErrorPtr to = &xmlLastError;
    xmlNodePtr baseptr = NULL;

    if (code == XML_ERR_OK)
        return;
    if ((xmlGetWarningsDefaultValue == 0) && (level == XML_ERR_WARNING))
        return;
    if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) ||
        (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) ||
	(domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) {
	ctxt = (xmlParserCtxtPtr) ctx;
	if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
	    (ctxt->sax->initialized == XML_SAX2_MAGIC) &&
	    (ctxt->sax->serror != NULL)) {
	    schannel = ctxt->sax->serror;
	    data = ctxt->userData;
	}
    }
    /*
     * Check if structured error handler set
     */
    if (schannel == NULL) {
	schannel = xmlStructuredError;
	/*
	 * if user has defined handler, change data ptr to user's choice
	 */
	if (schannel != NULL)
	    data = xmlStructuredErrorContext;
    }
    /*
     * Formatting the message
     */
    if (msg == NULL) {
        str = (char *) xmlStrdup(BAD_CAST "No error message provided");
    } else {
        XML_GET_VAR_STR(msg, str);
    }

    /*
     * specific processing if a parser context is provided
     */
    if (ctxt != NULL) {
        if (file == NULL) {
            input = ctxt->input;
            if ((input != NULL) && (input->filename == NULL) &&
                (ctxt->inputNr > 1)) {
                input = ctxt->inputTab[ctxt->inputNr - 2];
            }
            if (input != NULL) {
                file = input->filename;
                line = input->line;
                col = input->col;
            }
        }
        to = &ctxt->lastError;
    } else if ((node != NULL) && (file == NULL)) {
	int i;

	if ((node->doc != NULL) && (node->doc->URL != NULL)) {
	    baseptr = node;
/*	    file = (const char *) node->doc->URL; */
	}
	for (i = 0;
	     ((i < 10) && (node != NULL) && (node->type != XML_ELEMENT_NODE));
	     i++)
	     node = node->parent;
        if ((baseptr == NULL) && (node != NULL) &&
	    (node->doc != NULL) && (node->doc->URL != NULL))
	    baseptr = node;

	if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
	    line = node->line;
	if ((line == 0) || (line == 65535))
	    line = xmlGetLineNo(node);
    }

    /*
     * Save the information about the error
     */
    xmlResetError(to);
    to->domain = domain;
    to->code = code;
    to->message = str;
    to->level = level;
    if (file != NULL)
        to->file = (char *) xmlStrdup((const xmlChar *) file);
    else if (baseptr != NULL) {
#ifdef LIBXML_XINCLUDE_ENABLED
	/*
	 * We check if the error is within an XInclude section and,
	 * if so, attempt to print out the href of the XInclude instead
	 * of the usual "base" (doc->URL) for the node (bug 152623).
	 */
        xmlNodePtr prev = baseptr;
	int inclcount = 0;
	while (prev != NULL) {
	    if (prev->prev == NULL)
	        prev = prev->parent;
	    else {
	        prev = prev->prev;
		if (prev->type == XML_XINCLUDE_START) {
		    if (--inclcount < 0)
		        break;
		} else if (prev->type == XML_XINCLUDE_END)
		    inclcount++;
	    }
	}
	if (prev != NULL) {
	    if (prev->type == XML_XINCLUDE_START) {
		prev->type = XML_ELEMENT_NODE;
		to->file = (char *) xmlGetProp(prev, BAD_CAST "href");
		prev->type = XML_XINCLUDE_START;
	    } else {
		to->file = (char *) xmlGetProp(prev, BAD_CAST "href");
	    }
	} else
#endif
	    to->file = (char *) xmlStrdup(baseptr->doc->URL);
	if ((to->file == NULL) && (node != NULL) && (node->doc != NULL)) {
	    to->file = (char *) xmlStrdup(node->doc->URL);
	}
    }
    to->line = line;
    if (str1 != NULL)
        to->str1 = (char *) xmlStrdup((const xmlChar *) str1);
    if (str2 != NULL)
        to->str2 = (char *) xmlStrdup((const xmlChar *) str2);
    if (str3 != NULL)
        to->str3 = (char *) xmlStrdup((const xmlChar *) str3);
    to->int1 = int1;
    to->int2 = col;
    to->node = node;
    to->ctxt = ctx;

    if (to != &xmlLastError)
        xmlCopyError(to,&xmlLastError);

    if (schannel != NULL) {
	schannel(data, to);
	return;
    }

    /*
     * Find the callback channel if channel param is NULL
     */
    if ((ctxt != NULL) && (channel == NULL) &&
        (xmlStructuredError == NULL) && (ctxt->sax != NULL)) {
        if (level == XML_ERR_WARNING)
	    channel = ctxt->sax->warning;
        else
	    channel = ctxt->sax->error;
	data = ctxt->userData;
    } else if (channel == NULL) {
	channel = xmlGenericError;
	if (ctxt != NULL) {
	    data = ctxt;
	} else {
	    data = xmlGenericErrorContext;
	}
    }
    if (channel == NULL)
        return;

    if ((channel == xmlParserError) ||
        (channel == xmlParserWarning) ||
	(channel == xmlParserValidityError) ||
	(channel == xmlParserValidityWarning))
	xmlReportError(to, ctxt, str, NULL, NULL);
    else if ((channel == (xmlGenericErrorFunc) fprintf) ||
             (channel == xmlGenericErrorDefaultFunc))
	xmlReportError(to, ctxt, str, channel, data);
    else
	channel(data, "%s", str);
}

/**
 * __xmlSimpleError:
 * @domain: where the error comes from
 * @code: the error code
 * @node: the context node
 * @extra:  extra informations
 *
 * Handle an out of memory condition
 */
void
__xmlSimpleError(int domain, int code, xmlNodePtr node,
                 const char *msg, const char *extra)
{

    if (code == XML_ERR_NO_MEMORY) {
	if (extra)
	    __xmlRaiseError(NULL, NULL, NULL, NULL, node, domain,
			    XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra,
			    NULL, NULL, 0, 0,
			    "Memory allocation failed : %s\n", extra);
	else
	    __xmlRaiseError(NULL, NULL, NULL, NULL, node, domain,
			    XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL,
			    NULL, NULL, 0, 0, "Memory allocation failed\n");
    } else {
	__xmlRaiseError(NULL, NULL, NULL, NULL, node, domain,
			code, XML_ERR_ERROR, NULL, 0, extra,
			NULL, NULL, 0, 0, msg, extra);
    }
}
/**
 * xmlParserError:
 * @ctx:  an XML parser context
 * @msg:  the message to display/transmit
 * @...:  extra parameters for the message display
 *
 * Display and format an error messages, gives file, line, position and
 * extra parameters.
 */
void XMLCDECL
xmlParserError(void *ctx, const char *msg, ...)
{
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
    xmlParserInputPtr input = NULL;
    xmlParserInputPtr cur = NULL;
    char * str;

    if (ctxt != NULL) {
	input = ctxt->input;
	if ((input != NULL) && (input->filename == NULL) &&
	    (ctxt->inputNr > 1)) {
	    cur = input;
	    input = ctxt->inputTab[ctxt->inputNr - 2];
	}
	xmlParserPrintFileInfo(input);
    }

    xmlGenericError(xmlGenericErrorContext, "error: ");
    XML_GET_VAR_STR(msg, str);
    xmlGenericError(xmlGenericErrorContext, "%s", str);
    if (str != NULL)
	xmlFree(str);

    if (ctxt != NULL) {
	xmlParserPrintFileContext(input);
	if (cur != NULL) {
	    xmlParserPrintFileInfo(cur);
	    xmlGenericError(xmlGenericErrorContext, "\n");
	    xmlParserPrintFileContext(cur);
	}
    }
}

/**
 * xmlParserWarning:
 * @ctx:  an XML parser context
 * @msg:  the message to display/transmit
 * @...:  extra parameters for the message display
 *
 * Display and format a warning messages, gives file, line, position and
 * extra parameters.
 */
void XMLCDECL
xmlParserWarning(void *ctx, const char *msg, ...)
{
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
    xmlParserInputPtr input = NULL;
    xmlParserInputPtr cur = NULL;
    char * str;

    if (ctxt != NULL) {
	input = ctxt->input;
	if ((input != NULL) && (input->filename == NULL) &&
	    (ctxt->inputNr > 1)) {
	    cur = input;
	    input = ctxt->inputTab[ctxt->inputNr - 2];
	}
	xmlParserPrintFileInfo(input);
    }

    xmlGenericError(xmlGenericErrorContext, "warning: ");
    XML_GET_VAR_STR(msg, str);
    xmlGenericError(xmlGenericErrorContext, "%s", str);
    if (str != NULL)
	xmlFree(str);

    if (ctxt != NULL) {
	xmlParserPrintFileContext(input);
	if (cur != NULL) {
	    xmlParserPrintFileInfo(cur);
	    xmlGenericError(xmlGenericErrorContext, "\n");
	    xmlParserPrintFileContext(cur);
	}
    }
}

/************************************************************************
 *									*
 *			Handling of validation errors			*
 *									*
 ************************************************************************/

/**
 * xmlParserValidityError:
 * @ctx:  an XML parser context
 * @msg:  the message to display/transmit
 * @...:  extra parameters for the message display
 *
 * Display and format an validity error messages, gives file,
 * line, position and extra parameters.
 */
void XMLCDECL
xmlParserValidityError(void *ctx, const char *msg, ...)
{
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
    xmlParserInputPtr input = NULL;
    char * str;
    int len = xmlStrlen((const xmlChar *) msg);
    static int had_info = 0;

    if ((len > 1) && (msg[len - 2] != ':')) {
	if (ctxt != NULL) {
	    input = ctxt->input;
	    if ((input->filename == NULL) && (ctxt->inputNr > 1))
		input = ctxt->inputTab[ctxt->inputNr - 2];

	    if (had_info == 0) {
		xmlParserPrintFileInfo(input);
	    }
	}
	xmlGenericError(xmlGenericErrorContext, "validity error: ");
	had_info = 0;
    } else {
	had_info = 1;
    }

    XML_GET_VAR_STR(msg, str);
    xmlGenericError(xmlGenericErrorContext, "%s", str);
    if (str != NULL)
	xmlFree(str);

    if ((ctxt != NULL) && (input != NULL)) {
	xmlParserPrintFileContext(input);
    }
}

/**
 * xmlParserValidityWarning:
 * @ctx:  an XML parser context
 * @msg:  the message to display/transmit
 * @...:  extra parameters for the message display
 *
 * Display and format a validity warning messages, gives file, line,
 * position and extra parameters.
 */
void XMLCDECL
xmlParserValidityWarning(void *ctx, const char *msg, ...)
{
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
    xmlParserInputPtr input = NULL;
    char * str;
    int len = xmlStrlen((const xmlChar *) msg);

    if ((ctxt != NULL) && (len != 0) && (msg[len - 1] != ':')) {
	input = ctxt->input;
	if ((input->filename == NULL) && (ctxt->inputNr > 1))
	    input = ctxt->inputTab[ctxt->inputNr - 2];

	xmlParserPrintFileInfo(input);
    }

    xmlGenericError(xmlGenericErrorContext, "validity warning: ");
    XML_GET_VAR_STR(msg, str);
    xmlGenericError(xmlGenericErrorContext, "%s", str);
    if (str != NULL)
	xmlFree(str);

    if (ctxt != NULL) {
	xmlParserPrintFileContext(input);
    }
}

/************************************************************************
 *									*
 *			Extended Error Handling				*
 *									*
 ************************************************************************/

/**
 * xmlGetLastError:
 *
 * Get the last global error registered. This is per thread if compiled
 * with thread support.
 *
 * Returns NULL if no error occurred or a pointer to the error
 */
xmlErrorPtr
xmlGetLastError(void)
{
    if (xmlLastError.code == XML_ERR_OK)
        return (NULL);
    return (&xmlLastError);
}

/**
 * xmlResetError:
 * @err: pointer to the error.
 *
 * Cleanup the error.
 */
void
xmlResetError(xmlErrorPtr err)
{
    if (err == NULL)
        return;
    if (err->code == XML_ERR_OK)
        return;
    if (err->message != NULL)
        xmlFree(err->message);
    if (err->file != NULL)
        xmlFree(err->file);
    if (err->str1 != NULL)
        xmlFree(err->str1);
    if (err->str2 != NULL)
        xmlFree(err->str2);
    if (err->str3 != NULL)
        xmlFree(err->str3);
    memset(err, 0, sizeof(xmlError));
    err->code = XML_ERR_OK;
}

/**
 * xmlResetLastError:
 *
 * Cleanup the last global error registered. For parsing error
 * this does not change the well-formedness result.
 */
void
xmlResetLastError(void)
{
    if (xmlLastError.code == XML_ERR_OK)
        return;
    xmlResetError(&xmlLastError);
}

/**
 * xmlCtxtGetLastError:
 * @ctx:  an XML parser context
 *
 * Get the last parsing error registered.
 *
 * Returns NULL if no error occurred or a pointer to the error
 */
xmlErrorPtr
xmlCtxtGetLastError(void *ctx)
{
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;

    if (ctxt == NULL)
        return (NULL);
    if (ctxt->lastError.code == XML_ERR_OK)
        return (NULL);
    return (&ctxt->lastError);
}

/**
 * xmlCtxtResetLastError:
 * @ctx:  an XML parser context
 *
 * Cleanup the last global error registered. For parsing error
 * this does not change the well-formedness result.
 */
void
xmlCtxtResetLastError(void *ctx)
{
    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;

    if (ctxt == NULL)
        return;
    ctxt->errNo = XML_ERR_OK;
    if (ctxt->lastError.code == XML_ERR_OK)
        return;
    xmlResetError(&ctxt->lastError);
}

/**
 * xmlCopyError:
 * @from:  a source error
 * @to:  a target error
 *
 * Save the original error to the new place.
 *
 * Returns 0 in case of success and -1 in case of error.
 */
int
xmlCopyError(xmlErrorPtr from, xmlErrorPtr to) {
    char *message, *file, *str1, *str2, *str3;

    if ((from == NULL) || (to == NULL))
        return(-1);

    message = (char *) xmlStrdup((xmlChar *) from->message);
    file = (char *) xmlStrdup ((xmlChar *) from->file);
    str1 = (char *) xmlStrdup ((xmlChar *) from->str1);
    str2 = (char *) xmlStrdup ((xmlChar *) from->str2);
    str3 = (char *) xmlStrdup ((xmlChar *) from->str3);

    if (to->message != NULL)
        xmlFree(to->message);
    if (to->file != NULL)
        xmlFree(to->file);
    if (to->str1 != NULL)
        xmlFree(to->str1);
    if (to->str2 != NULL)
        xmlFree(to->str2);
    if (to->str3 != NULL)
        xmlFree(to->str3);
    to->domain = from->domain;
    to->code = from->code;
    to->level = from->level;
    to->line = from->line;
    to->node = from->node;
    to->int1 = from->int1;
    to->int2 = from->int2;
    to->node = from->node;
    to->ctxt = from->ctxt;
    to->message = message;
    to->file = file;
    to->str1 = str1;
    to->str2 = str2;
    to->str3 = str3;

    return 0;
}

#define bottom_error
#include "elfgcchack.h"


text:
#include "RBFPopulation.h"
#include "RBFNeuron.h"
#include "Projection.h"
#include "RBFInputData.h"

namespace verve
{
	RBFPopulation::RBFPopulation()
	: Population()
	{
		mContinuousResolution = 0;
		mNumDiscreteDimensions = 0;
		mNumContinuousDimensions = 0;
		mIsDynamic = true;
		mSingleState = false;
		mStdDevWidth = 0;
	}

	RBFPopulation::~RBFPopulation()
	{
	}

	void RBFPopulation::init(const RBFInputData& inputData, bool isDynamic)
	{
		assert(inputData.contResolution > 0);

		clear();

		mContinuousResolution = inputData.contResolution;
		mNumDiscreteDimensions = inputData.numDiscInputs;
		mNumContinuousDimensions = inputData.numContInputs;
		mIsDynamic = isDynamic;

		// The RBF std. dev. width equals the distance of one standard
		// deviation from the RBF center.  This value affects the width
		// of each RBF's Gaussian curve (and, thus, how much the RBFs
		// will overlap).

		// RBF WIDTH METHOD 1: Make the RBF width depend on the resolution
		// (and distance between neighboring RBFs).  We'll set it equal
		// to the distance between neighboring RBFs.
		mStdDevWidth = 2 / (real)mContinuousResolution;

		// RBF WIDTH METHOD 2: Use a constant width that is independent
		// of the resolution.  We'll set it to a fraction of the input
		// range (which is 2).
		//mStdDevWidth = (real)0.5;

		// Check if this is a "null" Population with a single, constantly-
		// active Neuron.
		if (0 == mNumDiscreteDimensions && 0 == mNumContinuousDimensions)
		{
			mSingleState = true;

			// Just create a single RBF to represent the one possible
			// "state."
			Population::init(1);

			// Keep the single RBFNeuron active constantly.
			mNeurons[0]->setFiringRate(1);

			return;
		}

		// Check if this is a non-dynamic RBFPopulation.  If so, create
		// an RBF for every position in the input space.
		if (!isDynamic)
		{
			RBFInputData tempInputData;
			tempInputData.init(inputData.numDiscInputs,
				inputData.discNumOptionsData, inputData.discInputData,
				inputData.numContInputs, inputData.contResolution,
				inputData.contCircularData, inputData.contInputData);
			unsigned numStates = tempInputData.computeNumUniqueStates(
				inputData.contResolution);
			for (unsigned int i = 0; i < numStates; ++i)
			{
				tempInputData.setToUniqueState(i, numStates,
					inputData.contResolution);
				makeNewRBF(tempInputData);
			}
		}

		// If we're using a dynamic RBFPopulation, we don't need to create
		// any RBFNeurons at this point.  They'll get created dynamically
		// later.
	}

	void RBFPopulation::resetShortTermMemory()
	{
		Population::resetShortTermMemory();

		// Empty the lists of active Neurons.
		mActiveNeurons.clear();

		if (mSingleState)
		{
			// Keep the single RBFNeuron active constantly.
			mNeurons[0]->setFiringRate(1);
		}
	}

	void RBFPopulation::clear()
	{
		Population::clear();
	}

	void RBFPopulation::updateFiringRatesRBF(const RBFInputData& inputData,
		bool allowDynamicRBFCreation)
	{
		mActiveNeurons.clear();

		if (mSingleState)
		{
			// This is basically a null Population with a single,
			// constantly-active Neuron.

			// Track the active Neuron.
			mActiveNeurons.push_back(mNeurons.back());
			return;
		}

		// Assume we need to make a new RBF until we find an existing
		// one with high activation.
		bool needNewRBF = true;

		unsigned int numRBFs = (unsigned int)mNeurons.size();
		for (unsigned int i = 0; i < numRBFs; ++i)
		{
			RBFNeuron* neuron = static_cast<RBFNeuron*>(mNeurons[i]);
			RBFActivationCode code = neuron->updateFiringRate(inputData);

			if (HIGH_ACTIVATION == code)
			{
				needNewRBF = false;

				// Track the active Neuron.
				mActiveNeurons.push_back(neuron);
			}
			else if (LOW_ACTIVATION == code)
			{
				// Track the active Neuron.
				mActiveNeurons.push_back(neuron);
			}
		}

		if (allowDynamicRBFCreation && mIsDynamic && needNewRBF)
		{
			makeNewRBF(inputData);
			Neuron* newRBFNeuron = mNeurons.back();
			connectNewRBFToTargets(newRBFNeuron);

			// Set the new RBFNeuron's activation high because it is located
			// right on the current data point.
			newRBFNeuron->setFiringRate(1);

			// Save the new RBFNeuron in the active Neuron list.
			mActiveNeurons.push_back(newRBFNeuron);
		}
	}

	void RBFPopulation::createNeuron(unsigned int id)
	{
		RBFNeuron* neuron = new RBFNeuron(id);
		mNeurons.push_back(neuron);
	}

	void RBFPopulation::makeNewRBF(const RBFInputData& inputData)
	{
		// Create the new RBFNeuron.
		createNeuron((unsigned int)mNeurons.size());
		RBFNeuron* newRBFNeuron = static_cast<RBFNeuron*>(mNeurons.back());

		// The RBF's "new RBF threshold" is the RBF's "personal space."
		// If any points fall within this distance from its center, no
		// new RBFs will be created.  Since the approximate distance
		// between each RBF along a given dimension is 2 / resolution,
		// we'll use it as the threshold value.  This value must be
		// related to the resolution because this value will affect
		// the total number of RBFs created in the dynamic case (which
		// is the purpose of the resolution parameter).
		real newRBFThreshold = 2 / (real)mContinuousResolution;

		// mStdDevWidth must be >= 0.25 * newRBFThreshold to ensure
		// that the RBFs creation threshold distance isn't beyond
		// the activation threshold.  The 0.25 comes from the fact
		// that we set the activation threshold to 4 * stdDevWidth
		// in RBFNeuron::init.
		assert(mStdDevWidth >= (real)0.25 * newRBFThreshold);

		// Initialize the RBF.
		newRBFNeuron->init(mStdDevWidth, newRBFThreshold, inputData);
	}

	void RBFPopulation::connectNewRBFToTargets(Neuron* n)
	{
		// Connect the new RBFNeuron to the target Populations by
		// notifying the output Projections of the new Neuron.
		unsigned int numProjections = (unsigned int)mOutputProjections.size();
		for (unsigned int i = 0; i < numProjections; ++i)
		{
			mOutputProjections[i]->addPreNeuron(n);
		}
	}

	unsigned int RBFPopulation::getNumActiveNeurons()const
	{
		return (unsigned int)mActiveNeurons.size();
	}

	Neuron* RBFPopulation::getActiveNeuron(unsigned int i)
	{
		return mActiveNeurons.at(i);
	}

	real RBFPopulation::computeMaxActivationSum()const
	{
		// The following computes the maximum possible activation sum of all
		// RBFs.  We can then use this value to adjust the learning rate to
		// ensure stable learning.  The method we use here depends on
		// whether the RBF std. dev. width (mStdDevWidth) is constant or
		// if it depends on the resolution.
		real maxActivationSum = 0;

		if (0 == mNumContinuousDimensions)
		{
			// We only have discrete inputs (or no inputs at all), so there
			// will only be 1 RBF active at once.
			maxActivationSum = 1;
		}
		else
		{
			// RBF ACTIVATION SUM METHOD 1: Assuming std. dev. width depends
			// on resolution.  In this case, we will use the experimentally-
			// determined relationship: sum = 2.5^n, where n is the number
			// of continuous dimensions.
			maxActivationSum = globals::pow((real)2.5,
				(real)mNumContinuousDimensions);

			//// RBF ACTIVATION SUM METHOD 2: Assuming std. dev. width is
			//// constant.  In this case, we will use the experimentally-
			//// determined relationship for std. dev. width = 0.5:
			//// sum = 0.7477 * 0.42^(n-1) * resolution^n, where n is the
			//// number of continuous dimensions.
			//assert((real)0.5 == mStdDevWidth);
			//maxActivationSum = (real)0.7477 * globals::pow((real)0.42,
			//	(real)mNumContinuousDimensions - 1) * globals::pow(
			//	(real)mContinuousResolution, (real)mNumContinuousDimensions);
		}

		return maxActivationSum;
	}
}


text:
package co.cask.cdap.internal.app.deploy.pipeline;

import co.cask.cdap.api.ProgramSpecification;
import co.cask.cdap.api.app.ApplicationSpecification;
import co.cask.cdap.api.flow.FlowSpecification;
import co.cask.cdap.api.mapreduce.MapReduceSpecification;
import co.cask.cdap.api.service.ServiceSpecification;
import co.cask.cdap.api.spark.SparkSpecification;
import co.cask.cdap.api.worker.WorkerSpecification;
import co.cask.cdap.api.workflow.WorkflowSpecification;
import co.cask.cdap.data2.metadata.store.MetadataStore;
import co.cask.cdap.data2.metadata.system.AbstractSystemMetadataWriter;
import co.cask.cdap.data2.metadata.system.AppSystemMetadataWriter;
import co.cask.cdap.data2.metadata.system.ProgramSystemMetadataWriter;
import co.cask.cdap.pipeline.AbstractStage;
import co.cask.cdap.proto.Id;
import co.cask.cdap.proto.ProgramType;
import com.google.common.reflect.TypeToken;

import java.util.ArrayList;
import java.util.List;

/**
 * Stage to write system metadata for an application.
 */
public class SystemMetadataWriterStage extends AbstractStage<ApplicationWithPrograms> {

  private final MetadataStore metadataStore;

  public SystemMetadataWriterStage(MetadataStore metadataStore) {
    super(TypeToken.of(ApplicationWithPrograms.class));
    this.metadataStore = metadataStore;
  }

  @Override
  public void process(ApplicationWithPrograms input) throws Exception {
    // add system metadata for apps
    ApplicationSpecification appSpec = input.getSpecification();
    AbstractSystemMetadataWriter appSystemMetadataWriter = new AppSystemMetadataWriter(metadataStore, input.getId(),
                                                                                appSpec);
    appSystemMetadataWriter.write();

    // add system metadata for programs
    writeProgramSystemMetadata(input.getId(), ProgramType.FLOW, appSpec.getFlows().values());
    writeProgramSystemMetadata(input.getId(), ProgramType.MAPREDUCE, appSpec.getMapReduce().values());
    writeProgramSystemMetadata(input.getId(), ProgramType.SERVICE, appSpec.getServices().values());
    writeProgramSystemMetadata(input.getId(), ProgramType.SPARK, appSpec.getSpark().values());
    writeProgramSystemMetadata(input.getId(), ProgramType.WORKER, appSpec.getWorkers().values());
    writeProgramSystemMetadata(input.getId(), ProgramType.WORKFLOW, appSpec.getWorkflows().values());

    // Emit input to the next stage
    emit(input);
  }

  private void writeProgramSystemMetadata(Id.Application appId, ProgramType programType,
                                          Iterable<? extends ProgramSpecification> specs) {
    for (ProgramSpecification spec : specs) {
      Id.Program programId = Id.Program.from(appId, programType, spec.getName());
      ProgramSystemMetadataWriter writer = new ProgramSystemMetadataWriter(metadataStore, programId, spec);
      writer.write();
    }
  }
}


text:
package commands

type AssignDefaultSecurityGroups struct {
	BaseCFConfigCommand
	BasePeekCommand
}

//Execute - creates security groups
func (c *AssignDefaultSecurityGroups) Execute([]string) error {
	var cfMgmt *CFMgmt
	var err error
	if cfMgmt, err = InitializePeekManagers(c.BaseCFConfigCommand, c.Peek); err == nil {
		err = cfMgmt.SecurityGroupManager.AssignDefaultSecurityGroups()
	}
	return err
}


text:
<?php

# load zipstream class
require '../zipstream.php';

# get path to current file
$pwd = dirname(__FILE__);

# add some random files
$files = array(
  '../extras/zip-appnote-6.3.1-20070411.txt',
  '../zipstream.php',
);

# create new zip stream object
$zip = new ZipStream('test.zip', array(
  'comment' => 'this is a zip file comment.  hello?'
));

# common file options
$file_opt = array(
  # file creation time (2 hours ago)
  'time'    => time() - 2 * 3600,

  # file comment
  'comment' => 'this is a file comment. hi!',
);

# add files under folder 'asdf'
foreach ($files as $file) {
  # build absolute path and get file data
  $path = ($file[0] == '/') ? $file : "$pwd/$file";
  $data = file_get_contents($path);

  # add file to archive
  $zip->add_file('asdf/' . basename($file), $data, $file_opt);
}

# add same files again wihtout a folder
foreach ($files as $file) {
  # build absolute path and get file data
  $path = ($file[0] == '/') ? $file : "$pwd/$file";
  $data = file_get_contents($path);

  # add file to archive
  $zip->add_file(basename($file), $data, $file_opt);
}

# finish archive
$zip->finish();

?>


text:
<?php

declare(strict_types=1);

namespace App\Controller\Api\Admin\Stations;

use App\Controller\Api\Admin\StationsController;
use App\Entity;
use App\Environment;
use App\Http\Response;
use App\Http\ServerRequest;
use DeepCopy;
use Doctrine\Common\Collections\Collection;
use Psr\Http\Message\ResponseInterface;

class CloneAction extends StationsController
{
    public const CLONE_MEDIA_STORAGE = 'media_storage';
    public const CLONE_RECORDINGS_STORAGE = 'recordings_storage';
    public const CLONE_PODCASTS_STORAGE = 'podcasts_storage';

    public const CLONE_PLAYLISTS = 'playlists';
    public const CLONE_MOUNTS = 'mounts';
    public const CLONE_REMOTES = 'remotes';
    public const CLONE_STREAMERS = 'streamers';
    public const CLONE_PERMISSIONS = 'permissions';
    public const CLONE_WEBHOOKS = 'webhooks';

    public function __invoke(
        ServerRequest $request,
        Response $response,
        Environment $environment,
        mixed $id
    ): ResponseInterface {
        $record = $this->getRecord($id);
        $data = (array)$request->getParsedBody();

        $toClone = $data['clone'];

        $copier = new DeepCopy\DeepCopy();
        $copier->addFilter(
            new DeepCopy\Filter\Doctrine\DoctrineProxyFilter(),
            new DeepCopy\Matcher\Doctrine\DoctrineProxyMatcher()
        );
        $copier->addFilter(
            new DeepCopy\Filter\SetNullFilter(),
            new DeepCopy\Matcher\PropertyNameMatcher('id')
        );
        $copier->addFilter(
            new DeepCopy\Filter\Doctrine\DoctrineEmptyCollectionFilter(),
            new DeepCopy\Matcher\PropertyTypeMatcher(Collection::class)
        );

        $copier->addFilter(
            new DeepCopy\Filter\KeepFilter(),
            new DeepCopy\Matcher\PropertyMatcher(Entity\RolePermission::class, 'role')
        );
        $copier->addFilter(
            new DeepCopy\Filter\KeepFilter(),
            new DeepCopy\Matcher\PropertyMatcher(Entity\StationPlaylistMedia::class, 'media')
        );

        /** @var Entity\Station $record */
        /** @var Entity\Station $newStation */
        $newStation = $copier->copy($record);

        $newStation->setName($data['name'] ?? ($newStation->getName() . ' - Copy'));
        $newStation->setDescription($data['description'] ?? $newStation->getDescription());

        if (in_array(self::CLONE_MEDIA_STORAGE, $toClone, true)) {
            $newStation->setMediaStorageLocation($record->getMediaStorageLocation());
        }
        if (in_array(self::CLONE_RECORDINGS_STORAGE, $toClone, true)) {
            $newStation->setRecordingsStorageLocation($record->getRecordingsStorageLocation());
        }
        if (in_array(self::CLONE_PODCASTS_STORAGE, $toClone, true)) {
            $newStation->setPodcastsStorageLocation($record->getPodcastsStorageLocation());
        }

        // Set new radio base directory
        $station_base_dir = $environment->getStationDirectory();
        $newStation->setRadioBaseDir($station_base_dir . '/' . $newStation->getShortName());

        $newStation->ensureDirectoriesExist();

        // Persist all newly created records (and relations).
        $this->em->persist($newStation->getMediaStorageLocation());
        $this->em->persist($newStation->getRecordingsStorageLocation());
        $this->em->persist($newStation->getPodcastsStorageLocation());
        $this->em->persist($newStation);
        $this->em->flush();
        $this->em->clear();

        if (in_array(self::CLONE_PLAYLISTS, $toClone, true)) {
            $afterCloning = function (
                Entity\StationPlaylist $oldPlaylist,
                Entity\StationPlaylist $newPlaylist,
                Entity\Station $newStation
            ) use (
                $copier,
                $toClone
            ): void {
                foreach ($oldPlaylist->getScheduleItems() as $oldScheduleItem) {
                    /** @var Entity\StationSchedule $newScheduleItem */
                    $newScheduleItem = $copier->copy($oldScheduleItem);
                    $newScheduleItem->setPlaylist($newPlaylist);

                    $this->em->persist($newScheduleItem);
                }

                if (in_array(self::CLONE_MEDIA_STORAGE, $toClone, true)) {
                    foreach ($oldPlaylist->getFolders() as $oldPlaylistFolder) {
                        /** @var Entity\StationPlaylistFolder $newPlaylistFolder */
                        $newPlaylistFolder = $copier->copy($oldPlaylistFolder);
                        $newPlaylistFolder->setStation($newStation);
                        $newPlaylistFolder->setPlaylist($newPlaylist);
                        $this->em->persist($newPlaylistFolder);
                    }

                    foreach ($oldPlaylist->getMediaItems() as $oldMediaItem) {
                        /** @var Entity\StationPlaylistMedia $newMediaItem */
                        $newMediaItem = $copier->copy($oldMediaItem);

                        $newMediaItem->setPlaylist($newPlaylist);
                        $this->em->persist($newMediaItem);
                    }
                }
            };

            $record = $this->reloadableEm->refetch($record);
            $this->cloneCollection($record->getPlaylists(), $newStation, $copier, $afterCloning);
        }

        if (in_array(self::CLONE_MOUNTS, $toClone, true)) {
            $record = $this->reloadableEm->refetch($record);
            $this->cloneCollection($record->getMounts(), $newStation, $copier);
        } else {
            $newStation = $this->reloadableEm->refetch($newStation);

            // Create default mountpoints if station supports them.
            $frontendAdapter = $this->adapters->getFrontendAdapter($newStation);
            $this->stationRepo->resetMounts($newStation, $frontendAdapter);
        }

        if (in_array(self::CLONE_REMOTES, $toClone, true)) {
            $record = $this->reloadableEm->refetch($record);
            $this->cloneCollection($record->getRemotes(), $newStation, $copier);
        }

        if (in_array(self::CLONE_STREAMERS, $toClone, true)) {
            $record = $this->reloadableEm->refetch($record);

            $afterCloning = function (
                Entity\StationStreamer $oldStreamer,
                Entity\StationStreamer $newStreamer,
                Entity\Station $station
            ) use (
                $copier
            ): void {
                foreach ($oldStreamer->getScheduleItems() as $oldScheduleItem) {
                    /** @var Entity\StationSchedule $newScheduleItem */
                    $newScheduleItem = $copier->copy($oldScheduleItem);
                    $newScheduleItem->setStreamer($newStreamer);

                    $this->em->persist($newScheduleItem);
                }
            };

            $this->cloneCollection($record->getStreamers(), $newStation, $copier, $afterCloning);
        }

        if (in_array(self::CLONE_PERMISSIONS, $toClone, true)) {
            $record = $this->reloadableEm->refetch($record);
            $this->cloneCollection($record->getPermissions(), $newStation, $copier);
        }

        if (in_array(self::CLONE_WEBHOOKS, $toClone, true)) {
            $record = $this->reloadableEm->refetch($record);
            $this->cloneCollection($record->getWebhooks(), $newStation, $copier);
        }

        // Clear the EntityManager for later functions.
        $newStation = $this->reloadableEm->refetch($newStation);

        $this->configuration->assignRadioPorts($newStation, true);
        $this->configuration->writeConfiguration($newStation);
        $this->em->flush();

        return $response->withJson(Entity\Api\Status::created());
    }

    protected function cloneCollection(
        Collection $collection,
        Entity\Station $newStation,
        DeepCopy\DeepCopy $copier,
        ?callable $afterCloning = null
    ): void {
        $newStation = $this->reloadableEm->refetch($newStation);

        foreach ($collection as $oldRecord) {
            /** @var Entity\Interfaces\StationCloneAwareInterface $newRecord */
            $newRecord = $copier->copy($oldRecord);
            $newRecord->setStation($newStation);

            $this->em->persist($newRecord);

            if (is_callable($afterCloning)) {
                $afterCloning($oldRecord, $newRecord, $newStation);
            }
        }

        $this->em->flush();
        $this->em->clear();
    }
}


text:
SYNONYM

#### According to
Index Fungorum

#### Published in
null

#### Original name
Peltidea hymenina Ach.

### Remarks
null


text:
from django.conf.urls import url
from .views import (
    index,
    # Import de vistas CRUD de Cashier
    CashierListView, CashierDetailView, CashierCreationView, CashierUpdateView, CashierDeleteView,
    # Import de vistas CRUD de BoxCashier
    BoxCashierListView, BoxCashierDetailView, BoxCashierCreationView, BoxCashierUpdateView, BoxCashierDeleteView,
    # Import de vistas CRUD de Consignment
    ConsignmentListView, ConsignmentDetailView, ConsignmentCreationView, ConsignmentUpdateView, ConsignmentDeleteView,
    # Import de vistas de Filtrado
    search,
)

urlpatterns = [
    # URL index 'localhost:8000/cash
    url(r'^$', index),

    # URL's del CRUD de CAJA
    url(r'^cashier/$', CashierListView.as_view(), name='cashier_list'),

    # url(r'^cashier/(?P<pk>\d+)$', CashierDetailView.as_view(), name='cashier_detail'),
    url(r'^cashier/(?P<pk>\d+)$', CashierDetailView.as_view(), name='cashier_detail'),

    url(r'^cashier/create$', CashierCreationView.as_view(), name='cashier_create'),
    url(r'^cashier/update/(?P<pk>\d+)$', CashierUpdateView.as_view(), name='cashier_edit'),
    url(r'^cashier/delete/(?P<pk>\d+)$', CashierDeleteView.as_view(), name='cashier_delete'),

    # URL's del CRUD de CAJACAJERO
    url(r'^boxcashier/$', BoxCashierListView.as_view(), name='boxcashier_list'),
    url(r'^boxcashier/(?P<pk>\d+)$', BoxCashierDetailView.as_view(), name='boxcashier_detail'),

    url(r'^boxcashier/Aperturar$', BoxCashierCreationView.as_view(), name='boxcashier_AperturarCaja'),
    url(r'^boxcashier/Cerrar/(?P<pk>\d+)$', BoxCashierUpdateView.as_view(), name='boxcashier_CerrarCaja'),

    url(r'^boxcashier/delete/(?P<pk>\d+)$', BoxCashierDeleteView.as_view(), name='boxcashier_delete'),

    # URL's del CRUD de Remesas

    # url(r'^search/$', search, name='search'),
    # url(r'^consignment/$', ConsignmentListView.as_view(), name='consignment_list'),
    url(r'^consignment/$', search, name='consignment_list'),
    url(r'^consignment/(?P<pk>\d+)$', ConsignmentDetailView.as_view(), name='consignment_detail'),
    url(r'^consignment/create$', ConsignmentCreationView.as_view(), name='consignment_create'),
    url(r'^consignment/update/(?P<pk>\d+)$', ConsignmentUpdateView.as_view(), name='consignment_edit'),
    url(r'^consignment/delete/(?P<pk>\d+)$', ConsignmentDeleteView.as_view(), name='consignment_delete'),

]