Exemple #1
0
static void
search_stats_notify_word(query_type_t type, const gchar *search,
	const host_addr_t unused_addr, guint16 unused_port)
{
    word_vec_t *wovec;
    guint wocnt;
    guint i;
    gchar *buf;

	(void) unused_addr;
	(void) unused_port;

    if (QUERY_SHA1 == type)
        return;

	buf = g_strdup(search);
   	wocnt = word_vec_make(buf, &wovec);

	if (wocnt != 0) {
		for (i = 0; i < wocnt; i++)
			search_stats_tally(&wovec[i]);

		word_vec_free(wovec, wocnt);
	}

    G_FREE_NULL(buf);
}
Exemple #2
0
static void
search_stats_notify_routed(query_type_t unused_type, const char *unused_search,
                           const host_addr_t addr, guint16 port)
{
    word_vec_t wovec;

    (void) unused_type;
    (void) unused_search;

    wovec.word = deconstify_char(host_addr_port_to_string(addr, port));
    wovec.len = strlen(wovec.word);
    wovec.amount = 1;

    search_stats_tally(&wovec);
}
Exemple #3
0
static void
search_stats_notify_whole(query_type_t type, const gchar *search,
	const host_addr_t unused_addr, guint16 unused_port)
{
    word_vec_t wovec;
	gchar buf[1024];

	(void) unused_addr;
	(void) unused_port;

    gm_snprintf(buf, sizeof buf, QUERY_SHA1 == type ? "urn:sha1:%s" : "[%s]",
		search);

	wovec.word = buf;
    wovec.len = strlen(wovec.word);
    wovec.amount = 1;

    search_stats_tally(&wovec);
}
Exemple #4
0
static void
search_stats_notify_whole(query_type_t type, const char *search,
                          const host_addr_t unused_addr, guint16 unused_port)
{
    word_vec_t wovec;
    char buf[1024];

    (void) unused_addr;
    (void) unused_port;

    concat_strings(buf, sizeof buf,
                   type == QUERY_SHA1 ? "urn:sha1:" : "[",
                   search,
                   type == QUERY_SHA1 ? "" : "]",
                   (void *) 0);

    wovec.word = buf;
    wovec.len = strlen(wovec.word);
    wovec.amount = 1;

    search_stats_tally(&wovec);
}
Exemple #5
0
static void
search_stats_notify_word(query_type_t type, const char *search,
                         const host_addr_t unused_addr, guint16 unused_port)
{
    word_vec_t *wovec;
    unsigned wocnt;

    (void) unused_addr;
    (void) unused_port;

    if (type == QUERY_SHA1)
        return;

    wocnt = word_vec_make(search, &wovec);
    if (wocnt != 0) {
        unsigned i;

        for (i = 0; i < wocnt; i++) {
            search_stats_tally(&wovec[i]);
        }
        word_vec_free(wovec, wocnt);
    }
}