#include "include/conf.h"
#include "include/defs.h"
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
+
#define REPORT_EVERY_X_LINES 5000
#define MAX_OPEN_USER_FILES 10
struct stat logstat;
struct userinfostruct *uinfo;
struct userfilestruct *first_user_file, *ufile, *ufile1, *prev_ufile;
+ static int split=0;
+ static int convert=0;
+ static int output_css=0;
+ int option_index;
+ static struct option long_options[]=
+ {
+ {"convert",no_argument,&convert,1},
+ {"css",no_argument,&output_css,1},
+ {"split",no_argument,&split,1},
+ {0,0,0,0}
+ };
#ifdef HAVE_LOCALE_H
setlocale(LC_TIME,"");
strcpy(TopsitesSortType,"D");
LongUrl=0;
strcpy(FontFace,"Verdana,Tahoma,Arial");
- datetimeby=DATETIME_ELAP;
+ datetimeby=DATETIME_BYTE;
strcpy(CharSet,"ISO-8859-1");
Privacy=0;
strcpy(PrivacyString,"***.***.***.***");
NtlmUserFormat=NTLMUSERFORMAT_DOMAINUSER;
IndexTree=INDEX_TREE_FILE;
strcpy(RealtimeTypes,"GET,PUT,CONNECT");
- strcpy(RealtimeUnauthRec,"show");
+ RealtimeUnauthRec=REALTIME_UNAUTH_REC_SHOW;
RedirectorIgnoreDate=false;
DansguardianIgnoreDate=false;
DataFileUrl=DATAFILEURL_IP;
strcpy(Title,_("Squid User Access Report"));
- while((ch = getopt(argc, argv, "a:b:c:d:e:f:g:u:l:L:o:s:t:w:hijmnprvxyz")) != -1){
+ while((ch = getopt_long_only(argc, argv, "a:b:c:d:e:f:g:u:l:L:o:s:t:w:hijmnprvxyz",long_options,&option_index)) != -1){
switch(ch)
{
+ case 0:
+ break;
case 'a':
strcpy(addr,optarg);
break;
case 'z':
debugz++;
break;
- case ':':
+ /*case ':':
debuga(_("Option -%c require an argument\n"),optopt);
errflg++;
- break;
+ break;*/
case '?':
usage(argv[0]);
exit(EXIT_FAILURE);
+ default:
+ abort();
}
-
}
if (errflg>0) {
NAccessLog++;
}
- if(strcmp(hexclude,"onvert") == 0 && strcmp(site,"plit") != 0) {
- convlog(AccessLog[0], df, dfrom, duntil);
+ if(output_css) {
+ css_content(stdout);
exit(EXIT_SUCCESS);
}
-
- if(strcmp(site,"plit") == 0) {
- splitlog(AccessLog[0], df, dfrom, duntil, hexclude);
+ if(split) {
+ splitlog(AccessLog[0], df, dfrom, duntil, convert);
+ exit(EXIT_SUCCESS);
+ }
+ if(convert) {
+ convlog(AccessLog[0], df, dfrom, duntil);
exit(EXIT_SUCCESS);
}
exit(EXIT_FAILURE);
}
getword_start(&gwarea,data);
- if(strcmp(df,"u") == 0) {
- if (getword_atoll(&imonth,&gwarea,'/')<0){
- debuga(_("Maybe you have a broken date in your %s file\n"),arq);
- exit(EXIT_FAILURE);
- }
- if (getword_atoll(&iday,&gwarea,'/')<0){
- debuga(_("Maybe you have a broken date in your %s file\n"),arq);
- exit(EXIT_FAILURE);
- }
- } else {
- if (getword_atoll(&iday,&gwarea,'/')<0){
- debuga(_("Maybe you have a broken date in your %s file\n"),arq);
- exit(EXIT_FAILURE);
- }
- if (getword_atoll(&imonth,&gwarea,'/')<0){
- debuga(_("Maybe you have a broken date in your %s file\n"),arq);
- exit(EXIT_FAILURE);
- }
+ if (getword_atoll(&iday,&gwarea,'/')<0 || iday<1 || iday>31){
+ debuga(_("Maybe you have a broken date in your %s file\n"),arq);
+ exit(EXIT_FAILURE);
+ }
+ if (getword_atoll(&imonth,&gwarea,'/')<0 || imonth<1 || imonth>12){
+ debuga(_("Maybe you have a broken date in your %s file\n"),arq);
+ exit(EXIT_FAILURE);
}
if (getword_atoll(&iyear,&gwarea,'\0')<0){
debuga(_("Maybe you have a broken date in your %s file\n"),arq);
break;
}
- if(strncmp(df,"u",1)==0)
- strftime(dia, sizeof(dia), "%m/%d/%Y", t);
- else
- strftime(dia, sizeof(dia), "%d/%m/%Y", t);
+ strftime(dia, sizeof(dia), "%d/%m/%Y", t);
snprintf(hora,sizeof(hora),"%02d:%02d:%02d",t->tm_hour,t->tm_min,t->tm_sec);
if(debugm)