"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/browsers.c" between
goaccess-1.6.5.tar.gz and goaccess-1.7.tar.gz

About: GoAccess is a real-time web log analyzer and interactive viewer ("text-based").

browsers.c  (goaccess-1.6.5):browsers.c  (goaccess-1.7)
skipping to change at line 37 skipping to change at line 37
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stddef.h> #include <stddef.h>
#include "opesys.h"
#include "browsers.h" #include "browsers.h"
#include "error.h" #include "error.h"
#include "settings.h" #include "settings.h"
#include "util.h" #include "util.h"
#include "xmalloc.h" #include "xmalloc.h"
/* ###NOTE: The size of the list is proportional to the run time, /* ###NOTE: The size of the list is proportional to the run time,
* which makes this pretty slow */ * which makes this pretty slow */
skipping to change at line 404 skipping to change at line 405
} }
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 type[BROWSER_TYPE_LEN]; char btype[BROWSER_TYPE_LEN];
char *browser, *a; char otype[OPESYS_TYPE_LEN];
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, type)) != NULL) if ((a = xstrdup (agent), browser = verify_browser (a, btype)) != NULL)
free (browser); free (browser);
free (a); free (a);
return strcmp (type, "Crawlers") == 0 ? 1 : 0; if (strcmp (btype, "Crawlers") == 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 554 skipping to change at line 572
* On success, a malloc'd string containing the browser is returned. */ * On success, a malloc'd string containing the browser is returned. */
char * char *
verify_browser (char *str, char *type) { verify_browser (char *str, char *type) {
char *match = NULL, *token = NULL; char *match = NULL, *token = NULL;
int i = 0; int i = 0;
size_t j = 0; size_t j = 0;
if (str == NULL || *str == '\0') if (str == NULL || *str == '\0')
return NULL; return NULL;
if ((match = check_http_crawler (str)) && (token = parse_crawler (str, match,
type)))
return token;
/* check user's list */ /* check user's list */
for (i = 0; i < conf.browsers_hash_idx; ++i) { for (i = 0; i < conf.browsers_hash_idx; ++i) {
if ((match = strstr (str, conf.user_browsers_hash[i][0])) == NULL) if ((match = strstr (str, conf.user_browsers_hash[i][0])) == NULL)
continue; continue;
return parse_browser (match, type, i, conf.user_browsers_hash); return parse_browser (match, type, i, conf.user_browsers_hash);
} }
/* try heuristics */
if ((match = check_http_crawler (str)) && (token = parse_crawler (str, match,
type)))
return token;
/* 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));
 End of changes. 6 change blocks. 
8 lines changed or deleted 27 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)