]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Take the length of the label in the locale language into account when placing it...
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Fri, 7 May 2010 21:40:33 +0000 (21:40 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Fri, 7 May 2010 21:40:33 +0000 (21:40 +0000)
getconf.c
grepday.c
include/conf.h
log.c
util.c

index a2f9e089cdd12f2dc43dda471f4c8e0dc1894ac3..62f43d746a07df9d8aeff6a1d6ab799a65e56d71 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -41,7 +41,7 @@ struct param_list
    unsigned long int exclude;
 };
 
-struct param_list report_type_values[]=
+static struct param_list report_type_values[]=
 {
    {"users_sites",REPORT_TYPE_USERS_SITES,0},
    {"topusers",REPORT_TYPE_TOPUSERS,0},
@@ -54,7 +54,7 @@ struct param_list report_type_values[]=
    {"downloads",REPORT_TYPE_DOWNLOADS,0},
 };
 
-struct param_list data_field_values[]=
+static struct param_list data_field_values[]=
 {
    {"user",DATA_FIELD_USER,0},
    {"date",DATA_FIELD_DATE,0},
@@ -67,7 +67,7 @@ struct param_list data_field_values[]=
    {"elapsed",DATA_FIELD_ELAPSED,0},
 };
 
-struct param_list topuserfields_values[]=
+static struct param_list topuserfields_values[]=
 {
    {"NUM",TOPUSERFIELDS_NUM,0},
    {"DATE_TIME",TOPUSERFIELDS_DATE_TIME,0},
@@ -84,7 +84,7 @@ struct param_list topuserfields_values[]=
    {"AVERAGE",TOPUSERFIELDS_AVERAGE,0},
 };
 
-struct param_list userreportfields_values[]=
+static struct param_list userreportfields_values[]=
 {
    {"CONNECT",USERREPORTFIELDS_CONNECT,0},
    {"BYTES",USERREPORTFIELDS_BYTES,0},
@@ -98,38 +98,44 @@ struct param_list userreportfields_values[]=
    {"AVERAGE",USERREPORTFIELDS_AVERAGE,0},
 };
 
-struct param_list index_values[]=
+static struct param_list index_values[]=
 {
    {"yes",INDEX_YES,~INDEX_YES},
    {"no",INDEX_NO,~INDEX_NO},
    {"only",INDEX_ONLY,~INDEX_ONLY},
 };
 
-struct param_list index_tree_values[]=
+static struct param_list index_tree_values[]=
 {
    {"date",INDEX_TREE_DATE,~INDEX_TREE_DATE},
    {"file",INDEX_TREE_FILE,~INDEX_TREE_FILE},
 };
 
-struct param_list ntml_userformat_values[]=
+static struct param_list ntml_userformat_values[]=
 {
    {"user",NTLMUSERFORMAT_USER,~NTLMUSERFORMAT_USER},
    {"domainname+username",NTLMUSERFORMAT_DOMAINUSER,~NTLMUSERFORMAT_DOMAINUSER},
 };
 
-struct param_list recnouser_values[]=
+static struct param_list recnouser_values[]=
 {
    {"ip",RECORDWITHOUTUSER_IP,~RECORDWITHOUTUSER_IP},
    {"ignore",RECORDWITHOUTUSER_IGNORE,~RECORDWITHOUTUSER_IGNORE},
    {"everybody",RECORDWITHOUTUSER_EVERYBODY,~RECORDWITHOUTUSER_EVERYBODY},
 };
 
-struct param_list datafileurl_values[]=
+static struct param_list datafileurl_values[]=
 {
    {"ip",DATAFILEURL_IP,~DATAFILEURL_IP},
    {"name",DATAFILEURL_NAME,~DATAFILEURL_NAME},
 };
 
