sarg  2.4.0
About: SARG ia a Squid Analysis Report Generator.
  Fossies Dox: sarg-2.4.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

index.c File Reference

Create the HTML index of the reports */. More...

#include "include/conf.h"
#include "include/defs.h"
Include dependency graph for index.c:

Go to the source code of this file.

Macros

#define MY_LSTAT   stat
 
#define MAX_CREATION_DATE   15
 

Functions

static void make_date_index (void)
 
static void make_file_index (void)
 
static void file_index_to_date_index (const char *entry)
 
static void date_index_to_file_index (const char *entry)
 
void make_index (void)
 
static long long int get_file_size (struct stat *statb)
 
static long long int get_size (char *path, int path_size)
 
static long long int make_date_index_day (char *monthdir, int monthdir_size, int order, const char *yearnum, const char *monthnum)
 
static void name_month (int month, char *month_name, int month_size)
 
static long long int make_date_index_month (char *yeardir, int yeardir_size, int order, const char *yearnum)
 

Detailed Description

Create the HTML index of the reports */.

/*!

Definition in file index.c.

Macro Definition Documentation

◆ MAX_CREATION_DATE

#define MAX_CREATION_DATE   15

◆ MY_LSTAT

#define MY_LSTAT   stat

Definition at line 33 of file index.c.

Function Documentation

◆ date_index_to_file_index()

static void date_index_to_file_index ( const char *  entry)
static
Bug:
The links to the images in the reports are broken after moving the directories as the the HTML files are not at the right level for the images any more.

Definition at line 961 of file index.c.

References _, conv_month_name(), debuga(), df, format_path(), MAXLEN, outdir, and val1.

Referenced by make_index().

Here is the caller graph for this function:

◆ file_index_to_date_index()

static void file_index_to_date_index ( const char *  entry)
static

Definition at line 821 of file index.c.

References _, cmd, conv_month(), debuga(), debuga_more(), df, format_path(), MAXLEN, outdir, and PortableMkDir().

Referenced by make_index().

Here is the caller graph for this function:

◆ get_file_size()

static long long int get_file_size ( struct stat *  statb)
static

Get the effective size of a regular file or directory.

Parameters
statbThe structure filled by lstat(2).
Returns
The size occupied on the disk (more or less).

The actual size occupied on disk by a file or a directory table is not a trivial computation. It must take into account sparse files, compression, deduplication and probably many more.

Here, we assume the file takes a whole number of blocks (which is not the case of ReiserFS); the block size is constant (which is not the case of ZFS); every data block is stored in one individal block (no deduplication as is done by btrfs); data are not compressed (unlike ReiserFS and ZFS).

As we are dealing with directories containing mostly text and a few compressed pictures, we don't worry about sparse files with lot of zeros that would take less blocks than the actual file size.

Definition at line 112 of file index.c.

Referenced by get_size(), make_date_index_day(), and make_date_index_month().

Here is the caller graph for this function:

◆ get_size()

static long long int get_size ( char *  path,
int  path_size 
)
static

Get the size of a directory.

The size is the size of the directory content excluding the directory table. The "du" tool on Linux returns the content size including the directory table.

Parameters
pathThe directory whose size is computed. This is a buffer that must be big enough to contains the deepest path as directory entries are appended to the string this buffer contains.
path_sizeThe number of bytes available in the path buffer.
Returns
The number of bytes occupied by the directory content.

Definition at line 141 of file index.c.

References _, debuga(), debuga_more(), get_file_size(), and MY_LSTAT.

Referenced by make_date_index_day().

Here is the caller graph for this function:

◆ make_date_index()

static void make_date_index ( void  )
static

Rebuild a date index tree in the output directory.

Definition at line 531 of file index.c.

References _, close_html_header(), debuga(), debuga_more(), fixnum(), HTML_JS_NONE, INDEX_HTML_FILE, IndexFields, INDEXFIELDS_DIRSIZE, IndexSortOrder, make_date_index_month(), MAXLEN, ngettext, outdir, write_html_header(), and write_html_trailer().

Referenced by make_index().

Here is the caller graph for this function:

◆ make_date_index_day()

static long long int make_date_index_day ( char *  monthdir,
int  monthdir_size,
int  order,
const char *  yearnum,
const char *  monthnum 
)
static

Rebuild the html index file for a day when the reports are grouped in a date tree.

Parameters
monthdirThe buffer containing the path where the html index file must be rebuild. The buffer must be big enough to contain the deepest path in that directory as the buffer is used to concatenate the directory entries.
monthdir_sizeThe size, in byte, of the monthdir buffer.
orderA postive number to sort the index file in positive order. A negative value sort it in decreasing order.
yearnumThe string naming the year in the date tree.
monthnumThe string naming the month in the date tree.
Returns
The approximate size occupied by the directory.

Definition at line 233 of file index.c.

References _, close_html_header(), debuga(), debuga_more(), fixnum(), get_file_size(), get_size(), HTML_JS_NONE, INDEX_HTML_FILE, IndexFields, INDEXFIELDS_DIRSIZE, MY_LSTAT, ngettext, write_html_header(), and write_html_trailer().

Referenced by make_date_index_month().

Here is the caller graph for this function:

◆ make_date_index_month()

static long long int make_date_index_month ( char *  yeardir,
int  yeardir_size,
int  order,
const char *  yearnum 
)
static

Rebuild the html index file for a month when the reports are grouped in a date tree.

Parameters
yeardirThe buffer containing the path where the html index file must be rebuild. The buffer must be big enough to contain the deepest path in that directory as the buffer is used to concatenate the directory entries.
yeardir_sizeThe size, in byte, of the yeardir buffer.
orderA postive number to sort the index file in positive order. A negative value sort it in decreasing order.
yearnumThe string naming the year in the date tree.
Returns
The approximate size occupied by the directory.

Definition at line 391 of file index.c.

References _, close_html_header(), debuga(), debuga_more(), fixnum(), get_file_size(), HTML_JS_NONE, INDEX_HTML_FILE, IndexFields, INDEXFIELDS_DIRSIZE, make_date_index_day(), MY_LSTAT, name_month(), ngettext, write_html_header(), and write_html_trailer().

Referenced by make_date_index().

Here is the caller graph for this function:

◆ make_file_index()

static void make_file_index ( void  )
static

Definition at line 646 of file index.c.

References _, buildymd(), close_html_header(), conv_month(), debuga(), debuga_more(), df, fixnum(), formatdate(), getword_multisep(), getword_skip(), getword_start(), HTML_JS_SORTTABLE, if, INDEX_HTML_FILE, IndexSortOrder, MAX_CREATION_DATE, MAXLEN, ngettext, obtdate(), obttotal(), obtuser(), outdir, ReplaceIndex, safe_strcpy(), SortTableJs, write_html_header(), and write_html_trailer().

Referenced by make_index().

Here is the caller graph for this function:

◆ make_index()

void make_index ( void  )

Definition at line 42 of file index.c.

References _, date_index_to_file_index(), debug, debuga(), debuga_more(), file_index_to_date_index(), Index, INDEX_HTML_FILE, INDEX_NO, INDEX_TREE_DATE, IndexTree, LastLog, make_date_index(), make_file_index(), MAXLEN, mklastlog(), and outdir.

Referenced by gerarel().

Here is the caller graph for this function:

◆ name_month()

static void name_month ( int  month,
char *  month_name,
int  month_size 
)
static

Get the name of a month based on its number.

Parameters
monthThe month number starting from one.
month_nameThe buffer to store the month name.
month_sizeThe size of the month_name buffer.

Definition at line 365 of file index.c.

References _, debuga(), and N_.

Referenced by make_date_index_month().

Here is the caller graph for this function: