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)  

defs.h File Reference

Declaration of the structures and functions. More...

Include dependency graph for defs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  getwordstruct
 
struct  generalitemstruct
 
struct  userinfostruct
 What is known about a user. More...
 
struct  globalstatstruct
 Global statistics. More...
 
struct  ReadLogDataStruct
 Log filtering criterion. More...
 
struct  PerUserLimitStruct
 How to log every user crossing the download limit. More...
 

Typedefs

typedef struct longlinestructlongline
 
typedef struct userscanstructuserscan
 Scan through the known users. More...
 
typedef struct DayStructDayObject
 The object to store the daily statistics. More...
 

Enumerations

enum  DebugLogLevel { LogLevel_Process =1, LogLevel_Debug, LogLevel_Source, LogLevel_Data }
 Constants to compare the log level to display messages. More...
 
enum  UserProcessError {
  USERERR_NoError, USERERR_NameTooLong, USERERR_Excluded, USERERR_InvalidChar,
  USERERR_EmptyUser, USERERR_SysUser, USERERR_Ignored, USERERR_Untracked
}
 Error codes returned by process_user. More...
 
enum  PerUserFileCreationEnum { PUFC_Always, PUFC_AsRequired }
 How to handle the per_user_limit file creation. More...
 
enum  PerUserOutputEnum { PUOE_UserId, PUOE_UserIp }
 What to write into the per_user_limit file. More...
 

Functions

void htaccess (const struct userinfostruct *uinfo)
 
void authfail_open (void)
 
void authfail_write (const struct ReadLogStruct *log_entry)
 
void authfail_close (void)
 
bool is_authfail (void)
 
void authfail_report (void)
 
void authfail_cleanup (void)
 
void convlog (const char *arq, char df, const struct ReadLogDataStruct *ReadFilter)
 
void css_content (FILE *fp_css)
 
void css (FILE *fp_css)
 
void dansguardian_log (const struct ReadLogDataStruct *ReadFilter)
 
void dansguardian_report (void)
 
void data_file (char *tmp)
 
FileObjectdecomp (const char *arq)
 
void denied_open (void)
 
void denied_write (const struct ReadLogStruct *log_entry)
 
void denied_close (void)
 
bool is_denied (void)
 
void gen_denied_report (void)
 
void denied_cleanup (void)
 
void download_open (void)
 
void download_write (const struct ReadLogStruct *log_entry, const char *url)
 
void download_close (void)
 
bool is_download (void)
 
void download_report (void)
 
void free_download (void)
 
void set_download_suffix (const char *list)
 
bool is_download_suffix (const char *url)
 
void download_cleanup (void)
 
FILE * Email_OutputFile (const char *Module)
 
void Email_Send (FILE *fp, const char *Subject)
 
void gethexclude (const char *hexfile, int debug)
 
void getuexclude (const char *uexfile, int debug)
 
int vhexclude (const char *url)
 
int vuexclude (const char *user)
 
bool is_indexonly (void)
 
void free_exclude (void)
 
int fnmatch (const char *pattern, const char *string, int flags)
 
void getconf (const char *File)
 
void greport_prepare (void)
 
void greport_day (const struct userinfostruct *user)
 
void greport_cleanup (void)
 
void htmlrel (void)
 
void index_only (const char *dirname, int debug)
 
int ip2name_config (const char *param)
 
void ip2name_forcedns (void)
 
void ip2name (char *ip, int ip_len)
 
void ip2name_cleanup (void)
 
void name2ip (char *name, int name_size)
 
void mklastlog (const char *outdir)
 
longline longline_create (void)
 
void longline_reset (longline line)
 
char * longline_read (FileObject *fp_in, longline line)
 
void longline_destroy (longline *line_ptr)
 
void make_index (void)
 
int ReadLogFile (struct ReadLogDataStruct *Filter)
 
bool GetLogPeriod (struct tm *Start, struct tm *End)
 
void realtime (void)
 
void redirector_log (const struct ReadLogDataStruct *ReadFilter)
 
void redirector_report (void)
 
void report_day (const struct userinfostruct *user)
 
void gerarel (const struct ReadLogDataStruct *ReadFilter)
 
int ger_read (char *buffer, struct generalitemstruct *item, const char *filename)
 
void totalger (FILE *fp_gen, const char *filename)
 
void siteuser (void)
 
void smartfilter_report (void)
 
void sort_users_log (const char *tmp, int debug, struct userinfostruct *uinfo)
 
void tmpsort (const struct userinfostruct *uinfo)
 
void sort_labels (const char **label, const char **order)
 
void splitlog (const char *arq, char df, const struct ReadLogDataStruct *ReadFilter, int convert, const char *splitprefix)
 
void topsites (void)
 
void topuser (void)
 
DayObject day_prepare (void)
 
void day_cleanup (DayObject ddata)
 
void day_newuser (DayObject ddata)
 
void day_addpoint (DayObject ddata, const char *date, const char *time, long long int elap, long long int bytes)
 
void day_totalize (DayObject ddata, const char *tmp, const struct userinfostruct *uinfo)
 
void day_deletefile (const struct userinfostruct *uinfo)
 
void read_hostalias (const char *Filename)
 
void free_hostalias (void)
 
const char * skip_scheme (const char *url)
 
const char * process_url (const char *url, bool full_url)
 
void url_hostname (const char *url, char *hostname, int hostsize)
 
void usage (const char *prog)
 
FILE * UserAgent_Open (void)
 
void UserAgent_Write (FILE *fp, const struct tm *Time, const char *Ip, const char *User, const char *Agent)
 
void UserAgent_Readlog (const struct ReadLogDataStruct *ReadFilter)
 
void UserAgent (void)
 
struct userinfostructuserinfo_create (const char *userid, const char *ip)
 
void userinfo_free (void)
 
void userinfo_label (struct userinfostruct *uinfo, const char *label)
 
struct userinfostructuserinfo_find_from_file (const char *filename)
 
struct userinfostructuserinfo_find_from_id (const char *id)
 
struct userinfostructuserinfo_find_from_ip (const char *ip)
 
userscan userinfo_startscan (void)
 
void userinfo_stopscan (userscan uscan)
 
struct userinfostructuserinfo_advancescan (userscan uscan)
 
void userinfo_clearflag (void)
 
void read_useralias (const char *Filename)
 
void free_useralias (void)
 
enum UserProcessError process_user (const char **UserPtr, const char *IpAddress, bool *IsIp)
 
void init_usertab (const char *UserTabFile)
 
void user_find (char *mappedname, int namelen, const char *userlogin)
 
void close_usertab (void)
 
void getword_start (struct getwordstruct *gwarea, const char *line)
 
void getword_restart (struct getwordstruct *gwarea)
 
int getword (char *word, int limit, struct getwordstruct *gwarea, char stop)
 
int getword_limit (char *word, int limit, struct getwordstruct *gwarea, char stop)
 
int getword_multisep (char *word, int limit, struct getwordstruct *gwarea, char stop)
 
int getword_skip (int limit, struct getwordstruct *gwarea, char stop)
 
int getword_atoll (long long int *number, struct getwordstruct *gwarea, char stop)
 
int getword_atoi (int *number, struct getwordstruct *gwarea, char stop)
 
int getword_atol (long int *number, struct getwordstruct *gwarea, char stop)
 
int getword_atolu (unsigned long int *number, struct getwordstruct *gwarea, char stop)
 
int getword_ptr (char *orig_line, char **word, struct getwordstruct *gwarea, char stop)
 
long long int my_atoll (const char *nptr)
 
int is_absolute (const char *path)
 
void getnumlist (const char *paramname, const char *buffer, int *list, int maxvalue)
 
bool numlistcontains (const int *list, int maxvalue, int value)
 
int conv_month (const char *month)
 
const char * conv_month_name (int month)
 
void buildymd (const char *dia, const char *mes, const char *ano, char *wdata, int wdata_size)
 
void date_from (struct ReadLogDataStruct *ReadFilter)
 
char * fixnum (long long int value, int n)
 
char * fixnum2 (long long int value, int n)
 
void fixnone (char *str)
 
char * fixtime (long long int elap)
 
void fixendofline (char *str)
 
void show_info (FILE *fp_ou)
 
void show_sarg (FILE *fp_ou, int depth)
 
void write_logo_image (FILE *fp_ou)
 
void write_html_head (FILE *fp_ou, int depth, const char *page_title, int javascript)
 
void write_html_header (FILE *fp_ou, int depth, const char *title, int javascript)
 
void close_html_header (FILE *fp_ou)
 
void write_html_trailer (FILE *fp_ou)
 
void output_html_string (FILE *fp_ou, const char *str, int maxlen)
 
void output_html_url (FILE *fp_ou, const char *url)
 
void output_html_link (FILE *fp_ou, const char *url, int maxlen)
 
void debuga (const char *File, int Line, const char *msg,...)
 
void debuga_more (const char *msg,...)
 
void debugaz (const char *File, int Line, const char *msg,...)
 
void my_lltoa (unsigned long long int n, char *s, int ssize, int len)
 
void url_module (const char *url, char *w2)
 
void url_to_anchor (const char *url, char *anchor, int size)
 
void safe_strcpy (char *dest, const char *src, int length)
 
void strip_latin (char *line)
 
char * buildtime (long long int elap)
 
int obtdate (const char *dirname, const char *name, char *data)
 
void formatdate (char *date, int date_size, int year, int month, int day, int hour, int minute, int second, int dst)
 
void computedate (int year, int month, int day, struct tm *t)
 
int obtuser (const char *dirname, const char *name)
 
void obttotal (const char *dirname, const char *name, int nuser, long long int *tbytes, long long int *media)
 
void version (void)
 
int vercode (const char *code)
 
void load_excludecodes (const char *ExcludeCodes)
 
void free_excludecodes (void)
 
int PortableMkDir (const char *path, int mode)
 
bool my_mkdir (const char *name)
 
void makeTmpDir (const char *tmp)
 
int testvaliduserchar (const char *user)
 
char * strlow (char *string)
 
char * strup (char *string)
 
int month2num (const char *month)
 
int builddia (int day, int month, int year)
 
int compare_date (const struct tm *date1, const struct tm *date2)
 
bool IsTreeFileDirName (const char *Name)
 
bool IsTreeYearFileName (const char *Name)
 
bool IsTreeMonthFileName (const char *Name)
 
bool IsTreeDayFileName (const char *Name)
 
int vrfydir (const struct periodstruct *per1, const char *addr, const char *site, const char *us)
 
int getperiod_fromsarglog (const char *arqtt, struct periodstruct *period)
 
void getperiod_fromrange (struct periodstruct *period, const struct ReadLogDataStruct *ReadFilter)
 
void getperiod_torange (const struct periodstruct *period, int *dfrom, int *duntil)
 
void getperiod_merge (struct periodstruct *main, struct periodstruct *candidate)
 
int getperiod_buildtext (struct periodstruct *period)
 
void removetmp (const char *outdir)
 
void zdate (char *ftime, int ftimesize, char DateFormat)
 
char * get_param_value (const char *param, char *line)
 
int compar (const void *, const void *)
 
void unlinkdir (const char *dir, bool contentonly)
 
