client.cpp 724 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <time.h>
  2. #include "log.h"
  3. #include "message_file.h"
  4. time_t site_timestamp(const char*time)
  5. {
  6. //秒、分、时、天、周、月、年, 脑残的设计
  7. struct tm t={0};
  8. t.tm_sec=time[0];
  9. t.tm_min=time[1];
  10. t.tm_hour=time[2];
  11. t.tm_mday=time[3];
  12. t.tm_mon=time[5]-1;
  13. t.tm_year=time[6]+100;
  14. return mktime(&t);
  15. }
  16. int main()
  17. {
  18. unsigned char b[2048];
  19. char m[2048];
  20. message_file mf(stdin);
  21. uint64_t time=0;
  22. int len;
  23. while((len=mf.get_line(&time,(char*)b,sizeof(b),m))>0)
  24. {
  25. if(!((b[2]==0x84) && (b[3]==0x3b)))
  26. continue;
  27. int diff=abs(time/1000-site_timestamp((const char*)&b[10]));
  28. if(diff>300)
  29. {
  30. printf("%d:%s\n",diff,m);
  31. }
  32. else
  33. {
  34. // printf ("%d\n",diff);
  35. }
  36. }
  37. return 0;
  38. }