]>
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 FILE *decomp(const char *arq
, bool *pipe
)
35 if(access(arq
, R_OK
) != 0) {
36 debuga(_("File not found: %s\n"),arq
);
41 if(arqlen
>3 && strcmp(arq
+arqlen
-3,".gz") == 0) {
42 debuga(_("Decompressing log file \"%s\" with zcat\n"),arq
);
43 if (snprintf(cmd
,sizeof(cmd
),"zcat \"%s\"",arq
)>=sizeof(cmd
)) {
44 debuga(_("decompression command too long for log file %s\n"),arq
);
48 return(popen(cmd
,"r"));
51 if(arqlen
>4 && strcmp(arq
+arqlen
-4,".bz2") == 0) {
52 debuga(_("Decompressing log file \"%s\" with bzcat\n"),arq
);
53 if (snprintf(cmd
,sizeof(cmd
),"bzcat \"%s\"",arq
)>=sizeof(cmd
)) {
54 debuga(_("decompression command too long for log file %s\n"),arq
);
58 return(popen(cmd
,"r"));
61 if(arqlen
>2 && strcmp(arq
+arqlen
-2,".Z") == 0) {
62 debuga(_("Decompressing log file \"%s\" with zcat\n"),arq
);
63 if (snprintf(cmd
,sizeof(cmd
),"zcat \"%s\"",arq
)>=sizeof(cmd
)) {
64 debuga(_("decompression command too long for log file %s\n"),arq
);
68 return(popen(cmd
,"r"));
72 return(MY_FOPEN(arq
,"r"));