+static struct param_list displayvalue_values[]=
+{
+   {"bytes",DISPLAY_BYTES,~DISPLAY_BYTES},
+   {"abbreviation",DISPLAY_ABBREV,~DISPLAY_ABBREV},
+};
+
 static int is_param(const char *param,const char *buf)
 {
    int plen;
@@ -505,7 +511,7 @@ static void parmtest(char *buf)
 
    if (getparam_string("parsed_output_log_compress",buf,ParsedOutputLogCompress,sizeof(ParsedOutputLogCompress))>0) return;
 
-   if (getparam_string("displayed_values",buf,DisplayedValues,sizeof(DisplayedValues))>0) return;
+   if (getparam_list("displayed_values",SET_LIST(displayvalue_values),buf,&DisplayedValues)>0) return;
 
    if (getparam_int("authfail_report_limit",buf,&AuthfailReportLimit)>0) return;
 
index 4d999e88cd3154cafb8b3965896fcd492e41aac7..0482dcfee860e129e3a6f0dacbfe08a96f2d4e91 100644 (file)
--- a/grepday.c
+++ b/grepday.c
 
 #if defined(HAVE_GD)
 
-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;
-
 #if defined(HAVE_ICONV_H) && defined(gdFTEX_Unicode)
 #include <iconv.h>
-#define SARGgdImageStringFT I18NgdImageStringFT
+#define USE_ICONV 1
+#endif
 
-static char * I18NgdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
-                         double ptsize, double angle, int x, int y, char *string)
+struct GraphDataStruct
 {
+#ifdef USE_ICONV
    iconv_t localtoutf;
-   char *sstring, *str, *sstr, *retval;
-   size_t slen, sslen;
-
-   slen = strlen(string) + 1; // We must include string termination character
-   sslen = slen * 2;          // We assume that UTF8 maximum 2 times large than local
-   sstring = (char *)malloc(sslen);
-   if (!sstring) {
-      debuga(_("malloc error (%zu bytes required)\n"),sslen);
-      exit(EXIT_FAILURE);
-   }
-
-   str = (char *) string;
-   sstr = (char *) sstring;
+#endif
+   int lavender;
+   int darkblue;
+   int dimgray;
+   int goldenrod;
+   int goldenrod2;
+   int gray;
+   int silver;
+   int black;
+   int color1;
+   int color2;
+   int color3;
+   gdImage *im;
+   char *string;
+   size_t string_size;
+};
+
+enum TextRefPos
+{
+   TRP_TopLeft,
+   TRP_TopCenter,
+   TRP_TopRight,
+   TRP_BottomLeft,
+   TRP_BottomCenter,
+   TRP_BottomRight,
+   TRP_CenterLeft,
+   TRP_Center,
+   TRP_CenterRight,
+};
+
+static char * Sarg_gdImageStringFT (struct GraphDataStruct *gdata, int fg, char *fontlist,
+                         double ptsize, double angle, int x, int y, char *string,enum TextRefPos RefPos)
+{
+   char *sstring, *retval;
+   int brect[8];
+   int minx,miny,maxx,maxy;
+   int i;
+
+#ifdef USE_ICONV
+   if (gdata->localtoutf!=(iconv_t)-1) {
+      char *str;
+      char *sstr;
+      size_t slen, sslen;
+
+      slen = strlen(string) + 1; // We must include string termination character
+      sslen = slen * 2;          // We assume that UTF8 maximum 2 times large than local
+      if (sslen>gdata->string_size) {
+         sstring = (char *)realloc(gdata->string,sslen);
+         if (!sstring) {
+            debuga(_("realloc error (%zu bytes required)\n"),sslen);
+            exit(EXIT_FAILURE);
+         }
+         gdata->string=sstring;
+         gdata->string_size=sslen;
+      } else {
+         sstring=gdata->string;
+         sslen=gdata->string_size;
+      }
 
-   localtoutf = iconv_open ("UTF-8", CharSet);
-   if (localtoutf==(iconv_t)-1) {
-      debuga(_("(grepday) iconv cannot convert from %s to UTF-8 - %s\n"),CharSet,strerror(errno));
-      strcpy(sstring,string); //show something sensible on the graph
-   }
-   else {
-      if (iconv (localtoutf, (ICONV_CONST char **)&str, &slen, &sstr, &sslen)==-1) {
+      str = string;
+      sstr = sstring;
+      if (iconv (gdata->localtoutf, (ICONV_CONST char **)&str, &slen, &sstr, &sslen)==-1) {
          debuga(_("(grepday) iconv failed to convert string \"%s\" from %s to UTF-8 - %s\n"),string,CharSet,strerror(errno));
-         strcpy(sstring,string); //show something sensible on the graph
+         sstring=string; //show something sensible on the graph
+      }
+   } else {
+      sstring=string; //show something sensible on the graph
+   }
+#else
+   sstring=string;
+#endif
+
+   if (RefPos!=TRP_BottomLeft) {
+      retval = gdImageStringFTEx (NULL, brect, fg, fontlist, ptsize, angle, 0, 0, sstring, gdFTEX_Unicode);
+      if (retval) {
+         debuga(_("libgd failed to calculate the bounding box of the text \"%s\": %s\n"),sstring,retval);
+         exit(EXIT_FAILURE);
+      }
+      /*
+      From libgd documentation, brect contains this without taking into account the angle:
+      0  lower left corner, X position
+      1  lower left corner, Y position
+      2  lower right corner, X position
+      3  lower right corner, Y position
+      4  upper right corner, X position
+      5  upper right corner, Y position
+      6  upper left corner, X position
+      7  upper left corner, Y position
+      */
+      minx=maxx=brect[0];
+      miny=maxy=brect[1];
+      for (i=2 ; i<7 ; i+=2) {
+         if (minx>brect[i]) minx=brect[i];
+         if (maxx<brect[i]) maxx=brect[i];
+         if (miny>brect[i+1]) miny=brect[i+1];
+         if (maxy<brect[i+1]) maxy=brect[i+1];
       }
-      iconv_close (localtoutf);
    }
 
-   retval = gdImageStringFTEx (im, brect, fg, fontlist, ptsize, angle, x, y, sstring, gdFTEX_Unicode);
-   free(sstring);
+   switch (RefPos)
+   {
+      case TRP_TopLeft:
+         y-=miny;
+         break;
+
+      case TRP_TopCenter:
+         x-=(maxx-minx)/2;
+         y-=miny;
+         break;
+
+      case TRP_TopRight:
+         x-=maxx;
+         y-=miny;
+         break;
+
+      case TRP_BottomLeft:
+         break;
+
+      case TRP_BottomCenter:
+         x-=(maxx-minx)/2;
+         break;
+
+      case TRP_BottomRight:
+         x-=maxx;
+         break;
+
+      case TRP_Center:
+         x-=(maxx-minx)/2;
+         y+=(maxy-miny)/2;
+         break;
+
+      case TRP_CenterLeft:
+         y+=(maxy-miny)/2;
+         break;
+
+      case TRP_CenterRight:
+         x-=maxx;
+         y+=(maxy-miny)/2;
+         break;
+   }
+   retval = gdImageStringFTEx (gdata->im, brect, fg, fontlist, ptsize, angle, x, y, sstring, gdFTEX_Unicode);
+   if (retval) {
+      debuga(_("libgd failed to render the text \"%s\": %s\n"),sstring,retval);
+      exit(EXIT_FAILURE);
+   }
 
    return retval;
 }
-#else
-#define SARGgdImageStringFT gdImageStringFT
-#endif
 
-static void bar(int x1,long long int n)
+static void bar(struct GraphDataStruct *gdata,int x1,long long int n)
 {
    gdPoint points[4];
-   int brect[8];
    int val=0, x;
    long long int num;
-   char v[15];
 
    static const long long int limits[400]={0,500,1000,2000,3000,4000,
        5000,6000,7000,8000,9000,10000,
@@ -154,43 +255,6 @@ static void bar(int x1,long long int n)
     3900000000LL,4000000000LL,4100000000LL,4200000000LL,4300000000LL,4400000000LL,
     4500000000LL,4600000000LL,4700000000LL,4800000000LL,4900000000LL,5000000000LL};
 
-   if(strcmp(GraphDaysBytesBarColor,"orange") == 0) {
-      color1 = gdImageColorAllocate(im, 255, 233, 142);
-      color2 = gdImageColorAllocate(im, 220, 163, 72);
-      color3 = gdImageColorAllocate(im, 255, 198, 107);
-   }
-   if(strcmp(GraphDaysBytesBarColor,"blue") == 0) {
-      color1 = gdImageColorAllocate(im, 62, 80, 167);
-      color2 = gdImageColorAllocate(im, 40, 51, 101);
-      color3 = gdImageColorAllocate(im, 57, 73, 150);
-   }
-   if(strcmp(GraphDaysBytesBarColor,"green") == 0) {
-      color1 = gdImageColorAllocate(im,120,166,129);
-      color2 = gdImageColorAllocate(im,84,113,82);
-      color3 = gdImageColorAllocate(im,158,223,167);
-   }
-   if(strcmp(GraphDaysBytesBarColor,"yellow") == 0) {
-      color1 = gdImageColorAllocate(im,185,185,10);
-      color2 = gdImageColorAllocate(im,111,111,10);
-      color3 = gdImageColorAllocate(im,166,166,10);
-   }
-   if(strcmp(GraphDaysBytesBarColor,"brown") == 0) {
-      color1 = gdImageColorAllocate(im,97,45,27);
-      color2 = gdImageColorAllocate(im,60,30,20);
-      color3 = gdImageColorAllocate(im,88,41,26);
-   }
-   if(strcmp(GraphDaysBytesBarColor,"red")  == 0){
-      color1 = gdImageColorAllocate(im,185,10,10);
-      color2 = gdImageColorAllocate(im,111,10,10);
-      color3 = gdImageColorAllocate(im,166,10,10);
-   }
-
-   blue = gdImageColorAllocate(im, 0, 0, 255);
-   white = gdImageColorAllocate(im, 255, 255, 255);
-   dimgray = gdImageColorAllocate(im, 105, 105, 105);
-   goldenrod = gdImageColorAllocate(im, 234, 234, 174);
-   goldenrod2 = gdImageColorAllocate(im, 207, 181, 59);
-
    num = n;
    val = 55;
    for(x=0; x<=366; x++) {
@@ -200,7 +264,7 @@ static void bar(int x1,long long int n)
       }
    }
 
-   gdImageFilledRectangle(im, x1, val, x1+11, 425, color3);
+   gdImageFilledRectangle(gdata->im, x1, val, x1+11, 425, gdata->color3);
 
    points[0].x = x1+7;
    points[0].y = val-5;
@@ -210,15 +274,13 @@ static void bar(int x1,long long int n)
    points[2].y = val;
    points[3].x = x1+17;
    points[3].y = val-5;
-   gdImageFilledPolygon(im, points, 4, color1);
-
-   gdImageLine(im, x1+8, val-2, x1+8, val-10, dimgray);
-   gdImageFilledRectangle(im, x1-2, val-20, x1+18, val-10, goldenrod);
-   gdImageRectangle(im, x1-2, val-20, x1+18, val-10, goldenrod2);
+   gdImageFilledPolygon(gdata->im, points, 4, gdata->color1);
 
-   snprintf(v,6,"%s",fixnum(num,0));
+   gdImageLine(gdata->im, x1+8, val-2, x1+8, val-10, gdata->dimgray);
+   gdImageFilledRectangle(gdata->im, x1-2, val-20, x1+18, val-10, gdata->goldenrod);
+   gdImageRectangle(gdata->im, x1-2, val-20, x1+18, val-10, gdata->goldenrod2);
 
-   SARGgdImageStringFT(im,&brect[0],black,GraphFont,6,0.0,x1-1,val-12,v);
+   Sarg_gdImageStringFT(gdata,gdata->black,GraphFont,6,0.0,x1+8,val-12,fixnum(num,0),TRP_BottomCenter);
 
    points[0].x = x1+17;
    points[0].y = val-5;
@@ -228,7 +290,7 @@ static void bar(int x1,long long int n)
    points[2].y = 426;
    points[3].x = x1+17;
    points[3].y = 420;
-   gdImageFilledPolygon(im, points, 4, color2);
+   gdImageFilledPolygon(gdata->im, points, 4, gdata->color2);
 
    return;
 }
@@ -240,15 +302,12 @@ void greport_day(const struct userinfostruct *uinfo)
    FILE *fp_in, *pngout;
    int x, y;
    int x1;
-   int brect[8];
    char wdirname[MAXLEN];
    char graph[MAXLEN];
    char buf[MAXLEN];
    char csort[255];
-   char data[20];
    char s[15];
    char tmp5[MAXLEN];
-   int  count=0;
    int oday=0;
    int day=0;
    long long int llday;
@@ -258,153 +317,37 @@ void greport_day(const struct userinfostruct *uinfo)
    time_t t;
    struct tm *local;
    int cstatus;
+   long long datapoints[31];
+   gdPoint points[4];
    struct getwordstruct gwarea;
-   struct getwordstruct gwarea1;
+   struct GraphDataStruct gdata;
+   const int ImgXSize=720;
+   const int ImgYSize=480;
+   const int LeftMargin=60;
+   const int RightMargin=20;
+   const int TopMargin=60;
+   const int BottomMargin=60;
+   const int TickLength=3;
+   const int ZTickLength=5;
+   int BottomGraph;
+   int RightGraph;
 
-   if(!Graphs || GraphFont[0]=='\0') {
-      unlink(wdirname);
-      return;
-   }
-   if(access(GraphFont, R_OK) != 0) {
-      debuga(_("(grepday) Fontname %s not found\n"),GraphFont);
+   if (snprintf(wdirname,sizeof(wdirname),"%s/%s.day",tmp,uinfo->filename)>=sizeof(wdirname)) {
+      debuga(_("user name too long for %s/%s.day\n"),tmp,uinfo->filename);
       exit(EXIT_FAILURE);
    }
-
-   im = gdImageCreate(720, 480);
-
-   lavender = gdImageColorAllocate(im, 230, 230, 250);
-   white = gdImageColorAllocate(im, 255, 255, 255);
-   gray = gdImageColorAllocate(im, 192, 192, 192);
-   silver = gdImageColorAllocate(im, 211, 211, 211);
-   black = gdImageColorAllocate(im, 0, 0, 0);
-   blue = gdImageColorAllocate(im, 35, 35, 227);
-   dimgray = gdImageColorAllocate(im, 105, 105, 105);
-   darkblue = gdImageColorAllocate(im, 0, 0, 139);
-
-   gdImageRectangle(im, 0, 0, 719, 479, dimgray);
-   gdImageFilledRectangle(im, 60, 60, 700, 420, silver);
-
-   points[0].x = 50;
-   points[0].y = 65;
-   points[1].x = 50;
-   points[1].y = 425;
-   points[2].x = 60;
-   points[2].y = 420;
-   points[3].x = 60;
-   points[3].y = 60;
-   gdImageFilledPolygon(im, points, 4, gray);
-
-   points[0].x = 60;
-   points[0].y = 420;
-   points[1].x = 50;
-   points[1].y = 425;
-   points[2].x = 690;
-   points[2].y = 425;
-   points[3].x = 700;
-   points[3].y = 420;
-   gdImageFilledPolygon(im, points, 4, gray);
-
-   gdImageLine(im, 50, 65, 50, 430, black);
-   gdImageLine(im, 45, 425, 690, 425, black);
-   gdImageLine(im, 50, 425, 60, 420, black);
-   gdImageLine(im, 60, 420, 60, 60, black);
-   gdImageLine(im, 700, 60, 700, 420, black);
-   gdImageLine(im, 690, 425, 700, 420, black);
-
-   for(x=415; x>=65; x=x-10) {
-      gdImageLine(im, 50, x, 60, x-5, dimgray);
-      gdImageLine(im, 47, x, 50, x, dimgray);
+   if(access(wdirname, R_OK) != 0) {
+      return;
    }
-
-   for(x=60; x<=420; x=x+10)
-      gdImageLine(im, 60, x, 700, x, dimgray);
-
-   gdImageLine(im, 60, 420, 700, 420, black);
-
-   for(x=70; x<=680; x=x+20)
-      gdImageLine(im, x, 425, x, 428, dimgray);
-
-   y=65;
-   for(x=1; x<=31; x++) {
-      sprintf(s,"%02d",x);
-      SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,y,437,s);
-      y=y+20;
+   if(!Graphs || GraphFont[0]=='\0') {
+      unlink(wdirname);
+      return;
    }
 
-   t = time(NULL);
-   local = localtime(&t);
-   if(strcmp(DateFormat,"u") == 0)
-      strftime(ftime, sizeof(ftime), "%b/%d/%Y %H:%M", local);
-   if(strcmp(DateFormat,"e") == 0)
-      strftime(ftime, sizeof(ftime), "%d/%b/%Y-%H:%M", local);
-
-   SARGgdImageStringFT(im,&brect[0],darkblue,GraphFont,7,0.0,620,470,ftime);
-   if(ShowSargInfo) SARGgdImageStringFT(im,&brect[0],darkblue,GraphFont,10,0.0,257,15,"SARG, ");
-   SARGgdImageStringFT(im,&brect[0],darkblue,GraphFont,10,0.0,300,15,Title);
-   sprintf(warea,_("Period: %s"),period.text);
-   SARGgdImageStringFT(im,&brect[0],darkblue,GraphFont,9,0.0,300,27,warea);
-   sprintf(warea,_("User: %s"),uinfo->label);
-   SARGgdImageStringFT(im,&brect[0],darkblue,GraphFont,9,0.0,300,38,warea);
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,418,"  50K");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,408,"250K");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,398,"500K");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,388,"   1M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,378,"   2M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,368,"   3M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,358,"   4M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,348,"   5M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,338,"   6M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,328,"   7M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,318,"   8M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,308,"   9M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,298," 10M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,288," 15M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,278," 20M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,268," 30M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,258," 40M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,248," 50M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,238," 60M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,228," 70M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,218," 80M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,208," 90M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,198,"100M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,188,"200M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,178,"300M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,168,"400M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,158,"500M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,148,"600M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,138,"700M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,128,"800M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,118,"900M");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23,108,"   1G");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23, 98,"   2G");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23, 88,"   3G");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23, 78,"   4G");
-   SARGgdImageStringFT(im,&brect[0],dimgray,GraphFont,7,0.0,23, 68,"   5G");
-   if(strcmp(datetimeby,"bytes") == 0)
-      SARGgdImageStringFT(im,&brect[0],black,GraphFont,10,3.14/2,20,248,_("BYTES"));
-   else
-      SARGgdImageStringFT(im,&brect[0],black,GraphFont,10,3.14/2,20,248,_("ELAPSED TIME"));
-   SARGgdImageStringFT(im,&brect[0],black,GraphFont,10,0.0,330,460,_("DAYS"));
-
-   if (snprintf(graph,sizeof(graph),"%s/%s/graph_day.png",outdirname,uinfo->filename)>=sizeof(graph)) {
-      debuga(_("user name too long for %s/%s/graph_day.png\n"),outdirname,uinfo->filename);
-      exit(EXIT_FAILURE);
-   }
-   if (snprintf(wdirname,sizeof(wdirname),"%s/%s.day",tmp,uinfo->filename)>=sizeof(wdirname)) {
-      debuga(_("user name too long for %s/%s.day\n"),tmp,uinfo->filename);
-      exit(EXIT_FAILURE);
-   }
    if (snprintf(tmp5,sizeof(tmp5),"%s/%s.graph",tmp,uinfo->filename)>=sizeof(tmp5)) {
       debuga(_("user name too long for %s/%s.graph\n"),tmp,uinfo->filename);
       exit(EXIT_FAILURE);
    }
