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)  

userinfo.c File Reference
#include "include/conf.h"
#include "include/defs.h"
#include "include/stringbuffer.h"
#include "include/alias.h"
Include dependency graph for userinfo.c:

Go to the source code of this file.

Data Structures

struct  usergroupstruct
 Group the users in one allocation unit. Structure to store a group of users and reduce the number of memory allocations. More...
 
struct  userscanstruct
 Hold pointer to scan through the user list. More...
 

Macros

#define USERS_PER_GROUP   50
 The number of users to group in one unit. More...
 

Functions

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)
 

Variables

static struct usergroupstructfirst_user_group =NULL
 The first group of users. More...
 
static int AnonymousCounter =0
 The counter to generate unique user number when AnonymousOutputFiles is set. More...
 
static StringBufferObject UserStrings =NULL
 String buffer to store the user's related constants. More...
 
static AliasObject UserAliases =NULL
 User aliases. More...
 
struct ReadLogDataStruct ReadFilter
 The log file filtering. More...
 
char StripUserSuffix [256]
 Domain suffix to strip from the user name. More...
 
int StripSuffixLen
 Length of the suffix to strip from the user name. More...
 
char * userfile
 The list of the system users. More...
 

Macro Definition Documentation

◆ USERS_PER_GROUP

#define USERS_PER_GROUP   50

The number of users to group in one unit.

Definition at line 33 of file userinfo.c.

Function Documentation

◆ 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:

◆ 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_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:

◆ 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:

Variable Documentation

◆ AnonymousCounter

int AnonymousCounter =0
static

The counter to generate unique user number when AnonymousOutputFiles is set.

Definition at line 62 of file userinfo.c.

Referenced by userinfo_create().

◆ first_user_group

struct usergroupstruct* first_user_group =NULL
static

◆ ReadFilter

◆ StripSuffixLen

int StripSuffixLen

Length of the suffix to strip from the user name.

Definition at line 95 of file readlog.c.

Referenced by process_user().

◆ StripUserSuffix

char StripUserSuffix[256]

Domain suffix to strip from the user name.

Definition at line 93 of file readlog.c.

Referenced by process_user().

◆ UserAliases

AliasObject UserAliases =NULL
static

User aliases.

Definition at line 66 of file userinfo.c.

Referenced by free_useralias(), process_user(), and read_useralias().

◆ userfile

char* userfile

The list of the system users.

Definition at line 40 of file log.c.

Referenced by getusers(), main(), and process_user().

◆ UserStrings

StringBufferObject UserStrings =NULL
static

String buffer to store the user's related constants.

Definition at line 64 of file userinfo.c.

Referenced by userinfo_create(), userinfo_free(), and userinfo_label().