void emptytmpdir (const char *dir)
 
int extract_address_mask (const char *buf, const char **text, unsigned char *ipv4, unsigned short int *ipv6, int *nbits, const char **next)
 
int format_path (const char *file, int line, char *output_buffer, int buffer_size, const char *format,...)
 
void append_to_path (char *base_path, int base_path_size, const char *append)
 

Detailed Description

Declaration of the structures and functions.

Definition in file defs.h.

Typedef Documentation

◆ DayObject

typedef struct DayStruct* DayObject

The object to store the daily statistics.

Definition at line 126 of file defs.h.

◆ longline

typedef struct longlinestruct* longline

Definition at line 33 of file defs.h.

◆ userscan

typedef struct userscanstruct* userscan

Scan through the known users.

Definition at line 105 of file defs.h.

Enumeration Type Documentation

◆ DebugLogLevel

Constants to compare the log level to display messages.

Enumerator
LogLevel_Process 

Process informational messages.

LogLevel_Debug 

Debug level messages.

LogLevel_Source 

Display the source file name and line number along with the message.

LogLevel_Data 

Display data about what is processed.

Definition at line 12 of file defs.h.

◆ PerUserFileCreationEnum

How to handle the per_user_limit file creation.

Enumerator
PUFC_Always 

Purge the file if it exists or create an empty file.

PUFC_AsRequired 

Delete old files and don't create a new file unless necessary.

Definition at line 156 of file defs.h.

◆ PerUserOutputEnum

What to write into the per_user_limit file.

Enumerator
PUOE_UserId 
PUOE_UserIp 

Definition at line 167 of file defs.h.

◆ UserProcessError

Error codes returned by process_user.

Enumerator
USERERR_NoError 
USERERR_NameTooLong 
USERERR_Excluded 
USERERR_InvalidChar 
USERERR_EmptyUser 
USERERR_SysUser 
USERERR_Ignored 
USERERR_Untracked 

Definition at line 64 of file defs.h.

Function Documentation

◆ append_to_path()

void append_to_path ( char *  base_path,
int  base_path_size,
const char *  append 
)

Definition at line 2681 of file util.c.

References _, and debuga().

Referenced by main().

Here is the caller graph for this function:

◆ authfail_cleanup()

void authfail_cleanup ( void  )

Remove any temporary file left by the authfail module.

Definition at line 299 of file authfail.c.

References _, authfail_unsort, debuga(), fp_authfail, and KeepTempLog.

Referenced by main().

Here is the caller graph for this function:

◆ authfail_close()

void authfail_close ( void  )

Close the file opened by authfail_open().

Definition at line 81 of file authfail.c.

References _, authfail_unsort, debuga(), and fp_authfail.

Referenced by ReadLogFile().

Here is the caller graph for this function:

◆ authfail_open()

void authfail_open ( void  )

Open a file to store the authentication failure.

Returns
The file handle or NULL if no file is necessary.

Definition at line 43 of file authfail.c.

References _, authfail_unsort, debuga(), debugaz(), debugz, format_path(), fp_authfail, LogLevel_Process, MY_FOPEN, Privacy, REPORT_TYPE_AUTH_FAILURES, ReportType, and tmp.

Referenced by ReadLogFile().

Here is the caller graph for this function:

◆ authfail_report()

◆ authfail_write()

void authfail_write ( const struct ReadLogStruct log_entry)

Write one entry in the unsorted authentication file file provided that it is required.

Parameters
log_entryThe entry to write into the log file.

Definition at line 67 of file authfail.c.

References authfail_exists, ReadLogStruct::EntryTime, fp_authfail, ReadLogStruct::HttpCode, ReadLogStruct::Ip, ReadLogStruct::Url, and ReadLogStruct::User.

Referenced by ReadOneLogFile().

Here is the caller graph for this function:

◆ builddia()

int builddia ( int  day,
int  month,
int  year 
)

Definition at line 534 of file util.c.

Referenced by ReadOneLogFile().

Here is the caller graph for this function:

◆ buildtime()

char* buildtime ( long long int  elap)

Definition at line 807 of file util.c.

Referenced by htmlrel(), TopUser_HtmlReport(), and TopUser_TextEmail().

Here is the caller graph for this function:

◆ buildymd()

void buildymd ( const char *  dia,
const char *  mes,
const char *  ano,
char *  wdata,
int  wdata_size 
)

Definition at line 566 of file util.c.

References month2num().

Referenced by make_file_index().

Here is the caller graph for this function:

◆ close_html_header()

void close_html_header ( FILE *  fp_ou)

Definition at line 2152 of file util.c.

Referenced by authfail_report(), dansguardian_report(), download_report(), gen_denied_report(), gerarel(), htmlrel(), make_date_index(), make_date_index_day(), make_date_index_month(), make_file_index(), redirector_report(), report_day(), siteuser(), topsites(), TopUser_HtmlReport(), and UserAgent().

Here is the caller graph for this function:

◆ close_usertab()

void close_usertab ( void  )

Free the memory and resources allocated by init_usertab().

Definition at line 478 of file usertab.c.

References destroy_cache(), and userfile.

Referenced by main().

Here is the caller graph for this function:

◆ compar()

int compar ( const void *  ,
const void *   
)

Definition at line 1951 of file util.c.

◆ compare_date()

int compare_date ( const struct tm *  date1,
const struct tm *  date2 
)

Compare two dates.

Parameters
date1The first date to compare.
date2The second date to compare.
Return values
-1If date1<date2.
0If date1==date2.
1if date1>date2.

Definition at line 549 of file util.c.

Referenced by ReadOneLogFile(), and UserAgent_Write().

Here is the caller graph for this function:

◆ computedate()

void computedate ( int  year,
int  month,
int  day,
struct tm *  t 
)

Definition at line 892 of file util.c.

Referenced by authfail_report(), download_report(), gen_denied_report(), redirector_report(), and report_day().

Here is the caller graph for this function:

◆ conv_month()

int conv_month ( const char *  month)

Definition at line 575 of file util.c.

References mtab1.

Referenced by file_index_to_date_index(), and make_file_index().

Here is the caller graph for this function:

◆ conv_month_name()

const char* conv_month_name ( int  month)

Definition at line 584 of file util.c.

References mtab1.

Referenced by date_index_to_file_index(), and vrfydir().

Here is the caller graph for this function:

◆ convlog()

void convlog ( const char *  arq,
char  df,
const struct ReadLogDataStruct ReadFilter 
)

Definition at line 30 of file convlog.c.

References _, getwordstruct::current, ReadLogDataStruct::DateRange, debuga(), df, ReadLogDataStruct::EndDate, ReadLogDataStruct::EndTime, FileObject_Close(), FileObject_GetLastCloseError(), FileObject_GetLastOpenError(), FileObject_Open(), getword(), getword_start(), longline_create(), longline_destroy(), longline_read(), ReadFilter, and ReadLogDataStruct::StartTime.

Referenced by main().

Here is the caller graph for this function:

◆ css()

void css ( FILE *  fp_css)

Definition at line 82 of file css.c.

References css_content(), and ExternalCSSFile.

Referenced by header(), and write_html_head().

Here is the caller graph for this function:

◆ css_content()

void css_content ( FILE *  fp_css)

Definition at line 30 of file css.c.

References BgColor, BgImage, FontFace, FontSize, HeaderBgColor, HeaderColor, HeaderFontSize, LogoTextColor, SortTableJs, TiColor, TitleFontSize, TxBgColor, and TxColor.

Referenced by css(), and main().

Here is the caller graph for this function:

◆ dansguardian_log()

void dansguardian_log ( const struct ReadLogDataStruct ReadFilter)

Definition at line 30 of file dansguardian_log.c.

References _, code2, dansguardian_count, DansGuardianConf, DansguardianFilterOutDate, debug, debuga(), debuga_more(), ReadLogDataStruct::EndTime, fixendofline(), format_path(), getperiod_torange(), getword(), getword_atoi(), getword_ptr(), getword_skip(), getword_start(), KeepTempLog, MAXLEN, MY_FOPEN, period, ReadFilter, ReadLogDataStruct::StartTime, and tmp.

Referenced by gerarel().

Here is the caller graph for this function:

◆ dansguardian_report()

void dansguardian_report ( void  )

Definition at line 38 of file dansguardian_report.c.

References _, close_html_header(), dansguardian_count, DansGuardianReportLimit, debuga(), debugaz(), debugz, df, format_path(), getword(), getword_ptr(), getword_start(), periodstruct::html, HTML_JS_NONE, INDEX_TREE_DATE, IndexTree, ip2name(), Ip2Name, KeepTempLog, LogLevel_Process, MAXLEN, MY_FOPEN, name, outdirname, output_html_link(), period, show_ignored_dansguardian(), tmp, user_find(), UserIp, write_html_header(), and write_html_trailer().

Referenced by gerarel().

Here is the caller graph for this function:

◆ data_file()

◆ date_from()

void date_from ( struct ReadLogDataStruct ReadFilter)

Definition at line 1619 of file util.c.

References _, ReadLogDataStruct::DateRange, debuga(), ReadLogDataStruct::EndDate, ReadFilter, and ReadLogDataStruct::StartDate.

Referenced by main().

Here is the caller graph for this function:

◆ day_addpoint()

void day_addpoint ( DayObject  ddata,
const char *  date,
const char *  time,
long long int  elap,
long long int  bytes 
)

Store one data point in the statistics.

Parameters
ddataThe object to store the statistics.
dateThe date of the data point formated as day/month/year.
timeThe time of the data point.
elapThe time spent processing the user's request on the proxy.
bytesThe number of bytes transfered by the user.

Definition at line 95 of file totday.c.

References _, DayStruct::bytes, DayStruct::daylist, debuga(), DayStruct::elap, DayStruct::maxindex, and DayStruct::ndaylist.

Referenced by gerarel().

Here is the caller graph for this function:

◆ day_cleanup()

void day_cleanup ( DayObject  ddata)

Free the memory allocated by day_prepare().

Parameters
ddataThe object returned by day_prepare().

Definition at line 65 of file totday.c.

Referenced by gerarel().

Here is the caller graph for this function:

◆ day_deletefile()

void day_deletefile ( const struct userinfostruct uinfo)

Delete the temporary file generated by day_totalize().

Parameters
uinfoThe user whose daily statistics are to be deleted.

Definition at line 194 of file totday.c.

References _, debuga(), debuga_more(), userinfostruct::filename, KeepTempLog, and tmp.

Referenced by TopUser_HtmlReport().

Here is the caller graph for this function:

◆ day_newuser()

void day_newuser ( DayObject  ddata)

Prepare the object for a new user.

Parameters
ddataThe object created by day_prepare().

Definition at line 75 of file totday.c.

References DayStruct::bytes, DayStruct::elap, DayStruct::maxindex, and DayStruct::ndaylist.

Referenced by gerarel().

Here is the caller graph for this function:

◆ day_prepare()

DayObject day_prepare ( void  )

Prepare the object to store the daily statistics of one user.

Returns
The object to pass to other functions in this module. The object must be freed with a call to day_cleanup().

Definition at line 46 of file totday.c.

References _, and debuga().

