/* Split 'str' into strings separated by commas. Note: out points into 'str'.  */
static bool split_str(char *str, char ***out, size_t *count)
/* Split 'str' into strings separated by commas. Note: out points into 'str'.  */
static bool split_str(char *str, char ***out, size_t *count)
{
  char **res;
  char *lasts;
  char *s;
  size_t  i;
  size_t items = 1;
  s = strchr(str, ',');
  while(s) {
    items++;
    s = strchr(++s, ',');
  }
  res = calloc(items, sizeof(char *));
  if(!res)
    return FALSE;
  for(i = 0, s = strtok_r(str, ",", &lasts); s && i < items;
      s = strtok_r(NULL, ",", &lasts), i++)
    res[i] = s;
  *out = res;
  *count = items;
  return TRUE;
}