コード例 #1
0
ファイル: UIStyleSettings.cpp プロジェクト: Prcuvu/weasel
bool UIStyleSettings::GetPresetColorSchemes(std::vector<ColorSchemeInfo>* result) {
	if (!result) return false;
	result->clear();
	RimeConfig config = {0};
	api_->settings_get_config(settings_, &config);
	RimeApi* rime = rime_get_api();
	RimeConfigIterator preset = {0};
	if (!rime->config_begin_map(&preset, &config, "preset_color_schemes")) {
		return false;
	}
	while (rime->config_next(&preset)) {
		std::string name_key(preset.path);
		name_key += "/name";
		const char* name = rime->config_get_cstring(&config, name_key.c_str());
		std::string author_key(preset.path);
		author_key += "/author";
		const char* author = rime->config_get_cstring(&config, author_key.c_str());
		if (!name) continue;
		ColorSchemeInfo info;
		info.color_scheme_id = preset.key;
		info.name = name;
		if (author) info.author = author;
		result->push_back(info);
	}
	return true;
}
コード例 #2
0
ファイル: data.c プロジェクト: jeversmann/hacktxpebble
void put_entry(char *name, char *value) {
  // Get out the values at the master key
  uint32_t tmp[BUFFER_SIZE/4];
  persist_read_data(MASTER_KEY, tmp, BUFFER_SIZE);

  // Update the store with new stuff
  int key = next_key++;
  persist_write_string(name_key(key), name);
  persist_write_string(value_key(key), value);

  // Write back the master key's new value
  tmp[key] = key;
  persist_write_data(MASTER_KEY, tmp, BUFFER_SIZE);
}
コード例 #3
0
ファイル: command.c プロジェクト: matthiasbeyer/tasknc
void run_command_unbind(char *argstr) /* {{{ */
{
	/**
	 * unbind a key
	 * syntax - mode key
	 */
	char *modestr = NULL, *keystr = NULL, *keyname = NULL;
	prog_mode mode;
	int ret = 0;

	/* parse args */
	if (argstr != NULL)
		ret = sscanf(argstr, "%ms %m[^\n]", &modestr, &keystr);
	if (ret != 2)
	{
		statusbar_message(cfg.statusbar_timeout, "syntax: unbind <mode> <key>");
		tnc_fprintf(logfp, LOG_ERROR, "syntax: unbind <mode> <key> [%d](%s)", ret, argstr);
		goto cleanup;
	}

	/* parse mode */
	if (str_eq(modestr, "pager"))
		mode = MODE_PAGER;
	else if (str_eq(modestr, "tasklist"))
		mode = MODE_TASKLIST;
	else
		mode = MODE_ANY;

	int key = parse_key(keystr);

	remove_keybinds(key, mode);
	keyname = name_key(key);
	statusbar_message(cfg.statusbar_timeout, "key unbound: %s (%d)", keyname, key);
	goto cleanup;

cleanup:
	free(keyname);
	free(modestr);
	free(keystr);
	return;
} /* }}} */
コード例 #4
0
ファイル: test_i.cpp プロジェクト: asdlei00/ACE
CORBA::Boolean
inventory_i::getCDinfo (const char * artist,
                        char *& title,
                        CORBA::Float_out price)
{
  CORBA::Boolean in_stock = 0;
  price = 0.0f;
  ACE_CString name_key ("Beatles");
  ACE_CString name (artist);
  CORBA::String_var tmp = title;
  ACE_UNUSED_ARG (tmp);

  if (name.strstr (name_key) != ACE_CString::npos)
    {
      ACE_CString title_key ("Sgt. Pepper");
      ACE_CString working_title (title);

      if (working_title.strstr (title_key) != ACE_CString::npos)
        {
          title =
            CORBA::string_dup ("Sgt. Pepper's Lonely Hearts Club Band");

          price = 13.49f;

          in_stock = 1;
        }
      else
        {
          title = CORBA::string_dup ("not found");
        }
    }
  else
    {
      title = CORBA::string_dup ("not found");
    }

  return in_stock;
}
コード例 #5
0
ファイル: command.c プロジェクト: matthiasbeyer/tasknc
void run_command_bind(char *args) /* {{{ */
{
	/**
	 * create a new keybind
	 * syntax - mode key function [funcarg]
	 */
	int key, ret = 0;
	char *function = NULL, *arg = NULL, *keystr = NULL, *modestr = NULL, *keyname = NULL;
	void (*func)();
	funcmap *fmap;
	prog_mode mode;

	/* parse command */
	if (args != NULL)
		ret = sscanf(args, "%ms %ms %ms %m[^\n]", &modestr, &keystr, &function, &arg);
	if (ret < 3)
	{
		statusbar_message(cfg.statusbar_timeout, "syntax: bind <mode> <key> <function> <args>");
		tnc_fprintf(logfp, LOG_ERROR, "syntax: bind <mode> <key> <function> <args> [%d](%s)", ret, args);
		goto cleanup;
	}

	/* parse mode string */
	if (str_eq(modestr, "tasklist"))
		mode = MODE_TASKLIST;
	else if (str_eq(modestr, "pager"))
		mode = MODE_PAGER;
	else
	{
		tnc_fprintf(logfp, LOG_ERROR, "bind: invalid mode (%s)", modestr);
		goto cleanup;
	}

	/* parse key */
	key = parse_key(keystr);

	/* map function to function call */
	fmap = find_function(function, mode);
	if (fmap==NULL)
	{
		tnc_fprintf(logfp, LOG_ERROR, "bind: invalid function specified (%s)", args);
		goto cleanup;
	}
	func = fmap->function;

	/* error out if there is no argument specified when required */
	if (fmap->argn>0 && arg==NULL)
	{
		statusbar_message(cfg.statusbar_timeout, "bind: argument required for function %s", function);
		goto cleanup;
	}

	/* add keybind */
	add_keybind(key, func, arg, mode);
	keyname = name_key(key);
	statusbar_message(cfg.statusbar_timeout, "key %s (%d) bound to %s - %s", keyname, key, modestr, name_function(func));
	goto cleanup;

cleanup:
	free(function);
	free(arg);
	free(keystr);
	free(modestr);
	free(keyname);
	return;
} /* }}} */
コード例 #6
0
ファイル: data.c プロジェクト: jeversmann/hacktxpebble
void read_data_name(uint32_t key, char *buffer) {
  persist_read_string(name_key(key), buffer, BUFFER_SIZE);
}
コード例 #7
0
ファイル: Token.cpp プロジェクト: 12019/Antitoken
int Token::dump_container(DWORD id){
	int ret;
	vector<BYTE> v;
	char path[260],bid[20];
	
	char *header = "header.key",
		*masks = "masks.key",
		*primary = "primary.key",
		*name = "name.key",
		*pos;

	if ((ret = this->dump_name(v, id)) != 0){
		if (this->debug)
			cout << "[-] ERROR: dump_name returned: " << ret << endl;
		return ret;
	}
	memset(path, 0, 260);
	memset(bid, 0, 20);
	
	BYTE *tname = v.data();
	strncpy(path, (char *)(tname + 4), v.size() > 8 ? 4 : v.size() - 4);
	strcat(path, ".");
	strcat(path, itoa(id, bid, 10));
	CreateDirectory(path, NULL);
	if (this->debug) cout << "[*] CreateDirectory: " << path << endl; //DEBUG
	strcat(path, "\\");
	pos = path + strlen(path);

	strcpy(pos, name);
	ofstream name_key(path, ios::out | ios::binary);
	if (strlen(this->name) > 0){ // name specified
		int len = strlen(this->name);
		BYTE *b = new BYTE[len + 4];
		b[0] = 0x30;
		b[1] = len + 2;
		b[2] = 0x16;
		b[3] = len;
		for (int i = 0; i < len; i++)
			b[4 + i] = this->name[i];
		name_key << b;
		delete[] b;
	}
	else {
		if (v[4] == 'N') v[4] = 'M';
		else v[4] = 'N';
		name_key << v;
	}
	name_key.close();
	if(this->debug) cout << "[*] write name: " << path << endl; //DEBUG
	memset(pos, 0, strlen(name) + 1);

	strcpy(pos, header);
	ofstream header_key(path, ios::out | ios::binary);
	if ((ret = this->dump_header(v, id)) != 0){
		if (this->debug)
			cout << "[-] ERROR: dump_header returned: " << ret << endl;
		return ret;
	}
	header_key << v;
	header_key.close();
	if (this->debug) cout << "[*] write header: " << path << endl; //DEBUG
	memset(pos, 0, strlen(header) + 1);

	strcpy(pos, masks);
	ofstream masks_key(path, ios::out | ios::binary);
	if ((ret = this->dump_masks(v, id)) != 0){
		if (this->debug)
			cout << "[-] ERROR: dump_masks returned: " << ret << endl;
		return ret;
	}
	masks_key << v;
	masks_key.close();
	if (this->debug) cout << "[*] write masks: " << path << endl; //DEBUG
	memset(pos, 0, strlen(masks) + 1);
	
	strcpy(pos, primary);
	ofstream primary_key(path, ios::out | ios::binary);
	if ((ret = this->dump_primary(v, id)) != 0){
		if (this->debug)
			cout << "[=] ERROR: dump_primary returned: " << ret << endl;
		return ret;
	}
	primary_key << v;
	primary_key.close();
	if (this->debug) cout << "[*] write primary: " << path << endl; //DEBUG
	memset(pos, 0, strlen(primary) + 1);

	return 0;
}