Fixed inconsequential memory leaks that clutered the valgrind reports.
Added more warning options at compile time.
Fixed the warnings highlighted by -Wextra.
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)
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
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
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"
--- /dev/null
+/*!\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.
+*/
#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;
#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];
{
FILE *fp_in, *pngout;
int x, y;
+ int x1;
int brect[8];
char wdirname[MAXLEN];
char graph[MAXLEN];
time_t t;
struct tm *local;
int cstatus;
+ char s[15];
+
#ifdef HAVE_GD
if(strcmp(Graphs,"yes") != 0) {
if(strcmp(oday,day) != 0) {
strcpy(warea,oday);
x1 = 44 +(atoi(oday) * 20);
- bar(tot);
+ bar(x1,tot);
strcpy(oday,day);
tot=0;
}
if(tot) {
x1 = 44 +(atoi(day) * 20);
- bar(tot);
+ bar(x1,tot);
}
gdImagePng(im, pngout);
return;
}
+
+void greport_cleanup(void)
+{
+#ifdef HAVE_GD
+ gdFontCacheShutdown();
+#endif
+}
(void)rewinddir(dirp);
(void)closedir(dirp);
+ greport_cleanup();
return;
}
// grepday.c
void greport_day(const char *user);
+void greport_cleanup(void);
// html.c
void htmlrel(void);
-#define VERSION PACKAGE_VERSION" Oct-12-2009"
+#define VERSION PACKAGE_VERSION" Oct-13-2009"
#define PGM PACKAGE_NAME
#define URL "http://sarg.sourceforge.net"
strcpy(ImageFile,"../../../images");
dataonly=0;
- if(DataFile[0] != '\0');
+ if(DataFile[0] != '\0')
dataonly++;
subs(TopUserFields,sizeof(TopUserFields),"%BYTES","SETYB");
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;
}
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);
}