]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Documentation of grepday.c.
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Tue, 13 Oct 2009 08:18:33 +0000 (08:18 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Tue, 13 Oct 2009 08:18:33 +0000 (08:18 +0000)
Fixed inconsequential memory leaks that clutered the valgrind reports.
Added more warning options at compile time.
Fixed the warnings highlighted by -Wextra.

CMakeLists.txt
configure
configure.in
documentation/grepday.txt [new file with mode: 0644]
grepday.c
html.c
include/defs.h
include/info.h
log.c
report.c
squidguard_log.c

index 7be88a04d333fc3306736c06f5afa62f6b2310cb..fca7c35415f78c50c3fbd5fbd90b9a78e7a3ae2b 100755 (executable)
@@ -3,7 +3,7 @@ PROJECT(sarg C)
 SET(sarg_VERSION 2)
 SET(sarg_REVISION 2)
 SET(sarg_BUILD "6rc1")
-SET(sarg_BUILDDATE "Oct-12-2009")
+SET(sarg_BUILDDATE "Oct-13-2009")
 
 INCLUDE(AddFileDependencies)
 INCLUDE(CheckIncludeFile)
@@ -247,7 +247,7 @@ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "solaris")
 
 OPTION(ENABLE_EXTRA_PROTECT "Enable compile and runtime extra protections" OFF)
 IF(ENABLE_EXTRA_PROTECT)
-   SET_TARGET_PROPERTIES(sarg PROPERTIES COMPILE_FLAG "${CFLAGS} -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=2 -Werror")
+   SET_TARGET_PROPERTIES(sarg PROPERTIES COMPILE_FLAG "${CFLAGS} -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=2 -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter")
 ENDIF(ENABLE_EXTRA_PROTECT)
 
 # Save the configuration for the project
index 5928d7519866e9222c0f1f0b666ef74006faee0d..951857771a736de245157cc7031a19beb4ca0977 100755 (executable)
--- a/configure
+++ b/configure
@@ -6462,7 +6462,7 @@ echo "using $IMAGEDIR as the directory of the images"
 if test "${enable_extraprotection+set}" = set; then
   enableval=$enable_extraprotection;
     if test "$enableval"; then
-       CFLAGS="${CFLAGS} -Werror=format-security -fstack-protector -Werror"
+       CFLAGS="${CFLAGS} -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=2 -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter"
     fi
 
 else
index 0b433156209f2ce4e8ae7f6fc3eefbca996e0b0b..dabbc0a3b55ce867ec67aaf0e892e2867b9bb478 100644 (file)
@@ -154,7 +154,7 @@ AC_ARG_ENABLE(extraprotection,
                         Enable compile and runtime extra protections ],
 [
     if test "$enableval"; then
-       CFLAGS="${CFLAGS} -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=2 -Werror"
+       CFLAGS="${CFLAGS} -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=2 -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter"
     fi
 ],[IMAGEDIR="${datarootdir}/sarg/images"])
 echo "using $IMAGEDIR as the directory of the images"
diff --git a/documentation/grepday.txt b/documentation/grepday.txt
new file mode 100644 (file)
index 0000000..ade174a
--- /dev/null
@@ -0,0 +1,62 @@
+/*!\file grepday.c
+\brief Produce the graphics of the reports.
+*/
+
+
+/*! \def SARGgdImageStringFT
+Link to the proper function to draw a text on the GD image depending on the version of libgd.
+*/
+
+
+
+
+
+/*! \var static char *font1;
+The name of the TTF font file to use to draw the text on the GD image.
+*/
+
+
+
+
+
+/*! \fn char * I18NgdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
+                         double ptsize, double angle, int x, int y, char *string)
+Draw a text on the GD image after converting the current character set defined by ::CharSet into UTF-8
+as requested by libgd.
+
+\param im The GD image to draw the text on.
+\param brect A variable to store the bounding rectangle of the text.
+\param fg The color to render the text.
+\param fontlist The name of the font to use to render the text.
+\param ptsize A scale factor to scale the text.
+\param angle The angle to rotate the text counter-clockwise in radian.
+\param x The X position of the text on the image.
+\param y The Y position of the text on the image.
+\param string The string to write.
+
+\return The return code of \c gdImageStringFTEx. It is NULL on success or an error
+string on failure.
+
+\note See the official documentation of gdImageStringFT at http://www.libgd.org/Font#char_.2AgdImageStringFT.28gdImagePtr_im.2C_int_.2Abrect.2C_int_fg.2C_char_.2Afontname.2C_double_ptsize.2C_double_angle.2C_int_x.2C_int_y.2C_char_.2Astring.29_.28FUNCTION.29
+*/
+
+
+
+
+
+/*! \fn static void bar(int x1,long long int n)
+Draw one bar of the graph.
+
+\param x1 The X position of the bar.
+\param n The height of the bar.
+*/
+
+
+
+
+
+/*! \fn void greport_day(const char *user)
+Draw the graphic of the report for the user.
+
+\param user The name of the user for which to draw the graphic.
+*/
index 656cafa54780c54b553beb67edbf37985bbdaf49..916df8c9c7fec73ec28dfd02bfb356d5fccb5db8 100644 (file)
--- a/grepday.c
+++ b/grepday.c
 #include "include/conf.h"
 #include "include/defs.h"
 
