Re: [PATCH] Enhance virBuffer code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Richard W.M. Jones" <rjones@xxxxxxxxxx> 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)

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]