|
@@ -51,17 +51,21 @@ int _ttail_search_closest_files(ttail_t* t)
|
51
|
51
|
ret = _ttail_file_minmax(t, i, ftm[i]);
|
52
|
52
|
if(ret < 0)
|
53
|
53
|
{
|
54
|
|
- fprintf(stderr, "Minmax error\n");
|
55
|
54
|
goto _ttail_search_closest_files_loop_err;
|
56
|
55
|
}
|
57
|
56
|
else if (ret == 1)
|
58
|
57
|
{
|
59
|
|
- fprintf(stderr, "Warning : unable to find a valid date \
|
|
58
|
+ fprintf(stderr, "Error : unable to find a valid date \
|
60
|
59
|
in '%s'\n", t->logfile_name[i]);
|
61
|
60
|
free(ftm[i]);
|
62
|
61
|
ftm[i] = NULL;
|
63
|
62
|
fclose(t->logfile[i]);
|
64
|
63
|
t->logfile[i] = NULL;
|
|
64
|
+ if(!ttail_permissive(t))
|
|
65
|
+ {
|
|
66
|
+ ttail_strict_msg();
|
|
67
|
+ goto _ttail_search_closest_files_loop_err;
|
|
68
|
+ }
|
65
|
69
|
continue;
|
66
|
70
|
}
|
67
|
71
|
if(i && prev_found &&
|
|
@@ -312,6 +316,11 @@ running binary search algorithm in '%s'\n", t->logfile_name[*id]);
|
312
|
316
|
}
|
313
|
317
|
cmpres=0;
|
314
|
318
|
ret = _ttail_file_cur_cmp(t, *id, in, &cmpres);
|
|
319
|
+ if(!ret && !ttail_permissive(t))
|
|
320
|
+ {
|
|
321
|
+ ttail_strict_msg();
|
|
322
|
+ return -1;
|
|
323
|
+ }
|
315
|
324
|
if((min && cmpres < 0) || (!min && cmpres > 0))
|
316
|
325
|
{
|
317
|
326
|
break;
|
|
@@ -336,6 +345,10 @@ running binary search algorithm in '%s'\n", t->logfile_name[*id]);
|
336
|
345
|
fprintf(stderr, "No files to scan\n");
|
337
|
346
|
return 0;
|
338
|
347
|
}
|
|
348
|
+ if(*id == t->logfile_sz)
|
|
349
|
+ {
|
|
350
|
+ return 0;
|
|
351
|
+ }
|
339
|
352
|
/* the answer is somewhere in *id file */
|
340
|
353
|
*off = _ttail_file_search_from_end(t, *id, in);
|
341
|
354
|
return 0;
|
|
@@ -606,6 +619,7 @@ inline int _ttail_file_minmax(ttail_t* t, size_t id, struct tm tm[2])
|
606
|
619
|
fp = t->logfile[id];
|
607
|
620
|
if(!fp)
|
608
|
621
|
{
|
|
622
|
+ fprintf(stderr, "File pointer is null !\n");
|
609
|
623
|
return 1;
|
610
|
624
|
}
|
611
|
625
|
if(fseek(fp, 0, SEEK_SET) < 0)
|
|
@@ -623,6 +637,22 @@ inline int _ttail_file_minmax(ttail_t* t, size_t id, struct tm tm[2])
|
623
|
637
|
{
|
624
|
638
|
break;
|
625
|
639
|
}
|
|
640
|
+ if(!ttail_permissive(t))
|
|
641
|
+ {
|
|
642
|
+ if(t->verbose <= 0)
|
|
643
|
+ {
|
|
644
|
+ fprintf(stderr,
|
|
645
|
+ "Unable to find a date in logline\n");
|
|
646
|
+ }
|
|
647
|
+ else
|
|
648
|
+ {
|
|
649
|
+ fprintf(stderr,
|
|
650
|
+ "Unable to find a date in '%s'\n",
|
|
651
|
+ ttail_file_getline_buf(t));
|
|
652
|
+ }
|
|
653
|
+ ttail_strict_msg();
|
|
654
|
+ return -1;
|
|
655
|
+ }
|
626
|
656
|
}
|
627
|
657
|
if(fseek(fp, -1, SEEK_END) < 0)
|
628
|
658
|
{
|
|
@@ -633,6 +663,8 @@ inline int _ttail_file_minmax(ttail_t* t, size_t id, struct tm tm[2])
|
633
|
663
|
{
|
634
|
664
|
if((cur = _ttail_file_start_line(t, id)) < 0)
|
635
|
665
|
{
|
|
666
|
+ fprintf(stderr, "Error will searching line starts in\
|
|
667
|
+%s\n", t->logfile_name[id]);
|
636
|
668
|
return -1;
|
637
|
669
|
}
|
638
|
670
|
if(ttail_file_getline(t, id) < 0)
|
|
@@ -647,6 +679,22 @@ inline int _ttail_file_minmax(ttail_t* t, size_t id, struct tm tm[2])
|
647
|
679
|
{
|
648
|
680
|
return 1;
|
649
|
681
|
}
|
|
682
|
+ else if(!ttail_permissive(t))
|
|
683
|
+ {
|
|
684
|
+ if(t->verbose <= 0)
|
|
685
|
+ {
|
|
686
|
+ fprintf(stderr,
|
|
687
|
+ "Unable to find a date in logline\n");
|
|
688
|
+ }
|
|
689
|
+ else
|
|
690
|
+ {
|
|
691
|
+ fprintf(stderr,
|
|
692
|
+ "Unable to find a date in '%s'\n",
|
|
693
|
+ ttail_file_getline_buf(t));
|
|
694
|
+ }
|
|
695
|
+ ttail_strict_msg();
|
|
696
|
+ return -1;
|
|
697
|
+ }
|
650
|
698
|
if(fseek(fp, cur-1, SEEK_SET) < 0)
|
651
|
699
|
{
|
652
|
700
|
perror("Unable to manipulate fp");
|
|
@@ -872,11 +920,11 @@ inline int _ttail_file_cur_cmp(ttail_t* t, size_t id, const struct tm* tm ,
|
872
|
920
|
return -1;
|
873
|
921
|
}
|
874
|
922
|
ret = ttail_logline2date(t, ttail_file_getline_buf(t), &ctm);
|
875
|
|
- if(ret)
|
|
923
|
+ if(ret < 0)
|
876
|
924
|
{
|
877
|
925
|
return -1;
|
878
|
926
|
}
|
879
|
|
- else if(ret == 1)
|
|
927
|
+ else if(ret > 1)
|
880
|
928
|
{
|
881
|
929
|
return 1;
|
882
|
930
|
}
|