Skip to content

Commit

Permalink
Added some missing comments to the code
Browse files Browse the repository at this point in the history
  • Loading branch information
allinurl committed Jul 15, 2013
1 parent c1af998 commit 80bcdfd
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 42 deletions.
19 changes: 18 additions & 1 deletion gdashboard.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* gmenu.c -- goaccess menus
* gmenu.c -- goaccess main dashboard
* Copyright (C) 2009-2013 by Gerardo Orellana <[email protected]>
* GoAccess - An Ncurses apache weblog analyzer & interactive viewer
*
Expand Down Expand Up @@ -640,6 +640,7 @@ render_content (WINDOW * win, GDashModule * module_data, int *y, int *offset,
}
}

/* entry point to render dashboard */
void
display_content (WINDOW * win, GLog * logger, GDash * dash,
GScrolling * scrolling)
Expand All @@ -665,6 +666,7 @@ display_content (WINDOW * win, GLog * logger, GDash * dash,
}
}

/* every module other than VISITORS will use total req as base */
switch (i) {
case VISITORS:
process = g_hash_table_size (ht_unique_visitors);
Expand Down Expand Up @@ -741,6 +743,7 @@ perform_find_dash_scroll (GScrolling * scrolling, GModule module)
find_t.module = module;
}

/* find item within the given sub_list */
static int
find_next_sub_item (GSubList * sub_list, regex_t * regex)
{
Expand Down Expand Up @@ -833,6 +836,7 @@ perform_next_find (GHolder * h, GScrolling * scrolling)
return 0;
}

/* render find dialog */
int
render_find_dialog (WINDOW * main_win, GScrolling * scrolling)
{
Expand Down Expand Up @@ -866,6 +870,7 @@ render_find_dialog (WINDOW * main_win, GScrolling * scrolling)
return valid;
}

/* get bandwidth consumption for given key */
static unsigned long long
get_bandwidth (const char *key, GModule module)
{
Expand Down Expand Up @@ -899,6 +904,7 @@ get_bandwidth (const char *key, GModule module)
return 0;
}

/* get time taken to serve the request, in microseconds for given key */
static unsigned long long
get_serve_time (const char *key, GModule module)
{
Expand Down Expand Up @@ -928,6 +934,8 @@ get_serve_time (const char *key, GModule module)
return 0;
}

/* iterate over holder and get the key index.
* return -1 if not found */
int
get_item_idx_in_holder (GHolder * holder, char *k)
{
Expand All @@ -945,6 +953,7 @@ get_item_idx_in_holder (GHolder * holder, char *k)
return -1;
}

/* add an item from a sub_list to the dashboard */
static void
add_sub_item_to_dash (GDash ** dash, GHolderItem item, GModule module, int *i)
{
Expand Down Expand Up @@ -991,6 +1000,7 @@ get_geoip_data (const char *data)
return (char *) location;
}

/* add a host item to holder */
static void
add_host_node (GHolder * h, int hits, char *data, unsigned long long bw,
unsigned long long usecs)
Expand Down Expand Up @@ -1035,6 +1045,7 @@ add_host_node (GHolder * h, int hits, char *data, unsigned long long bw,
h->idx++;
}

/* add a browser item to holder */
static void
add_os_browser_node (GHolder * h, int hits, char *data, unsigned long long bw)
{
Expand Down Expand Up @@ -1070,6 +1081,7 @@ add_os_browser_node (GHolder * h, int hits, char *data, unsigned long long bw)
free (type);
}

/* add a status code item to holder */
static void
add_status_code_node (GHolder * h, int hits, char *data, unsigned long long bw)
{
Expand Down Expand Up @@ -1102,6 +1114,7 @@ add_status_code_node (GHolder * h, int hits, char *data, unsigned long long bw)
}
}

/* add a first level item to dashboard */
static void
add_item_to_dash (GDash ** dash, GHolderItem item, GModule module)
{
Expand All @@ -1119,6 +1132,7 @@ add_item_to_dash (GDash ** dash, GHolderItem item, GModule module)
(*idx)++;
}

/* load holder's data into dashboard */
void
load_data_to_dash (GHolder * h, GDash * dash, GModule module,
GScrolling * scrolling)
Expand Down Expand Up @@ -1242,6 +1256,7 @@ load_host_to_holder (GHolder * h, char *ip)
}
}

/* load raw hash table's data into holder */
void
load_data_to_holder (GRawData * raw_data, GHolder * h, GModule module,
GSort sort)
Expand Down Expand Up @@ -1291,6 +1306,7 @@ load_data_to_holder (GRawData * raw_data, GHolder * h, GModule module,
free_raw_data (raw_data);
}

/* iterate over the key/value pairs in the hash table */
static void
raw_data_iter (gpointer k, gpointer v, gpointer data_ptr)
{
Expand All @@ -1317,6 +1333,7 @@ raw_data_iter (gpointer k, gpointer v, gpointer data_ptr)
raw_data->idx++;
}

/* store the key/value pairs from a hash table into raw_data */
GRawData *
parse_raw_data (GHashTable * ht, int ht_size, GModule module)
{
Expand Down
4 changes: 4 additions & 0 deletions gmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "util.h"
#include "ui.h"

/* allocate memory for a new GMenu instance */
GMenu *
new_gmenu (WINDOW * parent, int h, int w, int y, int x)
{
Expand All @@ -54,6 +55,7 @@ new_gmenu (WINDOW * parent, int h, int w, int y, int x)
return menu;
}

/* displays a menu to its associated window */
int
post_gmenu (GMenu * menu)
{
Expand All @@ -76,6 +78,7 @@ post_gmenu (GMenu * menu)
return 0;
}

/* main work horse of the menu system processing input events */
void
gmenu_driver (GMenu * menu, int c)
{
Expand Down Expand Up @@ -111,6 +114,7 @@ gmenu_driver (GMenu * menu, int c)
}
}

/* render an actual menu item */
void
draw_menu_item (GMenu * menu, char *s, int x, int y, int w, int color,
int checked)
Expand Down
4 changes: 4 additions & 0 deletions goaccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ house_keeping (GLog * logger, GDash * dash)
g_hash_table_destroy (ht_unique_visitors);
}

/* allocate memory for an instance of holder */
static void
allocate_holder (void)
{
Expand Down Expand Up @@ -221,6 +222,7 @@ allocate_holder (void)
}
}

/* allocate memory for an instance of dashboard */
static void
allocate_data ()
{
Expand Down Expand Up @@ -320,6 +322,7 @@ allocate_hosts_holder (char *ip)
load_host_to_holder (holder + HOSTS, ip);
}

/* render all windows */
void
render_screens (GLog * logger)
{
Expand Down Expand Up @@ -359,6 +362,7 @@ render_screens (GLog * logger)
"Nothing valid to process.");
}

/* collapse the current expanded module */
static void
collapse_current_module (void)
{
Expand Down
2 changes: 2 additions & 0 deletions output.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "gdashboard.h"
#include "util.h"

/* sanitize output with html entities for special chars */
static void
clean_output (FILE * fp, char *s)
{
Expand Down Expand Up @@ -775,6 +776,7 @@ print_html_summary (FILE * fp, GLog * logger)
free (size);
}

/* entry point to generate a report writing it to the fp */
void
output_html (GLog * logger, GHolder * holder)
{
Expand Down
Loading

0 comments on commit 80bcdfd

Please sign in to comment.