]>
git.ipfire.org Git - thirdparty/sarg.git/blob - decomp.c
2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
6 * please look at http://sarg.sourceforge.net/donations.php
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
9 * ---------------------------------------------------------------------
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 #include "include/conf.h"
28 #include "include/defs.h"
30 void decomp(char *arq
, char *zip
, const char *tmp
)
36 if(access(arq
, R_OK
) != 0) {
37 debuga(_("File not found: %s\n"),arq
);
42 if(arqlen
>3 && strcmp(arq
+arqlen
-3,".gz") == 0) {
43 debuga(_("Decompressing log file: %s > %s/sarg/sarg-file.in (zcat)\n"),arq
,tmp
);
44 if (snprintf(cmd
,sizeof(cmd
),"zcat \"%s\" > \"%s/sarg/sarg-file.in\"",arq
,tmp
)>=sizeof(cmd
)) {
45 debuga(_("decompression command too long for log file %s\n"),arq
);
49 if (!WIFEXITED(cstatus
) || WEXITSTATUS(cstatus
)) {
50 debuga(_("command return status %d\n"),WEXITSTATUS(cstatus
));
51 debuga(_("command: %s\n"),cmd
);
55 sprintf(arq
,"%s/sarg/sarg-file.in",tmp
);
59 if(arqlen
>4 && strcmp(arq
+arqlen
-4,".bz2") == 0) {
60 debuga(_("Decompressing log file: %s > %s/sarg/sarg-file.in (bzcat)\n"),arq
,tmp
);
61 if (snprintf(cmd
,sizeof(cmd
),"bzcat \"%s\" > \"%s/sarg/sarg-file.in\"",arq
,tmp
)>=sizeof(cmd
)) {
62 debuga(_("decompression command too long for log file %s\n"),arq
);
66 if (!WIFEXITED(cstatus
) || WEXITSTATUS(cstatus
)) {
67 debuga(_("command return status %d\n"),WEXITSTATUS(cstatus
));
68 debuga(_("command: %s\n"),cmd
);
72 sprintf(arq
,"%s/sarg/sarg-file.in",tmp
);
76 if(arqlen
>2 && strcmp(arq
+arqlen
-2,".Z") == 0) {
77 debuga(_("Decompressing log file: %s (uncompress)\n"),arq
);
78 if (snprintf(cmd
,sizeof(cmd
),"zcat \"%s\" > \"%s/sarg/sarg-file.in\"",arq
,tmp
)>=sizeof(cmd
)) {
79 debuga(_("decompression command too long for log file %s\n"),arq
);
83 if (!WIFEXITED(cstatus
) || WEXITSTATUS(cstatus
)) {
84 debuga(_("command return status %d\n"),WEXITSTATUS(cstatus
));
85 debuga(_("command: %s\n"),cmd
);
89 sprintf(arq
,"%s/sarg/sarg-file.in",tmp
);
97 void recomp(const char *arq
, const char *zip
)
102 if(access(arq
, R_OK
) != 0) {
103 debuga(_("File not found: %s\n"),arq
);
107 if((strcmp(zip
,"gzip") != 0) &&
108 (strcmp(zip
,"compress") != 0))
111 debuga(_("Compressing log file: %s\n"),arq
);
113 if (snprintf(cmd
,sizeof(cmd
),"%s \"%s\"",zip
,arq
)>=sizeof(cmd
)) {
114 debuga(_("compression command too long for log file %s\n"),arq
);
118 if (!WIFEXITED(cstatus
) || WEXITSTATUS(cstatus
)) {
119 debuga(_("command return status %d\n"),WEXITSTATUS(cstatus
));
120 debuga(_("command: %s\n"),cmd
);