-
-   if(access(wdirname, R_OK) != 0) {
-      gdImageDestroy(im);
-      return;
-   }
-
    if(strcmp(DateFormat,"e") == 0)
       sprintf(csort,"sort -t\"/\" -k 1,1 -o \"%s\" \"%s\"",tmp5,wdirname);
    else
@@ -421,61 +364,246 @@ void greport_day(const struct userinfostruct *uinfo)
       debuga(_("(grepday) Cannot open log file %s\n"),tmp5);
       exit(EXIT_FAILURE);
    }
+   unlink(wdirname);
 
-   if((pngout=fopen(graph,"wb"))==NULL) {
-      debuga(_("(grepday) Cannot open log file %s\n"),graph);
-      exit(EXIT_FAILURE);
-   }
-
+   memset(datapoints,0,sizeof(datapoints));
+   oday=-1;
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
       fixendofline(buf);
       getword_start(&gwarea,buf);
-      if (getword(data,sizeof(data),&gwarea,'\t')<0) {
+      if (getword_atoll(&llday,&gwarea,'/')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp5);
          exit(EXIT_FAILURE);
       }
-      getword_start(&gwarea1,data);
-      if (getword_atoll(&llday,&gwarea1,'/')<0) {
-         debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp5);
-         exit(EXIT_FAILURE);
-      }
-      if(strcmp(DateFormat,"u") == 0) {
-         if (getword_atoll(&llday,&gwarea1,'/')<0) {
+      if(DateFormat[0]=='u') {
+         if (getword_atoll(&llday,&gwarea,'/')<0) {
             debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp5);
             exit(EXIT_FAILURE);
          }
       }
       day=(int)llday;
-      if(!count) {
-         oday=day;
-         count++;
-      }
-      if (getword_skip(20,&gwarea,'\t')<0 || getword_atoll(&bytes,&gwarea,'\t')<0) {
+      if (day<1 || day>31) continue;
+      if (getword_skip(20,&gwarea,'\t')<0 || getword_skip(20,&gwarea,'\t')<0 || getword_atoll(&bytes,&gwarea,'\t')<0) {
          debuga(_("Maybe you have a broken record or garbage in your %s file\n"),tmp5);
          exit(EXIT_FAILURE);
       }
 
       if(oday!=day) {
-         x1 = 44 +(oday * 20);
-         bar(x1,tot);
+         if (oday>0) datapoints[oday-1]=tot;
          oday=day;
          tot=0;
       }
       tot+=bytes;
    }
+   fclose(fp_in);
+   unlink(tmp5);
+   if (oday>0) datapoints[oday-1]=tot;
+
+   if(access(GraphFont, R_OK) != 0) {
+      debuga(_("(grepday) Fontname %s not found\n"),GraphFont);
+      exit(EXIT_FAILURE);
+   }
+   memset(&gdata,0,sizeof(gdata));
+
+#ifdef USE_ICONV
+   gdata.localtoutf = iconv_open ("UTF-8", CharSet);
+   if (gdata.localtoutf==(iconv_t)-1) {
+      debuga(_("(grepday) iconv cannot convert from %s to UTF-8 - %s\n"),CharSet,strerror(errno));
+   }
+#endif
+
+   gdata.im = gdImageCreate(ImgXSize, ImgYSize);
+   BottomGraph=ImgYSize-BottomMargin;
+   RightGraph=ImgXSize-RightMargin;
+
+   // first allocated color is the background
+   gdata.lavender = gdImageColorAllocate(gdata.im, 230, 230, 250);
+   gdata.gray = gdImageColorAllocate(gdata.im, 192, 192, 192);
+   gdata.silver = gdImageColorAllocate(gdata.im, 211, 211, 211);
+   gdata.black = gdImageColorAllocate(gdata.im, 0, 0, 0);
+   gdata.dimgray = gdImageColorAllocate(gdata.im, 105, 105, 105);
+   gdata.darkblue = gdImageColorAllocate(gdata.im, 0, 0, 139);
+   gdata.goldenrod = gdImageColorAllocate(gdata.im, 234, 234, 174);
+   gdata.goldenrod2 = gdImageColorAllocate(gdata.im, 207, 181, 59);
+
+   if(strcmp(GraphDaysBytesBarColor,"orange") == 0) {
+      gdata.color1 = gdImageColorAllocate(gdata.im, 255, 233, 142);
+      gdata.color2 = gdImageColorAllocate(gdata.im, 220, 163, 72);
+      gdata.color3 = gdImageColorAllocate(gdata.im, 255, 198, 107);
+   }
+   else if(strcmp(GraphDaysBytesBarColor,"blue") == 0) {
+      gdata.color1 = gdImageColorAllocate(gdata.im, 62, 80, 167);
+      gdata.color2 = gdImageColorAllocate(gdata.im, 40, 51, 101);
+      gdata.color3 = gdImageColorAllocate(gdata.im, 57, 73, 150);
+   }
+   else if(strcmp(GraphDaysBytesBarColor,"green") == 0) {
+      gdata.color1 = gdImageColorAllocate(gdata.im,120,166,129);
+      gdata.color2 = gdImageColorAllocate(gdata.im,84,113,82);
+      gdata.color3 = gdImageColorAllocate(gdata.im,158,223,167);
+   }
+   else if(strcmp(GraphDaysBytesBarColor,"yellow") == 0) {
+      gdata.color1 = gdImageColorAllocate(gdata.im,185,185,10);
+      gdata.color2 = gdImageColorAllocate(gdata.im,111,111,10);
+      gdata.color3 = gdImageColorAllocate(gdata.im,166,166,10);
+   }
+   else if(strcmp(GraphDaysBytesBarColor,"brown") == 0) {
+      gdata.color1 = gdImageColorAllocate(gdata.im,97,45,27);
+      gdata.color2 = gdImageColorAllocate(gdata.im,60,30,20);
+      gdata.color3 = gdImageColorAllocate(gdata.im,88,41,26);
+   }
+   else if(strcmp(GraphDaysBytesBarColor,"red")  == 0){
+      gdata.color1 = gdImageColorAllocate(gdata.im,185,10,10);
+      gdata.color2 = gdImageColorAllocate(gdata.im,111,10,10);
+      gdata.color3 = gdImageColorAllocate(gdata.im,166,10,10);
+   } else {
+      debuga(_("Unknown color \"%s\" requested for the graph. Using orange instead\n"),GraphDaysBytesBarColor);
+      gdata.color1 = gdImageColorAllocate(gdata.im, 255, 233, 142);
+      gdata.color2 = gdImageColorAllocate(gdata.im, 220, 163, 72);
+      gdata.color3 = gdImageColorAllocate(gdata.im, 255, 198, 107);
+   }
+
+   // rectangle around the image
+   gdImageRectangle(gdata.im, 0, 0, ImgXSize-1, ImgYSize-1, gdata.dimgray);
+   // backtround of the graph
+   gdImageFilledRectangle(gdata.im, LeftMargin, TopMargin, RightGraph, BottomGraph, gdata.silver);
+
+   // depth of the left Y axis
+   points[0].x = LeftMargin-10;
+   points[0].y = TopMargin+5;
+   points[1].x = LeftMargin-10;
+   points[1].y = BottomGraph+5;
+   points[2].x = LeftMargin;
+   points[2].y = BottomGraph;
+   points[3].x = LeftMargin;
+   points[3].y = TopMargin;
+   gdImageFilledPolygon(gdata.im, points, 4, gdata.gray);
+
+   // depth of the bottom X axis
+   points[0].x = LeftMargin;
+   points[0].y = BottomGraph;
+   points[1].x = LeftMargin-10;
+   points[1].y = BottomGraph+5;
+   points[2].x = RightGraph-10;
+   points[2].y = BottomGraph+5;
+   points[3].x = RightGraph;
+   points[3].y = BottomGraph;
+   gdImageFilledPolygon(gdata.im, points, 4, gdata.gray);
+
+   // vertical exterior line of the depth
+   gdImageLine(gdata.im, LeftMargin-10, TopMargin+5, LeftMargin-10, BottomGraph+5+ZTickLength, gdata.black);
+   // horizontal exterior line of the depth
+   gdImageLine(gdata.im, LeftMargin-10-ZTickLength, BottomGraph+5, RightGraph-10, BottomGraph+5, gdata.black);
+   // diagonal line between the two depths
+   gdImageLine(gdata.im, LeftMargin-10, BottomGraph+5, LeftMargin, BottomGraph, gdata.black);
+   // vertical left line of the graph
+   gdImageLine(gdata.im, LeftMargin, BottomGraph, LeftMargin, TopMargin, gdata.black);
+   // horizontal bottom line of the graph
+   gdImageLine(gdata.im, LeftMargin, BottomGraph, RightGraph, BottomGraph, gdata.black);
+   // vertical right line of the graph
+   gdImageLine(gdata.im, RightGraph, TopMargin, RightGraph, BottomGraph, gdata.black);
+   // diagonal line to close the right of the bottom depth
+   gdImageLine(gdata.im, RightGraph-10, BottomGraph+5, RightGraph, BottomGraph, gdata.black);
+
+   // Y axis ticks
+   for(x=BottomGraph-10; x>=TopMargin; x=x-10) {
+      gdImageLine(gdata.im, LeftMargin-10, x+5, LeftMargin, x, gdata.dimgray);
+      gdImageLine(gdata.im, LeftMargin-10-TickLength, x+5, LeftMargin-10, x+5, gdata.dimgray);
+   }
+
+   // horizontal background lines
+   for(x=TopMargin; x<=BottomGraph-10; x=x+10)
+      gdImageLine(gdata.im, LeftMargin, x, RightGraph, x, gdata.dimgray);
+
+   // X axis ticks and labels
+   x=LeftMargin-10+20;
+   for(y=1; y<=31; y++) {
+      gdImageLine(gdata.im, x, BottomGraph+5, x, BottomGraph+5+TickLength, gdata.dimgray);
+      sprintf(s,"%02d",y);
+      Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,x,BottomGraph+5+TickLength+1,s,TRP_TopCenter);
+      x=x+20;
+   }
+
+   t = time(NULL);
+   local = localtime(&t);
+   if(strcmp(DateFormat,"u") == 0)
+      strftime(ftime, sizeof(ftime), "%b/%d/%Y %H:%M", local);
+   if(strcmp(DateFormat,"e") == 0)
+      strftime(ftime, sizeof(ftime), "%d/%b/%Y-%H:%M", local);
+
+   Sarg_gdImageStringFT(&gdata,gdata.darkblue,GraphFont,7,0.0,ImgXSize-10,ImgYSize-10,ftime,TRP_BottomRight);
+   if(ShowSargInfo) Sarg_gdImageStringFT(&gdata,gdata.darkblue,GraphFont,10,0.0,300,15,_("SARG, "),TRP_BottomRight);
+   Sarg_gdImageStringFT(&gdata,gdata.darkblue,GraphFont,10,0.0,300,15,Title,TRP_BottomLeft);
+   sprintf(warea,_("Period: %s"),period.text);
+   Sarg_gdImageStringFT(&gdata,gdata.darkblue,GraphFont,9,0.0,300,27,warea,TRP_BottomLeft);
+   sprintf(warea,_("User: %s"),uinfo->label);
+   Sarg_gdImageStringFT(&gdata,gdata.darkblue,GraphFont,9,0.0,300,38,warea,TRP_BottomLeft);
+
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-10+5,"50K",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-20+5,"250K",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-30+5,"500K",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-40+5,"1M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-50+5,"2M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-60+5,"3M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-70+5,"4M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-80+5,"5M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-90+5,"6M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-100+5,"7M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-110+5,"8M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-120+5,"9M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-130+5,"10M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-140+5,"15M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-150+5,"20M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-160+5,"30M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-170+5,"40M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-180+5,"50M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-190+5,"60M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-200+5,"70M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-210+5,"80M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-220+5,"90M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-230+5,"100M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-240+5,"200M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-250+5,"300M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-260+5,"400M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-270+5,"500M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-280+5,"600M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-290+5,"700M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-300+5,"800M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-310+5,"900M",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-320+5,"1G",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-330+5,"2G",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-340+5,"3G",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-350+5,"4G",TRP_CenterRight);
+   Sarg_gdImageStringFT(&gdata,gdata.dimgray,GraphFont,7,0.0,LeftMargin-10-TickLength,BottomGraph-360+5,"5G",TRP_CenterRight);
+   if(strcmp(datetimeby,"bytes") == 0)
+      Sarg_gdImageStringFT(&gdata,gdata.black,GraphFont,10,3.141592/2,20,ImgYSize/2,_("BYTES"),TRP_CenterLeft);
+   else
+      Sarg_gdImageStringFT(&gdata,gdata.black,GraphFont,10,3.141592/2,20,ImgYSize/2,_("ELAPSED TIME"),TRP_CenterLeft);
+   Sarg_gdImageStringFT(&gdata,gdata.black,GraphFont,10,0.0,ImgXSize/2,ImgYSize-20,_("DAYS"),TRP_BottomCenter);
 
