Use LC_TIME to format the dates and times according to the selected locale.
SET(sarg_VERSION 2)
SET(sarg_REVISION 2)
SET(sarg_BUILD "7rc1")
-SET(sarg_BUILDDATE "Dec-10-2009")
+SET(sarg_BUILDDATE "Dec-18-2009")
INCLUDE(AddFileDependencies)
INCLUDE(CheckIncludeFile)
CHECK_INCLUDE_FILE(stdarg.h HAVE_STDARG_H)
CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE(limits.h HAVE_LIMITS_H)
+CHECK_INCLUDE_FILE(locale.h HAVE_LOCALE_H)
CHECK_FUNCTION_EXISTS(bzero HAVE_BZERO)
CHECK_INCLUDE_FILE(gdfonts.h HAVE_GDFONTS_H)
CHECK_INCLUDE_FILE(gdfontmb.h HAVE_GDFONTMB_H)
CHECK_INCLUDE_FILE(gdfontg.h HAVE_GDFONTG_H)
- FIND_LIBRARY(GD_LIBRARY NAMES gd DOC "The GD library")
+ FIND_LIBRARY(GD_LIBRARY NAMES gd bgd DOC "The GD library")
IF(GD_LIBRARY)
#CHECK_LIBRARY_EXISTS(gd gdImagePng "." HAVE_GD)
- TARGET_LINK_LIBRARIES(sarg gd)
+ TARGET_LINK_LIBRARIES(sarg ${GD_LIBRARY})
SET(HAVE_GD GD_LIBRARY CACHE PATH DOC "True IF GD was found")
SET(HAVE_GD CACHE BOOL DOC "True IF must use GD")
ENDIF(GD_LIBRARY)
INSTALL(FILES sarg.conf DESTINATION "${SYSCONFDIR}" RENAME sarg.conf.exemple)
INSTALL(FILES exclude_codes user_limit_block css.tpl DESTINATION "${SYSCONFDIR}")
INSTALL(FILES sarg.1 DESTINATION "${MANDIR}")
-INSTALL(DIRECTORY languages/ DESTINATION "${LANGDIR}" PATTERN "CVS" EXCLUDE)
-INSTALL(DIRECTORY images/ DESTINATION "${IMAGEDIR}" PATTERN "CVS" EXCLUDE)
-INSTALL(DIRECTORY fonts/ DESTINATION "${FONTDIR}" FILES_MATCHING PATTERN "*.ttf" PATTERN "CVS" EXCLUDE)
+INSTALL(DIRECTORY languages/ DESTINATION "${LANGDIR}" PATTERN ".svn" EXCLUDE)
+INSTALL(DIRECTORY images/ DESTINATION "${IMAGEDIR}" PATTERN ".svn" EXCLUDE)
+INSTALL(DIRECTORY fonts/ DESTINATION "${FONTDIR}" FILES_MATCHING PATTERN "*.ttf" PATTERN ".svn" EXCLUDE)
# Package creation
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Squid Analysis Report Generator")
SET(CPACK_PACKAGE_VERSION_PATCH "${sarg_BUILD}")
SET(CPACK_GENERATOR TGZ)
SET(CPACK_SOURCE_GENERATOR TGZ)
-SET(CPACK_SOURCE_IGNORE_FILES "/CVS/" "/debian/" "/html/" "Makefile$" "config\\\\.log$" "config\\\\.status$" ".*~$" "\\\\.o$")
+SET(CPACK_SOURCE_IGNORE_FILES "/.svn/" "/debian/" "/html/" "Makefile$" "config\\\\.log$" "config\\\\.status$" ".*~$" "\\\\.o$")
INCLUDE(CPack)
SARG ChangeLog
-Dec-15-2009 Version 2.2.7
+Dec-18-2009 Version 2.2.7
- Extra compile and run time protection (FORTIFY_SOURCE) fixed in configure.
- Use tabulations as columns separator in intermediary files to avoid problems when a field of the log contains a space.
- Input log file type detection partly rewritten to clearly distinguish which type is processed where.
- Read the input log file from standard input if log file name is -.
- Use string pointers in getword instead of copying the strings over and over.
+ - Use LC_TIME to format some dates and times in the report according to the selected locale.
-Dec-14-2009 Version 2.2.6.1
+Dec-17-2009 Version 2.2.6.1
- Remove unecessary dependency on off_t.
- Configuration doesn't fail if rlim_t is not available.
- Test for the availability of -Werror=implicit-function-declaration and -Werror=format flags in gcc (thanks to Murilo Moreira de Oliveira and pjetko).
- Remove warnings if libgd is not available.
- The date stored in sarg-date is now stored in a more machine readable form (thanks to rcastanheira for pointing this out).
- The date read from sarg-date was not properly parsed and would produce a wrongly sorted index accross a year change (thanks to rcastanheira for pointing this out).
+ - my_mkdir changed to avoid the use of getword, be simpler and, maybe, work reliably on windows.
Oct-14-2009 Version 2.2.6
- Protection against buffer overflows in getword and friends and report the origin of the error instead of always blaming access.log.
+
for ac_header in stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \
dirent.h sys/socket.h netdb.h arpa/inet.h sys/types.h netinet/in.h sys/stat.h \
ctype.h gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h iconv.h \
- errno.h sys/resource.h sys/wait.h stdarg.h inttypes.h limits.h
+ errno.h sys/resource.h sys/wait.h stdarg.h inttypes.h limits.h locale.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
int
main ()
{
-FILE *f = fopen64 ("/tmp/foo","r");
+FILE *f = fopen64 ("/tmp/foo","r");fclose(f);
;
return 0;
}
AC_CHECK_HEADERS(stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \
dirent.h sys/socket.h netdb.h arpa/inet.h sys/types.h netinet/in.h sys/stat.h \
ctype.h gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h iconv.h \
- errno.h sys/resource.h sys/wait.h stdarg.h inttypes.h limits.h)
+ errno.h sys/resource.h sys/wait.h stdarg.h inttypes.h limits.h locale.h)
AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD="yes", HAVE_GD="")
# needs to be defined for it
AC_MSG_CHECKING([for fopen64])
AC_CACHE_VAL(bu_cv_have_fopen64,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");]])],[bu_cv_have_fopen64=yes],[saved_CFLAGS=$CFLAGS
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[FILE *f = fopen64 ("/tmp/foo","r");fclose(f);]])],[bu_cv_have_fopen64=yes],[saved_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE"
AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");],
bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE",
-/*! \fn void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second)
+/*! \fn void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second,int dst)
Format a date to display it in the report.
\param date The buffer to write the formatted date into.
\param hour The hour to format.
\param minute The minute to format.
\param second The second to format.
+\param dst A positive number if the daylight saving is active, zero if it is not active and a negative number if it is unknown.
*/
/*
* AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
- * 1998, 2008
+ * 1998, 2009
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
*
* SARG donations:
/*
* AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
- * 1998, 2008
+ * 1998, 2009
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
*
* SARG donations:
#include "include/conf.h"
#include "include/defs.h"
-#if defined(HAVE_GD) && defined(HAVE_ICONV_H) && defined(gdFTEX_Unicode)
+#if defined(HAVE_GD)
static int blue;
static int white;
//static char *font1 = FONTDIR"/FreeSans.ttf";
static char *font1 = FONTDIR"/DejaVuSans.ttf";
+#if defined(HAVE_ICONV_H) && defined(gdFTEX_Unicode)
#include <iconv.h>
#define SARGgdImageStringFT I18NgdImageStringFT
#define SARGgdImageStringFT gdImageStringFT
#endif
-#ifdef HAVE_GD
static void bar(int x1,long long int n)
{
gdPoint points[4];
return;
}
-#endif
+#endif //HAVE_GD
void greport_day(const char *user)
{
unlink(wdirname);
unlink(tmp5);
-#endif
+#endif //HAVE_GD
return;
}
#ifdef HAVE_WINSOCK_H
#include <winsock.h>
#endif
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
#if defined(HAVE_FOPEN64)
#define _FILE_OFFSET_BITS 64
#cmakedefine HAVE_LIMITS_H
#cmakedefine HAVE_WINDOWS_H
#cmakedefine HAVE_WINSOCK_H
+#cmakedefine HAVE_LOCALE_H
#cmakedefine IBERTY_LIB
void strip_latin(char *line);
char *buildtime(long long int elap);
void 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);
+void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second,int dst);
void obtuser(const char *dirname, const char *name, char *tuser);
void obttotal(const char *dirname, const char *name, char *tbytes, char *tuser, char *media);
void version(void);
-#define VERSION PACKAGE_VERSION" Dec-10-2009"
+#define VERSION PACKAGE_VERSION" Dec-18-2009"
#define PGM PACKAGE_NAME
#define URL "http://sarg.sourceforge.net"
char d1[3], d2[3];
char m1[4], m2[4];
struct getwordstruct gwarea;
+ int iyear, imonth, iday, ihour, iminute, isecond, idst;
if(LastLog[0] != '\0') mklastlog(outdir);
obtdate(outdir,direntp->d_name,data);
obtuser(outdir,direntp->d_name,tuser);
obttotal(outdir,direntp->d_name,tbytes,tuser,media);
- if (sscanf(data,"%d-%d-%d %d:%d:%d",&iyear,&imonth,&iday,&ihour,&iminute,&isecond)==6) {
- formatdate(data,sizeof(data),iyear,imonth,iday,ihour,iminute,isecond);
+ if (sscanf(data,"%d-%d-%d %d:%d:%d %d",&iyear,&imonth,&iday,&ihour,&iminute,&isecond,&idst)==7) {
+ formatdate(data,sizeof(data),iyear,imonth,iday,ihour,iminute,isecond,idst);
fprintf(fp_tmp,"%04d%02d%02d%02d%02d%02d;%s;%s;%s;%s;%s;%s\n",iyear,imonth,iday,ihour,iminute,isecond, direntp->d_name, data, tuser, tbytes, media,newname);
} else {
/*
/*
* AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
- * 1998, 2008
+ * 1998, 2009
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
*
* SARG donations:
while(record<sizeof(text)/sizeof(text[0]) && fgets(buf,sizeof(buf),fp_text)!=NULL) {
if (buf[0] == '#') {
+ begin=buf;
text[record][0] = '\0';
} else {
begin = strchr(buf,'\"');
bzero(IncludeUsers, MAXLEN);
bzero(ExcludeString, MAXLEN);
+#ifdef HAVE_LOCALE_H
+ setlocale(LC_TIME,"");
+#endif
+
for(x=0; x<=254; x++)
warq[x][0]='\0';
/*
* AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
- * 1998, 2008
+ * 1998, 2009
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
*
* SARG donations:
/*
* AUTHOR: Pedro Lineu Orso pedro.orso@gmail.com
- * 1998, 2008
+ * 1998, 2009
* SARG Squid Analysis Report Generator http://sarg.sourceforge.net
*
* SARG donations:
void my_mkdir(const char *name)
{
- char w0[255];
- char w1[255];
- char w2[255];
- struct getwordstruct gwarea;
+ char w0[MAXLEN];
+ int i;
+ int chars;
if(!is_absolute(name)) {
fprintf(stderr,"SARG: Invalid path (%s). Please, use absolute paths only.\n",name);
exit(1);
}
- strcpy(w0,name);
- strcpy(w2,"/");
- getword_start(&gwarea,w0);
- if (getword_multisep(w1,sizeof(w1),&gwarea,'/')<0) {
- printf("SARG: Maybe you have a broken record or garbage in the directory name %s.\n",name);
- exit(1);
- }
- while(strchr(gwarea.current,'/')) {
- if (getword_multisep(w1,sizeof(w1),&gwarea,'/')<0) {
- printf("SARG: Maybe you have a broken record or garbage in the directory name %s.\n",name);
+ chars=0;
+ for (i=0 ; name[i] ; i++) {
+ if (i>=sizeof(w0)) {
+ fprintf(stderr,"SARG: directory name too long %s\n",name);
exit(1);
}
- strcat(w2,w1);
- if(access(w2, R_OK) != 0) {
- if(mkdir(w2,0755)) {
- fprintf(stderr,"SARG: mkdir %s %s\n",w2,strerror(errno));
- fprintf(stderr,"SARG: process aborted.\n");
- exit(1);
+ if (chars>0 && name[i] == '/') {
+ w0[i] = '\0';
+ if(access(w0, R_OK) != 0) {
+ if(mkdir(w0,0755)) {
+ fprintf(stderr,"SARG: mkdir %s %s\n",w0,strerror(errno));
+ fprintf(stderr,"SARG: process aborted.\n");
+ exit(1);
+ }
}
}
- strcat(w2,"/");
+ if (name[i] != '/') chars++;
+ w0[i] = name[i];
}
- strcat(w2,gwarea.current);
- if(access(w2, R_OK) != 0) {
- if(mkdir(w2,0755)) {
- fprintf(stderr,"SARG: mkdir %s %s\n",w2,strerror(errno));
+
+ if(access(name, R_OK) != 0) {
+ if(mkdir(name,0755)) {
+ fprintf(stderr,"SARG: mkdir %s %s\n",name,strerror(errno));
fprintf(stderr,"SARG: process aborted.\n");
exit(1);
}
}
-void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second)
+void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second,int dst)
{
struct tm ltm;
- time_t curtime;
memset(<m,0,sizeof(ltm));
- ltm.tm_year=year-1900;
- ltm.tm_mon=month-1;
- ltm.tm_mday=day;
- ltm.tm_hour=hour;
- ltm.tm_min=minute;
- ltm.tm_sec=second;
- curtime=mktime(<m); //tm cannot be used directly because we need the date normalization made by mktime.
- strftime(date,date_size,"%a %b %d %H:%M:%S %Z %Y",localtime(&curtime));
+ if (year>=1900) ltm.tm_year=year-1900;
+ if (month>=1 && month<=12) ltm.tm_mon=month-1;
+ if (day>=1 && day<=31) ltm.tm_mday=day;
+ if (hour>=0 && hour<24) ltm.tm_hour=hour;
+ if (minute>=0 && minute<60) ltm.tm_min=minute;
+ if (second>=0 && second<60) ltm.tm_sec=second;
+ ltm.tm_isdst=dst;
+ //strftime(date,date_size,"%a %b %d %H:%M:%S %Z %Y",<m);
+ strftime(date,date_size,"%c",<m);
}
char d1[3], d2[3];
char m1[4], m2[4];
time_t curtime;
+ struct tm *loctm;
int cstatus;
if(strcmp(IndexTree,"date") == 0) {
}
time(&curtime);
//strftime(wdir,sizeof(wdir),"%a %b %d %H:%M:%S %Z %Y",localtime(&curtime));
- strftime(wdir,sizeof(wdir),"%Y-%m-%d %H:%M:%S",localtime(&curtime));
- fprintf(fp_ou,"%s\n",wdir);
+ loctm=localtime(&curtime);
+ strftime(wdir,sizeof(wdir),"%Y-%m-%d %H:%M:%S",loctm);
+ fprintf(fp_ou,"%s %d\n",wdir,loctm->tm_isdst);
fclose(fp_ou);
strcpy(per2,IMAGEDIR);
t = time(NULL);
local = localtime(&t);
+ /*
if(strcmp(DateFormat,"u") == 0)
strftime(ftime, ftimesize, "%b/%d/%Y %H:%M", local);
if(strcmp(DateFormat,"e") == 0)
strftime(ftime, ftimesize, "%d/%b/%Y-%H:%M", local);
if(strcmp(DateFormat,"w") == 0)
strftime(ftime, ftimesize, "%V-%H-%M", local);
-
+ */
+ strftime(ftime, ftimesize, "%x %X", local);
return;
}