json.c (goaccess-1.6.5) | : | json.c (goaccess-1.7) | ||
---|---|---|---|---|
skipping to change at line 93 | skipping to change at line 93 | |||
{VISIT_TIMES , print_json_data , NULL } , | {VISIT_TIMES , print_json_data , NULL } , | |||
{VIRTUAL_HOSTS , print_json_data , NULL } , | {VIRTUAL_HOSTS , print_json_data , NULL } , | |||
{REFERRERS , print_json_data , NULL } , | {REFERRERS , print_json_data , NULL } , | |||
{REFERRING_SITES , print_json_data , NULL } , | {REFERRING_SITES , print_json_data , NULL } , | |||
{KEYPHRASES , print_json_data , NULL } , | {KEYPHRASES , print_json_data , NULL } , | |||
{STATUS_CODES , print_json_data , print_json_sub_items } , | {STATUS_CODES , print_json_data , print_json_sub_items } , | |||
{REMOTE_USER , print_json_data , NULL } , | {REMOTE_USER , print_json_data , NULL } , | |||
{CACHE_STATUS , print_json_data , NULL } , | {CACHE_STATUS , print_json_data , NULL } , | |||
#ifdef HAVE_GEOLOCATION | #ifdef HAVE_GEOLOCATION | |||
{GEO_LOCATION , print_json_data , print_json_sub_items } , | {GEO_LOCATION , print_json_data , print_json_sub_items } , | |||
{ASN , print_json_data , NULL} , | ||||
#endif | #endif | |||
{MIME_TYPE , print_json_data , print_json_sub_items } , | {MIME_TYPE , print_json_data , print_json_sub_items } , | |||
{TLS_TYPE , print_json_data , print_json_sub_items } , | {TLS_TYPE , print_json_data , print_json_sub_items } , | |||
}; | }; | |||
/* *INDENT-ON* */ | /* *INDENT-ON* */ | |||
/* Get panel output data for the given module. | /* Get panel output data for the given module. | |||
* | * | |||
* If not found, NULL is returned. | * If not found, NULL is returned. | |||
skipping to change at line 350 | skipping to change at line 351 | |||
if (!last) | if (!last) | |||
pjson (json, "%.*s\"%s\": %" PRIu64 ",%.*s", sp, TAB, key, val, nlines, NL); | pjson (json, "%.*s\"%s\": %" PRIu64 ",%.*s", sp, TAB, key, val, nlines, NL); | |||
else | else | |||
pjson (json, "%.*s\"%s\": %" PRIu64 "", sp, TAB, key, val); | pjson (json, "%.*s\"%s\": %" PRIu64 "", sp, TAB, key, val); | |||
} | } | |||
/* Write to a buffer a JSON string key, int value pair. */ | /* Write to a buffer a JSON string key, int value pair. */ | |||
static void | static void | |||
pskeyfval (GJSON * json, const char *key, float val, int sp, int last) { | pskeyfval (GJSON * json, const char *key, float val, int sp, int last) { | |||
if (!last) | if (!last) | |||
pjson (json, "%.*s\"%s\": \"%4.2f\",%.*s", sp, TAB, key, val, nlines, NL); | pjson (json, "%.*s\"%s\": \"%05.2f\",%.*s", sp, TAB, key, val, nlines, NL); | |||
else | else | |||
pjson (json, "%.*s\"%s\": \"%4.2f\"", sp, TAB, key, val); | pjson (json, "%.*s\"%s\": \"%05.2f\"", sp, TAB, key, val); | |||
} | } | |||
/* Write to a buffer the open block item object. */ | /* Write to a buffer the open block item object. */ | |||
static void | static void | |||
popen_obj (GJSON * json, int iisp) { | popen_obj (GJSON * json, int iisp) { | |||
/* open data metric block */ | /* open data metric block */ | |||
pjson (json, "%.*s{%.*s", iisp, TAB, nlines, NL); | pjson (json, "%.*s{%.*s", iisp, TAB, nlines, NL); | |||
} | } | |||
/* Output the open block item object. */ | /* Output the open block item object. */ | |||
skipping to change at line 982 | skipping to change at line 983 | |||
} | } | |||
/* A wrapper function to output geolocation fields for the given host. */ | /* A wrapper function to output geolocation fields for the given host. */ | |||
static void | static void | |||
print_json_host_geo (GJSON * json, GSubList * sl, int iisp) { | print_json_host_geo (GJSON * json, GSubList * sl, int iisp) { | |||
GSubItem *iter; | GSubItem *iter; | |||
int i; | int i; | |||
static const char *key[] = { | static const char *key[] = { | |||
"country", | "country", | |||
"city", | "city", | |||
"asn", | ||||
"hostname", | "hostname", | |||
}; | }; | |||
pjson (json, ",%.*s", nlines, NL); | pjson (json, ",%.*s", nlines, NL); | |||
/* Iterate over child properties (country, city, etc) and print them out */ | /* Iterate over child properties (country, city, asn, etc) and print them out */ | |||
for (i = 0, iter = sl->head; iter; iter = iter->next, i++) { | for (i = 0, iter = sl->head; iter; iter = iter->next, i++) { | |||
pjson (json, "%.*s\"%s\": \"", iisp, TAB, key[iter->metrics->id]); | pjson (json, "%.*s\"%s\": \"", iisp, TAB, key[iter->metrics->id]); | |||
escape_json_output (json, iter->metrics->data); | escape_json_output (json, iter->metrics->data); | |||
pjson (json, (i != sl->size - 1) ? "\",%.*s" : "\"", nlines, NL); | pjson (json, (i != sl->size - 1) ? "\",%.*s" : "\"", nlines, NL); | |||
} | } | |||
} | } | |||
/* Output Geolocation data and the IP's hostname. */ | /* Output Geolocation data and the IP's hostname. */ | |||
static void | static void | |||
print_json_host_items (GJSON * json, GHolderItem * item, GPercTotals totals, | print_json_host_items (GJSON * json, GHolderItem * item, GPercTotals totals, | |||
End of changes. 5 change blocks. | ||||
3 lines changed or deleted | 5 lines changed or added |