예제 #1
0
파일: url_list.c 프로젝트: emabo/mulk
int add_new_url_and_check(const url_list_t *base_elem, const char *url, char **relative_url)
{
	UriUriA *uri = NULL;
	url_list_t *elem;

	if ((uri = create_absolute_uri(base_elem->uri, url)) == NULL)
		goto Rejected; 

	/* check protocol */
	if (!is_uri_http(uri) && (!option_values.follow_ftp || !is_uri_ftp(uri)))
		goto Rejected; 

	/* check domains */
	if (!is_host_compatible_with_domains(uri))
		goto Rejected; 

	if (!(elem = push_unique_uri(uri, base_elem->level + 1)))
		goto Rejected; 

	if (relative_url)
		*relative_url = extract_relative_url(elem->filename, base_elem->filename);

	return 0;

Rejected:
	uri_free(uri);
	return -1;
}
예제 #2
0
파일: url_list.c 프로젝트: emabo/mulk
mulk_type_return_t mulk_add_new_url(const char *url)
{
	UriUriA *new_uri = NULL;
#ifdef ENABLE_RECURSION
	char *host = NULL;
#endif
	
	if ((new_uri = create_absolute_uri(NULL, url)) == NULL)
		goto Rejected;

#ifdef ENABLE_RECURSION
	if ((host = get_host(new_uri)) == NULL)
		goto Rejected; 
#endif

	if (!push_unique_uri(new_uri, 1))
		goto Rejected;

#ifdef ENABLE_RECURSION
	add_url_to_default_domains(host);

	string_free(host);
#endif

	return MULK_RET_OK;

Rejected:
#ifdef ENABLE_RECURSION
	string_free(host);
#endif
	uri_free(new_uri);

	return MULK_RET_URL_ERR;
}
예제 #3
0
파일: url_list.c 프로젝트: henrycg/mulk
mulk_type_return_t mulk_add_new_url(const char *url)
{
	UriUriA *new_uri = NULL;
	mulk_type_return_t ret = MULK_RET_OK;
	
	if ((new_uri = create_absolute_uri(NULL, url)) == NULL)
		return MULK_RET_URL_ERR;

#ifdef ENABLE_RECURSION
	if ((ret = add_url_to_default_domains(new_uri)) != MULK_RET_OK)
		return ret;
#endif
	push_unique_uri(new_uri, 1);

	return ret;
}
예제 #4
0
파일: url_list.c 프로젝트: henrycg/mulk
void add_new_url_and_check(const char *base_url, const char *url, int level)
{
	UriUriA *uri = NULL;

	if ((uri = create_absolute_uri(base_url, url)) == NULL)
		return;

	/* check protocol */
	if (!is_uri_http(uri) && (!option_values.follow_ftp || !is_uri_ftp(uri))) {
		uri_free(uri);
		return;
	}

	/* check domains */
	if (!is_host_compatible_with_domains(uri)) {
		uri_free(uri);
		return;
	}

	push_unique_uri(uri, level);
}