char tbytes[20];
char media[20];
char ftime[128];
- char day[16], mon[16], year[6], hour[10];
+ char day[16], mon[16], year[40], hour[10];
char h[3], m[3], s[3];
int cstatus;
char y1[5], y2[5];
char d1[3], d2[3];
char m1[4], m2[4];
+ int iyear, imonth, iday, ihour, iminute, isecond;
if(LastLog[0] != '\0') mklastlog(outdir);
obtdate(outdir,direntp->d_name,data);
obtuser(outdir,direntp->d_name,tuser);
obttotal(outdir,direntp->d_name,tbytes,tuser,media);
- strcpy(html,data);
- if (getword_multisep(mon,sizeof(mon),html,' ')<0) {
- printf("SARG: Maybe you have a broken week day in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
- exit(1);
- }
- if (getword_multisep(mon,sizeof(mon),html,' ')<0) {
- printf("SARG: Maybe you have a broken month in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
- exit(1);
- }
- if (getword_multisep(day,sizeof(day),html,' ')<0) {
- printf("SARG: Maybe you have a broken day in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
- exit(1);
- }
- if (getword_multisep(hour,sizeof(hour),html,' ')<0) {
- printf("SARG: Maybe you have a broken time in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
- exit(1);
- }
- if (getword_multisep(year,sizeof(year),html,' ')<0) {
- printf("SARG: Maybe you have a broken year in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
- exit(1);
- }
- strcpy(html,hour);
- if (getword_multisep(h,sizeof(h),html,':')<0) {
- printf("SARG: Maybe you have a broken hour in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
- exit(1);
- }
- if (getword_multisep(m,sizeof(m),html,':')<0) {
- printf("SARG: Maybe you have a broken minute in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
- exit(1);
- }
- if (getword_multisep(s,sizeof(s),html,0)<0) {
- printf("SARG: Maybe you have a broken second in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
- exit(1);
+ if (sscanf(data,"%d-%d-%d %d:%d:%d",&iyear,&imonth,&iday,&ihour,&iminute,&isecond)==6) {
+ fprintf(fp_tmp,"%04d%02d%02d%02d%02d%02d;%s;%s;%s;%s;%s;%s\n",iyear,imonth,iday,ihour,iminute,isecond, direntp->d_name, data, tuser, tbytes, media,newname);
+ } else {
+ /*
+ Old code to parse a date stored by sarg before 2.2.6.1 in the sarg-date file of each report directory.
+ */
+ strcpy(html,data);
+ if (getword_multisep(mon,sizeof(mon),html,' ')<0) {
+ printf("SARG: Maybe you have a broken week day in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ exit(1);
+ }
+ if (getword_multisep(mon,sizeof(mon),html,' ')<0) {
+ printf("SARG: Maybe you have a broken month in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ exit(1);
+ }
+ if (getword_multisep(day,sizeof(day),html,' ')<0) {
+ printf("SARG: Maybe you have a broken day in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ exit(1);
+ }
+ if (getword_multisep(hour,sizeof(hour),html,' ')<0) {
+ printf("SARG: Maybe you have a broken time in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ exit(1);
+ }
+ do {
+ if (getword_multisep(year,sizeof(year),html,' ')<0) {
+ printf("SARG: Maybe you have a broken year in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ exit(1);
+ }
+ } while (year[0] && !isdigit(year[0])); //skip time zone information with spaces until the year is found
+ strcpy(html,hour);
+ if (getword_multisep(h,sizeof(h),html,':')<0) {
+ printf("SARG: Maybe you have a broken hour in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ exit(1);
+ }
+ if (getword_multisep(m,sizeof(m),html,':')<0) {
+ printf("SARG: Maybe you have a broken minute in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ exit(1);
+ }
+ if (getword_multisep(s,sizeof(s),html,0)<0) {
+ printf("SARG: Maybe you have a broken second in your %s%s/sarg-date file.\n",outdir,direntp->d_name);
+ exit(1);
+ }
+ buildymd(day,mon,year,ftime);
+ fprintf(fp_tmp,"%s%s%s%s;%s;%s;%s;%s;%s;%s\n",ftime, h, m, s, direntp->d_name, data, tuser, tbytes, media,newname);
}
- buildymd(day,mon,year,ftime);
- fprintf(fp_tmp,"%s%s%s%s;%s;%s;%s;%s;%s;%s\n",ftime, h, m, s, direntp->d_name, data, tuser, tbytes, media,newname);
continue;
}
}