Implementation of the supporting functions for the StringList structure that works with a list of allocated strings. More...
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include "strdup.h"
#include "stringlist.h"
Go to the source code of this file.
Functions | |
void | StringList_Initialize (StringList *stringList) |
Initialize the given string list. | |
void | StringList_Clear (StringList *stringList) |
Clear the specified string list. All strings in the list are released. The string list can then be used to add new strings. | |
bool | StringList_AddString (StringList *stringList, const char *string) |
Add a string to the given string list. | |
bool | StringList_AddStrings (StringList *stringList, const char **strings, size_t numStrings) |
Add an array of strings to the given string list. | |
void | StringList_Remove (StringList *stringList, int removeIndex) |
Remove the specified string from the given string list. | |
int | StringList_Find (StringList *stringList, const char *string) |
Search the given string list for the given string. If found, return the index of the found string. | |
Implementation of the supporting functions for the StringList structure that works with a list of allocated strings.
Definition in file stringlist.c.
bool StringList_AddString | ( | StringList * | stringList, |
const char * | string | ||
) |
Add a string to the given string list.
stringList | A pointer to a StringList representing the list of strings. |
string | The string to add to the list. The string is duplicated and appended to the list. |
Definition at line 49 of file stringlist.c.
References STRDUP.
Referenced by Group_AddUser(), Group_GetAllUsers(), Groups_GetAllGroups(), Groups_GetGroupsWithUser(), ParseOptions(), and Users_GetAllUsers().
bool StringList_AddStrings | ( | StringList * | stringList, |
const char ** | strings, | ||
size_t | numStrings | ||
) |
Add an array of strings to the given string list.
stringList | A pointer to a StringList representing the list of strings. |
strings | Pointer to an array of strings to add to the list. The strings are duplicated and appended to the list. |
numStrings | Number of strings in the strings parameter to add. |
Definition at line 90 of file stringlist.c.
References STRDUP.
void StringList_Clear | ( | StringList * | stringList | ) |
Clear the specified string list. All strings in the list are released. The string list can then be used to add new strings.
stringList | The StringList to clear. |
Definition at line 30 of file stringlist.c.
References StringList_Initialize().
Referenced by _Mediator_Example_AddUserToGroup(), _Mediator_Example_RemoveUser(), _Mediator_Example_RemoveUserFromAllGroups(), _Mediator_Example_RemoveUserFromGroup(), _Mediator_Example_ShowAllGroups(), _Mediator_Example_ShowAllGroupsContainingUser(), _Mediator_Example_ShowAllUsers(), _Mediator_Example_ShowUsersInGroup(), Group_Destroy(), and main().
int StringList_Find | ( | StringList * | stringList, |
const char * | string | ||
) |
Search the given string list for the given string. If found, return the index of the found string.
stringList | A pointer to a StringList representing the list of string to search. |
string | The string to search for. |
Definition at line 157 of file stringlist.c.
Referenced by Group_FindUser(), and main().
void StringList_Initialize | ( | StringList * | stringList | ) |
Initialize the given string list.
stringList | Pointer to a StringList structure that is to be initialized. Cannot be NULL |
Definition at line 17 of file stringlist.c.
Referenced by Group_Create(), main(), and StringList_Clear().
void StringList_Remove | ( | StringList * | stringList, |
int | removeIndex | ||
) |
Remove the specified string from the given string list.
stringList | A pointer to a StringList representing the list of strings. |
removeIndex | Index of the string to remove from the list. Call StringList_Find() to get the index. |
Definition at line 137 of file stringlist.c.
Referenced by Group_RemoveUser().