]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Use portable long long format specifiers.
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Tue, 1 Jun 2010 14:42:03 +0000 (14:42 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Tue, 1 Jun 2010 14:42:03 +0000 (14:42 +0000)
Use correct char type with iconv

CMakeLists.txt
email.c
grepday.c
html.c
report.c
topsites.c
topuser.c
totday.c
totger.c
util.c

index fb0a815eab0e76a9cbebd518528c44461f0a552e..791381d43c2148e4efabbaed78ddee4c81162576 100755 (executable)
@@ -177,25 +177,41 @@ IF(ENABLE_ICONV)
       ENDIF(ICONV_LIBRARY)
       CHECK_FUNCTION_EXISTS(iconv_open HAVE_ICONV)
 
-      SET(ICONV_CONST_FILE ${CMAKE_BINARY_DIR}/consticonv.c)
-      FILE(WRITE ${ICONV_CONST_FILE} "
-#include <stdlib.h>
+      IF(NOT USE_CONST_ICONV)
+         SET(ICONV_CONST_FILE ${CMAKE_BINARY_DIR}/consticonv.c)
+         FILE(WRITE ${ICONV_CONST_FILE} "
 #include <iconv.h>
-extern
-#ifdef __cplusplus
-"C"
-#endif
-#if defined(__STDC__) || defined(__cplusplus)
-size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#ifdef __CLASSIC_C__
+int main(){
+  int ac;
+  char*av[];
 #else
-size_t iconv();
+int main(int ac, char*av[]){
 #endif
+  iconv_t localtoutf=(iconv_t)-1;
+  const char *str=\"\";
+  char *sstr=\"\";
+  size_t slen=0, sslen=0;
+
+  iconv (localtoutf, (const char **)&str, &slen, &sstr, &sslen);
+  if(ac > 1000)
+    {
+    return *av[0];
+    }
+  return 0;
+}
 ")
-      TRY_COMPILE(USE_CONST_ICONV ${CMAKE_BINARY_DIR} ${ICONV_CONST_FILE})
-      FILE(REMOVE ${ICONV_CONST_FILE})
-      IF(USE_CONST_ICONV)
-         SET(ICONV_CONST "\"const\"")
-      ENDIF(USE_CONST_ICONV)
+         TRY_COMPILE(USE_CONST_ICONV ${CMAKE_BINARY_DIR} ${ICONV_CONST_FILE} CMAKE_FLAGS -DLINK_LIBRARIES="iconv")
+         FILE(REMOVE ${ICONV_CONST_FILE})
+         IF(USE_CONST_ICONV)
+            SET(ICONV_CONST "const" CACHE STRING "The type of char to use with iconv")
+            MESSAGE(STATUS "iconv requires const char **")
+         ELSEIF(USE_CONST_ICONV)
+            SET(ICONV_CONST "" CACHE STRING "The type of char to use with iconv")
+            MESSAGE(STATUS "iconv requires char **")
+         ENDIF(USE_CONST_ICONV)
+         SET(USE_CONST_ICONV TRUE CACHE BOOL "Use const char ** with iconv")
+      ENDIF(NOT USE_CONST_ICONV)
    ENDIF(HAVE_ICONV_H)
 ENDIF(ENABLE_ICONV)
 
diff --git a/email.c b/email.c
index 2bb39400db749bd1a6b223df9b269ecb4df29c70..e7227592e9cce78627a132e964d8896c96b72795 100644 (file)
--- a/email.c
+++ b/email.c
@@ -82,7 +82,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
 #elif defined(__alpha) || __ALPHA
             fprintf(fp_top2,"%s\t%ld\t%ld\t%ld\n",olduser,tnbytes,tnacc,tnelap);
 #else
-            fprintf(fp_top2,"%s\t%lld\t%lld\t%lld\n",olduser,tnbytes,tnacc,tnelap);
+            fprintf(fp_top2,"%s\t%"PRId64"\t%"PRId64"\t%"PRId64"\n",olduser,tnbytes,tnacc,tnelap);
 #endif
             ttnbytes+=tnbytes;
             ttnacc+=tnacc;
@@ -105,7 +105,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
 #elif defined(__alpha) || __ALPHA
       fprintf(fp_top2,"%s\t%ld\t%ld\t%ld\n",olduser,tnbytes,tnacc,tnelap);
 #else
-      fprintf(fp_top2,"%s\t%lld\t%lld\t%lld\n",olduser,tnbytes,tnacc,tnelap);
+      fprintf(fp_top2,"%s\t%"PRId64"\t%"PRId64"\t%"PRId64"\n",olduser,tnbytes,tnacc,tnelap);
 #endif
       ttnbytes+=tnbytes;
       ttnacc+=tnacc;
@@ -134,7 +134,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
 #elif defined(__alpha) || __ALPHA
    fprintf(fp_top1,"TOTAL\t%ld\t%ld\t%ld\n",ttnbytes,ttnacc,ttnelap);
 #else
-   fprintf(fp_top1,"TOTAL\t%lld\t%lld\t%lld\n",ttnbytes,ttnacc,ttnelap);
+   fprintf(fp_top1,"TOTAL\t%"PRId64"\t%"PRId64"\t%"PRId64"\n",ttnbytes,ttnacc,ttnelap);
 #endif
    fclose(fp_top1);
 
@@ -210,7 +210,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
 #elif defined(__alpha) || __ALPHA
          fprintf(fp_top3,"%-7s %20s %8ld %15s %8s %9s %10ld\n",_("TOTAL")," ",ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),ttnelap);
 #else
-         fprintf(fp_top3,"%-7s %20s %8lld %15s %8s %9s %10lld\n",_("TOTAL")," ",ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),ttnelap);
+         fprintf(fp_top3,"%-7s %20s %8"PRId64" %15s %8s %9s %10"PRId64"\n",_("TOTAL")," ",ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),ttnelap);
 #endif
       } else {
 #if defined(__FreeBSD__)
@@ -218,7 +218,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
 #elif defined(__alpha) || __ALPHA
          fprintf(fp_top3,"%7d %20s %8lld %15s %3.2lf%% %10s %10ld %3.2lf%%\n",posicao,user,nacc,fixnum(nbytes,1),perc,buildtime(elap),elap,perc2);
 #else
-         fprintf(fp_top3,"%7d %20s %8lld %15s %3.2lf%% %10s %10lld %3.2lf%%\n",posicao,user,nacc,fixnum(nbytes,1),perc,buildtime(elap),elap,perc2);
+         fprintf(fp_top3,"%7d %20s %8"PRId64" %15s %3.2lf%% %10s %10"PRId64" %3.2lf%%\n",posicao,user,nacc,fixnum(nbytes,1),perc,buildtime(elap),elap,perc2);
 #endif
       }
    }
