src/common/string.c
/**
 * Search a string for a specific char
 *
 * Once the char has been found place the index position inside a provided
 * destination pointer
 *
 * If a valid index is found return NO_ERROR otherwise an error will be returned
 */
Search a string for a specific char
Once the char has been found place the index position inside a provided
destination pointer

If a valid index is found return NO_ERROR otherwise an error will be returned
Search a string for a specific char Once the char has been found place the index position inside a provided destination pointer If a valid index is found return NO_ERROR otherwise an error will be returned
enum natwm_error string_find_char(const char *haystack, char needle, size_t *index_dest)
{
        if (haystack == NULL) {
                return INVALID_INPUT_ERROR;
        }
        char ch = '\0';
        size_t index = 0;
        while ((ch = haystack[index]) != '\0' && ch != needle) {
                ++index;
        }
        if (ch == '\0') {
                return NOT_FOUND_ERROR;
        }
        SET_IF_NON_NULL(index_dest, index);
        return NO_ERROR;
}
enum natwm_error string_find_char ( const char * haystack , char needle , size_t * index_dest ) { if ( haystack == NULL ) { return INVALID_INPUT_ERROR ; } char ch = ' \0 ' ; size_t index = 0 ; while ( ( ch = haystack [ index ] ) != ' \0 ' && ch != needle ) { ++ index ; } if ( ch == ' \0 ' ) { return NOT_FOUND_ERROR ; } SET_IF_NON_NULL ( index_dest , index ) ; return NO_ERROR ; }
Search a string for a specific char
 Once the char has been found place the index position inside a provided
 destination pointer
Search a string for a specific char Once the char has been found place the index position inside a provided destination pointer