browsers.c (goaccess-1.7) | : | browsers.c (goaccess-1.7.1) | ||
---|---|---|---|---|
/** | /** | |||
6 browsers.c -- functions for dealing with browsers | 6 browsers.c -- functions for dealing with browsers | |||
* ______ ___ | * ______ ___ | |||
* / ____/___ / | _____________ __________ | * / ____/___ / | _____________ __________ | |||
* / / __/ __ \/ /| |/ ___/ ___/ _ \/ ___/ ___/ | * / / __/ __ \/ /| |/ ___/ ___/ _ \/ ___/ ___/ | |||
* / /_/ / /_/ / ___ / /__/ /__/ __(__ |__ ) | * / /_/ / /_/ / ___ / /__/ /__/ __(__ |__ ) | |||
* \____/\____/_/ |_\___/\___/\___/____/____/ | * \____/\____/_/ |_\___/\___/\___/____/____/ | |||
* | * | |||
* The MIT License (MIT) | * The MIT License (MIT) | |||
* Copyright (c) 2009-2022 Gerardo Orellana <hello @ goaccess.io> | * Copyright (c) 2009-2023 Gerardo Orellana <hello @ goaccess.io> | |||
* | * | |||
* Permission is hereby granted, free of charge, to any person obtaining a copy | * Permission is hereby granted, free of charge, to any person obtaining a copy | |||
* of this software and associated documentation files (the "Software"), to deal | * of this software and associated documentation files (the "Software"), to deal | |||
* in the Software without restriction, including without limitation the rights | * in the Software without restriction, including without limitation the rights | |||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||
* copies of the Software, and to permit persons to whom the Software is | * copies of the Software, and to permit persons to whom the Software is | |||
* furnished to do so, subject to the following conditions: | * furnished to do so, subject to the following conditions: | |||
* | * | |||
* The above copyright notice and this permission notice shall be included in al l | * The above copyright notice and this permission notice shall be included in al l | |||
* copies or substantial portions of the Software. | * copies or substantial portions of the Software. | |||
skipping to change at line 406 | skipping to change at line 406 | |||
fclose (file); | fclose (file); | |||
} | } | |||
/* Determine if the user-agent is a crawler. | /* Determine if the user-agent is a crawler. | |||
* | * | |||
* On error or is not a crawler, 0 is returned. | * On error or is not a crawler, 0 is returned. | |||
* If it is a crawler, 1 is returned . */ | * If it is a crawler, 1 is returned . */ | |||
int | int | |||
is_crawler (const char *agent) { | is_crawler (const char *agent) { | |||
char btype[BROWSER_TYPE_LEN]; | char btype[BROWSER_TYPE_LEN]; | |||
char otype[OPESYS_TYPE_LEN]; | char *browser, *a; | |||
char *browser, *os, *a; | ||||
if (agent == NULL || *agent == '\0') | if (agent == NULL || *agent == '\0') | |||
return 0; | return 0; | |||
if ((a = xstrdup (agent), browser = verify_browser (a, btype)) != NULL) | if ((a = xstrdup (agent), browser = verify_browser (a, btype)) != NULL) | |||
free (browser); | free (browser); | |||
free (a); | free (a); | |||
if (strcmp (btype, "Crawlers") == 0) | return strcmp (btype, "Crawlers") == 0 ? 1 : 0; | |||
return 1; | ||||
if (!conf.unknowns_as_crawlers) | ||||
return 0; | ||||
if (strcmp (btype, "Unknown") == 0) | ||||
return 1; | ||||
if ((a = xstrdup (agent), os = verify_os (a, otype)) != NULL) | ||||
free (os); | ||||
free (a); | ||||
if (strcmp (otype, "Unknown") == 0) | ||||
return 1; | ||||
return 0; | ||||
} | } | |||
/* Return the Opera 15 and beyond. | /* Return the Opera 15 and beyond. | |||
* | * | |||
* On success, the opera string and version is returned. */ | * On success, the opera string and version is returned. */ | |||
static char * | static char * | |||
parse_opera (char *token) { | parse_opera (char *token) { | |||
char *val = xmalloc (snprintf (NULL, 0, "Opera%s", token) + 1); | char *val = xmalloc (snprintf (NULL, 0, "Opera%s", token) + 1); | |||
sprintf (val, "Opera%s", token); | sprintf (val, "Opera%s", token); | |||
skipping to change at line 593 | skipping to change at line 576 | |||
/* fallback to default browser list */ | /* fallback to default browser list */ | |||
for (j = 0; j < ARRAY_SIZE (browsers); ++j) { | for (j = 0; j < ARRAY_SIZE (browsers); ++j) { | |||
if ((match = strstr (str, browsers_hash[j][0])) == NULL) | if ((match = strstr (str, browsers_hash[j][0])) == NULL) | |||
continue; | continue; | |||
return parse_browser (match, type, j, browsers_hash); | return parse_browser (match, type, j, browsers_hash); | |||
} | } | |||
if (conf.unknowns_log) | if (conf.unknowns_log) | |||
LOG_UNKNOWNS (("%-7s%s\n", "[BR]", str)); | LOG_UNKNOWNS (("%-7s%s\n", "[BR]", str)); | |||
xstrncpy (type, "Unknown", BROWSER_TYPE_LEN); | if (conf.unknowns_as_crawlers && strcmp (type, "Crawlers")) | |||
xstrncpy (type, "Crawlers", BROWSER_TYPE_LEN); | ||||
else | ||||
xstrncpy (type, "Unknown", BROWSER_TYPE_LEN); | ||||
return alloc_string ("Unknown"); | return alloc_string ("Unknown"); | |||
} | } | |||
End of changes. 4 change blocks. | ||||
21 lines changed or deleted | 7 lines changed or added |