Exemplo n.º 1
0
static int id2db_url(int id, int require_raw_query, int is_async,
		struct db_url** url)
{

	*url = get_db_url((unsigned int)id);
	if (*url==NULL) {
		LM_ERR("no db_url with id <%d>\n", id);
		return E_CFG;
	}

	/*
	 * Since mod_init() is run before function fixups, all DB structs
	 * are initialized and all DB capabilities are populated
	 */
	if (require_raw_query && !DB_CAPABILITY((*url)->dbf, DB_CAP_RAW_QUERY)) {
		LM_ERR("driver for DB URL [%u] does not support raw queries\n",
				(unsigned int)id);
		return -1;
	}

	if (is_async && !DB_CAPABILITY((*url)->dbf, DB_CAP_ASYNC_RAW_QUERY))
		LM_WARN("async() calls for DB URL [%u] will work "
		        "in normal mode due to driver limitations\n",
				(unsigned int)id);

	return 0;
}
Exemplo n.º 2
0
static int fixup_db_url(void ** param)
{
	struct db_url* url;
	unsigned int ui;
	str s;

	s.s = (char*)*param;
	s.len = strlen(s.s);

	if(str2int(&s, &ui)!=0) {
		LM_ERR("bad db_url number <%s>\n", (char *)(*param));
		return E_CFG;
	}

	url = get_db_url(ui);
	if (url==NULL) {
		LM_ERR("no db_url with id <%s>\n", (char *)(*param));
		return E_CFG;
	}
	pkg_free(*param);
	*param=(void *)url;
	return 0;
}
Exemplo n.º 3
0
static int fixup_db_url(void ** param, int require_raw_query, int is_async)
{
	struct db_url* url;
	unsigned int ui;
	str s;

	s.s = (char*)*param;
	s.len = strlen(s.s);

	if(str2int(&s, &ui)!=0) {
		LM_ERR("bad db_url number <%s>\n", (char *)(*param));
		return E_CFG;
	}

	url = get_db_url(ui);
	if (url==NULL) {
		LM_ERR("no db_url with id <%s>\n", (char *)(*param));
		return E_CFG;
	}

	/*
	 * Since mod_init() is run before function fixups, all DB structs
	 * are initialized and all DB capabilities are populated
	 */
	if (require_raw_query && !DB_CAPABILITY(url->dbf, DB_CAP_RAW_QUERY)) {
		LM_ERR("driver for DB URL [%u] does not support raw queries\n", ui);
		return -1;
	}

	if (is_async && !DB_CAPABILITY(url->dbf, DB_CAP_ASYNC_RAW_QUERY))
		LM_WARN("async() calls for DB URL [%u] will work "
		        "in normal mode due to driver limitations\n", ui);

	pkg_free(*param);
	*param=(void *)url;
	return 0;
}