Skip to content

Commit

Permalink
Minor changes to is_static() and ignore_static() functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
allinurl committed Mar 6, 2018
1 parent ecb419b commit 86b6eef
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ parse_long_opt (const char *name, const char *oarg)
MAX_IGNORE_STATUS);

/* ignore static requests */
if (!strcmp("ignore-statics", name))
if (!strcmp ("ignore-statics", name))
conf.ignore_statics = 1;

/* number of line tests */
Expand Down
73 changes: 35 additions & 38 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ static void insert_method (int data_nkey, const char *method, GModule module);
static void insert_protocol (int data_nkey, const char *proto, GModule module);
static void insert_agent (int data_nkey, int agent_nkey, GModule module);

static int is_static (GLogItem * logitem);

/* *INDENT-OFF* */
static GParse paneling[] = {
{
Expand Down Expand Up @@ -681,9 +679,9 @@ extract_referer_site (const char *referer, char *host)
* On error, or if not static, 0 is returned.
* On success, the 1 is returned. */
static int
verify_static_content (char *req)
verify_static_content (const char *req)
{
char *nul = req + strlen (req);
const char *nul = req + strlen (req);
const char *ext = NULL, *pch = NULL;
int elen = 0, i;

Expand Down Expand Up @@ -1693,6 +1691,16 @@ handle_crawler (const char *agent)
return (conf.ignore_crawlers && bot) || (conf.crawlers_only && !bot) ? 0 : 1;
}

/* A wrapper function to determine if the request is static.
*
* If the request is not static, 0 is returned.
* If the request is static, 1 is returned. */
static int
is_static (const char *req)
{
return verify_static_content (req);
}

/* Determine if the request of the given status code needs to be
* ignored.
*
Expand All @@ -1714,12 +1722,28 @@ ignore_status_code (const char *status)
* If the request line is not ignored, 0 is returned.
* If the request line is ignored, 1 is returned. */
static int
ignore_static(GLogItem * logitem)
ignore_static (const char *req)
{
if (conf.ignore_statics && is_static(logitem)) {
return 1;
}
return 0;
if (conf.ignore_statics && is_static (req))
return 1;
return 0;
}

/* Determine if the request status code is a 404.
*
* If the request is not a 404, 0 is returned.
* If the request is a 404, 1 is returned. */
static int
is_404 (GLogItem * logitem)
{
/* is this a 404? */
if (logitem->status && !memcmp (logitem->status, "404", 3))
return 1;
/* treat 444 as 404? */
else if (logitem->status && !memcmp (logitem->status, "444", 3) &&
conf.code444_as_404)
return 1;
return 0;
}

/* A wrapper function to determine if a log line needs to be ignored.
Expand All @@ -1737,7 +1761,7 @@ ignore_line (GLog * glog, GLogItem * logitem)
return 1;
if (ignore_status_code (logitem->status))
return 1;
if (ignore_static (logitem))
if (ignore_static (logitem->req))
return 1;

/* check if we need to remove the request's query string */
Expand All @@ -1747,33 +1771,6 @@ ignore_line (GLog * glog, GLogItem * logitem)
return 0;
}

/* A wrapper function to determine if the request is static.
*
* If the request is not static, 0 is returned.
* If the request is static, 1 is returned. */
static int
is_static (GLogItem * logitem)
{
return verify_static_content (logitem->req);
}

/* Determine if the request status code is a 404.
*
* If the request is not a 404, 0 is returned.
* If the request is a 404, 1 is returned. */
static int
is_404 (GLogItem * logitem)
{
/* is this a 404? */
if (logitem->status && !memcmp (logitem->status, "404", 3))
return 1;
/* treat 444 as 404? */
else if (logitem->status && !memcmp (logitem->status, "444", 3) &&
conf.code444_as_404)
return 1;
return 0;
}

/* A wrapper function to insert a keymap string key.
*
* If the given key exists, its value is returned.
Expand Down Expand Up @@ -2554,7 +2551,7 @@ pre_process_log (GLog * glog, char *line, int dry_run)

if (is_404 (logitem))
logitem->is_404 = 1;
else if (is_static (logitem))
else if (is_static (logitem->req))
logitem->is_static = 1;

logitem->uniq_key = get_uniq_visitor_key (logitem);
Expand Down

0 comments on commit 86b6eef

Please sign in to comment.