Referenced by gerarel().

Here is the caller graph for this function:

◆ day_totalize()

void day_totalize ( DayObject  ddata,
const char *  tmp,
const struct userinfostruct uinfo 
)

Store the dayly statistics in the file.

Parameters
ddataThe object containing the statistics.
tmpThe temporary directory to store the file into.
uinfoThe user's data.

Definition at line 140 of file totday.c.

References _, DayStruct::bytes, DATETIME_BYTE, DATETIME_ELAP, datetimeby, DayStruct::daylist, debuga(), debuga_more(), DayStruct::elap, userinfostruct::filename, DayStruct::maxindex, and tmp.

Referenced by gerarel().

Here is the caller graph for this function:

◆ debuga()

void debuga ( const char *  File,
int  Line,
const char *  msg,
  ... 
)

Write a debug message to stderr. The message is prefixed by "SARG:" to identify its origin.

Parameters
msgThe printf like message to format.
...The arguments to format in the message.

Definition at line 601 of file util.c.

References _, debugz, and LogLevel_Source.

Referenced by Alias_PrintList(), Alias_Store(), Alias_StoreIpv4(), Alias_StoreIpv6(), Alias_StoreName(), append_to_path(), AppendDirEntry(), authfail_cleanup(), authfail_close(), authfail_open(), authfail_report(), balance_node(), BuildDirDateList(), BuildDirList(), closett(), Common_ReadEntry(), convlog(), copy_images(), dansguardian_log(), dansguardian_report(), data_file(), date_from(), date_index_to_file_index(), day_addpoint(), day_deletefile(), day_prepare(), day_totalize(), decomp(), DeleteEmptyDirs(), denied_cleanup(), denied_close(), denied_open(), Dichotomic_Insert(), DisplayExcludeCount(), download_cleanup(), download_close(), download_open(), download_report(), download_sort(), Email_OutputFile(), Email_Send(), emptytmpdir(), ExtLog_ConcatUrl(), ExtLog_Fields(), ExtLog_ReadEntry(), file_index_to_date_index(), FileListIter_Next(), format_path(), gen_denied_report(), ger_read(), gerarel(), get_size(), getconf(), gethexclude(), GetLatestModified(), getnumlist(), getparam_2words(), getparam_int(), getparam_list(), getparam_quoted(), getparam_select(), getparam_sort(), getparam_string(), getparam_userlimit(), getuexclude(), getusers(), getword(), getword_atoi(), getword_atol(), getword_atoll(), getword_atolu(), getword_multisep(), getword_ptr(), getword_restart(), getword_skip(), grava_SmartFilter(), gravager(), gravaporuser(), greport_day(), greport_prepare(), htaccess(), htmlrel(), index_only(), init_file_usertab(), init_usertab(), ip2name(), ip2name_buildmoduleslist(), ip2name_chainmodule(), ip2name_configmodule(), ip2name_dns(), ip2name_exec(), ip2name_execconfig(), ip2name_forcedns(), load_excludecodes(), LogLine_Parse(), longline_read(), main(), make_date_index(), make_date_index_day(), make_date_index_month(), make_file_index(), make_index(), maketmp(), makeTmpDir(), mklastlog(), my_lltoa(), my_mkdir(), name2ip(), name_month(), obtdate(), obttotal(), obtuser(), parmtest(), parse_log(), process_user(), read_hostalias(), read_log(), read_useralias(), ReadLogFile(), ReadOneLogFile(), realtime(), redirector_log(), redirector_report(), removetmp(), report_day(), safe_strcpy(), Sarg_ReadEntry(), set_download_suffix(), set_total_users(), siteuser(), smartfilter_report(), sort_users_log(), splitlog(), Squid_ReadEntry(), store_exclude_ip4(), store_exclude_ip6(), store_exclude_url(), storenumlist(), tmpsort(), topsites(), topuser(), TopUser_HtmlReport(), TopUser_TextEmail(), totalger(), unlinkdir(), UserAgent(), UserAgent_Open(), UserAgent_Readlog(), userinfo_create(), userinfo_label(), and vrfydir().

Here is the caller graph for this function:

◆ debuga_more()

void debuga_more ( const char *  msg,
  ... 
)

Write a debug message to stderr. The message is supposed to be displayed after a message from debuga().

Parameters
msgThe printf like message to format.
...The arguments to format in the message.

Definition at line 631 of file util.c.

Referenced by authfail_report(), copy_images(), dansguardian_log(), data_file(), day_deletefile(), day_totalize(), emptytmpdir(), file_index_to_date_index(), gerarel(), get_size(), grava_SmartFilter(), gravaporuser(), greport_day(), htaccess(), htmlrel(), make_date_index(), make_date_index_day(), make_date_index_month(), make_file_index(), make_index(), maketmp(), mklastlog(), my_mkdir(), obtdate(), obttotal(), obtuser(), ReadLogFile(), ReadOneLogFile(), removetmp(), report_day(), smartfilter_report(), sort_users_log(), splitlog(), tmpsort(), unlinkdir(), and vrfydir().

Here is the caller graph for this function:

◆ debugaz()

void debugaz ( const char *  File,
int  Line,
const char *  msg,
  ... 
)

Write a debug message to stderr. The message is prefixed by "SARG: (info)".

Parameters
msgThe printf like message to format.
...The arguments to format in the message.

Definition at line 646 of file util.c.

References _, debugz, and LogLevel_Source.

Referenced by authfail_open(), authfail_report(), dansguardian_report(), denied_open(), download_open(), download_report(), gen_denied_report(), gerarel(), greport_prepare(), parmtest(), redirector_log(), redirector_report(), siteuser(), topsites(), and TopUser_HtmlReport().

Here is the caller graph for this function:

◆ decomp()

FileObject* decomp ( const char *  arq)

Open the log file. If it is compressed, uncompress it with the proper library.

Log files compressed with gzip, bzip2 can be uncompressed if sarg is compiled with the proper library.

If the log file does not exist, the process terminates with an error message.

Parameters
arqThe log file to process.

Definition at line 481 of file decomp.c.

References _, debuga(), and FileObject_FdOpen().

Referenced by read_log(), ReadOneLogFile(), splitlog(), and UserAgent_Readlog().

Here is the caller graph for this function:

◆ denied_cleanup()

void denied_cleanup ( void  )

Remove any temporary file left by the denied module.

Definition at line 291 of file denied.c.

References _, debuga(), denied_unsort, fp_denied, and KeepTempLog.

Referenced by main().

Here is the caller graph for this function:

◆ denied_close()

void denied_close ( void  )

Close the file opened by denied_open().

Definition at line 81 of file denied.c.

References _, debuga(), denied_unsort, and fp_denied.

Referenced by ReadLogFile().

Here is the caller graph for this function:

◆ denied_open()

void denied_open ( void  )

Open a file to store the denied accesses.

Returns
The file handle or NULL if no file is necessary.

Definition at line 43 of file denied.c.

References _, debuga(), debugaz(), debugz, denied_unsort, format_path(), fp_denied, LogLevel_Process, MY_FOPEN, Privacy, REPORT_TYPE_DENIED, ReportType, and tmp.

Referenced by ReadLogFile().

Here is the caller graph for this function:

◆ denied_write()

void denied_write ( const struct ReadLogStruct log_entry)

Write one entry in the unsorted denied file provided that it is required.

Parameters
log_entryThe entry to write into the log file.

Definition at line 67 of file denied.c.

References denied_exists, ReadLogStruct::EntryTime, fp_denied, ReadLogStruct::HttpCode, ReadLogStruct::Ip, ReadLogStruct::Url, and ReadLogStruct::User.

Referenced by ReadOneLogFile().

Here is the caller graph for this function:

◆ download_cleanup()

void download_cleanup ( void  )

Remove any temporary file left by the download module.

Definition at line 453 of file download.c.

References _, debuga(), download_unsort, and fp_download.

Referenced by main().

Here is the caller graph for this function:

◆ download_close()

void download_close ( void  )

Close the file opened by denied_open().

Definition at line 100 of file download.c.

References _, debuga(), download_unsort, and fp_download.

Referenced by ReadLogFile().

Here is the caller graph for this function:

◆ download_open()

void download_open ( void  )

Open a file to store the denied accesses.

Returns
The file handle or NULL if no file is necessary.

Definition at line 61 of file download.c.

References _, debuga(), debugaz(), debugz, download_unsort, format_path(), fp_download, LogLevel_Process, MY_FOPEN, Privacy, REPORT_TYPE_DOWNLOADS, ReportType, and tmp.

Referenced by ReadLogFile().

Here is the caller graph for this function:

◆ download_report()

◆ download_write()

void download_write ( const struct ReadLogStruct log_entry,
const char *  url 
)

Write one entry in the unsorted downloaded file provided that it is required.

Parameters
log_entryThe entry to write into the log file.
urlThe URL of the downloaded file.

Definition at line 86 of file download.c.

References download_exists, ReadLogStruct::EntryTime, fp_download, ReadLogStruct::HttpCode, ReadLogStruct::Ip, and ReadLogStruct::User.

Referenced by ReadOneLogFile().

Here is the caller graph for this function:

◆ Email_OutputFile()

FILE* Email_OutputFile ( const char *  Module)

Generate a file name to write the e-mail and open the file.

Parameters
ModuleThe module for which the e-mail is generated.
Returns
The file to which the e-mail can be written.

Definition at line 44 of file email.c.

References _, debuga(), email, EmailFileName, format_path(), and tmp.

Referenced by TopUser_TextEmail().

Here is the caller graph for this function:

◆ Email_Send()

void Email_Send ( FILE *  fp,
const char *  Subject 
)

Send the e-mail.

Parameters
fpThe file opened by Email_OutputFile().

Definition at line 66 of file email.c.

References _, debug, debuga(), email, EmailFileName, format_path(), KeepTempLog, MailUtility, MAXLEN, and warea.

Referenced by TopUser_TextEmail().

Here is the caller graph for this function:

◆ emptytmpdir()

void emptytmpdir ( const char *  dir)

Delete every file from the temporary directory where sarg is told to store its temporary files.

As any stray file left over by a previous run would be included in the report, we must delete every file from the temporary directory before we start processing the logs.

But the temporary directory is given by the user either in the configuration file or on the command line. We check that the user didn't give a wrong directory by looking at the files stored in the directory. If a single file is not one of ours, we abort.

Parameters
dirThe temporary directory to purge.

Definition at line 2401 of file util.c.

References _, debuga(), debuga_more(), MAXLEN, and unlinkdir().

Referenced by makeTmpDir().

Here is the caller graph for this function:

◆ extract_address_mask()

int extract_address_mask ( const char *  buf,
const char **  text,
unsigned char *  ipv4,
unsigned short int *  ipv6,
int *  nbits,
const char **  next 
)

Extract an url, IPv4 or IPv6 from a buffer. The IP addresses may end with a prefix size.

Parameters
bufThe buffer to parse.
textA pointer to set to the beginning of the string pattern. No terminating zero is inserted. The pointer may be NULL.
ipv4A 4 bytes buffer to store the bytes of the IPv4 address.
ipv6A 8 short integers buffer to store the values of the IPv6 address.
nbitsThe number of prefix bits for an IP address.
nextThe content of the line after the extracted address.
Return values
3The pattern is a IPv6 address.
2The pattern is a IPv4 address.
1The patter is a string.
0Empty pattern.

