- Add scconf_list_toarray() by Jamie Honan
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1617 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
0b7b3dff9c
commit
c13a417d8b
|
@ -366,6 +366,30 @@ int scconf_list_strings_length(const scconf_list * list)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char **scconf_list_toarray(const scconf_list * list)
|
||||||
|
{
|
||||||
|
const scconf_list * lp = list;
|
||||||
|
const char **tp;
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
|
while (lp) {
|
||||||
|
len++;
|
||||||
|
lp = lp->next;
|
||||||
|
}
|
||||||
|
tp = (const char **)malloc(sizeof(char *) * (len + 1));
|
||||||
|
if (!tp)
|
||||||
|
return tp;
|
||||||
|
lp = list;
|
||||||
|
len = 0;
|
||||||
|
while (lp) {
|
||||||
|
tp[len] = lp->data;
|
||||||
|
len++;
|
||||||
|
lp = lp->next;
|
||||||
|
}
|
||||||
|
tp[len] = NULL;
|
||||||
|
return tp;
|
||||||
|
}
|
||||||
|
|
||||||
char *scconf_list_strdup(const scconf_list * list, const char *filler)
|
char *scconf_list_strdup(const scconf_list * list, const char *filler)
|
||||||
{
|
{
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
|
|
|
@ -213,6 +213,13 @@ extern int scconf_list_strings_length(const scconf_list * list);
|
||||||
*/
|
*/
|
||||||
extern char *scconf_list_strdup(const scconf_list * list, const char *filler);
|
extern char *scconf_list_strdup(const scconf_list * list, const char *filler);
|
||||||
|
|
||||||
|
/* Returns an allocated array of const char *pointers to
|
||||||
|
* list elements.
|
||||||
|
* Last pointer is NULL
|
||||||
|
* Array must be freed, but pointers to strings belong to scconf_list
|
||||||
|
*/
|
||||||
|
extern const char **scconf_list_toarray(const scconf_list * list);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue