Skip to content

Commit

Permalink
space / indentation / code style cleanups
Browse files Browse the repository at this point in the history
git-svn-id: svn://cherokee-project.com/cherokee/trunk@863 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information
ADF committed Jul 28, 2007
1 parent 7db7dc3 commit 72858ed
Show file tree
Hide file tree
Showing 12 changed files with 308 additions and 261 deletions.
15 changes: 15 additions & 0 deletions ChangeLog
@@ -1,3 +1,18 @@
2007-07-28 A.D.F <adefacc@tin.it>

* cherokee/source_interpreter.c,
cherokee/sha1.c,
cherokee/regex.c,
cherokee/post.c,
cherokee/ncpus.c,
cherokee/md5crypt.c,
cherokee/md5.c,
cherokee/matching_list.c,
cherokee/match.c,
cherokee/icons.c,
cherokee/header.c
- space / indentation / code style cleanups.

2007-07-26 Alvaro Lopez Ortega <alvaro@alobbs.com>

* cherokee/util.c (cherokee_mkstemp): Added new function. It wraps
Expand Down
64 changes: 40 additions & 24 deletions cherokee/header.c
Expand Up @@ -255,10 +255,10 @@ parse_method (cherokee_header_t *hdr, char *line, char **pointer)

#define detect_method(l,str,mthd) \
if (cmp_str (line+1, ((const char *)str" ")+1)) { \
hdr->method = http_ ## mthd; \
*pointer += sizeof(str); \
return ret_ok; \
} \
hdr->method = http_ ## mthd; \
*pointer += sizeof(str); \
return ret_ok; \
}

/* Check the first letter of the method name, if it matches it
* can continue with the rest.
Expand Down Expand Up @@ -364,7 +364,8 @@ parse_request_first_line (cherokee_header_t *hdr, cherokee_buffer_t *buf, char *
/* Get the method
*/
ret = parse_method (hdr, line, &begin);
if (unlikely (ret != ret_ok)) goto error;
if (unlikely (ret != ret_ok))
goto error;

/* Get the protocol version
*/
Expand Down Expand Up @@ -418,7 +419,8 @@ parse_request_first_line (cherokee_header_t *hdr, cherokee_buffer_t *buf, char *
char *host = begin + 7;

dir = strchr (host, '/');
if (dir == NULL) goto error;
if (dir == NULL)
goto error;

/* Add the host header
*/
Expand Down Expand Up @@ -556,8 +558,7 @@ cherokee_header_parse (cherokee_header_t *hdr, cherokee_buffer_t *buffer, cherok

/* Parse the rest of headers
*/
while ((begin < header_end) && (end = get_new_line(begin)) != NULL)
{
while ((begin < header_end) && (end = get_new_line(begin)) != NULL) {
cuint_t header_len;
int val_offs;
int val_len;
Expand Down Expand Up @@ -620,7 +621,8 @@ cherokee_header_parse (cherokee_header_t *hdr, cherokee_buffer_t *buffer, cherok
ret = add_known_header (hdr, header_accept, val_offs, val_len);
} else if (header_equals ("Authorization", header_authorization, begin, header_len)) {
ret = add_known_header (hdr, header_authorization, val_offs, val_len);
} else goto unknown;
} else
goto unknown;
break;
case 'C':
if (header_equals ("Connection", header_connection, begin, header_len)) {
Expand All @@ -629,12 +631,14 @@ cherokee_header_parse (cherokee_header_t *hdr, cherokee_buffer_t *buffer, cherok
ret = add_known_header (hdr, header_content_length, val_offs, val_len);
} else if (header_equals ("Cookie", header_cookie, begin, header_len)) {
ret = add_known_header (hdr, header_cookie, val_offs, val_len);
} else goto unknown;
} else
goto unknown;
break;
case 'H':
if (header_equals ("Host", header_host, begin, header_len)) {
ret = add_known_header (hdr, header_host, val_offs, val_len);
} else goto unknown;
} else
goto unknown;
break;
case 'I':
if (header_equals ("If-Modified-Since", header_if_modified_since, begin, header_len)) {
Expand All @@ -643,31 +647,36 @@ cherokee_header_parse (cherokee_header_t *hdr, cherokee_buffer_t *buffer, cherok
ret = add_known_header (hdr, header_if_none_match, val_offs, val_len);
} else if (header_equals ("If-Range", header_if_range, begin, header_len)) {
ret = add_known_header (hdr, header_if_range, val_offs, val_len);
} else goto unknown;
} else
goto unknown;
break;
case 'K':
if (header_equals ("Keep-Alive", header_keepalive, begin, header_len)) {
ret = add_known_header (hdr, header_keepalive, val_offs, val_len);
} else goto unknown;
} else
goto unknown;
break;
case 'L':
if (header_equals ("Location", header_location, begin, header_len)) {
ret = add_known_header (hdr, header_location, val_offs, val_len);
} else goto unknown;
} else
goto unknown;
break;
case 'R':
if (header_equals ("Range", header_range, begin, header_len)) {
ret = add_known_header (hdr, header_range, val_offs, val_len);
} else if (header_equals ("Referer", header_referer, begin, header_len)) {
ret = add_known_header (hdr, header_referer, val_offs, val_len);
} else goto unknown;
} else
goto unknown;
break;
case 'U':
if (header_equals ("Upgrade", header_upgrade, begin, header_len)) {
ret = add_known_header (hdr, header_upgrade, val_offs, val_len);
} else if (header_equals ("User-Agent", header_user_agent, begin, header_len)) {
ret = add_known_header (hdr, header_user_agent, val_offs, val_len);
} else goto unknown;
} else
goto unknown;
break;
default:
unknown:
Expand Down Expand Up @@ -733,7 +742,8 @@ cherokee_header_copy_unknown (cherokee_header_t *hdr, char *name, int name_len,
cuint_t info_len;

ret = cherokee_header_get_unknown (hdr, name, name_len, &info, &info_len);
if (unlikely(ret != ret_ok)) return ret;
if (unlikely(ret != ret_ok))
return ret;

return cherokee_buffer_add (buf, info, info_len);
}
Expand Down Expand Up @@ -774,7 +784,8 @@ cherokee_header_copy_known (cherokee_header_t *hdr, cherokee_common_header_t hea
cuint_t info_len = 0;

ret = cherokee_header_get_known (hdr, header, &info, &info_len);
if (unlikely(ret != ret_ok)) return ret;
if (unlikely(ret != ret_ok))
return ret;

return cherokee_buffer_add (buf, info, info_len);
}
Expand All @@ -791,7 +802,8 @@ cherokee_header_copy_request (cherokee_header_t *hdr, cherokee_buffer_t *request
}

