Ejemplo n.º 1
0
Archivo: ini.c Proyecto: rxi/ini
const char* ini_get(ini_t *ini, const char *section, const char *key) {
  char *current_section = "";
  char *val;
  char *p = ini->data;

  if (*p == '\0') {
    p = next(ini, p);
  }

  while (p < ini->end) {
    if (*p == '[') {
      /* Handle section */
      current_section = p + 1;

    } else {
      /* Handle key */
      val = next(ini, p);
      if (!section || !strcmpci(section, current_section)) {
        if (!strcmpci(p, key)) {
          return val;
        }
      }
      p = val;
    }

    p = next(ini, p);
  }

  return NULL;
}
Ejemplo n.º 2
0
static long string_ci_compare(object s1, object s2) {
	TYPE_CHECK(STRING_P(s1),1,"string",s1);
	TYPE_CHECK(STRING_P(s2),2,"string",s2);
	return strcmpci(STRING_VALUE(s1), STRING_VALUE(s2));
}