unsigned int flags,
size_t *offset) /* to the hostname */
{
- CURLUcode result = CURLUE_OK;
+ CURLUcode ures = CURLUE_OK;
CURLcode ccode;
char *userp = NULL;
char *passwdp = NULL;
if(ccode) {
/* the only possible error from Curl_parse_login_details is out of
memory: */
- result = CURLUE_OUT_OF_MEMORY;
+ ures = CURLUE_OUT_OF_MEMORY;
goto out;
}
if(userp) {
if(flags & CURLU_DISALLOW_USER) {
/* Option DISALLOW_USER is set and URL contains username. */
- result = CURLUE_USER_NOT_ALLOWED;
+ ures = CURLUE_USER_NOT_ALLOWED;
goto out;
}
curlx_free(u->user);
u->password = NULL;
u->options = NULL;
- return result;
+ return ures;
}
UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, struct dynbuf *host,
/* used for HTTP/2 server push */
CURLUcode Curl_url_set_authority(CURLU *u, const char *authority)
{
- CURLUcode result;
+ CURLUcode ures;
struct dynbuf host;
DEBUGASSERT(authority);
curlx_dyn_init(&host, CURL_MAX_INPUT_LENGTH);
- result = parse_authority(u, authority, strlen(authority),
- CURLU_DISALLOW_USER, &host, !!u->scheme);
- if(result)
+ ures = parse_authority(u, authority, strlen(authority),
+ CURLU_DISALLOW_USER, &host, !!u->scheme);
+ if(ures)
curlx_dyn_free(&host);
else {
curlx_free(u->host);
u->host = curlx_dyn_ptr(&host);
}
- return result;
+ return ures;
}
/*
static CURLUcode handle_fragment(CURLU *u, const char *fragment,
size_t fraglen, unsigned int flags)
{
- CURLUcode result;
+ CURLUcode ures;
u->fragment_present = TRUE;
if(fraglen > 1) {
/* skip the leading '#' in the copy but include the terminating null */
if(flags & CURLU_URLENCODE) {
struct dynbuf enc;
curlx_dyn_init(&enc, CURL_MAX_INPUT_LENGTH);
- result = urlencode_str(&enc, fragment + 1, fraglen - 1, TRUE, FALSE);
- if(result)
- return result;
+ ures = urlencode_str(&enc, fragment + 1, fraglen - 1, TRUE, FALSE);
+ if(ures)
+ return ures;
u->fragment = curlx_dyn_ptr(&enc);
}
else {
if(qlen > 1) {
if(flags & CURLU_URLENCODE) {
struct dynbuf enc;
- CURLUcode result;
+ CURLUcode ures;
curlx_dyn_init(&enc, CURL_MAX_INPUT_LENGTH);
/* skip the leading question mark */
- result = urlencode_str(&enc, query + 1, qlen - 1, TRUE, TRUE);
- if(result)
- return result;
+ ures = urlencode_str(&enc, query + 1, qlen - 1, TRUE, TRUE);
+ if(ures)
+ return ures;
u->query = curlx_dyn_ptr(&enc);
}
else {
size_t pathlen, unsigned int flags,
bool is_file)
{
- CURLUcode result;
+ CURLUcode ures;
if(pathlen && (flags & CURLU_URLENCODE)) {
struct dynbuf enc;
curlx_dyn_init(&enc, CURL_MAX_INPUT_LENGTH);
- result = urlencode_str(&enc, path, pathlen, TRUE, FALSE);
- if(result)
- return result;
+ ures = urlencode_str(&enc, path, pathlen, TRUE, FALSE);
+ if(ures)
+ return ures;
pathlen = curlx_dyn_len(&enc);
path = u->path = curlx_dyn_ptr(&enc);
}
char schemebuf[MAX_SCHEME_LEN + 1];
size_t schemelen = 0;
size_t urllen;
- CURLUcode result = CURLUE_OK;
+ CURLUcode ures = CURLUE_OK;
struct dynbuf host;
bool is_file = FALSE;
curlx_dyn_init(&host, CURL_MAX_INPUT_LENGTH);
- result = Curl_junkscan(url, &urllen, !!(flags & CURLU_ALLOW_SPACE));
- if(result)
+ ures = Curl_junkscan(url, &urllen, !!(flags & CURLU_ALLOW_SPACE));
+ if(ures)
goto fail;
schemelen = Curl_is_absolute_url(url, schemebuf, sizeof(schemebuf),
/* handle the file: scheme */
if(schemelen && !strcmp(schemebuf, "file")) {
is_file = TRUE;
- result = parse_file(url, urllen, u, &host, &path, &pathlen);
+ ures = parse_file(url, urllen, u, &host, &path, &pathlen);
}
else {
const char *hostp = NULL;
size_t hostlen;
- result = parse_scheme(url, u, schemebuf, schemelen, flags, &hostp);
- if(result)
+ ures = parse_scheme(url, u, schemebuf, schemelen, flags, &hostp);
+ if(ures)
goto fail;
/* find the end of the hostname + port number */
/* this pathlen also contains the query and the fragment */
pathlen = urllen - (path - url);
if(hostlen) {
- result = parse_authority(u, hostp, hostlen, flags, &host,
- u->scheme != NULL);
- if(!result && (flags & CURLU_GUESS_SCHEME) && !u->scheme)
- result = guess_scheme(u, &host);
+ ures = parse_authority(u, hostp, hostlen, flags, &host,
+ u->scheme != NULL);
+ if(!ures && (flags & CURLU_GUESS_SCHEME) && !u->scheme)
+ ures = guess_scheme(u, &host);
}
else if(flags & CURLU_NO_AUTHORITY) {
/* allowed to be empty. */
if(curlx_dyn_add(&host, ""))
- result = CURLUE_OUT_OF_MEMORY;
+ ures = CURLUE_OUT_OF_MEMORY;
}
else
- result = CURLUE_NO_HOST;
+ ures = CURLUE_NO_HOST;
}
- if(!result) {
+ if(!ures) {
/* The path might at this point contain a fragment and/or a query to
handle */
const char *fragment = strchr(path, '#');
if(fragment) {
size_t fraglen = pathlen - (fragment - path);
- result = handle_fragment(u, fragment, fraglen, flags);
+ ures = handle_fragment(u, fragment, fraglen, flags);
/* after this, pathlen still contains the query */
pathlen -= fraglen;
}
}
- if(!result) {
+ if(!ures) {
const char *query = memchr(path, '?', pathlen);
if(query) {
size_t qlen = pathlen - (query - path);
- result = handle_query(u, query, qlen, flags);
+ ures = handle_query(u, query, qlen, flags);
pathlen -= qlen;
}
}
- if(!result)
+ if(!ures)
/* the fragment and query parts are trimmed off from the path */
- result = handle_path(u, path, pathlen, flags, is_file);
- if(!result) {
+ ures = handle_path(u, path, pathlen, flags, is_file);
+ if(!ures) {
u->host = curlx_dyn_ptr(&host);
return CURLUE_OK;
}
fail:
curlx_dyn_free(&host);
free_urlhandle(u);
- return result;
+ return ures;
}
/*
static CURLUcode parseurl_and_replace(const char *url, CURLU *u,
unsigned int flags)
{
- CURLUcode result;
+ CURLUcode ures;
CURLU tmpurl;
memset(&tmpurl, 0, sizeof(tmpurl));
- result = parseurl(url, &tmpurl, flags);
- if(!result) {
+ ures = parseurl(url, &tmpurl, flags);
+ if(!ures) {
free_urlhandle(u);
*u = tmpurl;
}
- return result;
+ return ures;
}
/*
static bool get_num_host_info(struct num_ip_data *ip_blob, LPCSTR hostname)
{
- bool result = FALSE;
struct in_addr ia;
int res = curlx_inet_pton(AF_INET, hostname, &ia);
if(res) {
ip_blob->size = sizeof(struct in_addr);
memcpy(&ip_blob->bData.ia, &ia, sizeof(struct in_addr));
- result = TRUE;
+ return TRUE;
}
else {
struct in6_addr ia6;
if(res) {
ip_blob->size = sizeof(struct in6_addr);
memcpy(&ip_blob->bData.ia6, &ia6, sizeof(struct in6_addr));
- result = TRUE;
+ return TRUE;
}
}
- return result;
+ return FALSE;
}
static bool get_alt_name_info(struct Curl_easy *data,
PCERT_ALT_NAME_INFO *alt_name_info,
LPDWORD alt_name_info_size)
{
- bool result = FALSE;
PCERT_INFO cert_info = NULL;
PCERT_EXTENSION extension = NULL;
CRYPT_DECODE_PARA decode_para = { sizeof(CRYPT_DECODE_PARA), NULL, NULL };
if(!ctx) {
failf(data, "schannel: Null certificate context.");
- return result;
+ return FALSE;
}
cert_info = ctx->pCertInfo;
if(!cert_info) {
failf(data, "schannel: Null certificate info.");
- return result;
+ return FALSE;
}
extension = CertFindExtension(szOID_SUBJECT_ALT_NAME2,
cert_info->rgExtension);
if(!extension) {
failf(data, "schannel: CertFindExtension() returned no extension.");
- return result;
+ return FALSE;
}
if(!CryptDecodeObjectEx(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
alt_name_info,
alt_name_info_size)) {
failf(data, "schannel: CryptDecodeObjectEx() returned no alternate name "
- "information.");
- return result;
+ "information.");
+ return FALSE;
}
- result = TRUE;
- return result;
+ return TRUE;
}
/* Verify the server's hostname */