示例#1
0
文件: ixml.c 项目: lince/ginga-hones
/*!
 * \brief Appends a string to a buffer, substituting some characters by escape
 * sequences.
 */
static void copy_with_escape(
	/*! [in,out] The input/output buffer. */
	ixml_membuf *buf,
	/*! [in] The string to copy from. */
	const char *p)
{
	int i;
	int plen;

	if (p == NULL) {
		return;
	}

	plen = strlen( p );

	for (i = 0; i < plen; i++) {
		switch (p[i]) {
		case '<':
			ixml_membuf_append_str(buf, "&lt;");
			break;

		case '>':
			ixml_membuf_append_str(buf, "&gt;");
			break;

		case '&':
			ixml_membuf_append_str(buf, "&amp;");
			break;

		case '\'':
			ixml_membuf_append_str(buf, "&apos;");
			break;

		case '\"':
			ixml_membuf_append_str(buf, "&quot;");
			break;

		default:
			ixml_membuf_append(buf, &p[i]);
			break;
		}
	}
}
示例#2
0
文件: ixml.c 项目: brolee/EMule-GIFC
/*================================================================
*   copy_with_escape
*
*
*=================================================================*/
void
copy_with_escape( INOUT ixml_membuf * buf,
                  IN char *p )
{
    int i;
    int plen;

    if( p == NULL )
        return;

    plen = strlen( p );

    for( i = 0; i < plen; i++ ) {
        switch ( p[i] ) {
            case '<':
                ixml_membuf_append_str( buf, "&lt;" );
                break;

            case '>':
                ixml_membuf_append_str( buf, "&gt;" );
                break;

            case '&':
                ixml_membuf_append_str( buf, "&amp;" );
                break;

            case '\'':
                ixml_membuf_append_str( buf, "&apos;" );
                break;

            case '\"':
                ixml_membuf_append_str( buf, "&quot;" );
                break;

            default:
                ixml_membuf_append( buf, &p[i] );
        }
    }
}