ret = cherokee_buffer_add (request, hdr->input_buffer->buf + hdr->request_off, hdr->request_len);
if (unlikely(ret < ret_ok)) return ret;
if (unlikely(ret < ret_ok))
return ret;

return cherokee_buffer_unescape_uri (request);
}
Expand All @@ -808,7 +820,8 @@ cherokee_header_copy_query_string (cherokee_header_t *hdr, cherokee_buffer_t *qu
}

ret = cherokee_buffer_add (query_string, hdr->input_buffer->buf + hdr->query_string_off, hdr->query_string_len);
if (unlikely(ret < ret_ok)) return ret;
if (unlikely(ret < ret_ok))
return ret;

return ret_ok;
}
Expand Down Expand Up @@ -843,7 +856,8 @@ cherokee_header_copy_request_w_args (cherokee_header_t *hdr, cherokee_buffer_t *
}

ret = cherokee_buffer_add (request, hdr->input_buffer->buf + hdr->request_off, hdr->request_args_len);
if (unlikely(ret < ret_ok)) return ret;
if (unlikely(ret < ret_ok))
return ret;

return cherokee_buffer_unescape_uri (request);
}
Expand All @@ -857,7 +871,8 @@ cherokee_header_copy_method (cherokee_header_t *hdr, cherokee_buffer_t *buf)
cuint_t len;

ret = cherokee_http_method_to_string (HDR_METHOD(hdr), &tmp, &len);
if (unlikely(ret != ret_ok)) return ret;
if (unlikely(ret != ret_ok))
return ret;

return cherokee_buffer_add (buf, tmp, len);
}
Expand All @@ -871,7 +886,8 @@ cherokee_header_copy_version (cherokee_header_t *hdr, cherokee_buffer_t *buf)
cuint_t len;

ret = cherokee_http_version_to_string (HDR_VERSION(hdr), &tmp, &len);
if (unlikely(ret != ret_ok)) return ret;
if (unlikely(ret != ret_ok))
return ret;

return cherokee_buffer_add (buf, tmp, len);
}
Expand Down Expand Up @@ -917,7 +933,7 @@ cherokee_header_has_header (cherokee_header_t *hdr, cherokee_buffer_t *buffer, i
/* Bad parameter value
*/
return ret_error;
}
}

/* Look for the starting point
*/
Expand Down
41 changes: 26 additions & 15 deletions cherokee/icons.c
Expand Up @@ -38,13 +38,16 @@ cherokee_icons_new (cherokee_icons_t **icons)
CHEROKEE_NEW_STRUCT(n, icons);

ret = cherokee_avl_init (&n->files);
if (unlikely(ret < ret_ok)) return ret;
if (unlikely(ret < ret_ok))
return ret;

ret = cherokee_avl_init (&n->files_matching);
if (unlikely(ret < ret_ok)) return ret;
if (unlikely(ret < ret_ok))
return ret;

ret = cherokee_avl_init (&n->suffixes);
if (unlikely(ret < ret_ok)) return ret;
if (unlikely(ret < ret_ok))
return ret;

