Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/include/svn_xml.h view on Meta::CPAN
/**
* @copyright
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
* @endcopyright
*
* @file svn_xml.h
* @brief XML code shared by various Subversion libraries.
*/
#ifndef SVN_XML_H
#define SVN_XML_H
#include <apr.h>
#include <apr_pools.h>
#include <apr_hash.h>
#include "svn_types.h"
#include "svn_string.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** The namespace all Subversion XML uses. */
#define SVN_XML_NAMESPACE "svn:"
/** Used as style argument to svn_xml_make_open_tag() and friends. */
enum svn_xml_open_tag_style {
/** <tag ...> */
svn_xml_normal = 1,
/** <tag ...>, no cosmetic newline */
svn_xml_protect_pcdata,
/** <tag .../> */
svn_xml_self_closing
};
/** Determine if a string of character @a data of length @a len is a
* safe bet for use with the svn_xml_escape_* functions found in this
* header.
*
* Return @c TRUE if it is, @c FALSE otherwise.
*
* Essentially, this function exists to determine whether or not
* simply running a string of bytes through the Subversion XML escape
* routines will produce legitimate XML. It should only be necessary
* for data which might contain bytes that cannot be safely encoded
* into XML (certain control characters, for example).
*/
svn_boolean_t
svn_xml_is_xml_safe(const char *data,
apr_size_t len);
/** Create or append in @a *outstr an xml-escaped version of @a string,
* suitable for output as character data.
*
* If @a *outstr is @c NULL, set @a *outstr to a new stringbuf allocated
* in @a pool, else append to the existing stringbuf there.
*/
void
svn_xml_escape_cdata_stringbuf(svn_stringbuf_t **outstr,
const svn_stringbuf_t *string,
apr_pool_t *pool);
/** Same as svn_xml_escape_cdata_stringbuf(), but @a string is an
* @c svn_string_t.
*/
void
svn_xml_escape_cdata_string(svn_stringbuf_t **outstr,
const svn_string_t *string,
apr_pool_t *pool);
/** Same as svn_xml_escape_cdata_stringbuf(), but @a string is a
* NULL-terminated C string.
*/
void
svn_xml_escape_cdata_cstring(svn_stringbuf_t **outstr,
const char *string,
apr_pool_t *pool);
/** Create or append in @a *outstr an xml-escaped version of @a string,
* suitable for output as an attribute value.
*
* If @a *outstr is @c NULL, set @a *outstr to a new stringbuf allocated
* in @a pool, else append to the existing stringbuf there.
*/
void
svn_xml_escape_attr_stringbuf(svn_stringbuf_t **outstr,
const svn_stringbuf_t *string,
apr_pool_t *pool);
/** Same as svn_xml_escape_attr_stringbuf(), but @a string is an
* @c svn_string_t.
*/
void
svn_xml_escape_attr_string(svn_stringbuf_t **outstr,
const svn_string_t *string,
apr_pool_t *pool);
/** Same as svn_xml_escape_attr_stringbuf(), but @a string is a
* NULL-terminated C string.
*/
void
svn_xml_escape_attr_cstring(svn_stringbuf_t **outstr,
const char *string,
apr_pool_t *pool);
/**
* Return UTF-8 string @a string if it contains no characters that are
* unrepresentable in XML. Else, return a copy of @a string,
* allocated in @a pool, with each unrepresentable character replaced
* by "?\uuu", where "uuu" is the three-digit unsigned decimal value
* of that character.
*
* Neither the input nor the output need be valid XML; however, the
* output can always be safely XML-escaped.
*
* @note The current implementation treats all Unicode characters as
* representable, except for most ASCII control characters (the
* exceptions being CR, LF, and TAB, which are valid in XML). There
* may be other UTF-8 characters that are invalid in XML; see
* http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=90591
* and its thread for details.
*
* @since New in 1.2.
*/
const char *
svn_xml_fuzzy_escape(const char *string,
apr_pool_t *pool);
/*---------------------------------------------------------------*/
/* Generalized Subversion XML Parsing */
/** A generalized Subversion XML parser object */
( run in 0.591 second using v1.01-cache-2.11-cpan-62beec7d96d )