|
@@ -6,8 +6,9 @@
|
|
|
#include <memory.h>
|
|
|
#include <time.h>
|
|
|
#include <stdint.h>
|
|
|
-#include "message_file.h"
|
|
|
|
|
|
+#include "message_file.h"
|
|
|
+#include "zstream.h"
|
|
|
namespace
|
|
|
{
|
|
|
char decode[256];
|
|
@@ -100,19 +101,24 @@ inline const char* now(char*date_str,uint64_t time)
|
|
|
return date_str;
|
|
|
}
|
|
|
|
|
|
-int message_file::put_line(uint64_t time,char*buf,int buflen)
|
|
|
+int message_file::put_line(FILE*fp,uint64_t time,char*buf,int buflen)
|
|
|
{
|
|
|
char b[8192];
|
|
|
|
|
|
- printf("[%s]\n",now(b,time));
|
|
|
+ fprintf(fp,"[%s]\n",now(b,time));
|
|
|
int n=0,t;
|
|
|
for(int i=0;i<buflen;i++)
|
|
|
{
|
|
|
t=(int)(unsigned char)buf[i];
|
|
|
n+=sprintf(&b[n],"%s ",encode[t]);
|
|
|
+
|
|
|
+ if((i+1)%32 == 0)
|
|
|
+ {
|
|
|
+ n+=sprintf(&b[n],"\n");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- printf("%s\n",b);
|
|
|
+ fprintf(fp,"%s\n",b);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
@@ -175,3 +181,43 @@ int message_file::get_line(uint64_t*time,char*buf,int buflen,char*m)
|
|
|
return o-buf;
|
|
|
}
|
|
|
|
|
|
+int message_file::get_card_message(uint32_t card_id,char*b)
|
|
|
+{
|
|
|
+ int len;
|
|
|
+ char buf[2048];
|
|
|
+ uint64_t time=0;
|
|
|
+
|
|
|
+ int ppos=0;
|
|
|
+ while((len=get_line(&time,buf,sizeof(buf)))>0)
|
|
|
+ {
|
|
|
+ zistream is(buf,len-2);
|
|
|
+ uint16_t cmd;
|
|
|
+ is>>skip(2)>>cmd;
|
|
|
+
|
|
|
+ if(cmd!=0x843b && cmd!=0x753b)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ is>>skip(16);
|
|
|
+
|
|
|
+ while(!is.eof())
|
|
|
+ {
|
|
|
+ uint32_t cid;
|
|
|
+ uint32_t gpos=is.pos();
|
|
|
+ is>>skip(1)>>cid;
|
|
|
+
|
|
|
+ if(cid!=card_id) continue;
|
|
|
+
|
|
|
+ if(ppos==0) memcpy(b,buf,ppos=20);
|
|
|
+ memcpy(&b[ppos],&buf[gpos],20);
|
|
|
+ ppos+=20;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ppos==0) continue;
|
|
|
+
|
|
|
+ ppos+=2;
|
|
|
+ }
|
|
|
+
|
|
|
+ return -1;
|
|
|
+}
|
|
|
+
|
|
|
+
|