/* Files and Suffixes are case insensitive
*/
Expand Down Expand Up @@ -99,14 +102,14 @@ cherokee_icons_add_file (cherokee_icons_t *icons, cherokee_buffer_t *icon, chero
cherokee_buffer_t *tmp = NULL;

ret = cherokee_buffer_dup (icon, &tmp);
if (unlikely (ret != ret_ok)) return ret;
if (unlikely (ret != ret_ok))
return ret;

if ((strchr (file->buf, '*') != NULL) ||
(strchr (file->buf, '?') != NULL))
{
(strchr (file->buf, '?') != NULL)) {
return cherokee_avl_add (&icons->files_matching, file, tmp);
}

return cherokee_avl_add (&icons->files, file, tmp);
}

Expand All @@ -118,7 +121,8 @@ cherokee_icons_add_suffix (cherokee_icons_t *icons, cherokee_buffer_t *icon, che
cherokee_buffer_t *tmp = NULL;

ret = cherokee_buffer_dup (icon, &tmp);
if (unlikely (ret != ret_ok)) return ret;
if (unlikely (ret != ret_ok))
return ret;

cherokee_avl_add (&icons->suffixes, suffix, tmp);
return ret_ok;
Expand Down Expand Up @@ -174,21 +178,24 @@ cherokee_icons_get_icon (cherokee_icons_t *icons,
/* Look for the filename
*/
ret = cherokee_avl_get (&icons->files, file, (void **)icon_ret);
if (ret == ret_ok) return ret_ok;
if (ret == ret_ok)
return ret_ok;

/* Look for the suffix
*/
suffix = strrchr (file->buf, '.');
if (suffix != NULL) {
ret = cherokee_avl_get_ptr (&icons->suffixes, suffix+1, (void **)icon_ret);
if (ret == ret_ok) return ret_ok;
if (ret == ret_ok)
return ret_ok;
}

/* Look for the wildcat matching
*/
ret = cherokee_avl_while (&icons->files_matching, match_file,
file, NULL, (void **)icon_ret);
if (ret == ret_ok) return ret_ok;
if (ret == ret_ok)
return ret_ok;

/* Default one
*/
Expand Down Expand Up @@ -239,7 +246,8 @@ configure_file (cherokee_config_node_t *config, void *data)
params[1] = &config->key;

ret = cherokee_config_node_read_list (config, NULL, add_file, params);
if ((ret != ret_ok) && (ret != ret_not_found)) return ret;
if ((ret != ret_ok) && (ret != ret_not_found))
return ret;

return ret_ok;
}
Expand All @@ -254,7 +262,8 @@ configure_suffix (cherokee_config_node_t *config, void *data)
params[1] = &config->key;

ret = cherokee_config_node_read_list (config, NULL, add_suffix, params);
if ((ret != ret_ok) && (ret != ret_not_found)) return ret;
if ((ret != ret_ok) && (ret != ret_not_found))
return ret;

return ret_ok;
}
Expand All @@ -269,13 +278,15 @@ cherokee_icons_configure (cherokee_icons_t *icons, cherokee_config_node_t *confi
ret = cherokee_config_node_get (config, "file", &subconf);
if (ret == ret_ok) {
ret = cherokee_config_node_while (subconf, configure_file, icons);
if (ret != ret_ok) return ret;
if (ret != ret_ok)
return ret;
}

ret = cherokee_config_node_get (config, "suffix", &subconf);
if (ret == ret_ok) {
ret = cherokee_config_node_while (subconf, configure_suffix, icons);
if (ret != ret_ok) return ret;
if (ret != ret_ok)
return ret;
}

ret = cherokee_config_node_get (config, "directory", &subconf);
Expand Down
1 change: 1 addition & 0 deletions cherokee/match.c
Expand Up @@ -46,6 +46,7 @@ cherokee_wildcard_match (const char *pattern, const char *text)
if (*text++ == '\0')
return ret_not_found;
break;

default:
if (*text == ch) {
if (*text) text++;
Expand Down
8 changes: 4 additions & 4 deletions cherokee/matching_list.c
Expand Up @@ -156,20 +156,20 @@ cherokee_matching_list_match (cherokee_matching_list_t *mlist, char *match)
case default_allow:
return match_default_allow (mlist, match);
break;

case default_deny:
return match_default_deny (mlist, match);
break;

case deny_allow:
return match_deny_allow (mlist, match);
break;

case allow_deny:
return match_allow_deny (mlist, match);
break;
}

SHOULDNT_HAPPEN;
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion cherokee/md5.c
Expand Up @@ -144,7 +144,7 @@ MD5Final(md5byte digest[16], struct MD5Context *ctx)

/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f,w,x,y,z,in,s) \
(w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
(w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)

/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
Expand Down

0 comments on commit 72858ed

Please sign in to comment.