]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Replace the IP address by the user ID in the e-mail report
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 28 Nov 2010 15:40:28 +0000 (15:40 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 28 Nov 2010 15:40:28 +0000 (15:40 +0000)
CMakeLists.txt
ChangeLog
email.c
include/info.h

index 5ff65b46788f99467fc393be23388977a7535896..314ac8870d580b41cf3c3b994efb97f66e9d5f8d 100755 (executable)
@@ -3,7 +3,7 @@ PROJECT(sarg C)
 SET(sarg_VERSION 2)
 SET(sarg_REVISION "3.2-pre1")
 SET(sarg_BUILD "")
-SET(sarg_BUILDDATE "Nov-22-2010")
+SET(sarg_BUILDDATE "Nov-28-2010")
 
 INCLUDE(AddFileDependencies)
 INCLUDE(CheckIncludeFile)
index fc0b682caedadce4d179a59acf4ebdf828ea8ca5..eda38c6e00ec1972de632f9406c80871dc29b77a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,9 @@
 SARG ChangeLog
 
-Nov-21-2010 Version 2.3.2-pre1
+Nov-28-2010 Version 2.3.2-pre1
                - Add support for sorttable.js (http://www.kryogenix.org/code/browser/sorttable/) to dynamically sort some tables (thanks to Éric).
                - Add the two command line options --lastlog and --keeplogs to set the number of reports to keep or to keep all the reports respectively (thanks to Emmanuel Lacour for the suggestion).
+               - Report the user ID in the e-mail report.
 
 Sep-18-2010 Version 2.3.1
                - Remove the distinct printf for the alpha architecture as it doesn't work anymore and is not necessary anyway.
diff --git a/email.c b/email.c
index 691e596785bcc366a9a078b1ff4aed6493040fc1..4a0ca946105715cfb6b4ddd5238c69adebe87480 100644 (file)
--- a/email.c
+++ b/email.c
@@ -49,6 +49,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
    struct getwordstruct gwarea;
    struct generalitemstruct item;
    longline line;
+   const struct userinfostruct *uinfo;
 
    snprintf(wger,sizeof(wger),"%s/sarg-general",dirname);
    if((fp_in=fopen(wger,"r"))==NULL) {
@@ -129,17 +130,6 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
 
    unlink(top2);
 
-   if((fp_top1=fopen(top1,"a"))==NULL) {
-      debuga(_("(email) Cannot open file %s\n"),top1);
-      exit(EXIT_FAILURE);
-   }
-#if defined(__FreeBSD__)
-   fprintf(fp_top1,"TOTAL\t%qu\t%qu\t%qu\n",ttnbytes,ttnacc,ttnelap);
-#else
-   fprintf(fp_top1,"TOTAL\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",(uint64_t)ttnbytes,(uint64_t)ttnacc,(uint64_t)ttnelap);
-#endif
-   fclose(fp_top1);
-
    if((fp_top1=fopen(top1,"r"))==NULL) {
       debuga(_("(email) Cannot open file %s\n"),top1);
       exit(EXIT_FAILURE);
@@ -201,27 +191,33 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
          exit(EXIT_FAILURE);
       }
 
+      uinfo=userinfo_find_from_id(user);
+      if (!uinfo) {
+         debuga(_("Unknown user ID %s in file %s\n"),user,top1);
+         exit(EXIT_FAILURE);
+      }
+
       perc=(ttnbytes) ? nbytes * 100. / ttnbytes : 0;
       perc2=(ttnelap) ? elap * 100. / ttnelap : 0;
 
       posicao++;
 
-      if(strcmp(user,"TOTAL") == 0){
-         fputs("------- -------------------- -------- --------------- ------- ---------- ---------- -------\n",fp_top3);
 #if defined(__FreeBSD__)
-         fprintf(fp_top3,"%-7s %20s %8qu %15s %8s %9s %10qu\n",_("TOTAL")," ",ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),ttnelap);
+      fprintf(fp_top3,"%7d %20s %8lld %15s %3.2lf%% %10s %10qu %3.2lf%%\n",posicao,uinfo->label,nacc,fixnum(nbytes,1),perc,buildtime(elap),elap,perc2);
 #else
-         fprintf(fp_top3,"%-7s %20s %8"PRIu64" %15s %8s %9s %10"PRIu64"\n",_("TOTAL")," ",(uint64_t)ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),(uint64_t)ttnelap);
+      fprintf(fp_top3,"%7d %20s %8"PRIu64" %15s %3.2lf%% %10s %10"PRIu64" %3.2lf%%\n",posicao,uinfo->label,(uint64_t)nacc,fixnum(nbytes,1),perc,buildtime(elap),(uint64_t)elap,perc2);
 #endif
-      } else {
+   }
+
+   // output total
+   fputs("------- -------------------- -------- --------------- ------- ---------- ---------- -------\n",fp_top3);
 #if defined(__FreeBSD__)
-         fprintf(fp_top3,"%7d %20s %8lld %15s %3.2lf%% %10s %10qu %3.2lf%%\n",posicao,user,nacc,fixnum(nbytes,1),perc,buildtime(elap),elap,perc2);
+   fprintf(fp_top3,"%-7s %20s %8qu %15s %8s %9s %10qu\n",_("TOTAL")," ",ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),ttnelap);
 #else
-         fprintf(fp_top3,"%7d %20s %8"PRIu64" %15s %3.2lf%% %10s %10"PRIu64" %3.2lf%%\n",posicao,user,(uint64_t)nacc,fixnum(nbytes,1),perc,buildtime(elap),(uint64_t)elap,perc2);
+   fprintf(fp_top3,"%-7s %20s %8"PRIu64" %15s %8s %9s %10"PRIu64"\n",_("TOTAL")," ",(uint64_t)ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),(uint64_t)ttnelap);
 #endif
-      }
-   }
 
+   // compute and write average
    if (totuser>0) {
       tnbytes=(totuser) ? ttnbytes / totuser : 0;
       avgacc=ttnacc/totuser;
index e9c1413ab67f0f2e915d0feef0bd73dc3ab89110..a397708dceaad828f35fde82cdc05de41e881a92 100755 (executable)
@@ -1,3 +1,3 @@
-#define VERSION PACKAGE_VERSION" Nov-23-2010"
+#define VERSION PACKAGE_VERSION" Nov-28-2010"
 #define PGM PACKAGE_NAME
 #define URL "http://sarg.sourceforge.net"