Skip to content

Commit

Permalink
Updated indentation on comments and line length.
Browse files Browse the repository at this point in the history
  • Loading branch information
allinurl committed May 2, 2024
1 parent 756d6c2 commit 2eb7e63
Show file tree
Hide file tree
Showing 36 changed files with 284 additions and 312 deletions.
3 changes: 1 addition & 2 deletions src/base64.c
Expand Up @@ -38,8 +38,7 @@
* On success, the encoded nul-terminated data, as a string is returned. */
char *
base64_encode (const void *buf, size_t size) {
static const char base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

char *str = (char *) xmalloc ((size + 3) * 4 / 3 + 1);

Expand Down
2 changes: 1 addition & 1 deletion src/bin2c.c
Expand Up @@ -84,7 +84,7 @@ main (int argc, char *argv[]) {

#ifdef USE_BZ2
// allocate for bz2.
bz2_size = (file_size + file_size / 100 + 1) + 600; // as per the documentation
bz2_size = (file_size + file_size / 100 + 1) + 600; // as per the documentation

if ((bz2_buf = malloc (bz2_size)) == NULL) {
fprintf (stderr, "Unable to malloc bin2c.c buffer\n");
Expand Down
2 changes: 1 addition & 1 deletion src/bitmap.h
Expand Up @@ -31,7 +31,7 @@
#ifndef BITMAP_H_INCLUDED
#define BITMAP_H_INCLUDED

#include <limits.h> /* for CHAR_BIT */
#include <limits.h> /* for CHAR_BIT */

typedef uint32_t word_t; // I want to change this, from uint32_t to uint64_t
enum { BITS_PER_WORD = sizeof (word_t) * CHAR_BIT };
Expand Down
18 changes: 9 additions & 9 deletions src/browsers.c
Expand Up @@ -245,15 +245,15 @@ static const char *browsers[][2] = {
{"MauiBot", "Crawlers"},
{"Cloud", "Crawlers"},
{"stagefright", "Crawlers"},
{"ZoteroTranslationServer", "Cralwers"}, /* Nodeja Zotero Translation Server https://github.com/zotero/translation-server */
{"ZoteroTranslationServer", "Cralwers"}, /* Nodeja Zotero Translation Server https://github.com/zotero/translation-server */

/* HTTP Library or HTTP Server User Agents - Suggest New Category */
{"axios", "HTTP Library"}, /* NodeJS axios axios-http.com */
{"lua-resty-http", "HTTP Library"}, /* Nginx lua-resty-http module */
{"axios", "HTTP Library"}, /* NodeJS axios axios-http.com */
{"lua-resty-http", "HTTP Library"}, /* Nginx lua-resty-http module */

/* Citation Services */
{"Citoid", "Citation"}, /* MediaWiki Citoid Citation Service https://www.mediawiki.org/wiki/Citoid */
{"EasyBib", "Citation"}, /* Easybib Citation https://easybib.com */
{"Citoid", "Citation"}, /* MediaWiki Citoid Citation Service https://www.mediawiki.org/wiki/Citoid */
{"EasyBib", "Citation"}, /* Easybib Citation https://easybib.com */

/* Podcast fetchers */
{"Downcast", "Podcasts"},
Expand Down Expand Up @@ -293,12 +293,12 @@ static const char *browsers[][2] = {
{"Uptime-Kuma", "Uptime"},

/* Performance and Caching - Suggest a new category */
{"ShortPixel", "Performance"}, /* Image Optimization */
{"WP Rocket", "Caching"}, /* Preloading Cache for WordPress Plugin */
{"ShortPixel", "Performance"}, /* Image Optimization */
{"WP Rocket", "Caching"}, /* Preloading Cache for WordPress Plugin */

/* Security - Suggest a new category */
{"Barracuda Sentinel", "Security"}, /* Barricuda spear fishing service */
{"ACI Site Scanner", "Security"}, /* Can't confirm specific vendor */
{"Barracuda Sentinel", "Security"}, /* Barricuda spear fishing service */
{"ACI Site Scanner", "Security"}, /* Can't confirm specific vendor */


{"Mozilla", "Others"}
Expand Down
3 changes: 1 addition & 2 deletions src/commons.c
Expand Up @@ -400,8 +400,7 @@ verify_panels (void) {
if (!conf.log_format)
return;

if (!strstr (conf.log_format, "%v") && ignore_panel_idx < TOTAL_MODULES &&
!conf.fname_as_vhost) {
if (!strstr (conf.log_format, "%v") && ignore_panel_idx < TOTAL_MODULES && !conf.fname_as_vhost) {
if (str_inarray ("VIRTUAL_HOSTS", conf.ignore_panels, ignore_panel_idx) < 0)
remove_module (VIRTUAL_HOSTS);
}
Expand Down
2 changes: 1 addition & 1 deletion src/commons.h
Expand Up @@ -62,7 +62,7 @@ extern struct tm now_tm;
/* real-time */
#define MAX_CHOICES_RT 50
/* max default items when date-spec = min */
#define MAX_CHOICES_MINUTE 1440 /* 24hrs */
#define MAX_CHOICES_MINUTE 1440 /* 24hrs */

/* date and time length - e.g., 2016/12/12 12:12:12 -0600 */
#define DATE_TIME 25 + 1
Expand Down
4 changes: 2 additions & 2 deletions src/csv.c
Expand Up @@ -175,7 +175,7 @@ print_csv_sub_items (FILE *fp, GHolder *h, int idx, GPercTotals totals) {
set_data_metrics (iter->metrics, &nmetrics, totals);

fprintf (fp, "\"%d\",", i); /* idx */
fprintf (fp, "\"%d\",", idx); /* parent idx */
fprintf (fp, "\"%d\",", idx); /* parent idx */
fprintf (fp, "\"%s\",", module_to_id (h->module));

/* output metrics */
Expand All @@ -196,7 +196,7 @@ print_csv_data (FILE *fp, GHolder *h, GPercTotals totals) {
set_data_metrics (h->items[i].metrics, &nmetrics, totals);

fprintf (fp, "\"%d\",", i); /* idx */
fprintf (fp, ","); /* no parent */
fprintf (fp, ","); /* no parent */
fprintf (fp, "\"%s\",", module_to_id (h->module));

/* output metrics */
Expand Down
15 changes: 6 additions & 9 deletions src/gdashboard.c
Expand Up @@ -59,9 +59,9 @@ reset_find (void) {

find_t.look_in_sub = 0;
find_t.module = 0;
find_t.next_idx = 0; /* next total index */
find_t.next_parent_idx = 0; /* next parent index */
find_t.next_sub_idx = 0; /* next sub item index */
find_t.next_idx = 0; /* next total index */
find_t.next_parent_idx = 0; /* next parent index */
find_t.next_sub_idx = 0; /* next sub item index */
find_t.pattern = NULL;
}

Expand Down Expand Up @@ -879,8 +879,7 @@ render_header (WINDOW *win, GDashModule *data, GModule cur_module, int *y) {

k = data->module + 1;
ind = cur_module == data->module ? '>' : ' ';
func = cur_module == data->module &&
conf.hl_header ? color_panel_active : color_panel_header;
func = cur_module == data->module && conf.hl_header ? color_panel_active : color_panel_header;
hd = xmalloc (snprintf (NULL, 0, "%c %d - %s", ind, k, data->head) + 1);
sprintf (hd, "%c %d - %s", ind, k, data->head);

Expand Down Expand Up @@ -1061,8 +1060,7 @@ render_cols (WINDOW *win, GDashModule *data, int *y) {

/* Iterate over all dashboard data and render its content. */
static void
render_content (WINDOW *win, GDashModule *data, int *y, int *offset,
int *total, GScroll *gscroll) {
render_content (WINDOW *win, GDashModule *data, int *y, int *offset, int *total, GScroll *gscroll) {
GModule module = data->module;
int i, j, size, h, w, data_pos = get_data_pos_rows ();

Expand Down Expand Up @@ -1388,8 +1386,7 @@ set_dash_metrics (GDash **dash, GMetrics *metrics, GModule module,
* If no items on the sub list, the function returns.
* On success, sub list data is set into the dashboard structure. */
static void
add_sub_item_to_dash (GDash **dash, GHolderItem item, GModule module, GPercTotals totals,
int *i) {
add_sub_item_to_dash (GDash **dash, GHolderItem item, GModule module, GPercTotals totals, int *i) {
GSubList *sub_list = item.sub_list;
GSubItem *iter;

Expand Down
26 changes: 13 additions & 13 deletions src/gdashboard.h
Expand Up @@ -38,23 +38,23 @@

#include "ui.h"

#define DASH_HEAD_POS 0 /* position of header line */
#define DASH_EMPTY_POS 1 /* empty line position */
#define DASH_COLS_POS 2 /* position of column names */
#define DASH_DASHES_POS 3 /* position of dashes under column names */
#define DASH_DATA_POS 4 /* data line position */
#define DASH_HEAD_POS 0 /* position of header line */
#define DASH_EMPTY_POS 1 /* empty line position */
#define DASH_COLS_POS 2 /* position of column names */
#define DASH_DASHES_POS 3 /* position of dashes under column names */
#define DASH_DATA_POS 4 /* data line position */

#define DASH_NON_DATA 5 /* number of rows without data stats */
#define DASH_COL_ROWS 2 /* number of rows for column values + dashed lines */
#define DASH_NON_DATA 5 /* number of rows without data stats */
#define DASH_COL_ROWS 2 /* number of rows for column values + dashed lines */

#define DASH_COLLAPSED 12 /* number of rows per panel (collapsed) */
#define DASH_EXPANDED 32 /* number of rows per panel (expanded) */
#define DASH_COLLAPSED 12 /* number of rows per panel (collapsed) */
#define DASH_EXPANDED 32 /* number of rows per panel (expanded) */

#define DASH_INIT_X 1 /* start position (x-axis) */
#define DASH_INIT_X 1 /* start position (x-axis) */

#define DASH_BW_LEN 11 /* max bandwidth string length, e.g., 151.69 MiB */
#define DASH_SRV_TM_LEN 9 /* max time served length, e.g., 483.00 us */
#define DASH_SPACE 1 /* space between columns (metrics) */
#define DASH_BW_LEN 11 /* max bandwidth string length, e.g., 151.69 MiB */
#define DASH_SRV_TM_LEN 9 /* max time served length, e.g., 483.00 us */
#define DASH_SPACE 1 /* space between columns (metrics) */

/* Common render data line fields */
typedef struct GDashRender_ {
Expand Down
2 changes: 1 addition & 1 deletion src/gdns.h
Expand Up @@ -45,7 +45,7 @@ typedef struct GDnsQueue_ {
int tail; /* index to tail of queue */
int size; /* queue size */
int capacity; /* length at most */
char buffer[QUEUE_SIZE][H_SIZE]; /* data item */
char buffer[QUEUE_SIZE][H_SIZE]; /* data item */
} GDnsQueue;

extern GDnsThread gdns_thread;
Expand Down
8 changes: 4 additions & 4 deletions src/geoip1.h
Expand Up @@ -36,10 +36,10 @@

#include "commons.h"

#define CITY_LEN 47 + 1 /* max string length for a city */
#define CONTINENT_LEN 47 + 1 /* max string length for a country */
#define COUNTRY_LEN 48 + 3 /* Country + two-letter Code */
#define ASN_LEN 64 + 6 /* ASN + 5 digit/16-bit number/code */
#define CITY_LEN 47 + 1 /* max string length for a city */
#define CONTINENT_LEN 47 + 1 /* max string length for a country */
#define COUNTRY_LEN 48 + 3 /* Country + two-letter Code */
#define ASN_LEN 64 + 6 /* ASN + 5 digit/16-bit number/code */

/* Type of IP */
typedef enum {
Expand Down
6 changes: 2 additions & 4 deletions src/gholder.c
Expand Up @@ -599,8 +599,7 @@ set_root_metrics (GRawDataItem item, GModule module, datatype type, GMetrics **n

/* Set all root panel data, including sub list items. */
static void
add_root_to_holder (GRawDataItem item, GHolder *h, datatype type,
GO_UNUSED const GPanel *panel) {
add_root_to_holder (GRawDataItem item, GHolder *h, datatype type, GO_UNUSED const GPanel *panel) {
GSubList *sub_list;
GMetrics *metrics, *nmetrics;
char *root = NULL;
Expand Down Expand Up @@ -639,8 +638,7 @@ add_root_to_holder (GRawDataItem item, GHolder *h, datatype type,
h->items[idx].metrics->bw.nbw += nmetrics->bw.nbw;
h->items[idx].metrics->hits += nmetrics->hits;
h->items[idx].metrics->visitors += nmetrics->visitors;
h->items[idx].metrics->avgts.nts =
h->items[idx].metrics->cumts.nts / h->items[idx].metrics->hits;
h->items[idx].metrics->avgts.nts = h->items[idx].metrics->cumts.nts / h->items[idx].metrics->hits;

if (nmetrics->maxts.nts > h->items[idx].metrics->maxts.nts)
h->items[idx].metrics->maxts.nts = nmetrics->maxts.nts;
Expand Down
27 changes: 9 additions & 18 deletions src/gkmhash.c
Expand Up @@ -447,8 +447,7 @@ ht_insert_keymap (GModule module, uint32_t date, uint32_t key, uint32_t *ckey) {
* On error, -1 is returned.
* On success 0 is returned */
int
ht_insert_rootmap (GModule module, uint32_t date, uint32_t key, const char *value,
uint32_t ckey) {
ht_insert_rootmap (GModule module, uint32_t date, uint32_t key, const char *value, uint32_t ckey) {
khash_t (is32) * hash = get_hash (module, date, MTRC_ROOTMAP);
khash_t (is32) * cache = get_hash_from_cache (module, MTRC_ROOTMAP);
char *dupval = NULL;
Expand All @@ -471,8 +470,7 @@ ht_insert_rootmap (GModule module, uint32_t date, uint32_t key, const char *valu
* On error, -1 is returned.
* On success 0 is returned */
int
ht_insert_datamap (GModule module, uint32_t date, uint32_t key, const char *value,
uint32_t ckey) {
ht_insert_datamap (GModule module, uint32_t date, uint32_t key, const char *value, uint32_t ckey) {
khash_t (is32) * hash = get_hash (module, date, MTRC_DATAMAP);
khash_t (is32) * cache = get_hash_from_cache (module, MTRC_DATAMAP);
char *dupval = NULL;
Expand Down Expand Up @@ -614,8 +612,7 @@ ht_insert_maxts (GModule module, uint32_t date, uint32_t key, uint64_t value, ui
* On error, or if key exists, -1 is returned.
* On success 0 is returned */
int
ht_insert_method (GModule module, uint32_t date, uint32_t key, const char *value,
uint32_t ckey) {
ht_insert_method (GModule module, uint32_t date, uint32_t key, const char *value, uint32_t ckey) {
GKDB *db = get_db_instance (DB_INSTANCE);
khash_t (ii08) * hash = get_hash (module, date, MTRC_METHODS);
khash_t (ii08) * cache = get_hash_from_cache (module, MTRC_METHODS);
Expand All @@ -640,8 +637,7 @@ ht_insert_method (GModule module, uint32_t date, uint32_t key, const char *value
* On error, or if key exists, -1 is returned.
* On success 0 is returned */
int
ht_insert_protocol (GModule module, uint32_t date, uint32_t key, const char *value,
uint32_t ckey) {
ht_insert_protocol (GModule module, uint32_t date, uint32_t key, const char *value, uint32_t ckey) {
GKDB *db = get_db_instance (DB_INSTANCE);
khash_t (ii08) * hash = get_hash (module, date, MTRC_PROTOCOLS);
khash_t (ii08) * cache = get_hash_from_cache (module, MTRC_PROTOCOLS);
Expand Down Expand Up @@ -1190,8 +1186,7 @@ ins_cache_map (GModule module, GSMetric metric, uint32_t key) {
}

static int
ins_cache_ii08 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t key,
uint32_t ckey) {
ins_cache_ii08 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t key, uint32_t ckey) {
khash_t (ii08) * hash = get_hash_from_store (store, module, metric);
khash_t (ii08) * cache = get_hash_from_cache (module, metric);
khint_t k;
Expand All @@ -1202,8 +1197,7 @@ ins_cache_ii08 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t
}

static int
ins_cache_is32 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t key,
uint32_t ckey) {
ins_cache_is32 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t key, uint32_t ckey) {
khash_t (is32) * hash = get_hash_from_store (store, module, metric);
khash_t (is32) * cache = get_hash_from_cache (module, metric);
khint_t k;
Expand All @@ -1214,8 +1208,7 @@ ins_cache_is32 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t
}

static int
inc_cache_ii32 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t key,
uint32_t ckey) {
inc_cache_ii32 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t key, uint32_t ckey) {
khash_t (ii32) * hash = get_hash_from_store (store, module, metric);
khash_t (ii32) * cache = get_hash_from_cache (module, metric);
khint_t k;
Expand All @@ -1226,8 +1219,7 @@ inc_cache_ii32 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t
}

static int
max_cache_iu64 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t key,
uint32_t ckey) {
max_cache_iu64 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t key, uint32_t ckey) {
khash_t (iu64) * hash = get_hash_from_store (store, module, metric);
khash_t (iu64) * cache = get_hash_from_cache (module, metric);
khint_t k;
Expand All @@ -1241,8 +1233,7 @@ max_cache_iu64 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t
}

static int
inc_cache_iu64 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t key,
uint32_t ckey) {
inc_cache_iu64 (GKHashStorage *store, GModule module, GSMetric metric, uint32_t key, uint32_t ckey) {
khash_t (iu64) * hash = get_hash_from_store (store, module, metric);
khash_t (iu64) * cache = get_hash_from_cache (module, metric);
khint_t k;
Expand Down
3 changes: 1 addition & 2 deletions src/gmenu.c
Expand Up @@ -64,8 +64,7 @@ new_gmenu (WINDOW *parent, int h, int w, int y, int x) {

/* Render actual menu item */
static void
draw_menu_item (GMenu *menu, char *s, int x, int y, int w, int checked,
GColors *(*func) (void)) {
draw_menu_item (GMenu *menu, char *s, int x, int y, int w, int checked, GColors *(*func) (void)) {
char check, *lbl = NULL;

if (menu->selectable) {
Expand Down
12 changes: 6 additions & 6 deletions src/goaccess.c
Expand Up @@ -351,8 +351,8 @@ allocate_data_by_module (GModule module, int col_data) {
size = holder[module].idx > col_data ? col_data : holder[module].idx;
}

dash->module[module].alloc_data = size; /* data allocated */
dash->module[module].ht_size = holder[module].ht_size; /* hash table size */
dash->module[module].alloc_data = size; /* data allocated */
dash->module[module].ht_size = holder[module].ht_size; /* hash table size */
dash->module[module].idx_data = 0;
dash->module[module].pos_y = 0;

Expand Down Expand Up @@ -901,7 +901,7 @@ tail_loop_html (Logs *logs) {
break;

for (i = 0, ret = 0; i < logs->size; ++i)
ret |= perform_tail_follow (&logs->glog[i]); /* 0.2 secs */
ret |= perform_tail_follow (&logs->glog[i]); /* 0.2 secs */

if (1 == ret)
tail_html ();
Expand Down Expand Up @@ -999,7 +999,7 @@ render_sort_dialog (void) {

static void
term_tail_logs (Logs *logs) {
struct timespec ts = {.tv_sec = 0,.tv_nsec = 200000000 }; /* 0.2 seconds */
struct timespec ts = {.tv_sec = 0,.tv_nsec = 200000000 }; /* 0.2 seconds */
uint32_t offset = 0;
int i, ret;

Expand Down Expand Up @@ -1182,13 +1182,13 @@ get_keys (Logs *logs) {
expand_current_module ();
display_content (main_win, dash, &gscroll);
break;
case KEY_DOWN: /* scroll main dashboard */
case KEY_DOWN: /* scroll main dashboard */
if ((gscroll.dash + main_win_height) < dash->total_alloc) {
gscroll.dash++;
display_content (main_win, dash, &gscroll);
}
break;
case KEY_MOUSE: /* handles mouse events */
case KEY_MOUSE: /* handles mouse events */
if (expand_on_mouse_click () == 0)
render_screens (offset);
break;
Expand Down

0 comments on commit 2eb7e63

Please sign in to comment.