diff --git a/DefineHeader.h b/DefineHeader.h
index cea0f02..cebc639 100644
--- a/DefineHeader.h
+++ b/DefineHeader.h
@@ -21,12 +21,22 @@
#include <sstream>
#include <algorithm>
using namespace std;
-typedef unsigned char BYTE, *PBYTE;
-typedef unsigned char UCHAR;
-typedef unsigned short WCHAR;
-typedef unsigned short USHORT;
-typedef unsigned int UINT;
-typedef unsigned int DWORD;
+// typedef unsigned char BYTE, *PBYTE;
+// typedef unsigned char UCHAR;
+// typedef unsigned short WCHAR;
+// typedef unsigned short USHORT;
+// typedef unsigned int UINT;
+// typedef unsigned int DWORD;
+
+#define PBYTE unsigned char *
+#define BYTE unsigned char
+#define UCHAR unsigned char
+#define WCHAR unsigned short
+#define USHORT unsigned short
+#define UINT unsigned int
+#define DWORD unsigned int
+
+
#define ALIGN(x, a) __ALIGN_MASK((x), (a) - 1)
#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
#define RK28_SEC2_RESERVED_LEN 473
diff --git a/RKLog.cpp b/RKLog.cpp
index 37dc62b..c24bbfe 100644
--- a/RKLog.cpp
+++ b/RKLog.cpp
@@ -74,8 +74,11 @@ bool CRKLog::Write(string text)
char szDateTime[100];
string strName;
FILE *file=NULL;
- time(&now);
- localtime_r(&now, &timeNow);
+ //time(&now);
+ //localtime_r(&now, &timeNow);
+
+ now =time(0);
+ localtime_s(&timeNow,&now);
sprintf(szDateTime, "%04d-%02d-%02d.txt", timeNow.tm_year + 1900, timeNow.tm_mon + 1, timeNow.tm_mday);
strName = m_path + m_name+szDateTime;
diff --git a/crc.cpp b/crc.cpp
index 8bd2647..9dd6ab8 100644
--- a/crc.cpp
+++ b/crc.cpp
@@ -188,15 +188,52 @@ unsigned int crc32_le(unsigned int crc, unsigned char *p, unsigned int len)
}
return nAccum;
*/
+#if 0
+
+ unsigned long long addr =(unsigned long long) p;
+ unsigned int *tab = crc32table_le;
+ crc = crc ^ 0xFFFFFFFF;
+ if(( (addr & 3) && len)){
+ do {
+ unsigned char *p = (unsigned char *)addr;
+ DO_CRC(*p++);
+ addr = (unsigned long long)p;
+ } while ((--len) && (addr &3 ));
+ }
+ if((len >= 4)){
+ unsigned int save_len = len & 3;
+ len = len >> 2;
+ addr-=4;
+ do {
+ addr +=4;
+ crc ^= *((unsigned int *)addr);
+ DO_CRC(0);
+ DO_CRC(0);
+ DO_CRC(0);
+ DO_CRC(0);
+ } while (--len);
+ addr+=4;
+ len = save_len;
+ }
+ if(len){
+ do {
+ unsigned char *p = (unsigned char *)addr;
+ DO_CRC(*p++);
+ addr = (unsigned long long)p;
+ } while (--len);
+ }
+ crc = crc ^ 0xFFFFFFFF;
+ return crc;
+#else
unsigned int *b =(unsigned int *)p;
unsigned int *tab = crc32table_le;
crc = crc ^ 0xFFFFFFFF;
- if((((long)b)&3 && len)){
+ if(( (((unsigned long long)b) & 3) && len)){
do {
unsigned char *p = (unsigned char *)b;
DO_CRC(*p++);
b = (unsigned int *)p;
- } while ((--len) && ((long)b)&3 );
+ } while ((--len) && ((unsigned long long)b)&3 );
}
if((len >= 4)){
unsigned int save_len = len & 3;
@@ -221,7 +258,7 @@ unsigned int crc32_le(unsigned int crc, unsigned char *p, unsigned int len)
}
crc = crc ^ 0xFFFFFFFF;
return crc;
-
+#endif
}
#define CRC16_CCITT 0x1021 //CRC operator
diff --git a/main.cpp b/main.cpp
index 72bd94b..0e864ca 100644
--- a/main.cpp
+++ b/main.cpp
@@ -3292,7 +3292,7 @@ bool handle_command(int argc, char* argv[], CRKScan *pScan)
return bSuccess;
}
-
+#include <unistd.h>
int main(int argc, char* argv[])
{
CRKScan *pScan = NULL;
@@ -3303,10 +3303,11 @@ int main(int argc, char* argv[])
struct stat statBuf;
g_ConfigItemVec.clear();
- sprintf(szProgramProcPath, "/proc/%d/exe", getpid());
- if (readlink(szProgramProcPath, szProgramDir, 256) == -1)
- strcpy(szProgramDir, ".");
- else {
+ // sprintf(szProgramProcPath, "/proc/%d/exe", getpid());
+ // if (readlink(szProgramProcPath, szProgramDir, 256) == -1)
+ // strcpy(szProgramDir, ".");
+ // else
+ {
char *pSlash;
pSlash = strrchr(szProgramDir, '/');
if (pSlash)
@@ -3317,7 +3318,7 @@ int main(int argc, char* argv[])
strConfigFile = szProgramDir;
strConfigFile += "/config.ini";
if (opendir(strLogDir.c_str()) == NULL)
- mkdir(strLogDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH);
+ mkdir(strLogDir.c_str());
g_pLogObject = new CRKLog(strLogDir.c_str(), "log",true);
if(stat(strConfigFile.c_str(), &statBuf) < 0) {
离线
好像不对,在这里失败了pComm = new CRKUsbComm(dev, g_pLogObject, bRet);
离线
在Linux下运行需要sudo 权限,否则同样的异常错误,具体原因不知道,建议在linux使用。
离线
群里某位大神写的xrock很好使
离线