[asterisk-dev] Fwd: [svn-commits] rizzo: trunk r45325 - /trunk/main/manager.c

Olle E Johansson oej at edvina.net
Tue Oct 17 11:56:03 MST 2006


Isn't XML utf8 by default? So why do we need to convert field names?
Just curious.

While changing the http interface, I would suggest adding a header to  
declare the
output as UTF8 as we did agree earlier on this list.

/Olle

Vidarebefordrat brev:

> Från: svn-commits at lists.digium.com
> Datum: tisdag 17 okt 2006 19.19.31 GMT+02:00
> Till: asterisk-commits at lists.digium.com, svn-commits at lists.digium.com
> Ämne: [svn-commits] rizzo: trunk r45325 - /trunk/main/manager.c
>
> Author: rizzo
> Date: Tue Oct 17 12:19:31 2006
> New Revision: 45325
>
> URL: http://svn.digium.com/view/asterisk?rev=45325&view=rev
> Log:
> document xml_copy_escape() and add an extra function, namely
> replace non-alphanum chars with underscore.
> This is useful when building field names in xml formatting.
>
>
> Modified:
>     trunk/main/manager.c
>
> Modified: trunk/main/manager.c
> URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c? 
> rev=45325&r1=45324&r2=45325&view=diff
> ====================================================================== 
> ========
> --- trunk/main/manager.c (original)
> +++ trunk/main/manager.c Tue Oct 17 12:19:31 2006
> @@ -240,9 +240,19 @@
>  	return ret;
>  }
>
> -static void xml_copy_escape(char **dst, size_t *maxlen, const char  
> *src, int lower)
> -{
> -	while (*src && (*maxlen > 6)) {
> +/*
> + * convert to xml with various conversion:
> + * mode & 1	-> lowercase;
> + * mode & 2	-> replace non-alphanumeric chars with underscore
> + */
> +static void xml_copy_escape(char **dst, size_t *maxlen, const char  
> *src, int mode)
> +{
> +	for ( ; *src && *maxlen > 6; src++) {
> +		if ( (mode & 2) && !isalnum(*src)) {
> +			*(*dst)++ = '_';
> +			(*maxlen)--;
> +			continue;
> +		}
>  		switch (*src) {
>  		case '<':
>  			strcpy(*dst, "&lt;");
> @@ -269,11 +279,11 @@
>  			(*dst) += 5;
>  			*maxlen -= 5;
>  			break;		
> +
>  		default:
> -			*(*dst)++ = lower ? tolower(*src) : *src;
> +			*(*dst)++ = mode ? tolower(*src) : *src;
>  			(*maxlen)--;
>  		}
> -		src++;
>  	}
>  }
>
>
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> svn-commits mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/svn-commits

---
* Olle E Johansson - oej at edvina.net
* Cell phone +46 70 593 68 51, Office +46 8 96 40 20, Sweden





More information about the asterisk-dev mailing list