~ubuntu-branches/ubuntu/natty/sarg/natty

« back to all changes in this revision

Viewing changes to totger.c

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2010-01-11 15:07:10 UTC
  • mfrom: (1.1.8 upstream) (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100111150710-mgvjhyjs13mrg0tb
Tags: 2.2.6-1
* New upstream release
  - Fixes issues in getword loop detection (Closes: #522284)
  - Removed patches integrated upstream
  - Fixes usertab parsing for IPv6 address (Closes: #504749)
  - Fixes typo in dansguardian_log.c (Closes: #540438)
  - Fixes error parsing squidGuard logs (Closes: #486895)

* debian/sarg-reports.conf
  - Fixed typo (Closes: #517356)

* debian/control
  - Added Build-Dep options on libgd2-xpm-dev (Closes: #540121)
  - Added Dependency on ${misc:Depends}
  - Added dependency on dpatch
  - Bumped Standard-Version to 3.8.3

* debian/compat
  - Upgraded debhelper compatibility to level 6

* debian/rules
  - Removed unnecessary upgrade of autoconf files
  - Added dpatch rules
  - Fixed configuration options and paths

* debian/patches/01_makefile-install-path
  - Fixed build-time installation paths

* debian/patches/02_config-file-references
  - Fixed references to configuration files

* debian/squid.conf
  - Sinced with upstream changes

* debian/{postrm,preinst,sarg.conf,sarg-reports,rules,dirs,sarg-reports.conf}
  - Moved configuration files to /etc/sarg and data directory to /var/lib/sarg
    (Closes: #553554, #502273)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * AUTHOR: Pedro Lineu Orso                         pedro.orso@gmail.com
3
 
 *                                                            1998, 2008
 
3
 *                                                            1998, 2009
4
4
 * SARG Squid Analysis Report Generator      http://sarg.sourceforge.net
5
5
 *
6
6
 * SARG donations:
24
24
 */
25
25
 
26
26
#include "include/conf.h"
 
27
#include "include/defs.h"
27
28
 
28
29
int totalger(const char *dirname, int debug, const char *outdir)
29
 
 
30
30
{
31
 
 
32
 
 
33
31
   FILE *fp_in, *fp_ou;
34
32
   long long int tnacc=0;
35
33
   long long int tnbytes=0;
36
34
   long long int telap=0;
37
35
   long long int tincache=0, toucache=0;
38
 
   char wger[MAXLEN], user[MAXLEN], nacc[16], nbytes[16], url[1024];
39
 
   char ip[MAXLEN], hora[9], data[11], elap[16];
40
 
   char incac[16], oucac[16];
 
36
   char wger[MAXLEN], user[MAXLEN], nacc[16], nbytes[16], url[MAXLEN];
 
37
   char ip[MAXLEN], hora[9], data[15], elap[16];
 
38
   char incac[30], oucac[30];
 
39
   char warea[MAXLEN];
41
40
 
42
41
   strcpy(wger,dirname);
43
42
   strcat(wger,"/sarg-general");
47
46
      exit(1);
48
47
   }
49
48
 
50
 
   fscanf(fp_in,"%s%s%s%s%s%s%s%s%s%s",user,nacc,nbytes,url,ip,hora,data,elap,incac,oucac);
51
 
 
52
 
   while(!feof(fp_in))
 
49
   while(fgets(warea,sizeof(warea),fp_in))
53
50
   {
 
51
      //printf("%s\n",warea);
 
52
      if (getword(user,sizeof(user),warea,' ')<0) {
 
53
         printf("SARG: Maybe you have a broken user in your %s file.\n",wger);
 
54
         exit(1);
 
55
      }
 
56
      if (getword(nacc,sizeof(nacc),warea,' ')<0) {
 
57
         printf("SARG: Maybe you have a broken number of access in your %s file.\n",wger);
 
58
         exit(1);
 
59
      }
 
60
      if (getword(nbytes,sizeof(nbytes),warea,' ')<0) {
 
61
         printf("SARG: Maybe you have a broken number of bytes in your %s file.\n",wger);
 
62
         exit(1);
 
63
      }
 
64
      if (getword(url,sizeof(url),warea,' ')<0) {
 
65
         printf("SARG: Maybe you have a broken url in your %s file.\n",wger);
 
66
         exit(1);
 
67
      }
 
68
      if (getword(ip,sizeof(ip),warea,' ')<0) {
 
69
         printf("SARG: Maybe you have a broken source IP address in your %s file.\n",wger);
 
70
         exit(1);
 
71
      }
 
72
      if (getword(hora,sizeof(hora),warea,' ')<0) {
 
73
         printf("SARG: Maybe you have a broken time in your %s file.\n",wger);
 
74
         exit(1);
 
75
      }
 
76
      if (getword(data,sizeof(data),warea,' ')<0) {
 
77
         printf("SARG: Maybe you have a broken date in your %s file.\n",wger);
 
78
         exit(1);
 
79
      }
 
80
      if (getword(elap,sizeof(elap),warea,' ')<0) {
 
81
         printf("SARG: Maybe you have a broken elapsed time in your %s file.\n",wger);
 
82
         exit(1);
 
83
      }
 
84
      if (getword(incac,sizeof(incac),warea,' ')<0) {
 
85
         printf("SARG: Maybe you have a broken in cache column in your %s file.\n",wger);
 
86
         exit(1);
 
87
      }
 
88
      if (getword(oucac,sizeof(oucac),warea,0)<0) {
 
89
         printf("SARG: Maybe you have a broken not in cache column in your %s file.\n",wger);
 
90
         exit(1);
 
91
      }
54
92
      tnacc+=my_atoll(nacc);
55
93
      tnbytes+=my_atoll(nbytes);
56
94
      telap+=my_atoll(elap);
57
95
      tincache+=my_atoll(incac);
58
96
      toucache+=my_atoll(oucac);
59
 
 
60
 
      fscanf(fp_in,"%s%s%s%s%s%s%s%s%s%s",user,nacc,nbytes,url,ip,hora,data,elap,incac,oucac);
61
97
   }
62
98
 
63
99
   fclose(fp_in);
77
113
   my_lltoa(telap,val3,15);
78
114
   my_lltoa(tincache,val4,15);
79
115
   my_lltoa(toucache,val5,15);
80
 
   sprintf(url,"TOTAL %s %s %s %s %s\n",val1,val2,val3,val4,val5);
81
 
   fputs(url,fp_ou);
 
116
   fprintf(fp_ou,"TOTAL %s %s %s %s %s\n",val1,val2,val3,val4,val5);
82
117
   fclose(fp_ou);
83
118
 
84
119
   return (0);