void xml_wrap_delimiters_to_buffer( struct buffer *dest, const char *src ) { upnp_assert( src != NULL ); if ( src == NULL ) return; for (;;) { char c = *src++; if ( c == '\0' ) break; if ( c == '&' ) append_string_to_buffer( dest, _amp ); else if ( c == '<' ) append_string_to_buffer( dest, _lt ); else if ( c == '>' ) append_string_to_buffer( dest, _gt ); else if ( c == '\'' ) append_string_to_buffer( dest, _apos ); else if ( c == '\"' ) append_string_to_buffer( dest, _quot ); else append_char_to_buffer( dest, c ); } }
match_value* make_operators(char* str, int op){ byte_buffer* bb = NULL; match_value* r = NULL; switch(op){ case STARTSW_OP: bb = new_byte_buffer(strlen(str)+2); append_string_to_buffer("^", bb); append_string_to_buffer(str, bb); append_bytes_to_buffer("\0", bb, 1); r = new_match_value_no_strdup(bb->buffer, REGEX_OP); free(str); break; case ENDSW_OP: bb = new_byte_buffer(strlen(str)+2); append_string_to_buffer(str, bb); append_string_to_buffer("$", bb); append_bytes_to_buffer("\0", bb, 1); r = new_match_value_no_strdup(bb->buffer, REGEX_OP); free(str); break; case WSSV_OP: bb = new_byte_buffer((strlen(str)+5)*4); append_string_to_buffer("(^", bb); append_string_to_buffer(str, bb); append_string_to_buffer("$)|", bb); append_string_to_buffer("(^", bb); append_string_to_buffer(str, bb); append_string_to_buffer(" )|", bb); append_string_to_buffer("( ", bb); append_string_to_buffer(str, bb); append_string_to_buffer("$)|", bb); append_string_to_buffer("( ", bb); append_string_to_buffer(str, bb); append_string_to_buffer(" )", bb); append_bytes_to_buffer("\0", bb, 1); r = new_match_value_no_strdup(bb->buffer, REGEX_OP); free(str); break; case DSV_OP: bb = new_byte_buffer((strlen(str)+5)*4); append_string_to_buffer("(^", bb); append_string_to_buffer(str, bb); append_string_to_buffer("$)|", bb); append_string_to_buffer("(^", bb); append_string_to_buffer(str, bb); append_string_to_buffer("-)|", bb); append_string_to_buffer("(-", bb); append_string_to_buffer(str, bb); append_string_to_buffer("$)|", bb); append_string_to_buffer("(-", bb); append_string_to_buffer(str, bb); append_string_to_buffer("-)", bb); append_bytes_to_buffer("\0", bb, 1); r = new_match_value_no_strdup(bb->buffer, REGEX_OP); free(str); break; case NO_OP: r = NULL; break; default: r = new_match_value_no_strdup(str, op); } free(bb); return r; }