A list of strings


Functions

StringList_t * slCreate (void)
 Create a string list "object".
void slDelete (StringList_t *list)
 Delete string list object.
int slGetNumEntries (StringList_t *list)
 Return number of entries.
int slAddEntry (StringList_t *list, const char *string)
 Adds a String to the end of the list.
char * slGetEntry (StringList_t *list, int index)
 Returns an entry of the list.
int slRemoveEntry (StringList_t *list, int index)
 Removes a String to the list.
int slFreeEntry (StringList_t *list, int index)
 Removes a String to the list and frees the string's memory.

Detailed Description

Implements a list of char* Strings

Function Documentation

StringList_t* slCreate ( void   ) 

Create a string list "object".

Returns:
A pointer to an "object" structure containing all necessary information, or NULL in case of error and errno will be set

void slDelete ( StringList_t *  list  ) 

Delete string list object.

Parameters:
list Pointer to the string list "object" structure

int slGetNumEntries ( StringList_t *  list  ) 

Return number of entries.

Parameters:
list Pointer to the string list "object" structure

int slAddEntry ( StringList_t *  list,
const char *  string 
)

Adds a String to the end of the list.

Parameters:
list Pointer to the list "object" structure
string The String to be saved
Returns:
Returns 0 if successfull, -1 in case of error and errno will be set:
  • EOVERFLOW: List overflow, there are too many entries in list
  • ENOMEM: Not enough memory to allocate string
Note:
This function creates a deep copy of the string.

char* slGetEntry ( StringList_t *  list,
int  index 
)

Returns an entry of the list.

Parameters:
list Pointer to the list "object" structure
index The index in the list. If index is negative, the index is counted backwars, i.e. -1 is the last string
Returns:
A pointer to the string if successfull, or NULL in case of error (and errno will be set).

int slRemoveEntry ( StringList_t *  list,
int  index 
)

Removes a String to the list.

Parameters:
list Pointer to the StringList_t "object" structure
index The index in the list to be removed. If index is negative, the index is counted backwars, i.e. -1 is the last string
Returns:
Returns the new number of elements in the list (can be 0) if successfull. In case of error, -1 is returned and errno willbe set.
Note:
The memory allocated for the string will not be freed. Please use free() to do this if you no longer need the string. The liFreeEntry() function is provided to remove an entry and automatically free the memory used.

int slFreeEntry ( StringList_t *  list,
int  index 
)

Removes a String to the list and frees the string's memory.

Parameters:
list Pointer to the StringList_t "object" structure
index The index in the list to be removed. If index is negative, the index is counted backwars, i.e. -1 is the last string
Returns:
Returns the new number of elements in the list (can be 0) if successfull. In case of error, -1 is returned and errno willbe set.


Generated by
doxygen
SourceForge.net Logo