1、在strings中查找key的位置
来源:
BusyBox-1.37.0 index_in_strings()
数据结构:
static const char keywords[] __attribute__((aligned(1))) = "bs\0""count\0""seek\0""skip\0""if\0""of\0";
算法:
int index_in_strings(const char *strings, const char *key)
{
int j, idx = 0;
while(*strings)
{
/* Do we see "key\0" at current position in strings? */
for(j = 0; *strings == key[j]; ++j)
{
if(*strings++ == '\0')
{
return idx; /* yes */
}
}
/* No. Move to the start of the next string. */
while(*strings++ != '\0')
{
continue;
}
idx++;
}
return -1;
}