-   if(tot) {
-      x1 = 44 +(day * 20);
-      bar(x1,tot);
+   for (day=0 ; day<31 ; day++) {
+      if (datapoints[day]>0) {
+         x1 = 44 +((day+1) * 20);
+         bar(&gdata,x1,datapoints[day]);
+      }
    }
 
-   gdImagePng(im, pngout);
+   if (snprintf(graph,sizeof(graph),"%s/%s/graph_day.png",outdirname,uinfo->filename)>=sizeof(graph)) {
+      debuga(_("user name too long for %s/%s/graph_day.png\n"),outdirname,uinfo->filename);
+      exit(EXIT_FAILURE);
+   }
+   if((pngout=fopen(graph,"wb"))==NULL) {
+      debuga(_("(grepday) Cannot open log file %s\n"),graph);
+      exit(EXIT_FAILURE);
+   }
+   gdImagePng(gdata.im, pngout);
    fclose(pngout);
-   gdImageDestroy(im);
+   gdImageDestroy(gdata.im);
 
-   fclose(fp_in);
-   unlink(wdirname);
-   unlink(tmp5);
+   if (gdata.string) free(gdata.string);
+#ifdef USE_ICONV
+   if (gdata.localtoutf!=(iconv_t)-1)
+      iconv_close (gdata.localtoutf);
+#endif
 
 #endif //HAVE_GD
 
index c0a56116f8855810035e68a718c28db1c1910afc..b4b2b8c6b4dd63d6f53f239241c2471621ad22ac 100755 (executable)
@@ -65,8 +65,6 @@
 #ifdef HAVE_GD_H
 #define HAVE_GD 1
 #include <gd.h>
-gdImagePtr im;
-gdPoint points[4];
 #endif
 #ifdef HAVE_GDFONTL_H
 #include <gdfontl.h>
@@ -233,6 +231,9 @@ int mkstemps(char *template, int suffixlen);
 #define DATAFILEURL_IP   0x0001UL
 #define DATAFILEURL_NAME 0x0002UL
 
+#define DISPLAY_BYTES 0x0001UL
+#define DISPLAY_ABBREV 0x0002UL
+
 struct periodstruct
 {
    //! The first date of the period.
@@ -341,7 +342,7 @@ bool BytesInSitesUsersReport;
 bool ShowSargLogo;
 char ParsedOutputLog[MAXLEN];
 char ParsedOutputLogCompress[512];
-char DisplayedValues[20];
+unsigned long int DisplayedValues;
 char HeaderFontSize[5];
 char TitleFontSize[5];
 char wwwDocumentRoot[MAXLEN];
@@ -397,9 +398,6 @@ int  dansguardian_count;
 int  squidguard_count;
 int  useragent_count;
 int  limit_flag;
-int  color1;
-int  color2;
-int  color3;
 int  z1, z2, z3;
 int  ttopen;
 int  sarglog;
diff --git a/log.c b/log.c
index 0f777fe1641f7bb2d9366008d784de64320779d6..b2905830e6477dd2d9b3aabbd4b4581f49106b58 100644 (file)
--- a/log.c
+++ b/log.c
@@ -249,7 +249,7 @@ int main(int argc,char *argv[])
    ShowSargLogo=true;
    strcpy(ParsedOutputLog,"no");
    strcpy(ParsedOutputLogCompress,"/bin/gzip -f");
-   strcpy(DisplayedValues,"abbreviation");
+   DisplayedValues=DISPLAY_ABBREV;
    strcpy(HeaderFontSize,"9px");
    strcpy(TitleFontSize,"11px");
    strcpy(AuthUserTemplateFile,"sarg_htaccess");
@@ -326,9 +326,6 @@ int main(int argc,char *argv[])
    debugm=0;
    iprel=false;
    userip=false;
-   color1=0;
-   color2=0;
-   color3=0;
    realt=false;
    realtime_refresh=3;
    realtime_access_log_lines=1000;
diff --git a/util.c b/util.c
index ad250da8d957c8e6ab8425776b366a0a536153c9..4821419900f925c5691a3e0338f3c26de7fe10d6 100644 (file)
--- a/util.c
+++ b/util.c
@@ -457,7 +457,7 @@ char *fixnum(long long int value, int n)
 
    my_lltoa(value, num, sizeof(num), 0);
 
-   if(strcmp(DisplayedValues,"abbreviation") == 0) {
+   if(DisplayedValues==DISPLAY_ABBREV) {
       numlen = strlen(num);
       if(numlen <= 3)
          sprintf(abbrev,"%s",num);