Definition at line 2534 of file util.c.

References addr, and mask.

Referenced by Alias_Replace(), Alias_Store(), gethexclude(), process_url(), and vhexclude().

Here is the caller graph for this function:

◆ fixendofline()

void fixendofline ( char *  str)

Definition at line 1911 of file util.c.

Referenced by dansguardian_log(), getconf(), gethexclude(), getuexclude(), greport_day(), init_file_usertab(), obtdate(), ReadOneLogFile(), redirector_log(), report_day(), and UserAgent().

Here is the caller graph for this function:

◆ fixnone()

void fixnone ( char *  str)

Definition at line 1900 of file util.c.

Referenced by getparam_2words(), getparam_quoted(), and getparam_string().

Here is the caller graph for this function:

◆ fixnum()

char* fixnum ( long long int  value,
int  n 
)

Definition at line 670 of file util.c.

References DISPLAY_ABBREV, DisplayedValues, MAXLEN_FIXNUM, my_lltoa(), and UseComma.

Referenced by htmlrel(), make_date_index(), make_date_index_day(), make_date_index_month(), make_file_index(), report_day(), siteuser(), topsites(), TopUser_HtmlReport(), and TopUser_TextEmail().

Here is the caller graph for this function:

◆ fixnum2()

char* fixnum2 ( long long int  value,
int  n 
)

Definition at line 767 of file util.c.

References MAXLEN_FIXNUM2, my_lltoa(), and UseComma.

Referenced by htmlrel(), and TopUser_HtmlReport().

Here is the caller graph for this function:

◆ fixtime()

char* fixtime ( long long int  elap)

Definition at line 1598 of file util.c.

Referenced by report_day(), and topsites().

Here is the caller graph for this function:

◆ fnmatch()

int fnmatch ( const char *  pattern,
const char *  string,
int  flags 
)

Simplified function to match a pattern against a file name. It is provided here for MingW which doesn't have that function.

Parameters
patternThe pattern to match. It can contain ? and *.
stringThe file name to match. Use slash as directory separator.
flags

Definition at line 39 of file fnmatch.c.

◆ format_path()

int format_path ( const char *  file,
int  line,
char *  output_buffer,
int  buffer_size,
const char *  format,
  ... 
)

◆ formatdate()

void formatdate ( char *  date,
int  date_size,
int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second,
int  dst 
)

Definition at line 871 of file util.c.

Referenced by make_file_index().

Here is the caller graph for this function:

◆ free_download()

void free_download ( void  )

Free the memory allocated by set_download_suffix().

Definition at line 324 of file download.c.

References DownloadSuffix, DownloadSuffixIndex, and NDownloadSuffix.

Referenced by main(), and set_download_suffix().

Here is the caller graph for this function:

◆ free_exclude()

void free_exclude ( void  )

Definition at line 387 of file exclude.c.

References exclude_ip4, exclude_name, excludeuser, num_exclude_name, and hostnamestruct::url.

Referenced by main().

Here is the caller graph for this function:

◆ free_excludecodes()

void free_excludecodes ( void  )

Definition at line 1874 of file util.c.

References excludecode.

Referenced by main().

Here is the caller graph for this function:

◆ free_hostalias()

void free_hostalias ( void  )

Free the memory allocated by read_hostalias().

Definition at line 633 of file url.c.

References hostalias_name::Alias, hostalias_ipv4::Alias, hostalias_ipv6::Alias, FirstAliasIpv4, FirstAliasIpv6, FirstAliasName, hostalias_name::HostName_Prefix, hostalias_name::HostName_Suffix, hostalias_name::Next, hostalias_ipv4::Next, and hostalias_ipv6::Next.

Referenced by main().

Here is the caller graph for this function:

◆ free_useralias()

void free_useralias ( void  )

Free the memory allocated by read_useralias().

Definition at line 364 of file userinfo.c.

References Alias_Destroy(), and UserAliases.

Referenced by main().

Here is the caller graph for this function:

◆ gen_denied_report()

◆ ger_read()

int ger_read ( char *  buffer,
struct generalitemstruct item,
const char *  filename 
)

◆ gerarel()

void gerarel ( const struct ReadLogDataStruct ReadFilter)

Definition at line 50 of file report.c.

References _, addr, ALIAS_PREFIX, arqtt, authfail_report(), close_html_header(), closett(), dansguardian_log(), dansguardian_report(), DansGuardianConf, datetimeby, day_addpoint(), day_cleanup(), day_newuser(), day_prepare(), day_totalize(), debug, debuga(), debuga_more(), debugaz(), debugz, download_report(), email, FileList_IsEmpty(), userinfostruct::filename, FileObject_Close(), FileObject_GetLastCloseError(), FileObject_GetLastOpenError(), FileObject_Open(), format_path(), fp_tt, gen_denied_report(), getword(), getword_atoll(), getword_ptr(), getword_skip(), getword_start(), globstat, grava_SmartFilter(), gravager(), gravaporuser(), gravatmp(), periodstruct::html, HTML_JS_NONE, htmlrel(), userinfostruct::id, userinfostruct::id_is_ip, globalstatstruct::incache, index_only(), INDEX_TREE_DATE, indexonly, IndexTree, init_usertab(), ip2name(), Ip2Name, iprel, KeepTempLog, userinfostruct::label, LogLevel_Process, longline_create(), longline_destroy(), longline_read(), make_index(), maketmp(), MAX_TRUNCATED_URL, MAX_USER_LEN, MAXLEN, MY_FOPEN, my_mkdir(), globalstatstruct::nacc, globalstatstruct::nbytes, globalstatstruct::oucache, outdirname, output_html_string(), period, pgettext, ReadFilter, redirector_log(), redirector_report(), removetmp(), REPORT_TYPE_AUTH_FAILURES, REPORT_TYPE_DENIED, REPORT_TYPE_DOWNLOADS, REPORT_TYPE_SITE_USER_TIME_DATE, REPORT_TYPE_SITES_USERS, REPORT_TYPE_TOPSITES, REPORT_TYPE_USERS_SITES, ReportType, safe_strcpy(), site, siteuser(), smartfilter, smartfilter_report(), sort_labels(), sort_users_log(), SuccessfulMsg, tmp, topsites(), topuser(), totalger(), ttopen, url_to_anchor(), us, user_find(), UserAgent(), UserAgent_Readlog(), UserAgentLog, userinfo_advancescan(), userinfo_label(), userinfo_startscan(), userinfo_stopscan(), UserTabFile, vrfydir(), and write_html_header().

Referenced by main().

Here is the caller graph for this function:

◆ get_param_value()

char* get_param_value ( const char *  param,
char *  line 
)

Definition at line 2326 of file util.c.

Referenced by redirector_log().

Here is the caller graph for this function:

◆ getconf()

void getconf ( const char *  File)

Definition at line 982 of file getconf.c.

References _, ConfigFile, debug, debuga(), debugz, fixendofline(), getconf(), getparam_string(), IncludeLevel, LogLevel_Data, MAXLEN, and parmtest().

Referenced by getconf(), and main().

Here is the caller graph for this function:

◆ gethexclude()

void gethexclude ( const char *  hexfile,
int  debug 
)

Read the file listing the host to exclude from the report.

Parameters
hexfileThe name of the file.
debugTrue to print debug information.

Definition at line 184 of file exclude.c.

References _, debug, debuga(), extract_address_mask(), fixendofline(), name, store_exclude_ip4(), store_exclude_ip6(), and store_exclude_url().

Referenced by main().

Here is the caller graph for this function:

◆ GetLogPeriod()

bool GetLogPeriod ( struct tm *  Start,
struct tm *  End 
)

Get the start and end date of the period covered by the log files.

Definition at line 915 of file readlog.c.

References EarliestDate, EarliestDateTime, LatestDate, and LatestDateTime.

Referenced by main().

Here is the caller graph for this function:

◆ getnumlist()

void getnumlist ( const char *  paramname,
const char *  buffer,
int *  list,
int  maxvalue 
)

Get a comma separated list of numbers and split them into separate values taking into account that no value may be greater than a maximum. If a value is a range, it is expended.

Any duplicate value is removed.

Parameters
paramnameName of the configuration parameter providing the list.
bufferThe string with the list of numbers.
listList where to store the numbers.
maxvalueThe maximum value allowed in the list.

The function terminate the application with an error message if the list is invalid.

Definition at line 1998 of file util.c.

References _, debuga(), and storenumlist().

Referenced by parmtest().

Here is the caller graph for this function:

◆ getperiod_buildtext()

int getperiod_buildtext ( struct periodstruct period)

Definition at line 1136 of file util.c.

References df, periodstruct::end, periodstruct::html, INDEX_TREE_FILE, IndexTree, period, safe_strcpy(), periodstruct::start, and periodstruct::text.

Referenced by main().

Here is the caller graph for this function:

◆ getperiod_fromrange()

void getperiod_fromrange ( struct periodstruct period,
const struct ReadLogDataStruct ReadFilter 
)

Fill the period with the specified range.

Parameters
periodThe period to change.
ReadFilterFilter containing the date range to write into the period.

Definition at line 1088 of file util.c.

References periodstruct::end, ReadLogDataStruct::EndDate, period, ReadFilter, periodstruct::start, and ReadLogDataStruct::StartDate.

Referenced by main().

Here is the caller graph for this function:

◆ getperiod_fromsarglog()

int getperiod_fromsarglog ( const char *  arqtt,
struct periodstruct period 
)

Definition at line 1009 of file util.c.

References arqtt, periodstruct::end, period, and periodstruct::start.

Referenced by Sarg_NewFile().

Here is the caller graph for this function:

◆ getperiod_merge()

void getperiod_merge ( struct periodstruct main,
struct periodstruct candidate 
)

Update the main period to encompass the period in candidate.

Definition at line 1122 of file util.c.

References periodstruct::end, main(), and periodstruct::start.

Referenced by Sarg_ReadEntry().

Here is the caller graph for this function:

◆ getperiod_torange()

void getperiod_torange ( const struct periodstruct period,
int *  dfrom,
int *  duntil 
)

Get the range from a period.

Parameters
periodThe period to convert to a range.
dfromThe variable to store the range beginning. It can be NULL.
duntilThe variable to store the range end. It can be NULL.

Definition at line 1111 of file util.c.

References periodstruct::end, period, and periodstruct::start.

Referenced by dansguardian_log(), redirector_log(), and UserAgent_Readlog().

Here is the caller graph for this function:

◆ getuexclude()

void getuexclude ( const char *  uexfile,
int  debug 
)

Definition at line 310 of file exclude.c.

References _, debug, debuga(), excludeuser, and fixendofline().

Referenced by main().

Here is the caller graph for this function:

◆ getword()

int getword ( char *  word,
int  limit,
struct getwordstruct gwarea,
char  stop 
)

Definition at line 90 of file util.c.

References _, getwordstruct::beginning, getwordstruct::current, and debuga().