@@ -232,7 +232,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
 #elif defined(__alpha) || __ALPHA
    fprintf(fp_top3,"%-7s %20s %8ld %15s %8s %9s %10ld\n",strip1," ",ttnacc/totuser,fixnum(tnbytes,1)," ",buildtime(ttnelap/totuser),ttnelap/totuser);
 #else
-   fprintf(fp_top3,"%-7s %20s %8lld %15s %8s %9s %10lld\n",strip1," ",ttnacc/totuser,fixnum(tnbytes,1)," ",buildtime(ttnelap/totuser),ttnelap/totuser);
+   fprintf(fp_top3,"%-7s %20s %8"PRId64" %15s %8s %9s %10"PRId64"\n",strip1," ",ttnacc/totuser,fixnum(tnbytes,1)," ",buildtime(ttnelap/totuser),ttnelap/totuser);
 #endif
 
    fclose(fp_top1);
index f0336af10b6e0a36c71f9fdfce06731f6cb62604..122fd7458e8324023ca8c089e0172a86dba9f0a8 100644 (file)
--- a/grepday.c
+++ b/grepday.c
@@ -141,7 +141,7 @@ static void Sarg_gdImageStringFT (struct GraphDataStruct *gdata, int fg, char *f
       if (sslen>gdata->string_size) {
          sstring = (char *)realloc(gdata->string,sslen);
          if (!sstring) {
-            debuga(_("realloc error (%zu bytes required)\n"),sslen);
+            debuga(_("realloc error (%"PRIu64" bytes required)\n"),(unsigned long long int)sslen);
             exit(EXIT_FAILURE);
          }
          gdata->string=(char *)sstring;
@@ -293,11 +293,11 @@ static int greport_compute_yaxis(struct PlotStruct *pdata,struct GraphDataStruct
    double ymag;
 
    if (pdata->ymin<0.) {
-      debuga(_("Minimum for Y scale of the graph is out of range: %lld\n"),pdata->ymin);
+      debuga(_("Minimum for Y scale of the graph is out of range: %"PRId64"\n"),pdata->ymin);
       return(-1);
    }
    if (pdata->ymax<=0.) {
-      debuga(_("Maximum for Y scale of the graph is out of range: %lld\n"),pdata->ymax);
+      debuga(_("Maximum for Y scale of the graph is out of range: %"PRId64"\n"),pdata->ymax);
       return(-1);
    }
 
diff --git a/html.c b/html.c
index 5ae585f3b09caa063fd814df7b4535d37db8b65b..22a94395ed8814d75c79e383c52af4e0d31cd7c4 100644 (file)
--- a/html.c
+++ b/html.c
@@ -424,7 +424,7 @@ void htmlrel(void)
                }
                if(strcmp(user_ip,olduserip) != 0) {
                   sprintf(wwork1,"%s",fixnum(unbytes,1));
-                  fprintf(fp_ou,"<tr><td></td><td class=\"data\">%s</td><td></td><td class=\"data\">%s</td><td></td><td></td><td></td><td class=\"data\">%s</td><td class=\"data\">%lld</td></tr>\n",olduserip,wwork1,buildtime(unelap),unelap);
+                  fprintf(fp_ou,"<tr><td></td><td class=\"data\">%s</td><td></td><td class=\"data\">%s</td><td></td><td></td><td></td><td class=\"data\">%s</td><td class=\"data\">%"PRId64"</td></tr>\n",olduserip,wwork1,buildtime(unelap),unelap);
 
                   strcpy(olduserip,user_ip);
                   unacc=0;
@@ -443,7 +443,7 @@ void htmlrel(void)
             unlink(tmp3);
 
             sprintf(wwork1,"%s",fixnum(unbytes,1));
-            fprintf(fp_ou,"<tr><td></td><td class=\"data\">%s</td><td></td><td class=\"data\">%s</td><td></td><td></td><td></td><td class=\"data\">%s</td><td class=\"data\">%lld</td></tr>\n",olduserip,wwork1,buildtime(unelap),unelap);
+            fprintf(fp_ou,"<tr><td></td><td class=\"data\">%s</td><td></td><td class=\"data\">%s</td><td></td><td></td><td></td><td class=\"data\">%s</td><td class=\"data\">%"PRId64"</td></tr>\n",olduserip,wwork1,buildtime(unelap),unelap);
          }
 
          unacc=0;
index b4ff0e96ccddd83cdaa429a1db142395642f7f66..b073154deaff7c070f3dd2248598a4677fb2ace0 100644 (file)
--- a/report.c
+++ b/report.c
@@ -475,7 +475,7 @@ void gravatmp(const struct userinfostruct *uinfo, const char *oldurl, long long
       exit(EXIT_FAILURE);
    }
 
-   fprintf(fp_ou,"%lld\t%lld\t%s\t%s\t%lld\t%lld\t%lld\n",nacc,nbytes,oldurl,oldmsg,nelap,incache,oucache);
+   fprintf(fp_ou,"%"PRId64"\t%"PRId64"\t%s\t%s\t%"PRId64"\t%"PRId64"\t%"PRId64"\n",nacc,nbytes,oldurl,oldmsg,nelap,incache,oucache);
 
    fclose(fp_ou);
    ttopen=0;
@@ -507,7 +507,7 @@ static void gravatmpf(const struct userinfostruct *uinfo,const char *oldurl, lon
       exit(EXIT_FAILURE);
    }
 
-   fprintf(fp_ou,"%lld\t%lld\t%s\t%s\t%lld\t%lld\t%lld\n",nacc,nbytes,oldurl,oldmsg,nelap,incache,oucache);
+   fprintf(fp_ou,"%"PRId64"\t%"PRId64"\t%s\t%s\t%"PRId64"\t%"PRId64"\t%"PRId64"\n",nacc,nbytes,oldurl,oldmsg,nelap,incache,oucache);
 
    if (fclose(fp_ou)==EOF) {
       debuga(_("Failed to close file %s - %s\n"),wdirname,strerror(errno));
@@ -547,8 +547,8 @@ static void gravatmp_hora(const char *dirname, const struct userinfostruct *uinf
 
    hour=atoi(hora);
    fprintf(fp_ou,"%s\t%d",data,hour);
-   if((datetimeby & DATETIME_BYTE)!=0) fprintf(fp_ou,"\t%lld",bytes);
-   if((datetimeby & DATETIME_ELAP)!=0) fprintf(fp_ou,"\t%lld",elap);
+   if((datetimeby & DATETIME_BYTE)!=0) fprintf(fp_ou,"\t%"PRId64,bytes);
+   if((datetimeby & DATETIME_ELAP)!=0) fprintf(fp_ou,"\t%"PRId64,elap);
    fputs("\n",fp_ou);
 
    if (fclose(fp_ou)==EOF) {
@@ -578,7 +578,7 @@ static void gravaporuser(const struct userinfostruct *uinfo, const char *dirname
       exit(EXIT_FAILURE);
    }
 
-   fprintf(fp_ou,"%s\t%s\t%s\t%s\t%lld\t%lld\n",ip,url,data,hora,tam,elap);
+   fprintf(fp_ou,"%s\t%s\t%s\t%s\t%"PRId64"\t%"PRId64"\n",ip,url,data,hora,tam,elap);
 
    fclose(fp_ou);
 
@@ -589,7 +589,7 @@ static void gravaporuser(const struct userinfostruct *uinfo, const char *dirname
 
 static void gravager(FILE *fp_gen, const struct userinfostruct *uinfo, long long int nacc, const char *url, long long int nbytes, const char *ip, const char *hora, const char *dia, long long int nelap, long long int incache, long long int oucache)
 {
-   fprintf(fp_gen,"%s\t%lld\t%lld\t%s\t%s\t%s\t%s\t%lld\t%lld\t%lld\n",uinfo->id,nacc,nbytes,url,ip,hora,dia,nelap,incache,oucache);
+   fprintf(fp_gen,"%s\t%"PRId64"\t%"PRId64"\t%s\t%s\t%s\t%s\t%"PRId64"\t%"PRId64"\t%"PRId64"\n",uinfo->id,nacc,nbytes,url,ip,hora,dia,nelap,incache,oucache);
    return;
 }
 
index 842ccb63a10aeac80282467313a802c78121f24d..3742825ab6b0d71a693e419112cf28f42e284029 100644 (file)
@@ -114,7 +114,7 @@ void topsites(void)
       }
 
       if(strcmp(item.url,ourl) != 0) {
-         fprintf(fp_ou,"%lld\t%lld\t%lld\t%s\n",tnacc,tnbytes,tntime,ourl);
+         fprintf(fp_ou,"%"PRId64"\t%"PRId64"\t%"PRId64"\t%s\n",tnacc,tnbytes,tntime,ourl);
          url_len=strlen(item.url);
          if (url_len>=ourl_size) {
             ourl_size=url_len+1;
@@ -139,7 +139,7 @@ void topsites(void)
    longline_destroy(&line);
 
    if (ourl) {
-      fprintf(fp_ou,"%lld\t%lld\t%lld\t%s\n",tnacc,tnbytes,tntime,ourl);
+      fprintf(fp_ou,"%"PRId64"\t%"PRId64"\t%"PRId64"\t%s\n",tnacc,tnbytes,tntime,ourl);
       free(ourl);
    }
 
index f02c83e987398086ae8d0205f5d780544deb32ad..8913863421bde87fcfdb14fe5ff04e7bcd65e5ae 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -88,7 +88,7 @@ void topuser(void)
          totuser++;
 
          if (olduser[0] != '\0') {
-            fprintf(fp_top2,"%s\t%lld\t%lld\t%lld\t%lld\t%lld\n",olduser,tnbytes,tnacc,tnelap,tnincache,tnoucache);
+            fprintf(fp_top2,"%s\t%"PRId64"\t%"PRId64"\t%"PRId64"\t%"PRId64"\t%"PRId64"\n",olduser,tnbytes,tnacc,tnelap,tnincache,tnoucache);
 
             ttnbytes+=tnbytes;
             ttnacc+=tnacc;
@@ -114,7 +114,7 @@ void topuser(void)
    longline_destroy(&line);
 
    if (olduser[0] != '\0') {
-      fprintf(fp_top2,"%s\t%lld\t%lld\t%lld\t%lld\t%lld\n",olduser,tnbytes,tnacc,tnelap,tnincache,tnoucache);
+      fprintf(fp_top2,"%s\t%"PRId64"\t%"PRId64"\t%"PRId64"\t%"PRId64"\t%"PRId64"\n",olduser,tnbytes,tnacc,tnelap,tnincache,tnoucache);
 
       ttnbytes+=tnbytes;
       ttnacc+=tnacc;
index 61472e2c0c2333e520d5fe180d418a0968d0e3d8..36ff220de32b7ff51793416139b0d3429f3a633a 100644 (file)
--- a/totday.c
+++ b/totday.c
@@ -124,9 +124,9 @@ void day_totalize(const char *tmp, const struct userinfostruct *uinfo, int index
       day=daynum%100;
       month=(daynum/100)%100;
       year=daynum/10000;
-      fprintf(fp_ou,"%d/%d/%d\t%lld",day,month,year,hour);
-      if ((datetimeby & DATETIME_BYTE)!=0) fprintf(fp_ou,"\t%lld",tbytes[i]);
-      if ((datetimeby & DATETIME_ELAP)!=0) fprintf(fp_ou,"\t%lld",telap[i]);
+      fprintf(fp_ou,"%d/%d/%d\t%"PRId64"",day,month,year,hour);
+      if ((datetimeby & DATETIME_BYTE)!=0) fprintf(fp_ou,"\t%"PRId64"",tbytes[i]);
+      if ((datetimeby & DATETIME_ELAP)!=0) fprintf(fp_ou,"\t%"PRId64"",telap[i]);
       fputs("\n",fp_ou);
    }
 
index 7691072a1ca24b9f0f4ff2a693d7128a4952a2ba..77422398b416915130dd9ca38de92e994f94006b 100644 (file)
--- a/totger.c
+++ b/totger.c
@@ -67,7 +67,7 @@ int totalger(const char *dirname, int debug, const char *outdir)
       exit(EXIT_FAILURE);
    }
 
-   if (fprintf(fp_in,"TOTAL\t%lld\t%lld\t%lld\t%lld\t%lld\n",tnacc,tnbytes,telap,tincache,toucache)<0) {
+   if (fprintf(fp_in,"TOTAL\t%"PRId64"\t%"PRId64"\t%"PRId64"\t%"PRId64"\t%"PRId64"\n",tnacc,tnbytes,telap,tincache,toucache)<0) {
       debuga(_("Failed to write the total line in %s\n"),wger);
       exit(EXIT_FAILURE);
    }
diff --git a/util.c b/util.c
index 69996313d1d71d5dbf163bed74cd382a9fe2f0c8..e0e71045b2c0fc08130f1c3a9e8a77575aa3a69e 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1118,7 +1118,7 @@ void zdate(char *ftime,int ftimesize, const char *DateFormat)
    if(strcmp(DateFormat,"e") == 0)
       strftime(ftime, ftimesize, "%d/%b/%Y-%H:%M", local);
    if(strcmp(DateFormat,"w") == 0)
-      strftime(ftime, ftimesize, "%V-%H-%M", local);
+      strftime(ftime, ftimesize, "%W-%H-%M", local);
    return;
 }