]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - topuser.c
Be more consistent with the use of the temporary directory (i.e. always use /tmp...
[thirdparty/sarg.git] / topuser.c
index f02c83e987398086ae8d0205f5d780544deb32ad..444cfc2ac6bdb59c50fa5321057feac1be416477 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -88,7 +88,11 @@ 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);
+            /*
+            This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
+            to print a long long int unless it is exactly 64-bits long.
+            */
+            fprintf(fp_top2,"%s\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",olduser,(uint64_t)tnbytes,(uint64_t)tnacc,(uint64_t)tnelap,(uint64_t)tnincache,(uint64_t)tnoucache);
 
             ttnbytes+=tnbytes;
             ttnacc+=tnacc;
@@ -114,7 +118,11 @@ 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);
+      /*
+      This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
+      to print a long long int unless it is exactly 64-bits long.
+      */
+      fprintf(fp_top2,"%s\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",olduser,(uint64_t)tnbytes,(uint64_t)tnacc,(uint64_t)tnelap,(uint64_t)tnincache,(uint64_t)tnoucache);
 
       ttnbytes+=tnbytes;
       ttnacc+=tnacc;
@@ -140,7 +148,7 @@ void topuser(void)
       order="";
 
    snprintf(top1,sizeof(top1),"%s/top",outdirname);
-   sprintf(csort,"sort -T \"%s\" %s %s -o \"%s\" \"%s\"", TempDir, order, sfield, top1, top2);
+   sprintf(csort,"sort -T \"%s\" %s %s -o \"%s\" \"%s\"", tmp, order, sfield, top1, top2);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));