/*
 * This method gets called when user tapped tab key.
 * line - points to command line
 * len - size of line that should be used for completions. This should be
 *   cursor position during tab hit.
 */
void process_tab(const char *line, int len)
{
	int argc;
	static split_arg_t buf[(LINE_BUF_MAX * 2) / sizeof(split_arg_t)];
	const struct method *method;

	argc = split_command(line, len, buf, sizeof(buf));
	tab_hit_count++;

	if (argc == 0)
		return;

	if (argc == 1) {
		command_completion(buf);
		return;
	}

	method = get_command(buf[0].ntcopy);
	if (method != NULL) {
		param_completion(argc, buf, method, 1);
	} else if (argc == 2) {
		method_completion(get_interface(buf[0].ntcopy), buf);
	} else {
		/* Find method for <interface, name> pair */
		method = get_interface_method(buf[0].ntcopy,
							buf[0].next->ntcopy);
		param_completion(argc, buf, method, 2);
	}
}
Exemple #2
0
static void init(void)
{
	static const char * const inames[] = {
		BT_PROFILE_HANDSFREE_ID,
		BT_PROFILE_ADVANCED_AUDIO_ID,
		BT_PROFILE_AV_RC_ID,
		BT_PROFILE_HEALTH_ID,
		BT_PROFILE_HIDHOST_ID,
		BT_PROFILE_PAN_ID,
		BT_PROFILE_GATT_ID,
		BT_PROFILE_SOCKETS_ID
	};
	const struct method *m;
	const char *argv[4];
	char init_audio[] = "audio init";
	char init_sco[] = "sco init";
	char init_bt[] = "bluetooth init";
	uint32_t i;

	process_line(init_audio);
	process_line(init_sco);
	process_line(init_bt);

	m = get_interface_method("bluetooth", "get_profile_interface");

	for (i = 0; i < NELEM(inames); ++i) {
		argv[2] = inames[i];
		m->func(3, argv);
	}

	/* Init what is available to init */
	for (i = 2; i < NELEM(interfaces) - 1; ++i) {
		m = get_interface_method(interfaces[i]->name, "init");
		if (m != NULL)
			m->func(2, argv);
	}
}