AoSearchString()

Updated: April 19, 2023

Check if a given value is in the given list of strings

Synopsis:

#include <aoi.h>

int AoSearchString(const char *list, 
                   const char *val, 
                   size_t val_len, 
                   unsigned flags);

Arguments:

list
A NULL-terminated, comma-separated list of strings to search, stored in one character buffer. Individual strings may be encoded in plain text or hexadecimal format; in the latter case, the string begins with \x or \X.

This buffer can contain an addon string setting that was retrieved by AoFindString().

val
A value, stored in a character buffer, to search for in the list of strings. The value can be a character string (text) or a numeric or binary value. It doesn't have to be NULL-terminated and can contain NUL (\0) characters.
val_len
The length (in bytes) of the value buffer.
flags
A bitfield of flags to configure the search. Currently, only AO_STRING_IGNORE_CASE is supported.

Library:

libaoi.so

Description:

This function searches for a representation of the given value (val) in the given list of strings (list). This offers a convenient way of looking through many strings in a list and determining if any match the search value based on either its exact character sequence or its hexadecimal representation (e.g., a list string of "\x4E4C" will match a search value of "NL"). The function also supports case-insensitive search for character string values.

Returns:

1 if a match for the value is found, 0 if it's not.

Example:

An example of using AoSearchString() to check if a given value is in a string setting read from an addon's Strings interface is given in the AoIterate() entry.