Referenced by authfail_report(), convlog(), dansguardian_log(), dansguardian_report(), data_file(), download_report(), gen_denied_report(), gerarel(), htmlrel(), name2ip(), obttotal(), parse_log(), redirector_report(), report_day(), smartfilter_report(), splitlog(), TopUser_HtmlReport(), TopUser_TextEmail(), UserAgent(), and UserAgent_Readlog().

Here is the caller graph for this function:

◆ getword_atoi()

int getword_atoi ( int *  number,
struct getwordstruct gwarea,
char  stop 
)

Definition at line 227 of file util.c.

References _, getwordstruct::beginning, getwordstruct::current, and debuga().

Referenced by dansguardian_log(), topsites(), and UserAgent_Readlog().

Here is the caller graph for this function:

◆ getword_atol()

int getword_atol ( long int *  number,
struct getwordstruct gwarea,
char  stop 
)

Definition at line 265 of file util.c.

References _, getwordstruct::beginning, getwordstruct::current, and debuga().

◆ getword_atoll()

int getword_atoll ( long long int *  number,
struct getwordstruct gwarea,
char  stop 
)

Definition at line 182 of file util.c.

References _, getwordstruct::beginning, getwordstruct::current, and debuga().

Referenced by data_file(), gerarel(), greport_day(), htmlrel(), obttotal(), parse_log(), redirector_report(), report_day(), topsites(), TopUser_HtmlReport(), and TopUser_TextEmail().

Here is the caller graph for this function:

◆ getword_atolu()

int getword_atolu ( unsigned long int *  number,
struct getwordstruct gwarea,
char  stop 
)

Definition at line 303 of file util.c.

References _, getwordstruct::beginning, getwordstruct::current, and debuga().

◆ getword_limit()

int getword_limit ( char *  word,
int  limit,
struct getwordstruct gwarea,
char  stop 
)

Definition at line 119 of file util.c.

References getwordstruct::current.

Referenced by parse_log().

Here is the caller graph for this function:

◆ getword_multisep()

int getword_multisep ( char *  word,
int  limit,
struct getwordstruct gwarea,
char  stop 
)

Definition at line 134 of file util.c.

References _, getwordstruct::beginning, getwordstruct::current, and debuga().

Referenced by make_file_index(), parmtest(), and ReadOneLogFile().

Here is the caller graph for this function:

◆ getword_ptr()

int getword_ptr ( char *  orig_line,
char **  word,
struct getwordstruct gwarea,
char  stop 
)
Note
Why pass the original buffer to the function ? Because we must modify it to insert the terminating ASCII zero for the word we return and that's not compatible with getword_restart(). Moreover, getword_start() sometime works on constant strings so this function require the original buffer to detect any missuse.

Definition at line 343 of file util.c.

References _, getwordstruct::beginning, getwordstruct::current, debuga(), and getwordstruct::modified.

Referenced by authfail_report(), dansguardian_log(), dansguardian_report(), data_file(), download_report(), gen_denied_report(), gerarel(), htmlrel(), redirector_report(), and topsites().

Here is the caller graph for this function:

◆ getword_restart()

void getword_restart ( struct getwordstruct gwarea)

◆ getword_skip()

int getword_skip ( int  limit,
struct getwordstruct gwarea,
char  stop 
)

Definition at line 160 of file util.c.

References _, getwordstruct::beginning, getwordstruct::current, and debuga().

Referenced by dansguardian_log(), data_file(), gerarel(), greport_day(), htmlrel(), make_file_index(), obttotal(), parse_log(), and UserAgent_Readlog().

Here is the caller graph for this function:

◆ getword_start()

void getword_start ( struct getwordstruct gwarea,
const char *  line 
)

◆ greport_cleanup()

void greport_cleanup ( void  )

Definition at line 782 of file grepday.c.

Referenced by TopUser_HtmlReport().

Here is the caller graph for this function:

◆ greport_day()

void greport_day ( const struct userinfostruct user)

Definition at line 666 of file grepday.c.

References _, DATETIME_BYTE, DATETIME_ELAP, datetimeby, debuga(), debuga_more(), userinfostruct::filename, fixendofline(), getword_atoll(), getword_skip(), getword_start(), GraphFont, Graphs, HTML_JS_NONE, INDEX_TREE_DATE, IndexTree, MAXLEN, outdirname, tmp, write_html_head(), and write_html_trailer().

Referenced by TopUser_HtmlReport().

Here is the caller graph for this function:

◆ greport_prepare()

void greport_prepare ( void  )

Definition at line 635 of file grepday.c.

References _, CharSet, ConfigFile, debuga(), debugaz(), debugz, GraphConfigFile, GraphFont, Graphs, and LogLevel_Process.

Referenced by TopUser_HtmlReport().

Here is the caller graph for this function:

◆ htaccess()

void htaccess ( const struct userinfostruct uinfo)

Definition at line 30 of file auth.c.

References _, AuthUserTemplateFile, debuga(), debuga_more(), userinfostruct::filename, userinfostruct::id, MAXLEN, outdirname, and UserAuthentication.

Referenced by htmlrel().

Here is the caller graph for this function:

◆ htmlrel()

void htmlrel ( void  )
Todo:
Instead of deleting the supernumerary directories, don't create them in the first place.

Definition at line 39 of file html.c.

References _, ALIAS_PREFIX, BlockIt, buildtime(), close_html_header(), debug, debuga(), debuga_more(), globalstatstruct::elap, PerUserLimitStruct::File, userinfostruct::filename, FileObject_Close(), FileObject_GetLastCloseError(), FileObject_GetLastOpenError(), FileObject_Open(), FileObject_Rewind(), fixnum(), fixnum2(), format_path(), getword(), getword_atoll(), getword_ptr(), getword_skip(), getword_start(), globstat, htaccess(), periodstruct::html, HTML_JS_SORTTABLE, userinfostruct::id, ImageFile, globalstatstruct::incache, INDEX_TREE_DATE, IndexTree, userinfostruct::ip, iprel, KeepTempLog, userinfostruct::label, PerUserLimitStruct::Limit, longline_create(), longline_destroy(), longline_read(), mask, MAX_TRUNCATED_URL, MAX_USER_LIMITS, MAXLEN, MY_FOPEN, globalstatstruct::nacc, globalstatstruct::nbytes, userinfostruct::no_report, globalstatstruct::oucache, outdirname, output_html_link(), output_html_url(), period, PerUserFileCreation, PerUserLimits, PerUserLimitsNumber, pgettext, PortableMkDir(), Privacy, PrivacyString, PrivacyStringColor, PUFC_Always, PUFC_AsRequired, PUOE_UserId, PUOE_UserIp, REPORT_TYPE_SITE_USER_TIME_DATE, REPORT_TYPE_TOPUSERS, ReportType, sort_labels(), SortTableJs, tmp, tmpsort(), userinfostruct::topuser, globalstatstruct::totuser, unlinkdir(), url_to_anchor(), userinfo_advancescan(), userinfo_startscan(), userinfo_stopscan(), UserReportFields, USERREPORTFIELDS_AVERAGE, USERREPORTFIELDS_BYTES, USERREPORTFIELDS_CONNECT, USERREPORTFIELDS_IN_CACHE_OUT, USERREPORTFIELDS_MILISEC, USERREPORTFIELDS_PTIME, USERREPORTFIELDS_SETYB, USERREPORTFIELDS_TOTAL, USERREPORTFIELDS_USED_TIME, UserReportLimit, warea, write_html_header(), write_html_trailer(), and wwwDocumentRoot.

Referenced by gerarel().

Here is the caller graph for this function:

◆ index_only()

void index_only ( const char *  dirname,
int  debug 
)

Definition at line 31 of file indexonly.c.

References _, debuga(), INDEX_HTML_FILE, and MAXLEN.

Referenced by gerarel().

Here is the caller graph for this function:

◆ init_usertab()

void init_usertab ( const char *  UserTabFile)

Initialize the data used by user_find().

If UserTabFile is ldap, the user ID is fetched from a LDAP server.

Parameters
UserTabFileThe name of the file to read or ldap. If it is empty, the function does nothing.
Note
The memory and resources allocated by this function must be released by a call to close_usertab().

Definition at line 426 of file usertab.c.

References _, debug, debuga(), init_file_usertab(), UserTabFile, UTT_File, UTT_Ldap, UTT_None, and which_usertab.

Referenced by data_file(), gerarel(), and realtime().

Here is the caller graph for this function:

◆ ip2name()

void ip2name ( char *  ip,
int  ip_len 
)

Convert an IP address into a name.

Parameters
ipThe IP address. It is replaced by the corresponding name if one can be found.
ip_lenThe length of the ip buffer.

The function does nothing if no module are configured.

Definition at line 216 of file ip2name.c.

References _, debuga(), Dichotomic_Create(), Dichotomic_Insert(), Dichotomic_Search(), FirstModule, INRC_Found, KnownIp, Ip2NameProcess::Name, Ip2NameProcess::Next, Ip2NameProcess::Resolve, and safe_strcpy().

Referenced by dansguardian_report(), data_file(), datashow(), gerarel(), parse_log(), redirector_report(), and UserAgent().

Here is the caller graph for this function:

◆ ip2name_cleanup()

void ip2name_cleanup ( void  )

Release the memory allocated to resolve the IP addresses into names.

Definition at line 251 of file ip2name.c.

References Dichotomic_Destroy(), and KnownIp.

Referenced by main().

Here is the caller graph for this function:

◆ ip2name_config()

int ip2name_config ( const char *  param)

Configure a module to resolve an IP address into a name.

Parameters
paramThe parameter found in the configuration file. It always begins after the "resolv_ip".
Return values
1Parameter processed.
0Parameter ignored.

Definition at line 153 of file ip2name.c.

References ip2name_buildmoduleslist(), and ip2name_configmodule().

Referenced by parmtest().

Here is the caller graph for this function:

◆ ip2name_forcedns()

void ip2name_forcedns ( void  )

Require the use of the DNS to resolve the IP addresses.

Definition at line 173 of file ip2name.c.

References _, debug, debuga(), FirstModule, Ip2Name, ModulesList, Ip2NameProcess::Name, Ip2NameProcess::Next, and Ip2NameModules::Process.

Referenced by main().

Here is the caller graph for this function:

◆ is_absolute()

int is_absolute ( const char *  path)

Definition at line 394 of file util.c.

Referenced by my_mkdir(), and parmtest().

Here is the caller graph for this function:

◆ is_authfail()

bool is_authfail ( void  )

Tell the caller if a authentication failure report exists.

Returns
True if the report is available or false if no report was generated.

Definition at line 99 of file authfail.c.

References authfail_exists.

Referenced by TopUser_HtmlReport().

Here is the caller graph for this function:

◆ is_denied()

bool is_denied ( void  )

Tell the caller if a denied report exists.

Returns
True if the report is available or false if no report was generated.

Definition at line 98 of file denied.c.

References denied_exists.

Referenced by TopUser_HtmlReport().

Here is the caller graph for this function:

◆ is_download()

bool is_download ( void  )

Tell the caller if a download report exists.

Returns
True if the report is available or false if no report was generated.

Definition at line 118 of file download.c.

