mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	add pa_proplist_to_string_sep()
This commit is contained in:
		
							parent
							
								
									4a66837b83
								
							
						
					
					
						commit
						a45f971e43
					
				
					 3 changed files with 28 additions and 7 deletions
				
			
		| 
						 | 
					@ -159,6 +159,7 @@ pa_proplist_setf;
 | 
				
			||||||
pa_proplist_sets;
 | 
					pa_proplist_sets;
 | 
				
			||||||
pa_proplist_size;
 | 
					pa_proplist_size;
 | 
				
			||||||
pa_proplist_to_string;
 | 
					pa_proplist_to_string;
 | 
				
			||||||
 | 
					pa_proplist_to_string_sep;
 | 
				
			||||||
pa_proplist_unset;
 | 
					pa_proplist_unset;
 | 
				
			||||||
pa_proplist_unset_many;
 | 
					pa_proplist_unset_many;
 | 
				
			||||||
pa_proplist_update;
 | 
					pa_proplist_update;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -259,21 +259,24 @@ const char *pa_proplist_iterate(pa_proplist *p, void **state) {
 | 
				
			||||||
    return prop->key;
 | 
					    return prop->key;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char *pa_proplist_to_string(pa_proplist *p) {
 | 
					char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep) {
 | 
				
			||||||
    const char *key;
 | 
					    const char *key;
 | 
				
			||||||
    void *state = NULL;
 | 
					    void *state = NULL;
 | 
				
			||||||
    pa_strbuf *buf;
 | 
					    pa_strbuf *buf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_assert(p);
 | 
					    pa_assert(p);
 | 
				
			||||||
 | 
					    pa_assert(sep);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    buf = pa_strbuf_new();
 | 
					    buf = pa_strbuf_new();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while ((key = pa_proplist_iterate(p, &state))) {
 | 
					    while ((key = pa_proplist_iterate(p, &state))) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
        const char *v;
 | 
					        const char *v;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!pa_strbuf_isempty(buf))
 | 
				
			||||||
 | 
					            pa_strbuf_puts(buf, sep);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ((v = pa_proplist_gets(p, key)))
 | 
					        if ((v = pa_proplist_gets(p, key)))
 | 
				
			||||||
            pa_strbuf_printf(buf, "%s = \"%s\"\n", key, v);
 | 
					            pa_strbuf_printf(buf, "%s = \"%s\"", key, v);
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
            const void *value;
 | 
					            const void *value;
 | 
				
			||||||
            size_t nbytes;
 | 
					            size_t nbytes;
 | 
				
			||||||
| 
						 | 
					@ -283,7 +286,7 @@ char *pa_proplist_to_string(pa_proplist *p) {
 | 
				
			||||||
            c = pa_xmalloc(nbytes*2+1);
 | 
					            c = pa_xmalloc(nbytes*2+1);
 | 
				
			||||||
            pa_hexstr((const uint8_t*) value, nbytes, c, nbytes*2+1);
 | 
					            pa_hexstr((const uint8_t*) value, nbytes, c, nbytes*2+1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            pa_strbuf_printf(buf, "%s = hex:%s\n", key, c);
 | 
					            pa_strbuf_printf(buf, "%s = hex:%s", key, c);
 | 
				
			||||||
            pa_xfree(c);
 | 
					            pa_xfree(c);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -291,6 +294,16 @@ char *pa_proplist_to_string(pa_proplist *p) {
 | 
				
			||||||
    return pa_strbuf_tostring_free(buf);
 | 
					    return pa_strbuf_tostring_free(buf);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char *pa_proplist_to_string(pa_proplist *p) {
 | 
				
			||||||
 | 
					    char *s, *t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    s = pa_proplist_to_string_sep(p, "\n");
 | 
				
			||||||
 | 
					    t = pa_sprintf_malloc("%s\n", s);
 | 
				
			||||||
 | 
					    pa_xfree(s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return t;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Remove all whitepsapce from the beginning and the end of *s. *s may
 | 
					/* Remove all whitepsapce from the beginning and the end of *s. *s may
 | 
				
			||||||
 * be modified. (from conf-parser.c) */
 | 
					 * be modified. (from conf-parser.c) */
 | 
				
			||||||
#define WHITESPACE " \t\n"
 | 
					#define WHITESPACE " \t\n"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -213,12 +213,19 @@ int pa_proplist_unset_many(pa_proplist *p, const char * const keys[]);
 | 
				
			||||||
 * have any particular order. \since 0.9.11 */
 | 
					 * have any particular order. \since 0.9.11 */
 | 
				
			||||||
const char *pa_proplist_iterate(pa_proplist *p, void **state);
 | 
					const char *pa_proplist_iterate(pa_proplist *p, void **state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Format the property list nicely as a human readable string. Call pa_xfree() on the result. \since
 | 
					/** Format the property list nicely as a human readable string. This
 | 
				
			||||||
 * 0.9.11 */
 | 
					 * works very much like pa_proplist_to_string_sep() and uses a newline
 | 
				
			||||||
 | 
					 * as seperator and appends one final one. Call pa_xfree() on the
 | 
				
			||||||
 | 
					 * result. \since 0.9.11 */
 | 
				
			||||||
char *pa_proplist_to_string(pa_proplist *p);
 | 
					char *pa_proplist_to_string(pa_proplist *p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Allocate a new property list and assign key/value from a human readable string. \since
 | 
					/** Format the property list nicely as a human readable string and
 | 
				
			||||||
 | 
					 * choose the seperator. Call pa_xfree() on the result. \since
 | 
				
			||||||
 * 0.9.15 */
 | 
					 * 0.9.15 */
 | 
				
			||||||
 | 
					char *pa_proplist_to_string_sep(pa_proplist *p, const char *sep);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** Allocate a new property list and assign key/value from a human
 | 
				
			||||||
 | 
					 * readable string. \since 0.9.15 */
 | 
				
			||||||
pa_proplist *pa_proplist_from_string(const char *str);
 | 
					pa_proplist *pa_proplist_from_string(const char *str);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /** Returns 1 if an entry for the specified key is existant in the
 | 
					  /** Returns 1 if an entry for the specified key is existant in the
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue