[Libvir] [PATCH] Enhance virBuffer code
Jim Meyering
jim at meyering.net
Thu Dec 13 22:21:31 UTC 2007
"Richard W.M. Jones" <rjones at redhat.com> wrote:
...
> + * virBufferURIEncodeString:
> + * @buf: the buffer to append to
> + * @str: the string argument which will be URI-encoded
> + *
> + * Append the string to the buffer. The string will be URI-encoded
> + * during the append (ie any non alpha-numeric characters are replaced
> + * with '%xx' hex sequences).
> + *
> + * Returns 0 successful, -1 in case of internal or API error.
> + */
> +int
> +virBufferURIEncodeString (virBufferPtr buf, const char *str)
> +{
> + int grow_size = 0;
> + const char *p;
> + unsigned char uc;
> + const char *hex = "0123456789abcdef";
> +
> + for (p = str; *p; ++p) {
> + /* Want to leave only strict 7 bit ASCII alphanumerics ... */
> + if ((*p >= '0' && *p <= '9') ||
> + (*p >= 'a' && *p <= 'z') ||
> + (*p >= 'A' && *p <= 'Z'))
...
> + for (p = str; *p; ++p) {
> + if ((*p >= '0' && *p <= '9') ||
> + (*p >= 'a' && *p <= 'z') ||
> + (*p >= 'A' && *p <= 'Z'))
Hi Rich,
What do you think of using this?
isascii (*p) && isalnum (*p)
More information about the libvir-list
mailing list