示例#1
0
文件: route.c 项目: GGGO/asterisk
void sip_route_process_header(struct sip_route *route, const char *header, int inserthead)
{
	const char *hop;
	int len = 0;
	const char *uri;

	if (!route) {
		ast_log(LOG_ERROR, "sip_route_process_header requires non-null route");
		ast_do_crash();
		return;
	}

	while (!get_in_brackets_const(header, &uri, &len)) {
		header = strchr(header, ',');
		if (header >= uri && header <= (uri + len)) {
			/* comma inside brackets */
			const char *next_br = strchr(header, '<');
			if (next_br && next_br <= (uri + len)) {
				header++;
				continue;
			}
			continue;
		}
		if ((hop = sip_route_add(route, uri, len, inserthead))) {
			ast_debug(2, "sip_route_process_header: <%s>\n", hop);
		}
		header = strchr(uri + len + 1, ',');
		if (header == NULL) {
			/* No more field-values, we're done with this header */
			break;
		}
		/* Advance past comma */
		header++;
	}
}
void ast_optional_api_unuse(const char *symname, ast_optional_fn *optional_ref,
	const char *module)
{
	struct optional_api *api;
	size_t i;

	api = get_api(symname);
	if (!api) {
		ast_log(LOG_ERROR, "%s: Could not find api\n", symname);
		ast_do_crash();
		return;
	}

	for (i = 0; i < api->users_len; ++i) {
		struct optional_api_user *user = api->users[i];

		if (user->optional_ref == optional_ref) {
			if (*user->optional_ref != user->stub) {
				*user->optional_ref = user->stub;
			}

			/* Remove from the list */
			api->users[i] = api->users[--api->users_len];

			optional_api_user_destroy(user);
			return;
		}
	}

	ast_log(LOG_ERROR, "%s: Could not find user %s\n", symname, module);
}
示例#3
0
文件: astmm.c 项目: litnimax/asterisk
/*!
 * \internal
 *
 * \note If DO_CRASH is not defined then the function returns.
 *
 * \return Nothing
 */
static void my_do_crash(void)
{
	/*
	 * Give the logger a chance to get the message out, just in case
	 * we abort(), or Asterisk crashes due to whatever problem just
	 * happened.
	 */
	usleep(1);
	ast_do_crash();
}
void ast_optional_api_use(const char *symname, ast_optional_fn *optional_ref,
	ast_optional_fn stub, const char *module)
{
	struct optional_api_user *user;
	struct optional_api *api;


	api = get_api(symname);
	if (!api) {
		ast_log(LOG_ERROR, "%s: Allocation failed\n", symname);
		ast_do_crash();
		return;
	}

	user = optional_api_user_create(optional_ref, stub, module);
	if (!user) {
		ast_log(LOG_ERROR, "%s: Allocation failed\n", symname);
		ast_do_crash();
		return;
	}

	/* Add user to the API */
	if (api->users_len + 1 > api->users_maxlen) {
		size_t new_maxlen = api->users_maxlen ? 2 * api->users_maxlen : 1;
		struct optional_api_user **new_list;

		new_list = ast_std_realloc(api->users, new_maxlen * sizeof(*new_list));
		if (!new_list) {
			optional_api_user_destroy(user);
			ast_log(LOG_ERROR, "Failed to allocate api list\n");
			ast_do_crash();
			return;
		}

		api->users_maxlen = new_maxlen;
		api->users = new_list;
	}

	api->users[api->users_len++] = user;

	optional_api_user_relink(user, api);
}
void ast_optional_api_unprovide(const char *symname, ast_optional_fn impl)
{
	struct optional_api *api;

	api = get_api(symname);
	if (!api) {
		ast_log(LOG_ERROR, "%s: Could not find api\n", symname);
		ast_do_crash();
		return;
	}

	optional_api_set_impl(api, 0);
}
void ast_optional_api_provide(const char *symname, ast_optional_fn impl)
{
	struct optional_api *api;

	api = get_api(symname);
	if (!api) {
		ast_log(LOG_ERROR, "%s: Allocation failed\n", symname);
		ast_do_crash();
		return;
	}

	optional_api_set_impl(api, impl);
}