References download_exists.

Referenced by TopUser_HtmlReport().

Here is the caller graph for this function:

◆ is_download_suffix()

bool is_download_suffix ( const char *  url)

Tell if the URL correspond to a downloaded file. The function takes the extension at the end of the URL with a maximum of 9 characters and compare it to the list of the download suffix in DownloadSuffix. If the suffix is found in the list, the function reports the URL as the download of a file.

Parameters
urlThe URL to test.
Return values
1The URL matches a suffix of a download.
0The URL is not a known download.
Note
A downloaded file cannot be detected if the file name is embedded in a GET or POST request. Only requests that ends with the file name can be detected.
A URL embedding another web site's address ending by .com at the end of the URL will match the download extension com if it is defined in the DownloadSuffix.

Definition at line 414 of file download.c.

References DownloadSuffix, DownloadSuffixIndex, and NDownloadSuffix.

Referenced by ReadOneLogFile().

Here is the caller graph for this function:

◆ is_indexonly()

bool is_indexonly ( void  )

Definition at line 381 of file exclude.c.

References excludeuser.

Referenced by main().

Here is the caller graph for this function:

◆ IsTreeDayFileName()

bool IsTreeDayFileName ( const char *  Name)

Check if the proposed file name can be the day part of a report tree build with IndexTree set to INDEX_TREE_DATE.

Definition at line 1392 of file util.c.

Referenced by BuildDirDateList().

Here is the caller graph for this function:

◆ IsTreeFileDirName()

bool IsTreeFileDirName ( const char *  Name)

Check if the proposed file name conforms to the directory structure layed out as a file tree. It is used to check if the file name enumerated while scanning a directory content may have been created by sarg running with IndexTree set to INDEX_TREE_FILE.

Definition at line 1257 of file util.c.

References DateFormat, and mtab1.

Referenced by BuildDirList().

Here is the caller graph for this function:

◆ IsTreeMonthFileName()

bool IsTreeMonthFileName ( const char *  Name)

Check if the proposed file name can be the month part of a report tree build with IndexTree set to INDEX_TREE_DATE.

Definition at line 1368 of file util.c.

Referenced by BuildDirDateList().

Here is the caller graph for this function:

◆ IsTreeYearFileName()

bool IsTreeYearFileName ( const char *  Name)

Check if the proposed file name can be the year part of a report tree build with IndexTree set to INDEX_TREE_DATE.

Definition at line 1350 of file util.c.

Referenced by BuildDirList().

Here is the caller graph for this function:

◆ load_excludecodes()

void load_excludecodes ( const char *  ExcludeCodes)

Definition at line 1816 of file util.c.

References _, debuga(), excludecode, and ExcludeCodes.

Referenced by main().

Here is the caller graph for this function:

◆ longline_create()

longline longline_create ( void  )

◆ longline_destroy()

void longline_destroy ( longline line_ptr)

Definition at line 168 of file longline.c.

References longlinestruct::buffer.

Referenced by authfail_report(), convlog(), data_file(), download_report(), gen_denied_report(), gerarel(), htmlrel(), obttotal(), read_hostalias(), read_log(), read_useralias(), ReadOneLogFile(), realtime(), redirector_report(), siteuser(), splitlog(), topsites(), topuser(), TopUser_HtmlReport(), TopUser_TextEmail(), and UserAgent_Readlog().

Here is the caller graph for this function:

◆ longline_read()

◆ longline_reset()

void longline_reset ( longline  line)

Definition at line 88 of file longline.c.

References longlinestruct::end, longlinestruct::length, and longlinestruct::start.

Referenced by UserAgent_Readlog().

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:

◆ makeTmpDir()

void makeTmpDir ( const char *  tmp)

Definition at line 475 of file util.c.

References _, debug, debuga(), emptytmpdir(), my_mkdir(), and tmp.

Referenced by main().

Here is the caller graph for this function:

◆ mklastlog()

void mklastlog ( const char *  outdir)

Definition at line 256 of file lastlog.c.

References _, BuildDirList(), debug, debuga(), debuga_more(), DeleteDirList(), DeleteEmptyDirs(), LastLog, MAXLEN, DirEntry::Name, DirEntry::Next, ngettext, outdir, unlinkdir(), and warea.

Referenced by make_index().

Here is the caller graph for this function:

◆ month2num()

int month2num ( const char *  month)

Definition at line 526 of file util.c.

References mtab1.

Referenced by buildymd(), Common_ReadEntry(), and UserAgent_Readlog().

Here is the caller graph for this function:

◆ my_atoll()

long long int my_atoll ( const char *  nptr)

Definition at line 372 of file util.c.

References MAXLLL.

Referenced by parmtest().

Here is the caller graph for this function:

◆ my_lltoa()

void my_lltoa ( unsigned long long int  n,
char *  s,
int  ssize,
int  len 
)

Definition at line 493 of file util.c.

References _, and debuga().

Referenced by fixnum(), fixnum2(), and saverecs().

Here is the caller graph for this function:

◆ my_mkdir()

bool my_mkdir ( const char *  name)

Recursively create a path by adding missing directory until the whole path is created.

Parameters
nameThe path to create.
Returns
True if the directory was created or false if it already existed

Definition at line 419 of file util.c.

References _, debuga(), debuga_more(), is_absolute(), MAXLEN, name, and PortableMkDir().

Referenced by gerarel(), main(), makeTmpDir(), ReadOneLogFile(), and vrfydir().

Here is the caller graph for this function:

◆ name2ip()

void name2ip ( char *  name,
int  name_size 
)

Definition at line 256 of file ip2name.c.

References _, addr, getwordstruct::beginning, debuga(), getword(), getword_start(), if, and name.

Referenced by saverecs().

Here is the caller graph for this function:

◆ numlistcontains()

bool numlistcontains ( const int *  list,
int  maxvalue,
int  value 
)

Search if the list contains the value.

Parameters
listThe list to search for a value.
maxvalueThe maximum value of the list.
valueThe value to search for.
Returns
True if the value is enabled in the list.

Definition at line 2091 of file util.c.

Referenced by ReadOneLogFile().

Here is the caller graph for this function:

◆ obtdate()

int obtdate ( const char *  dirname,
const char *  name,
char *  data 
)

Get the date stored in the sarg-date file of a directory with the connection data.

Parameters
dirnameThe directory to look for the connection directory.
nameThe name of the directory whose sarg-date file must be read.
dataThe buffer to store the content of the file. It must be more than 80 bytes long.
Return values
0No error.
-1File not found.

Definition at line 835 of file util.c.

References _, debuga(), debuga_more(), fixendofline(), MAXLEN, and name.

Referenced by make_file_index().

Here is the caller graph for this function:

◆ obttotal()

void obttotal ( const char *  dirname,
const char *  name,
int  nuser,
long long int *  tbytes,
long long int *  media 
)

Definition at line 938 of file util.c.

References _, debuga(), debuga_more(), FileObject_Close(), FileObject_GetLastCloseError(), FileObject_Open(), getword(), getword_atoll(), getword_skip(), getword_start(), longline_create(), longline_destroy(), longline_read(), MAX_USER_LEN, MAXLEN, and name.

Referenced by make_file_index().

Here is the caller graph for this function:

◆ obtuser()

int obtuser ( const char *  dirname,
const char *  name 
)

Definition at line 901 of file util.c.

References _, debuga(), debuga_more(), MAXLEN, and name.

Referenced by make_file_index().

Here is the caller graph for this function:

◆ output_html_link()

void output_html_link ( FILE *  fp_ou,
const char *  url,
int  maxlen 
)

Write a host name inside an A tag of a HTML file. If the host name starts with a star, it is assumed to be an alias that cannot be put inside a link so the A tag is not written around the host name.

Parameters
fp_ouThe handle of the HTML file.
urlThe host to display in the HTML file.
maxlenThe maximum number of characters to print into the host name.

Definition at line 2214 of file util.c.

References ALIAS_PREFIX, output_html_string(), output_html_url(), and skip_scheme().

Referenced by authfail_report(), dansguardian_report(), download_report(), gen_denied_report(), htmlrel(), redirector_report(), siteuser(), and topsites().

Here is the caller graph for this function:

◆ output_html_string()

void output_html_string ( FILE *  fp_ou,
const char *  str,
int  maxlen 
)

Definition at line 2163 of file util.c.

Referenced by gerarel(), output_html_link(), and UserAgent().

Here is the caller graph for this function:

◆ output_html_url()

void output_html_url ( FILE *  fp_ou,
const char *  url 
)

Definition at line 2194 of file util.c.

Referenced by authfail_report(), download_report(), gen_denied_report(), htmlrel(), output_html_link(), siteuser(), and topsites().

Here is the caller graph for this function:

◆ PortableMkDir()

int PortableMkDir ( const char *  path,
int  mode 
)

Definition at line 403 of file util.c.

Referenced by copy_images(), file_index_to_date_index(), htmlrel(), and my_mkdir().

Here is the caller graph for this function:

◆ process_url()

const char* process_url ( const char *  url,
bool  full_url 
)

Get the part of the URL necessary to generate the report.

Parameters
urlThe URL as extracted from the report.
full_urlTrue to keep the whole URL. If false, the URL is truncated to only keep the host name and port number.

Definition at line 862 of file url.c.

References alias_url_ipv4(), alias_url_ipv6(), alias_url_name(), extract_address_mask(), FirstAliasIpv4, FirstAliasIpv6, FirstAliasName, and skip_scheme().

Referenced by parse_log(), and ReadOneLogFile().

Here is the caller graph for this function:

◆ process_user()

enum UserProcessError process_user ( const char **  UserPtr,
const char *  IpAddress,
bool IsIp 
)

Replace the user's name or ID by an alias if one is defined.

Parameters
userThe user's name or ID as extracted from the report.
Return values
USERERR_NoErrorNo error.
USERERR_NameTooLongUser name too long.

Definition at line 377 of file userinfo.c.

References _, ALIAS_PREFIX, Alias_Replace(), debuga(), debugz, IncludeUsers, LogLevel_Process, MAX_USER_LEN, NtlmUserFormat, NTLMUSERFORMAT_USER, ReadFilter, RecordsWithoutUser, RECORDWITHOUTUSER_EVERYBODY, RECORDWITHOUTUSER_IGNORE, RECORDWITHOUTUSER_IP, safe_strcpy(), StripSuffixLen, StripUserSuffix, ReadLogDataStruct::SysUsers, testvaliduserchar(), us, UserAliases, USERERR_EmptyUser, USERERR_Excluded, USERERR_Ignored, USERERR_InvalidChar, USERERR_NameTooLong, USERERR_NoError, USERERR_SysUser, USERERR_Untracked, userfile, ReadLogDataStruct::UserFilter, UserIp, and vuexclude().

Referenced by parse_log(), and ReadOneLogFile().

Here is the caller graph for this function:

◆ read_hostalias()

void read_hostalias ( const char *  Filename)

Read the file containing the host names to alias in the report.

Parameters
FilenameThe name of the file.

Definition at line 575 of file url.c.

