-/*! \fn void obtdate(const char *dirname, const char *name, char *data)
-Get the date stored in the <tt>sarg-date</tt> file of a directory with the connection data.
-
-\param dirname The directory to look for the connection directory.
-\param name The name of the directory whose <tt>sarg-date</tt> file must be read.
-\param data The buffer to store the content of the file. It must be more than 80
-bytes long.
-*/
-
-
-
-
-
/*! \fn void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second,int dst)
Format a date to display it in the report.
void url_to_file(const char *url,char *file,int filesize);
void strip_latin(char *line);
char *buildtime(long long int elap);
-void obtdate(const char *dirname, const char *name, char *data);
+int obtdate(const char *dirname, const char *name, char *data);
void formatdate(char *date,int date_size,int year,int month,int day,int hour,int minute,int second,int dst);
void computedate(int year,int month,int day,struct tm *t);
int obtuser(const char *dirname, const char *name);
sortlist=NULL;
while ((direntp = readdir( dirp )) != NULL) {
if (strchr(direntp->d_name,'-') == 0) continue;
+ if (obtdate(outdir,direntp->d_name,data)<0) {
+ debuga(_("The directory \"%s%s\" looks like a report directory but doesn't contain a sarg-date file. You should delete it\n"),outdir,direntp->d_name);
+ continue;
+ }
item=malloc(sizeof(*item));
if (!item) {
debuga(_("not enough memory to sort the index\n"));
item->day=atoi(direntp->d_name);
}
item->sortnum=(item->year*16+item->month)*32+item->day;
- obtdate(outdir,direntp->d_name,data);
if (sscanf(data,"%d-%d-%d %d:%d:%d %d",&iyear,&imonth,&iday,&ihour,&iminute,&isecond,&idst)==7) {
formatdate(data,sizeof(data),iyear,imonth,iday,ihour,iminute,isecond,idst);
snprintf(item->creationdate,sizeof(item->creationdate),"%04d%02d%02d%02d%02d%02d",iyear,imonth,iday,ihour,iminute,isecond);
}
-void obtdate(const char *dirname, const char *name, char *data)
+/*!
+Get the date stored in the <tt>sarg-date</tt> file of a directory with the connection data.
+
+\param dirname The directory to look for the connection directory.
+\param name The name of the directory whose <tt>sarg-date</tt> file must be read.
+\param data The buffer to store the content of the file. It must be more than 80
+bytes long.
+
+\retval 0 No error.
+\retval -1 File not found.
+*/
+int obtdate(const char *dirname, const char *name, char *data)
{
FILE *fp_in;
char wdir[MAXLEN];
sprintf(wdir,"%s%s/date",dirname,name);
if ((fp_in = fopen(wdir, "rt")) == 0) {
data[0]='\0';
- return;
+ return(-1);
}
}
fclose(fp_in);
fixendofline(data);
- return;
+ return(0);
}