50 lines
1.3 KiB
C
50 lines
1.3 KiB
C
#ifndef STRING_H
|
|
#define STRING_H
|
|
|
|
/*
|
|
* string_copy - Allocate and copy a string
|
|
* @src: Source string to copy
|
|
*
|
|
* Returns: Newly allocated copy of src, or NULL on failure.
|
|
* Caller must free the returned pointer.
|
|
*/
|
|
char *string_copy(const char *src);
|
|
|
|
/*
|
|
* string_compare - Compare two strings
|
|
* @str1: First string
|
|
* @str2: Second string
|
|
*
|
|
* Returns: 0 if equal, negative if str1 < str2, positive if str1 > str2.
|
|
*/
|
|
int string_compare(const char *str1, const char *str2);
|
|
|
|
/*
|
|
* string_trim - Allocate and return a trimmed copy of a string
|
|
* @str: String to trim
|
|
*
|
|
* Returns: Newly allocated copy of str with leading and trailing whitespace
|
|
* removed, or NULL on failure. Caller must free the returned pointer.
|
|
*/
|
|
char *string_trim(const char *str);
|
|
|
|
/*
|
|
* string_search - Search if a string contains a different string.
|
|
* @src: Source string to search
|
|
* @search: String to search for
|
|
*
|
|
* Returns: -1 if not found, zero-based index of the searched string if found.
|
|
* Returns -1 if search string is empty or NULL.
|
|
*/
|
|
int string_search(const char *src, const char *search);
|
|
|
|
/*
|
|
* string_free - Free a string allocated by string functions
|
|
* @str: String to free (NULL-safe)
|
|
*
|
|
* Safe to call with NULL; does nothing in that case.
|
|
*/
|
|
void string_free(const char *str);
|
|
|
|
#endif
|