-int blue;
-int white;
-int lavender;
-int darkblue;
-int dimgray;
-int goldenrod;
-int goldenrod2;
-int gray;
-int silver;
-int black;
-int x1;
-//char *font1 = FONTDIR"/FreeSans.ttf";
-char *font1 = FONTDIR"/DejaVuSans.ttf";
-char s[15];
+static int blue;
+static int white;
+static int lavender;
+static int darkblue;
+static int dimgray;
+static int goldenrod;
+static int goldenrod2;
+static int gray;
+static int silver;
+static int black;
+//static char *font1 = FONTDIR"/FreeSans.ttf";
+static char *font1 = FONTDIR"/DejaVuSans.ttf";
 
 #if defined(HAVE_GD) && defined(HAVE_ICONV_H) && defined(gdFTEX_Unicode)
 #include <iconv.h>
 #define SARGgdImageStringFT I18NgdImageStringFT
 
-char * I18NgdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
+static char * I18NgdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
                          double ptsize, double angle, int x, int y, char *string)
 {
    iconv_t localtoutf;
@@ -76,7 +74,7 @@ char * I18NgdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
 #define SARGgdImageStringFT gdImageStringFT
 #endif
 
-void bar(long long int n)
+static void bar(int x1,long long int n)
 {
 #ifdef HAVE_GD
    gdPoint points[4];
@@ -236,6 +234,7 @@ void greport_day(const char *user)
 {
    FILE *fp_in, *pngout;
    int x, y;
+   int x1;
    int brect[8];
    char wdirname[MAXLEN];
    char graph[MAXLEN];
@@ -250,6 +249,8 @@ void greport_day(const char *user)
    time_t t;
    struct tm *local;
    int cstatus;
+   char s[15];
+
 #ifdef HAVE_GD
 
    if(strcmp(Graphs,"yes") != 0) {
@@ -450,7 +451,7 @@ void greport_day(const char *user)
       if(strcmp(oday,day) != 0) {
          strcpy(warea,oday);
          x1 = 44 +(atoi(oday) * 20);
-         bar(tot);
+         bar(x1,tot);
          strcpy(oday,day);
          tot=0;
       }
@@ -459,7 +460,7 @@ void greport_day(const char *user)
 
    if(tot) {
       x1 = 44 +(atoi(day) * 20);
-      bar(tot);
+      bar(x1,tot);
    }
 
    gdImagePng(im, pngout);
@@ -474,3 +475,10 @@ void greport_day(const char *user)
 
    return;
 }
+
+void greport_cleanup(void)
+{
+#ifdef HAVE_GD
+   gdFontCacheShutdown();
+#endif
+}
diff --git a/html.c b/html.c
index 4328642972c18da5eb8768257fa05f497c337372..4a913423d5707ea332f0ef5e70bf70baad95457c 100644 (file)
--- a/html.c
+++ b/html.c
@@ -751,6 +751,7 @@ void htmlrel(void)
 
    (void)rewinddir(dirp);
    (void)closedir(dirp);
+   greport_cleanup();
 
    return;
 }
index 9ecba63efef6c1dac948e96728457fbb2c1c793e..39ce32d0c9ae65dd9b22d4bd34196d738f272519 100755 (executable)
@@ -44,6 +44,7 @@ void getconf(void);
 
 // grepday.c
 void greport_day(const char *user);
+void greport_cleanup(void);
 
 // html.c
 void htmlrel(void);
index 8f3d68e2b7a92dd430d5a686f56f996159e61760..1ba848d24d09b7b7b5b59d42f0c552b2ed6a50ef 100755 (executable)
@@ -1,3 +1,3 @@
-#define VERSION PACKAGE_VERSION" Oct-12-2009"
+#define VERSION PACKAGE_VERSION" Oct-13-2009"
 #define PGM PACKAGE_NAME
 #define URL "http://sarg.sourceforge.net"
diff --git a/log.c b/log.c
index 84ceb0a4a7415df2620cd17a6db98aa99af2e5bb..b120d1710b34f7a2e2ab7d5ce2fae1b67dea6503 100644 (file)
--- a/log.c
+++ b/log.c
@@ -440,7 +440,7 @@ int main(int argc,char *argv[])
       strcpy(ImageFile,"../../../images");
 
    dataonly=0;
-   if(DataFile[0] != '\0');
+   if(DataFile[0] != '\0')
       dataonly++;
 
    subs(TopUserFields,sizeof(TopUserFields),"%BYTES","SETYB");
index b23140008b111884e0253bc0b7005885a0ea835b..9fbafe6bf5df9321f42a618881658bc1ccb58967 100644 (file)
--- a/report.c
+++ b/report.c
@@ -368,8 +368,11 @@ void gerarel(void)
       index_only(wdirname, debug);
    }
 
+   /*
+   2009-10-13(Frederic) This piece of code is never called so it is commented out for good.
    if(strlen(email) < 0)
       removetmp(dirname);
+   */
 
    return;
 }
index 3629dde1aa3d7fa9b7dc46500abded774713d1e3..51abe245a56e7817ac76e04bf7bc1106c2e29673 100644 (file)
@@ -282,6 +282,12 @@ void squidguard_log(void)
    if (fp_guard) fclose(fp_guard);
    if (fp_ou) fclose(fp_ou);
 
+   if (files_done) {
+      for (y=0; y<nfiles_done; y++)
+         if (files_done[y]) free(files_done[y]);
+      free(files_done);
+   }
+
    if(debug) {
       debuga("%s: %s",text[54],guard_ou);
    }