References _, hostalias_name::Alias, hostalias_ipv4::Alias, hostalias_ipv6::Alias, Alias_Store(), debug, debuga(), FileObject_Close(), FileObject_GetLastCloseError(), FileObject_GetLastOpenError(), FileObject_Open(), FirstAliasIpv4, FirstAliasIpv6, FirstAliasName, hostalias_name::HostName_Prefix, hostalias_name::HostName_Suffix, hostalias_ipv4::Ip, hostalias_ipv6::Ip, longline_create(), longline_destroy(), longline_read(), hostalias_ipv4::NBits, hostalias_ipv6::NBits, hostalias_name::Next, hostalias_ipv4::Next, and hostalias_ipv6::Next.

Referenced by main().

Here is the caller graph for this function:

◆ read_useralias()

void read_useralias ( const char *  Filename)

Read the file containing the user names to alias in the report.

Parameters
FilenameThe name of the file.

Definition at line 317 of file userinfo.c.

References _, Alias_Create(), Alias_PrintList(), Alias_Store(), debug, debuga(), FileObject_Close(), FileObject_GetLastCloseError(), FileObject_GetLastOpenError(), FileObject_Open(), longline_create(), longline_destroy(), longline_read(), and UserAliases.

Referenced by main().

Here is the caller graph for this function:

◆ ReadLogFile()

◆ realtime()

◆ redirector_log()

void redirector_log ( const struct ReadLogDataStruct ReadFilter)

Definition at line 302 of file redirector.c.

References _, debug, debuga(), debugaz(), debugz, files_done, fixendofline(), format_path(), get_param_value(), getperiod_torange(), KeepTempLog, LogLevel_Process, MAXLEN, nfiles_done, NRedirectorLogs, period, read_log(), ReadFilter, redirector_count, redirector_sorted, RedirectorLogs, SquidGuardConf, tmp, and wentp.

Referenced by gerarel().

Here is the caller graph for this function:

◆ redirector_report()

◆ removetmp()

void removetmp ( const char *  outdir)

Definition at line 1789 of file util.c.

References _, debug, debuga(), debuga_more(), outdir, RemoveTempFiles, and totalger().

Referenced by gerarel().

Here is the caller graph for this function:

◆ report_day()

void report_day ( const struct userinfostruct user)

Definition at line 32 of file repday.c.

References _, close_html_header(), computedate(), DATETIME_BYTE, DATETIME_ELAP, datetimeby, debuga(), debuga_more(), userinfostruct::filename, fixendofline(), fixnum(), fixtime(), format_path(), getword(), getword_atoll(), getword_start(), hours, periodstruct::html, HTML_JS_NONE, INDEX_TREE_DATE, IndexTree, userinfostruct::label, MAX_DATETIME_DAYS, MAXLEN, outdirname, period, tmp, write_html_header(), and write_html_trailer().

Referenced by TopUser_HtmlReport().

Here is the caller graph for this function:

◆ safe_strcpy()

void safe_strcpy ( char *  dest,
const char *  src,
int  length 
)

Copy a string without overflowing the buffer. The copied string is properly terminated by an ASCII zero.

Parameters
destThe destination buffer.
srcThe source buffer.
lengthThe size of the destination buffer. The program is aborted if the length is negative or zero.

Definition at line 1550 of file util.c.

References _, and debuga().

Referenced by gerarel(), get_usertab_name(), GetLatestModified(), getparam_userlimit(), getperiod_buildtext(), insert_node(), ip2name(), ip2name_dns(), ip2name_exec(), main(), make_file_index(), parmtest(), parse_log(), process_user(), ReadOneLogFile(), store_exclude_url(), StoreLogEntry(), topuser(), TopUser_TextEmail(), and user_find().

Here is the caller graph for this function:

◆ set_download_suffix()

void set_download_suffix ( const char *  list)

Set the list of the suffixes corresponding to the download of files you want to detect with is_download_suffix(). The list is sorted to make the search faster.

Parameters
listA comma separated list of the suffixes to set in DownloadSuffix.
Note
The memory allocated by this function must be freed by free_download().

Definition at line 345 of file download.c.

References _, debuga(), DownloadSuffix, DownloadSuffixIndex, free_download(), and NDownloadSuffix.

Referenced by main(), and parmtest().

Here is the caller graph for this function:

◆ show_info()

void show_info ( FILE *  fp_ou)

Definition at line 2097 of file util.c.

References _, df, PGM, ShowSargInfo, URL, VERSION, and zdate().

Referenced by write_html_trailer().

Here is the caller graph for this function:

◆ show_sarg()

void show_sarg ( FILE *  fp_ou,
int  depth 
)

Definition at line 2108 of file util.c.

References ShowSargLogo.

Referenced by write_html_header().

Here is the caller graph for this function:

◆ siteuser()

◆ skip_scheme()

const char* skip_scheme ( const char *  url)

Find the beginning of the URL beyond the scheme://

Parameters
urlThe url possibly containing a scheme.
Returns
The beginning of the url beyond the scheme.

Definition at line 839 of file url.c.

Referenced by output_html_link(), and process_url().

Here is the caller graph for this function:

◆ smartfilter_report()

void smartfilter_report ( void  )

Definition at line 30 of file smartfilter.c.

References _, BgColor, BgImage, CharSet, debuga(), debuga_more(), df, userinfostruct::filename, FontFace, FontSize, format_path(), getword(), getword_start(), HeaderBgColor, Height, periodstruct::html, userinfostruct::ip, KeepTempLog, userinfostruct::label, LogoImage, LogoText, LogoTextColor, MAXLEN, outdirname, period, PGM, ShowSargInfo, TiColor, Title, tmp, TxBgColor, TxColor, URL, userinfo_find_from_id(), VERSION, Width, write_logo_image(), and zdate().

Referenced by gerarel().

Here is the caller graph for this function:

◆ sort_labels()

void sort_labels ( const char **  label,
const char **  order 
)

Get the internationalized text to display when reporting the sort criterion and order of a user list.

Parameters
labelA pointer to set to the string of the sort criterion name.
orderA pointer to set to the string of the sort order name

Definition at line 160 of file sort.c.

References _, userinfostruct::label, pgettext, USER_SORT_CONNECT, USER_SORT_REVERSE, USER_SORT_SITE, USER_SORT_TIME, and UserSort.

Referenced by gerarel(), and htmlrel().

Here is the caller graph for this function:

◆ sort_users_log()

void sort_users_log ( const char *  tmp,
int  debug,
struct userinfostruct uinfo 
)

The function sorts the unsort file in the temporary directory. These files correspond to the format described in Output files.

Parameters
tmpThe temorary directory of the sarg files.
debugTrue to output debug information.
uinfoThe user whose log must be sorted.

The user's files are sorted by columns 5, 1 and 2 that are the columns of the number of bytes transfered, the date of the access and the time of the access.

The sorted files are written in files with the extension log and the name of the unsorted file without the unsort extension. The unsorted file is deleted just after the sorting.

Definition at line 112 of file sort.c.

References _, debug, debuga(), debuga_more(), userinfostruct::filename, KeepTempLog, MAXLEN, and tmp.

Referenced by data_file(), and gerarel().

Here is the caller graph for this function:

◆ splitlog()

void splitlog ( const char *  arq,
char  df,
const struct ReadLogDataStruct ReadFilter,
int  convert,
const char *  splitprefix 
)

Definition at line 46 of file splitlog.c.

References _, getwordstruct::current, ReadLogDataStruct::DateRange, debuga(), debuga_more(), decomp(), df, ReadLogDataStruct::EndDate, ReadLogDataStruct::EndTime, FileObject_Close(), FileObject_GetLastCloseError(), FileObject_GetLastOpenError(), getword(), getword_start(), longline_create(), longline_destroy(), longline_read(), MAXLEN, MY_FOPEN, outdir, ReadFilter, and ReadLogDataStruct::StartTime.

Referenced by main().

Here is the caller graph for this function:

◆ strip_latin()

void strip_latin ( char *  line)

Definition at line 1560 of file util.c.

Referenced by TopUser_TextEmail().

Here is the caller graph for this function:

◆ strlow()

char* strlow ( char *  string)

Definition at line 1759 of file util.c.

◆ strup()

char* strup ( char *  string)

Definition at line 1775 of file util.c.

◆ testvaliduserchar()

int testvaliduserchar ( const char *  user)

Definition at line 1933 of file util.c.

References UserInvalidChar.

Referenced by process_user().

Here is the caller graph for this function:

◆ tmpsort()

void tmpsort ( const struct userinfostruct uinfo)

Sort all the utmp files form the temporary directory. The sort can be made according to the number of connections, the accessed sites or the time of the access depending on the value of ::UserSortField. The sorting is either made in increasing or decreasing order as specified by the value of ::UserSortOrder.

Definition at line 36 of file sort.c.

References _, debug, debuga(), debuga_more(), userinfostruct::filename, KeepTempLog, MAXLEN, tmp, USER_SORT_CONNECT, USER_SORT_REVERSE, USER_SORT_SITE, USER_SORT_TIME, and UserSort.

Referenced by htmlrel().

Here is the caller graph for this function:

◆ topsites()

◆ topuser()

◆ totalger()

void totalger ( FILE *  fp_gen,
const char *  filename 
)

Write the total line at the end of the general file.

Definition at line 563 of file report.c.

References _, debuga(), globalstatstruct::elap, userinfostruct::filename, globstat, globalstatstruct::incache, globalstatstruct::nacc, globalstatstruct::nbytes, and globalstatstruct::oucache.

Referenced by gerarel(), and removetmp().

Here is the caller graph for this function:

◆ unlinkdir()

void unlinkdir ( const char *  dir,
bool  contentonly 
)

Definition at line 2339 of file util.c.

References _, debuga(), debuga_more(), and MAXLEN.

Referenced by CleanTemporaryDir(), emptytmpdir(), htmlrel(), mklastlog(), and vrfydir().

Here is the caller graph for this function:

◆ url_hostname()

void url_hostname ( const char *  url,
char *  hostname,
int  hostsize 
)

Extract the host name from the URL.

Parameters
urlThe url whose host name must be extracted.
hostnameThe buffer to store the host name.
hostsizeThe size of the host name buffer.
Note
The function is stupid at this time. It just searches for the first slash in the URL and truncates the URL there. It doesn't take the protocol into account nor the port number nor any user or password information.

Definition at line 909 of file url.c.

Referenced by saverecs().

Here is the caller graph for this function:

◆ url_module()

void url_module ( const char *  url,
char *  w2 
)

Definition at line 2231 of file util.c.

◆ url_to_anchor()

void url_to_anchor ( const char *  url,
char *  anchor,
int  size 
)

Mangle an URL to produce a part that can be used as an anchor in a html tag.

Parameters
urlThe URL to mangle.
anchorThe buffer to write the mangled URL.
sizeThe size of the buffer.

Definition at line 2261 of file util.c.

Referenced by gerarel(), and htmlrel().

Here is the caller graph for this function:

◆ usage()

void usage ( const char *  prog)

Definition at line 30 of file usage.c.

References _, PGM, and VERSION.

Referenced by main().

Here is the caller graph for this function:

◆ user_find()

void user_find ( char *  mappedname,
int  namelen,
const char *  userlogin 
)

