]>
git.ipfire.org Git - thirdparty/sarg.git/blob - sort.c
2 * AUTHOR: Pedro Lineu Orso orso@brturbo.com.br
4 * SARG Squid Analysis Report Generator http://sarg-squid.org
7 * please look at http://sarg.sourceforge.net/donations.php
8 * ---------------------------------------------------------------------
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
26 #include "include/conf.h"
32 struct dirent
*direntp
;
35 char arqou
[MAXLEN
], arqin
[MAXLEN
], wnome
[MAXLEN
], wnome2
[MAXLEN
];
36 char field1
[10]="2,2";
37 char field2
[10]="1,1";
38 char field3
[10]="3,3";
42 if(strstr(ReportType
,"users_sites") == 0) return;
48 while ((direntp
= readdir( dirp
)) != NULL
){
49 if(strstr(direntp
->d_name
,".utmp") == 0)
52 strcpy(wentp
,direntp
->d_name
);
56 getword(wnome2
,wentp
,'.');
59 if(strcmp(wentp
,"utmp") !=0) {
68 strcat(arqin
,direntp
->d_name
);
71 sprintf(msg
,"%s: %s",text
[54],arqou
);
76 strlow(UserSortOrder
);
78 if(strcmp(UserSortField
,"CONNECT") == 0) {
84 if(strcmp(UserSortField
,"SITE") == 0) {
90 if(strcmp(UserSortField
,"TIME") == 0) {
96 if(strcmp(UserSortOrder
,"normal") == 0)
100 sprintf(csort
,"sort -n -T %s %s -k %s -k %s -k %s -o %s %s",TempDir
,order
,field1
,field2
,field3
,arqou
,arqin
);
106 (void)rewinddir( dirp
);
107 (void)closedir( dirp
);
111 void sort_users_log(char *tmp
, int debug
)
115 struct dirent
*direntp
;
121 sprintf(wtmp
,"%s/sarg",tmp
);
123 dirp
= opendir(wtmp
);
124 while ( (direntp
= readdir( dirp
)) != NULL
){
125 if(strstr(direntp
->d_name
,".unsort") == 0)
127 strcpy(wdname
,direntp
->d_name
);
131 getword(wname2
,wdname
,'.');
134 if(strcmp(wdname
,"unsort") !=0) {
139 if(strcmp(direntp
->d_name
,"download.unsort") == 0)
140 sprintf(csort
,"sort -T %s -k 3,3 -k 1,1 -k 2,2 -k 5,5 -o %s/%s.log %s/%s.unsort",
141 tmp
, wtmp
, user
, wtmp
, user
);
143 sprintf(csort
,"sort -T %s -k 5,5 -k 1,1 -k 2,2 -o %s/%s.log %s/%s.unsort",
144 tmp
, wtmp
, user
, wtmp
, user
);
146 sprintf(wdname
,"%s/%s.unsort",wtmp
,user
);
151 (void)rewinddir( dirp
);
152 (void)closedir( dirp
);