Esempio n. 1
0
bool IniSetting::ResetSystemDefault(const std::string& name) {
  auto it = s_system_settings.find(name);
  if (it == s_system_settings.end()) {
    return false;
  }
  return ini_set(name, it->second, PHP_INI_SET_EVERY);
}
Esempio n. 2
0
int main(void)
{
	struct ini * ini = ini_new();
	assert(ini != NULL);
	
	FILE * fid = stdin;
	assert(fid != NULL);
	int res = ini_read(ini, fid);
	fclose(fid);
	
	assert(res == 0);
	
	ini_set(ini, "aa", "pswd", "1234");
	ini_set(ini, "aa", "pswd", "1234");
	ini_write(ini, stdout);
	ini_del(ini);
	return 0;
}
Esempio n. 3
0
bool IniSetting::SetSystem(const String& name, const Variant& value) {
  // Shouldn't be calling this function after the runtime options are loaded.
  assert(!s_system_settings_are_set);
  // Since we're going to keep these settings for the lifetime of the program,
  // we need to make them static.
  Variant eval_scalar_variant = value;
  eval_scalar_variant.setEvalScalar();
  s_system_settings[name.toCppString()] = eval_scalar_variant;
  return ini_set(name.toCppString(), value, PHP_INI_SET_EVERY);
}
Esempio n. 4
0
bool IniSetting::SetUser(const String& nameString, const String& value) {
  auto name = nameString.toCppString();
  auto it = s_savedDefaults->find(name);
  if (it == s_savedDefaults->end()) {
    Get(name, (*s_savedDefaults)[name]);
  }
  return ini_set(nameString, value, static_cast<Mode>(
    PHP_INI_USER | PHP_INI_ALL
  ));
}
Esempio n. 5
0
bool IniSetting::SetUser(const String& name, const Variant& value) {
  auto it = s_saved_defaults->find(name.toCppString());
  if (it == s_saved_defaults->end()) {
    Variant def;
    auto success = Get(name, def); // def gets populated here
    if (success) {
      (*s_saved_defaults)[name.toCppString()] = def;
    }
  }
  return ini_set(name.toCppString(), value, PHP_INI_SET_USER);
}
Esempio n. 6
0
bool IniSetting::SetUser(const std::string& name, const folly::dynamic& value,
                         FollyDynamic) {
  auto it = s_saved_defaults->find(name);
  if (it == s_saved_defaults->end()) {
    folly::dynamic def = nullptr;
    auto success = Get(name, def);
    if (success) {
      s_saved_defaults->insert(make_pair(name, def));
    }
  }
  return ini_set(name, value, PHP_INI_SET_USER);
}
Esempio n. 7
0
bool IniSetting::Set(const std::string& name, const folly::dynamic& value,
                     FollyDynamic) {
  // Need to make sure to update the value if the pair exists already
  // A general insert(make_pair) won't actually update new values.
  bool found = false;
  for (auto& pair : s_system_settings) {
    if (pair.first == name) {
      pair.second = value;
      found = true;
      break;
    }
  }
  if (!found) {
    s_system_settings.insert(make_pair(name, value));
  }
  return ini_set(name, value, PHP_INI_SET_EVERY);
}
Esempio n. 8
0
bool IniSetting::SetUser(const String& name, const String& value) {
  return ini_set(name, value, static_cast<Mode>(
    PHP_INI_USER | PHP_INI_ALL
  ));
}
Esempio n. 9
0
bool IniSetting::Set(const String& name, const String& value) {
  return ini_set(name, value, static_cast<Mode>(
    PHP_INI_ONLY | PHP_INI_SYSTEM | PHP_INI_PERDIR | PHP_INI_USER | PHP_INI_ALL
  ));
}
Esempio n. 10
0
void IniSetting::ResetSavedDefaults() {
  for (auto& item : *s_saved_defaults) {
    ini_set(item.first, item.second, PHP_INI_SET_USER);
  }
  s_saved_defaults->clear();
}
Esempio n. 11
0
bool IniSetting::Set(const std::string& name, const folly::dynamic& value,
                     FollyDynamic) {
    return ini_set(name, value, static_cast<Mode>(
                       PHP_INI_ONLY | PHP_INI_SYSTEM | PHP_INI_PERDIR | PHP_INI_USER | PHP_INI_ALL
                   ));
}
Esempio n. 12
0
extern int ini_load(ini_t * self)
{
	char *line;
	char *section;
	char *var, *value;
	int nread;
	size_t n;
	FILE *file;

	assert(self);

	file = fopen(self->filepath, "r");

	if (!file)
		return -1;

	section = NULL;

	line = NULL;

	while ((nread = getline(&line, &n, file)) >= 0) {
		*(line + strlen(line) - 1) = 0;
		strtrim(line);

		if (!strlen(line) || *line == '#') {
			continue;
		}

		eatcomments(line);

		if (*line == '[') {
			free(section);
			section = xmalloc(strlen(line) - 1);
			memset(section, 0, strlen(line) - 1);
			strncpy(section, line + 1, strlen(line) - 2);
			ini_add(self, strtrim(section));
			continue;
		}

		if (!section)
			continue;
		value = NULL;
		value = strchr(line, '=');

		if (!value)
			continue;

		var = xmalloc(strlen(line) - strlen(value) + 1);
		memset(var, 0, strlen(line) - strlen(value) + 1);
		strncpy(var, line, strlen(line) - strlen(value) - 1);
		++value;
		strtrim(value);
		if (*value == '"' && *(value + strlen(value) - 1) == '"') {
			*(value + strlen(value) - 1) = 0;
			value++;
		}
		ini_set(self, section, strtrim(var), strtrim(value));
		free(var);
	}
	free(line);
	free(section);
	fclose(file);

	return 0;
}
Esempio n. 13
0
bool IniSetting::Set(const std::string& name, const folly::dynamic& value,
                     FollyDynamic) {
  s_system_settings.insert(make_pair(name, value));
  return ini_set(name, value, PHP_INI_SET_EVERY);
}
Esempio n. 14
0
int ini_set_int(INI *pini,const char *key,int value)
{
	char buffer[VINT_LEN];
	sprintf(buffer,"%d\0",value);
	return ini_set(pini,key,buffer);
}