XMMS2
Functions
strlist.c File Reference

Functions for working with lists/arrays of strings. More...

#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <xmmsc/xmmsc_strlist.h>

Functions

char ** xmms_valist_to_strlist (const char *first, va_list ap)
 Convert a list of variable arguments into a list of strings. More...
 
char ** xmms_vargs_to_strlist (const char *first,...)
 Convert a variable number of arguments into a list of strings. More...
 
int xmms_strlist_len (char **data)
 Get the number of strings in a list. More...
 
void xmms_strlist_destroy (char **data)
 Destroy a list of strings. More...
 
char ** xmms_strlist_prepend_copy (char **data, char *newstr)
 Return a copy of a list with newstr prepended. More...
 
char ** xmms_strlist_copy (char **strlist)
 Return a deep copy of a list. More...
 

Detailed Description

Functions for working with lists/arrays of strings.

All such lists are assumed to be NULL-terminated.

Function Documentation

char** xmms_strlist_copy ( char **  strlist)

Return a deep copy of a list.

Parameters
strlistThe original list.
Returns
A newly allocated list of strings.
void xmms_strlist_destroy ( char **  data)

Destroy a list of strings.

Equivalent to g_strfreev().

Parameters
dataThe list to destroy.

Referenced by xmms_build_path().

int xmms_strlist_len ( char **  data)

Get the number of strings in a list.

Note that the real length of the (char **) array will be larger by 1 element (containing the terminating NULL).

Parameters
dataThe list of strings
Returns
Number of strings

Referenced by xmms_strlist_copy(), and xmms_strlist_prepend_copy().

char** xmms_strlist_prepend_copy ( char **  data,
char *  newstr 
)

Return a copy of a list with newstr prepended.

Parameters
dataThe original list.
newstrThe string to prepend.
Returns
A newly allocated list of strings.

Referenced by xmms_build_path().

char** xmms_valist_to_strlist ( const char *  first,
va_list  ap 
)

Convert a list of variable arguments into a list of strings.

Note: Assumes that the arguments provided are all strings.

Parameters
firstThe first string. Cannot be NULL.
apList of variable arguments.
Returns
A newly allocated list of strings.

Referenced by xmms_build_path(), and xmms_vargs_to_strlist().

char** xmms_vargs_to_strlist ( const char *  first,
  ... 
)

Convert a variable number of arguments into a list of strings.

Note: Assumes that the arguments provided are all strings.

Parameters
firstThe first string. Cannot be NULL.
...Variable number of strings.
Returns
A newly allocated list of strings.