Find the real name of the user with the ID or IP address in userlogin. The name is fetched from the source initialized by init_usertab().

The usertab data must have been initialized by init_usertab().

Parameters
mappednameA buffer to write the real name of the user.
namelenThe size of the buffer.
userloginThe ID or IP address of the user.

Definition at line 460 of file usertab.c.

References get_usertab_name(), safe_strcpy(), UTT_File, UTT_Ldap, and which_usertab.

Referenced by dansguardian_report(), data_file(), datashow(), gerarel(), and parse_log().

Here is the caller graph for this function:

◆ UserAgent()

void UserAgent ( void  )

Definition at line 207 of file useragent.c.

References _, close_html_header(), getwordstruct::current, debug, debuga(), fixendofline(), format_path(), getword(), getword_start(), HTML_JS_NONE, idate, INDEX_TREE_DATE, IndexTree, ip2name(), Ip2Name, KeepTempLog, MAXLEN, outdirname, output_html_string(), tmp, useragent_count, UserAgentEndDate, UserAgentStartDate, UserAgentTempLog, write_html_header(), and write_html_trailer().

Referenced by ExtLog_ReadEntry(), and gerarel().

Here is the caller graph for this function:

◆ UserAgent_Open()

FILE* UserAgent_Open ( void  )

Open the temporary file to store the useragent entries to be reported.

Returns
The file handle. It must be closed when the data have been written.

Definition at line 46 of file useragent.c.

References _, debuga(), format_path(), REPORT_TYPE_USERAGENT, ReportType, tmp, UserAgentEndDate, UserAgentStartDate, and UserAgentTempLog.

Referenced by ReadOneLogFile(), and UserAgent_Readlog().

Here is the caller graph for this function:

◆ UserAgent_Readlog()

void UserAgent_Readlog ( const struct ReadLogDataStruct ReadFilter)

Read the user provided useragent file and create a temporary file with the data to report.

Definition at line 90 of file useragent.c.

References _, getwordstruct::current, debug, debuga(), decomp(), ReadLogDataStruct::EndTime, FileListIter_Close(), FileListIter_Next(), FileListIter_Open(), FileObject_Close(), FileObject_GetLastCloseError(), FileObject_GetLastOpenError(), fp_log, getperiod_torange(), getword(), getword_atoi(), getword_skip(), getword_start(), longline_create(), longline_destroy(), longline_read(), longline_reset(), MAXLEN, month2num(), period, ReadFilter, ReadLogDataStruct::StartTime, totregsl, UserAgent_Open(), UserAgent_Write(), UserAgentLog, and UserAgentTempLog.

Referenced by gerarel().

Here is the caller graph for this function:

◆ UserAgent_Write()

void UserAgent_Write ( FILE *  fp,
const struct tm *  Time,
const char *  Ip,
const char *  User,
const char *  Agent 
)

Write a user agent entry into the temporary log.

Parameters
fpThe file opened by UserAgent_Open().
IpThe IP address using this agent.
UserThe user name.
AgentThe user agent string.

Definition at line 74 of file useragent.c.

References compare_date(), useragent_count, UserAgentEndDate, and UserAgentStartDate.

Referenced by ReadOneLogFile(), and UserAgent_Readlog().

Here is the caller graph for this function:

◆ userinfo_advancescan()

struct userinfostruct* userinfo_advancescan ( userscan  uscan)

Get the user pointed to by the object and advance the object to the next user.

Parameters
uscanThe object created by userinfo_start().
Returns
The user in the list or NULL if the end of the list is reached.

Definition at line 280 of file userinfo.c.

References userscanstruct::group, userscanstruct::index, usergroupstruct::list, usergroupstruct::next, and usergroupstruct::nusers.

Referenced by data_file(), gerarel(), and htmlrel().

Here is the caller graph for this function:

◆ userinfo_clearflag()

void userinfo_clearflag ( void  )

Clear the general purpose flag from all the user's info.

Definition at line 301 of file userinfo.c.

References first_user_group, userinfostruct::flag, usergroupstruct::list, usergroupstruct::next, and usergroupstruct::nusers.

Referenced by siteuser().

Here is the caller graph for this function:

◆ userinfo_create()

struct userinfostruct* userinfo_create ( const char *  userid,
const char *  ip 
)

Definition at line 73 of file userinfo.c.

References _, AnonymousCounter, AnonymousOutputFiles, debuga(), userinfostruct::filename, first_user_group, userinfostruct::id, userinfostruct::id_is_ip, userinfostruct::ip, userinfostruct::label, usergroupstruct::list, MAX_USER_FNAME_LEN, usergroupstruct::next, usergroupstruct::nusers, StringBuffer_Create(), StringBuffer_Store(), USERS_PER_GROUP, and UserStrings.

Referenced by parse_log(), and ReadOneLogFile().

Here is the caller graph for this function:

◆ userinfo_find_from_file()

struct userinfostruct* userinfo_find_from_file ( const char *  filename)

◆ userinfo_find_from_id()

struct userinfostruct* userinfo_find_from_id ( const char *  id)

Definition at line 218 of file userinfo.c.

References first_user_group, userinfostruct::id, usergroupstruct::list, usergroupstruct::next, and usergroupstruct::nusers.

Referenced by authfail_report(), download_report(), gen_denied_report(), parse_log(), redirector_report(), siteuser(), smartfilter_report(), TopUser_HtmlReport(), TopUser_TextEmail(), and vrfydir().

Here is the caller graph for this function:

◆ userinfo_find_from_ip()

struct userinfostruct* userinfo_find_from_ip ( const char *  ip)

◆ userinfo_free()

void userinfo_free ( void  )

Definition at line 177 of file userinfo.c.

References first_user_group, usergroupstruct::next, StringBuffer_Destroy(), and UserStrings.

Referenced by main().

Here is the caller graph for this function:

◆ userinfo_label()

void userinfo_label ( struct userinfostruct uinfo,
const char *  label 
)

Store the user's label.

Parameters
uinfoThe user info structure created by userinfo_create().
labelThe string label to store.

Definition at line 194 of file userinfo.c.

References _, debuga(), userinfostruct::id, userinfostruct::label, StringBuffer_Store(), and UserStrings.

Referenced by data_file(), gerarel(), and parse_log().

Here is the caller graph for this function:

◆ userinfo_startscan()

userscan userinfo_startscan ( void  )

Start the scanning of the user list.

Returns
The object to pass to subsequent scanning functions or NULL if it failed. The object must be freed with a call to userinfo_stop().

Definition at line 250 of file userinfo.c.

References first_user_group, userscanstruct::group, and userscanstruct::index.

Referenced by data_file(), gerarel(), and htmlrel().

Here is the caller graph for this function:

◆ userinfo_stopscan()

void userinfo_stopscan ( userscan  uscan)

Free the memory allocated by userinfo_start().

Parameters
uscanThe object created by userinfo_start().

Definition at line 266 of file userinfo.c.

Referenced by data_file(), gerarel(), and htmlrel().

Here is the caller graph for this function:

◆ vercode()

int vercode ( const char *  code)

Definition at line 1882 of file util.c.

References code, and excludecode.

Referenced by ReadOneLogFile().

Here is the caller graph for this function:

◆ version()

void version ( void  )

Definition at line 2300 of file util.c.

References _, CurrentLocale, debug, and VERSION.

Referenced by main().

Here is the caller graph for this function:

◆ vhexclude()

int vhexclude ( const char *  url)

Check if the URL is excluded as per the host exclusion list.

Parameters
urlThe URL to check.
Return values
1Keep the URL.
0Exclude the URL.

Definition at line 242 of file exclude.c.

References hostip6struct::address, exclude_ip4, exclude_ip6, exclude_name, extract_address_mask(), hostip4struct::mask, name, hostip6struct::nbits, hostnamestruct::ndots, num_exclude_ip4, num_exclude_ip6, num_exclude_name, and hostnamestruct::url.

Referenced by ReadOneLogFile().

Here is the caller graph for this function:

◆ vrfydir()

int vrfydir ( const struct periodstruct per1,
const char *  addr,
const char *  site,
const char *  us 
)

Create a directory to generate a report for the specified connection data and populate it with the a sarg-date file containing the current date.

The function also create an images directory in dir and copy all the files from the SYSCONFDIR/images into that directory.

Parameters
per1The date range in the form: YYYYMMMDD-YYYYMMMDD or DDMMMYYYY-DDMMMYYYY depending on the value of DateFormat.
addrThe ip address or host name to which the report is limited. If the string is empty, all the addresses are accepted.
siteThe destination site to which the report is limited. If the string is empty, all the sites are accepted.
usThe user to whom the report is limited. It is an empty string if all the users are accepted.

Definition at line 1427 of file util.c.

References _, addr, conv_month_name(), copy_images(), debug, debuga(), debuga_more(), df, periodstruct::end, userinfostruct::filename, format_path(), INDEX_TREE_DATE, IndexTree, MAXLEN, my_mkdir(), outdir, outdirname, OverwriteReport, site, periodstruct::start, unlinkdir(), us, and userinfo_find_from_id().

Referenced by gerarel().

Here is the caller graph for this function:

◆ vuexclude()

int vuexclude ( const char *  user)

Definition at line 364 of file exclude.c.

References excludeuser.

Referenced by process_user().

Here is the caller graph for this function:

◆ write_html_head()

void write_html_head ( FILE *  fp_ou,
int  depth,
const char *  page_title,
int  javascript 
)

Definition at line 2125 of file util.c.

References CharSet, css(), HTML_JS_SORTTABLE, and SortTableJs.

Referenced by greport_day(), and write_html_header().

Here is the caller graph for this function:

◆ write_html_header()

void write_html_header ( FILE *  fp_ou,
int  depth,
const char *  title,
int  javascript 
)

Definition at line 2144 of file util.c.

References show_sarg(), Title, write_html_head(), and write_logo_image().

Referenced by authfail_report(), dansguardian_report(), download_report(), gen_denied_report(), gerarel(), htmlrel(), make_date_index(), make_date_index_day(), make_date_index_month(), make_file_index(), redirector_report(), report_day(), siteuser(), topsites(), TopUser_HtmlReport(), and UserAgent().

Here is the caller graph for this function:

◆ write_html_trailer()

void write_html_trailer ( FILE *  fp_ou)

Definition at line 2157 of file util.c.

References show_info().

Referenced by authfail_report(), dansguardian_report(), download_report(), gen_denied_report(), greport_day(), htmlrel(), make_date_index(), make_date_index_day(), make_date_index_month(), make_file_index(), redirector_report(), report_day(), siteuser(), topsites(), TopUser_HtmlReport(), and UserAgent().

Here is the caller graph for this function:

◆ write_logo_image()

void write_logo_image ( FILE *  fp_ou)

Definition at line 2119 of file util.c.

References Height, LogoImage, LogoText, and Width.

Referenced by smartfilter_report(), and write_html_header().

Here is the caller graph for this function:

◆ zdate()

void zdate ( char *  ftime,
int  ftimesize,
char  DateFormat 
)

Definition at line 1581 of file util.c.

References DateFormat.

Referenced by show_info(), and smartfilter_report().

Here is the caller graph for this function: