SET(sarg_VERSION 2)
SET(sarg_REVISION 2)
SET(sarg_BUILD "6rc1")
-SET(sarg_BUILDDATE "Sep-24-2009")
+SET(sarg_BUILDDATE "Sep-30-2009")
INCLUDE(AddFileDependencies)
INCLUDE(CheckIncludeFile)
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 PATHS /usr/lib /usr/local/lib DOC "The GD library")
+ FIND_LIBRARY(GD_LIBRARY NAMES gd DOC "The GD library")
IF(GD_LIBRARY)
#CHECK_LIBRARY_EXISTS(gd gdImagePng "." HAVE_GD)
TARGET_LINK_LIBRARIES(sarg gd)
IF(HAVE_ICONV_H)
CHECK_FUNCTION_EXISTS(iconv_open HAVE_ICONV)
IF(!HAVE_ICONV)
- FIND_PATH(ICONV_INCLUDE_PATH NAMES iconv.h PATHS /usr/include /usr/local/include)
- FIND_LIBRARY(ICONV_LIBRARY NAMES iconv PATHS /lib /usr/lib /usr/local/lib DOC "The ICONV library")
+ FIND_PATH(ICONV_INCLUDE_PATH NAMES iconv.h)
+ FIND_LIBRARY(ICONV_LIBRARY NAMES iconv DOC "The ICONV library")
ENDIF(!HAVE_ICONV)
SET(ICONV_CONST_FILE ${CMAKE_BINARY_DIR}/consticonv.c)
IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
CHECK_INCLUDE_FILE(winsock.h HAVE_WINSOCK_H)
- FIND_LIBRARY(WSOCK_LIB NAMES wsock32 PATHS /usr/lib /usr/local/lib DOC "The winsock library")
+ FIND_LIBRARY(WSOCK_LIB NAMES wsock32 DOC "The winsock library")
#check_library_exists(wsock32 "." HAVE_WSOCK)
IF(WSOCK_LIB)
#set_target_properties(sarg PROPERTIES LINK_FLAGS "${LINK_FLAGS} -lwsock32")
CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)
IF(NOT HAVE_MKSTEMP)
# MingW provide mkstemps in libiberty but doesn't declare it in any header file
- FIND_LIBRARY(IBERTY_LIB NAMES iberty PATHS /mingw/lib DOC "The library of mingw containing mkstemps")
+ FIND_LIBRARY(IBERTY_LIB NAMES iberty DOC "The library of mingw containing mkstemps")
IF(IBERTY_LIB)
TARGET_LINK_LIBRARIES(sarg iberty)
ENDIF(IBERTY_LIB)
Any comment about the usage of cmake is welcome.
+
+
CONFIGURING SARG
It is recommended to build sarg out of the source directory. It makes it easier
make install
+
+
CONFIGURATION VARIABLES
These configuration variables are available on the first configuration run.
They are other configuration variables whose documentation is visible during the
configuration with ccmake.
+
+
+
+COMPILATION WITH MSYS+MINGW
+
+The autotools don't compile sarg with msys. You have to use cmake in an msys
+terminal.
+
+If cmake is not already installed on your system, download and uncompress the
+cmake sources in your home directory then run the following commands in an msys
+terminal:
+
+ configure
+ make
+ make install
+
+Permanently add the path to cmake.exe by appending this line at the end of your
+profile file (c:/msys/1.0/etc/profile):
+
+ export PATH="$PATH:/c/Program files/CMake/bin"
+
+Reopen the msys terminal or run the above command in the same terminal to
+register the new path.
+
+Get the sources of sarg and uncompress them in your home directory. Let's assume
+they are in a directory named "sarg".
+
+Create a separate directory at the same level as the sources of sarg and change
+to that directory. For instance, assuming your prompt is in the sarg directory,
+run the following commands:
+
+ mkdir ../bin
+ cd ../bin
+
+Configure, compile and install sarg:
+
+ cmake ../sarg -G "MSYS Makefiles"
+ make
+ make install
+
+This will compile sarg outside of the sources and install it in c:\Program
+Files\sarg.
+
+If the compilation fails because mkstemp cannot be found, ensure that the LIB
+and INCLUDE environment variables are set properly to the lib and include
+directories of mingw. For instance, type the following two commands and run make
+again:
+
+ export LIB=c:/mingw/lib
+ export INCLUDE=c:/mingw/include
+
+You can make them permanent by appending those two commands at the end of the
+profile file in c:/msys/1.0/etc/profile.
+
+
+
+
+CONFIGURING SARG TO RUN ON WINDOWS
+
+Cmake install a sample configuration file in c:/Program
+Files/sarg/etc/sarg/sarg.conf.exemple. Rename it as sarg.conf and edit it.
+
+You must change the following options:
+
+ access_log c:/Program Files/sarg/log/access.log
+ temporary_dir c:/Program Files/sarg/tmp
+ output_dir c:/Program Files/sarg/www/squid-reports
+
+Adjust and create the directories according to your configuration.
+
+You may have to adjust other options to suit your needs.
+
+If sarg complains about a missing rm or sort command, then you have to install
+the unxtools or run sarg from msys.
+
+If you want to run sarg from a regular dos prompt, download UnxUtils.zip from
+http://unxutils.sourceforge.net/ and uncompress it somewhere. Change the system
+path to include the usr\local\wbin directory before the Windows system
+directory.
+
+You must be sure that the unxutils are found before the windows native commands.
+To check this, open a dos prompt and type
+
+ls
+
+If it list the content of the directory, then the unxutils are found. Then type
+
+sort --help
+
+It should display the help of the sort command if the unxutils command is found
+first. If the windows command is found first, it will complain that the --help
+file cannot be found.
+
+Finally, if sort complains that it cannot write in the /tmp directory, either
+create that directory or set TMPDIR like this:
+
+ set TMPDIR=c:/Program Files/sarg/tmp
+
+It may be set to your TMP or TEMP directory or the temporary directory you named
+in your sarg.conf file.
fgets(period,sizeof(period),fp_in);
fclose(fp_in);
- sprintf(csort,"sort -b -T '%s' -k 3,3 -k 5,5 -o '%s' '%s'", TempDir, authfail_in, tmp4);
+ sprintf(csort,"sort -b -T \"%s\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"", TempDir, authfail_in, tmp4);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
if(debug)
debuga("%s: %s",text[54],guard_ou);
- sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 '%s' -o '%s'",guard_in, guard_ou);
+ sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 \"%s\" -o \"%s\"",guard_in, guard_ou);
cstatus=system(tmp6);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
fclose(fp_in);
fclose(fp_top2);
- sprintf(csort,"sort -n -T '%s' -r -k 2,2 -o '%s' '%s'", TempDir, top1, top2);
+ sprintf(csort,"sort -n -T \"%s\" -r -k 2,2 -o \"%s\" \"%s\"", TempDir, top1, top2);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
}
}
- sprintf(csort,"rm -rf '%s/sarg'",TempDir);
+ sprintf(csort,"rm -rf \"%s/sarg\"",TempDir);
system(csort);
return (0);
if(access(wdirname, R_OK) != 0)
return;
- sprintf(csort,"sort -t'/' -k 2,2 -o '%s' '%s'",tmp5,wdirname);
+ sprintf(csort,"sort -t\"/\" -k 2,2 -o \"%s\" \"%s\"",tmp5,wdirname);
if(strcmp(DateFormat,"e") == 0)
- sprintf(csort,"sort -t'/' -k 1,1 -o '%s' '%s'",tmp5,wdirname);
+ sprintf(csort,"sort -t\"/\" -k 1,1 -o \"%s\" \"%s\"",tmp5,wdirname);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fclose(fp_ip);
fclose(fp_ip2);
- sprintf(csort,"sort -n -T '%s' -k 1,1 -k 5,5 -o '%s' '%s'",TempDir,tmp3,tmp2);
+ sprintf(csort,"sort -n -T \"%s\" -k 1,1 -k 5,5 -o \"%s\" \"%s\"",TempDir,tmp3,tmp2);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
-#define VERSION PACKAGE_VERSION" Sep-24-2009"
+#define VERSION PACKAGE_VERSION" Sep-30-2009"
#define PGM PACKAGE_NAME
#define URL "http://sarg.sourceforge.net"
rename(val4,val3);
sprintf(val5,"%s/images",val2);
if(access(val5, R_OK) != 0) {
- sprintf(val5,"ln -s '%simages' '%s/images'",outdir,val2);
+ sprintf(val5,"ln -s \"%simages\" \"%s/images\"",outdir,val2);
cstatus=system(val5);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: command return status %d\n",WEXITSTATUS(cstatus));
}
if(strcmp(IndexTree,"date") == 0) {
- if(strcmp(IndexSortOrder,"A") == 0) sprintf(warea,"sort -k 1,1 '%s' -o '%s'", wdir_tmp, wdir_tmp2);
- else sprintf(warea,"sort -r -k 1,1 '%s' -o '%s'", wdir_tmp, wdir_tmp2);
+ if(strcmp(IndexSortOrder,"A") == 0) sprintf(warea,"sort -k 1,1 \"%s\" -o \"%s\"", wdir_tmp, wdir_tmp2);
+ else sprintf(warea,"sort -r -k 1,1 \"%s\" -o \"%s\"", wdir_tmp, wdir_tmp2);
cstatus=system(warea);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
(void)rewinddir(dirp2);
(void)closedir(dirp2);
sprintf(wdir_tmp3,"%s%s/index.sort",outdir,tmp4);
- if(strcmp(IndexSortOrder,"A") == 0) sprintf(csort,"sort -n '%s' -o '%s'", tmp3, wdir_tmp3);
- else sprintf(csort,"sort -n -r '%s' -o '%s'", tmp3, wdir_tmp3);
+ if(strcmp(IndexSortOrder,"A") == 0) sprintf(csort,"sort -n \"%s\" -o \"%s\"", tmp3, wdir_tmp3);
+ else sprintf(csort,"sort -n -r \"%s\" -o \"%s\"", tmp3, wdir_tmp3);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
(void)closedir(dirp3);
unlink(wdir_tmp3);
sprintf(tmp6,"%s%s/%s/index.sort",outdir,tmp4,wwork1);
- if(strcmp(IndexSortOrder,"A") == 0) sprintf(csort,"sort -n '%s' -o '%s'", tmp5, tmp6);
- else sprintf(csort,"sort -n -r '%s' -o '%s'", tmp5, tmp6);
+ if(strcmp(IndexSortOrder,"A") == 0) sprintf(csort,"sort -n \"%s\" -o \"%s\"", tmp5, tmp6);
+ else sprintf(csort,"sort -n -r \"%s\" -o \"%s\"", tmp5, tmp6);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
unlink(tmp6);
unlink(wdir_tmp2);
} else {
- if(strcmp(IndexSortOrder,"A") == 0) sprintf(warea,"sort -t';' -k 7,7 -k 1,1 '%s' -o '%s'", wdir_tmp, wdir_tmp2);
- else sprintf(warea,"sort -r -t';' -k 7,7 -k 1,1 '%s' -o '%s'", wdir_tmp, wdir_tmp2);
+ if(strcmp(IndexSortOrder,"A") == 0) sprintf(warea,"sort -t\";\" -k 7,7 -k 1,1 \"%s\" -o \"%s\"", wdir_tmp, wdir_tmp2);
+ else sprintf(warea,"sort -r -t\";\" -k 7,7 -k 1,1 \"%s\" -o \"%s\"", wdir_tmp, wdir_tmp2);
cstatus=system(warea);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
(void)closedir( dirp );
fclose(fp_ou);
- sprintf(buf,"sort -n -k 1,1 -o '%slastlog' '%s'",outdir,temp);
+ sprintf(buf,"sort -n -k 1,1 -o \"%slastlog\" \"%s\"",outdir,temp);
cstatus=system(buf);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
if(debug)
debuga("%s: %s",text[81],buf);
// sprintf(temp,"%s%s",outdir,buf);
- sprintf(temp,"rm -r '%s%s'",outdir,buf);
+ sprintf(temp,"rm -r \"%s%s\"",outdir,buf);
system(temp);
unlink(temp);
ftot--;
sprintf(warea,"%s/sarg",tmp);
if(access(warea, R_OK) == 0) {
- sprintf(tmp3,"rm -rf '%s'",warea);
+ sprintf(tmp3,"rm -rf \"%s\"",warea);
system(tmp3);
}
strcpy(arq_log,val4);
if(strcmp(ParsedOutputLogCompress,"nocompress") != 0) {
- sprintf(val1,"'%s' '%s'",ParsedOutputLogCompress,arq_log);
+ sprintf(val1,"\"%s\" \"%s\"",ParsedOutputLogCompress,arq_log);
cstatus=system(val1);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: command return status %d\n",WEXITSTATUS(cstatus));
}
if(strstr(ReportType,"denied") != 0) {
- sprintf(csort,"sort -T '%s' -k 3,3 -k 5,5 -o '%s' '%s'",tmp,tmp5,tmp4);
+ sprintf(csort,"sort -T \"%s\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"",tmp,tmp5,tmp4);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
// else unlink(arq);
if(strcmp(tmp,"/tmp") != 0) {
- sprintf(tmp4,"rm -rf '%s'",tmp);
+ sprintf(tmp4,"rm -rf \"%s\"",tmp);
system(tmp4);
}
pclose(fp);
fclose(tmp);
- sprintf(cmd,"sort -r -k 1,1 -k 2,2 -o '%s' '%s'",template2,template1);
+ sprintf(cmd,"sort -r -k 1,1 -k 2,2 -o \"%s\" \"%s\"",template2,template1);
cstatus=system(cmd);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
fgets(period,sizeof(period),fp_in);
fclose(fp_in);
- sprintf(csort,"sort -k 4,4 -k 1,1 -o '%s' '%s'",general2,general);
+ sprintf(csort,"sort -k 4,4 -k 1,1 -o \"%s\" \"%s\"",general2,general);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
fgets(period,sizeof(period),fp_in);
fclose(fp_in);
- sprintf(csort,"sort -n -k 1,1 -k 2,2 -k 3,3 -o '%s' '%s'",smart_ou,smart_in);
+ sprintf(csort,"sort -n -k 1,1 -k 2,2 -k 3,3 -o \"%s\" \"%s\"",smart_ou,smart_in);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
}
strcat(arqou,".txt");
- sprintf(csort,"sort -n -T '%s' %s -k %s -k %s -k %s -o '%s' '%s'",TempDir,order,field1,field2,field3,arqou,arqin);
+ sprintf(csort,"sort -n -T \"%s\" %s -k %s -k %s -k %s -o \"%s\" \"%s\"",TempDir,order,field1,field2,field3,arqou,arqin);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
}
if(strcmp(direntp->d_name,"download.unsort") == 0)
- sprintf(csort,"sort -T '%s' -k 3,3 -k 1,1 -k 2,2 -k 5,5 -o '%s/%s.log' '%s/%s.unsort'",
+ sprintf(csort,"sort -T \"%s\" -k 3,3 -k 1,1 -k 2,2 -k 5,5 -o \"%s/%s.log\" \"%s/%s.unsort\"",
tmp, wtmp, user, wtmp, user);
else
- sprintf(csort,"sort -T '%s' -k 5,5 -k 1,1 -k 2,2 -o '%s/%s.log' '%s/%s.unsort'",
+ sprintf(csort,"sort -T \"%s\" -k 5,5 -k 1,1 -k 2,2 -o \"%s/%s.log\" \"%s/%s.unsort\"",
tmp, wtmp, user, wtmp, user);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga("%s: %s",text[54],guard_ou);
}
- sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 '%s' -o '%s'",guard_in, guard_ou);
+ sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 \"%s\" -o \"%s\"",guard_in, guard_ou);
cstatus=system(tmp6);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
fgets(period,sizeof(period),fp_in);
fclose(fp_in);
- sprintf(csort,"sort -k 4,4 -o '%s' '%s'",general2,general);
+ sprintf(csort,"sort -k 4,4 -o \"%s\" \"%s\"",general2,general);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
if(strcmp(TopsitesSortType,"d") == 0)
strcpy(sortt,"-r");
- sprintf(csort,"sort %s -k %s -o '%s' '%s'",sortt,sortf,sites,general3);
+ sprintf(csort,"sort %s -k %s -o \"%s\" \"%s\"",sortt,sortf,sites,general3);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
if(strcmp(TopuserSortOrder,"normal") == 0)
order[0]='\0';
- sprintf(csort,"sort -n -T '%s' %s -k %s -o '%s' '%s'", TempDir, order, sfield, top1, top2);
+ sprintf(csort,"sort -n -T \"%s\" %s -k %s -o \"%s\" \"%s\"", TempDir, order, sfield, top1, top2);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
sprintf(arqout,"%s/%s.day",tmp,user);
sprintf(sortout,"%s/%s.sort",tmp,user);
- sprintf(csort,"sort -k 1,1 -k 2,2 -o '%s' '%s'",sortout,wdirname);
+ sprintf(csort,"sort -k 1,1 -k 2,2 -o \"%s\" \"%s\"",sortout,wdirname);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
debuga("%s: %s",text[54],tmp2);
}
- sprintf(csort,"sort -n -t '\\' -k 4,4 -k 3,3 -k 2,2 -k 1,1 -o '%s' '%s'",tmp2,tmp3);
+ sprintf(csort,"sort -n -t '\\' -k 4,4 -k 3,3 -k 2,2 -k 1,1 -o \"%s\" \"%s\"",tmp2,tmp3);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
fclose(fp_in);
fclose(fp_ou);
- sprintf(csort,"sort -n -t '\\' -k 3,3 -o '%s' '%s'",tmp3,tmp2);
+ sprintf(csort,"sort -n -t \"\\\" -k 3,3 -o \"%s\" \"%s\"",tmp3,tmp2);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
unlink(tmp3);
- sprintf(csort,"sort -n -r -k 1,1 -o '%s' '%s'",tmp3,tmp2);
+ sprintf(csort,"sort -n -r -k 1,1 -o \"%s\" \"%s\"",tmp3,tmp2);
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
}
} else {
if(access(dir,R_OK) == 0) {
- sprintf(csort,"rm -r '%s'",dir);
+ sprintf(csort,"rm -r \"%s\"",dir);
system(csort);
}
}
}
} else {
if(access(wdir,R_OK) == 0) {
- sprintf(csort,"rm -r '%s'",wdir);
+ sprintf(csort,"rm -r \"%s\"",wdir);
system(csort);
}
}
printf("SARG: process stoped. No actions taken.\n");
printf("SARG: ------------------------------------------------------------------------------\n");
- system("rm -rf '/tmp/sarg'");
- sprintf(tmp4,"rm -rf '%s'",dirname);
+ system("rm -rf \"/tmp/sarg\"");
+ sprintf(tmp4,"rm -rf \"%s\"",dirname);
system(tmp4);
- system("rm -rf '/tmp/sarg'");
+ system("rm -rf \"/tmp/sarg\"");
exit(1);
}