2020-06-23 15:53:23 +08:00
|
|
|
|
#include <stdio.h>
|
2020-06-23 15:27:59 +08:00
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
/* WIN32_LEAN_AND_MEAN?define???WINDOWS.H???
|
2020-06-23 15:53:23 +08:00
|
|
|
|
?????????希??????????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
????????????????? */
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#include <Mmsystem.h>
|
|
|
|
|
#include "iphlpapi.h"
|
|
|
|
|
#pragma comment(lib, "iphlpapi.lib ")
|
|
|
|
|
#include "../systeminc/version.h"
|
|
|
|
|
#include "../systeminc/tool.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _TIME_GET_TIME
|
|
|
|
|
LARGE_INTEGER tickCount;
|
|
|
|
|
LARGE_INTEGER CurrentTick;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Delay(ULONG ulMicroSeconds)
|
|
|
|
|
{
|
|
|
|
|
LARGE_INTEGER timeStop;
|
|
|
|
|
LARGE_INTEGER timeStart;
|
|
|
|
|
LARGE_INTEGER Freq;
|
|
|
|
|
ULONG ulTimeToWait;
|
|
|
|
|
|
|
|
|
|
if (!QueryPerformanceFrequency(&Freq))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ulTimeToWait = Freq.QuadPart * ulMicroSeconds / 1000 / 1000;
|
|
|
|
|
|
|
|
|
|
QueryPerformanceCounter(&timeStart);
|
|
|
|
|
|
|
|
|
|
timeStop = timeStart;
|
|
|
|
|
|
|
|
|
|
while (timeStop.QuadPart - timeStart.QuadPart < ulTimeToWait)
|
|
|
|
|
{
|
|
|
|
|
QueryPerformanceCounter(&timeStop);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL isXP()
|
|
|
|
|
{
|
|
|
|
|
OSVERSIONINFOEX os;
|
|
|
|
|
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
|
|
|
|
if (GetVersionEx((OSVERSIONINFO *)&os))
|
|
|
|
|
{
|
2020-06-23 15:53:23 +08:00
|
|
|
|
//狟醱跦擂唳掛陓洘瓚剿紱釬炵苀靡備
|
|
|
|
|
switch (os.dwMajorVersion){ //瓚剿翋唳掛瘍
|
2020-06-23 15:27:59 +08:00
|
|
|
|
case 4:
|
|
|
|
|
return FALSE;
|
|
|
|
|
case 5:
|
|
|
|
|
return TRUE;
|
|
|
|
|
case 6:
|
|
|
|
|
return FALSE;
|
|
|
|
|
default:
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int TimeGetTime(void)
|
|
|
|
|
{
|
|
|
|
|
#ifdef _TIME_GET_TIME
|
|
|
|
|
static __int64 time;
|
|
|
|
|
QueryPerformanceCounter(&CurrentTick);
|
|
|
|
|
return (unsigned int)(time = CurrentTick.QuadPart / tickCount.QuadPart);
|
|
|
|
|
//return GetTickCount();
|
|
|
|
|
#else
|
|
|
|
|
return GetTickCount();
|
|
|
|
|
//return timeGetTime();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int copyStringUntilDelim(unsigned char *, char delim, int, unsigned char *);
|
|
|
|
|
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ??更???????ㄅ??????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
int wordchk(char **pp)
|
|
|
|
|
{
|
|
|
|
|
char *p = *pp;
|
|
|
|
|
|
|
|
|
|
while (*p != 0)
|
|
|
|
|
{
|
|
|
|
|
switch (*p)
|
|
|
|
|
{
|
|
|
|
|
case '\t':
|
|
|
|
|
p++;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ' ':
|
|
|
|
|
p++;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
*pp = p;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ??更????????希???????????去
|
2020-06-23 15:27:59 +08:00
|
|
|
|
int getword(char **pp, char *q)
|
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
|
|
|
|
char *p = *pp;
|
|
|
|
|
|
|
|
|
|
wordchk(&p);
|
|
|
|
|
|
|
|
|
|
for (i = 0; *p != ' ' && *p != '\t' && *p != '\0'; p++, q++, i++)
|
|
|
|
|
{
|
|
|
|
|
*q = *p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*q = '\0';
|
|
|
|
|
*pp = p;
|
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
// ?????????
|
|
|
|
|
void freadline( char *ptbuf, FILE *fp )
|
|
|
|
|
{
|
|
|
|
|
char buf;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for( i = 0; ; i++ )
|
|
|
|
|
{
|
|
|
|
|
if( feof( fp ) != 0 )
|
|
|
|
|
{
|
|
|
|
|
*ptbuf--;
|
|
|
|
|
*ptbuf = '\0';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fread( &buf, 1, sizeof( unsigned char ), fp );
|
|
|
|
|
if( buf == ' ' )
|
|
|
|
|
{
|
|
|
|
|
*ptbuf++ = buf;
|
|
|
|
|
}else if (buf == '\t'){
|
|
|
|
|
*ptbuf++ = buf;
|
|
|
|
|
}else if (buf != 0x0d && buf != 0x0a){
|
|
|
|
|
*ptbuf++ = buf;
|
|
|
|
|
}else{
|
|
|
|
|
*ptbuf++ = '\0';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while ( feof(fp ) == 0 ){
|
|
|
|
|
fread( &buf ,1 , sizeof(unsigned char) , fp );
|
|
|
|
|
if (buf != 0x0d && buf != 0x0a ){
|
|
|
|
|
fseek( fp, -1, SEEK_CUR);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ?更???可?????更???刺????去??
|
2020-06-23 15:27:59 +08:00
|
|
|
|
int strstr2(char **pp, char *q)
|
|
|
|
|
{
|
|
|
|
|
char *p = *pp;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
wordchk(&p);
|
|
|
|
|
|
|
|
|
|
for (i = 1; *p++ == *q++; i++)
|
|
|
|
|
{
|
|
|
|
|
if (*q == 0)
|
|
|
|
|
{
|
|
|
|
|
*pp = p;
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ??更????????希???????π???刺??
|
2020-06-23 15:27:59 +08:00
|
|
|
|
int strint2(char **pp)
|
|
|
|
|
{
|
|
|
|
|
char moji[1024] = "";
|
|
|
|
|
char *p = *pp;
|
|
|
|
|
|
|
|
|
|
getword(&p, moji);
|
|
|
|
|
*pp = p;
|
|
|
|
|
|
|
|
|
|
return atoi(moji);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ??更????????希??????long??π???刺??
|
2020-06-23 15:27:59 +08:00
|
|
|
|
long strlong2(char **pp)
|
|
|
|
|
{
|
|
|
|
|
char moji[1024] = "";
|
|
|
|
|
char *p = *pp;
|
|
|
|
|
|
|
|
|
|
getword(&p, moji);
|
|
|
|
|
*pp = p;
|
|
|
|
|
|
|
|
|
|
return atol(moji);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ??更??Π??????????刺?
|
|
|
|
|
// ??πㄩNULL?? ... ??更????????
|
|
|
|
|
// NULL ... 更???Ψ???
|
2020-06-23 15:27:59 +08:00
|
|
|
|
inline unsigned char *searchDelimPoint(unsigned char *src, unsigned char delim)
|
|
|
|
|
{
|
|
|
|
|
unsigned char *pt = src;
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
if (*pt == '\0')
|
|
|
|
|
return (unsigned char *)0;
|
|
|
|
|
|
|
|
|
|
if (*pt < 0x80)
|
|
|
|
|
{
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// 1bayte更????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
if (*pt == delim)
|
|
|
|
|
{
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ??更???????????????刺?
|
2020-06-23 15:27:59 +08:00
|
|
|
|
pt++;
|
|
|
|
|
return pt;
|
|
|
|
|
}
|
|
|
|
|
pt++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// 2byte更????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
pt++;
|
|
|
|
|
if (*pt == '\0')
|
|
|
|
|
return (unsigned char *)0;
|
|
|
|
|
pt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2020-06-23 15:53:23 +08:00
|
|
|
|
????更???????????????????叉????????更???
|
2020-06-23 15:27:59 +08:00
|
|
|
|
??????????
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
char *src : ???更??
|
2020-06-23 15:27:59 +08:00
|
|
|
|
char delim : ????
|
|
|
|
|
int count : ????????????????
|
2020-06-23 15:53:23 +08:00
|
|
|
|
int maxlen : out ???????更?????
|
|
|
|
|
char *out : ?
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
??π 0ㄩ????????
|
|
|
|
|
1:更??Ψ????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
*/
|
|
|
|
|
int getStringToken(char *src, char delim, int count, int maxlen, char *out)
|
|
|
|
|
{
|
|
|
|
|
int c = 1;
|
|
|
|
|
int i;
|
|
|
|
|
unsigned char *pt;
|
|
|
|
|
|
|
|
|
|
pt = (unsigned char *)src;
|
|
|
|
|
for (i = 0; i < count - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
if (pt == (unsigned char *)0)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
pt = searchDelimPoint(pt, delim);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pt == (unsigned char *)0)
|
|
|
|
|
{
|
|
|
|
|
out[0] = '\0';
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return copyStringUntilDelim(pt, delim, maxlen, (unsigned char *)out);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2020-06-23 15:53:23 +08:00
|
|
|
|
更????更????更?????????????????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
char *src : ??更??
|
2020-06-23 15:27:59 +08:00
|
|
|
|
char delim : ????
|
2020-06-23 15:53:23 +08:00
|
|
|
|
int maxlen : ????????
|
|
|
|
|
char *out : ?
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
??π 0ㄩ????????
|
|
|
|
|
1:更??Ψ????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
*/
|
|
|
|
|
static int copyStringUntilDelim(unsigned char *src, char delim,
|
|
|
|
|
int maxlen, unsigned char *out)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < maxlen; i++)
|
|
|
|
|
{
|
|
|
|
|
if (src[i] < 0x80)
|
|
|
|
|
{
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// 1byte更????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
|
|
|
|
if (src[i] == delim)
|
|
|
|
|
{
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ??更??????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
out[i] = '\0';
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ???更?????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
out[i] = src[i];
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// Ψ更?????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
if (out[i] == '\0')
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// 2byte更????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ???更?????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
out[i] = src[i];
|
|
|
|
|
|
|
|
|
|
i++;
|
2020-06-23 15:53:23 +08:00
|
|
|
|
if (i >= maxlen) // ????????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ???更?????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
out[i] = src[i];
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// Ψ更???????????????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
if (out[i] == '\0')
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out[i] = '\0';
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2020-06-23 15:53:23 +08:00
|
|
|
|
???????intπ??????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
char *src : ???更??
|
|
|
|
|
char delim: ???????更??
|
2020-06-23 15:27:59 +08:00
|
|
|
|
int count :????????? ??????????
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
return value : π
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
int getIntegerToken(char *src, char delim, int count)
|
|
|
|
|
{
|
|
|
|
|
char s[128];
|
|
|
|
|
|
|
|
|
|
getStringToken(src, delim, count, sizeof(s)-1, s);
|
|
|
|
|
|
|
|
|
|
if (s[0] == '\0')
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
return atoi(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
double???????????
|
2020-06-23 15:53:23 +08:00
|
|
|
|
char *src : ???更??
|
|
|
|
|
char delim: ???????更??
|
2020-06-23 15:27:59 +08:00
|
|
|
|
int count :????????? ??????????
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
return value: π
|
2020-06-23 15:27:59 +08:00
|
|
|
|
*/
|
|
|
|
|
double getDoubleToken(char *src, char delim, int count)
|
|
|
|
|
{
|
|
|
|
|
char s[128];
|
|
|
|
|
|
|
|
|
|
getStringToken(src, delim, count, sizeof(s)-1, s);
|
|
|
|
|
|
|
|
|
|
return strtod(s, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2020-06-23 15:53:23 +08:00
|
|
|
|
chop??(UNIX??更??)
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
char *src : ??更??? ????????乖???????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
void chop(char *src)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0;; i++)
|
|
|
|
|
{
|
|
|
|
|
if (src[i] == 0)
|
|
|
|
|
break;
|
|
|
|
|
if (src[i] == '\n' && src[i + 1] == '\0')
|
|
|
|
|
{
|
|
|
|
|
src[i] = '\0';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2020-06-23 15:53:23 +08:00
|
|
|
|
int???????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
int *a : ???????
|
|
|
|
|
int siz : ??????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
int count : ???????????
|
2020-06-23 15:53:23 +08:00
|
|
|
|
?????????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
*/
|
|
|
|
|
void shiftIntArray(int *a, int siz, int count)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < siz - count; i++)
|
|
|
|
|
{
|
|
|
|
|
a[i] = a[i + count];
|
|
|
|
|
}
|
|
|
|
|
for (i = siz - count; i < siz; i++)
|
|
|
|
|
{
|
|
|
|
|
a[i] = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// 62更???int?阪???
|
2020-06-23 15:27:59 +08:00
|
|
|
|
// 0-9,a-z(10-35),A-Z(36-61)
|
|
|
|
|
int a62toi(char *a)
|
|
|
|
|
{
|
|
|
|
|
int ret = 0;
|
|
|
|
|
int fugo = 1;
|
|
|
|
|
|
|
|
|
|
while (*a != NULL)
|
|
|
|
|
{
|
|
|
|
|
ret *= 62;
|
|
|
|
|
if ('0' <= (*a) && (*a) <= '9')
|
|
|
|
|
ret += (*a) - '0';
|
|
|
|
|
else
|
|
|
|
|
if ('a' <= (*a) && (*a) <= 'z')
|
|
|
|
|
ret += (*a) - 'a' + 10;
|
|
|
|
|
else
|
|
|
|
|
if ('A' <= (*a) && (*a) <= 'Z')
|
|
|
|
|
ret += (*a) - 'A' + 36;
|
|
|
|
|
else
|
|
|
|
|
if (*a == '-')
|
|
|
|
|
fugo = -1;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
a++;
|
|
|
|
|
}
|
|
|
|
|
return ret*fugo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2020-06-23 15:53:23 +08:00
|
|
|
|
???????intπ??????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
char *src : ???更??
|
|
|
|
|
char delim: ???????更??
|
2020-06-23 15:27:59 +08:00
|
|
|
|
int count :????????? ??????????
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
return value : π
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
int getInteger62Token(char *src, char delim, int count)
|
|
|
|
|
{
|
|
|
|
|
char s[128];
|
|
|
|
|
|
|
|
|
|
getStringToken(src, delim, count, sizeof(s)-1, s);
|
|
|
|
|
if (s[0] == '\0')
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
return a62toi(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2020-06-23 15:53:23 +08:00
|
|
|
|
更???更??????更???坊????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
char *s1 : 更???
|
|
|
|
|
char *s2 : 更???
|
|
|
|
|
int len : ??坊?更???
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
int strncmpi(char *s1, char *s2, int len)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int c1, c2;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
if (s1[i] == '\0' || s2[i] == '\0')
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
c1 = tolower(s1[i]);
|
|
|
|
|
c2 = tolower(s2[i]);
|
|
|
|
|
|
|
|
|
|
if (c1 != c2)
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RECT intToRect(int left, int top, int right, int bottom)
|
|
|
|
|
{
|
|
|
|
|
RECT rc = { left, top, right, bottom };
|
|
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************
|
2020-06-23 15:53:23 +08:00
|
|
|
|
???????更??????1?兝?更????????
|
|
|
|
|
0?刺??SJIS??
|
2020-06-23 15:27:59 +08:00
|
|
|
|
******************************************************************/
|
|
|
|
|
int isOnlySpaceChars(char *data)
|
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
|
|
|
|
int returnflag = 0;
|
|
|
|
|
|
|
|
|
|
while (data[i] != '\0')
|
|
|
|
|
{
|
|
|
|
|
returnflag = 0;
|
|
|
|
|
if ((unsigned char)data[i] == ' ')
|
|
|
|
|
returnflag = 1;
|
|
|
|
|
if (IsDBCSLeadByte(data[i]))
|
|
|
|
|
{
|
|
|
|
|
if ((unsigned char)data[i] == 0x81
|
|
|
|
|
&& (unsigned char)data[i + 1] == 0x40)
|
|
|
|
|
{
|
|
|
|
|
returnflag = 1;
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
if (returnflag == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return returnflag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************************
|
2020-06-23 15:53:23 +08:00
|
|
|
|
更?????????向???
|
2020-06-23 15:27:59 +08:00
|
|
|
|
buffer: ????
|
2020-06-23 15:53:23 +08:00
|
|
|
|
string: ?向??更??
|
|
|
|
|
whereToinsert: ????向???
|
2020-06-23 15:27:59 +08:00
|
|
|
|
****************************/
|
|
|
|
|
void insertString(char *buffer, char *string, int whereToInsert)
|
|
|
|
|
{
|
|
|
|
|
int stringLength, bufferLength, i;
|
|
|
|
|
|
|
|
|
|
stringLength = strlen(string);
|
|
|
|
|
bufferLength = strlen(buffer);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i <= bufferLength - whereToInsert; i++)
|
|
|
|
|
{
|
|
|
|
|
buffer[bufferLength + stringLength - i] = buffer[bufferLength - i];
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < stringLength; i++)
|
|
|
|
|
{
|
|
|
|
|
buffer[whereToInsert + i] = string[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/****************************
|
2020-06-23 15:53:23 +08:00
|
|
|
|
更????????向???
|
2020-06-23 15:27:59 +08:00
|
|
|
|
buffer: ????
|
2020-06-23 15:53:23 +08:00
|
|
|
|
character: ?向??更??
|
|
|
|
|
whereToinsert: ????向???
|
2020-06-23 15:27:59 +08:00
|
|
|
|
****************************/
|
|
|
|
|
void insertChar(char *buffer, char character, int whereToInsert)
|
|
|
|
|
{
|
|
|
|
|
int bufferLength, i;
|
|
|
|
|
|
|
|
|
|
bufferLength = strlen(buffer);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i <= bufferLength - whereToInsert; i++)
|
|
|
|
|
{
|
|
|
|
|
buffer[bufferLength + 1 - i] = buffer[bufferLength - i];
|
|
|
|
|
}
|
|
|
|
|
buffer[whereToInsert] = character;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
|
??????????????????
|
|
|
|
|
*************************************************************/
|
|
|
|
|
typedef struct tagEscapeChar
|
|
|
|
|
{
|
|
|
|
|
char escapechar;
|
|
|
|
|
char escapedchar;
|
|
|
|
|
} EscapeChar;
|
|
|
|
|
|
|
|
|
|
static EscapeChar escapeChar[] =
|
|
|
|
|
{
|
|
|
|
|
{ '\n', 'n' },
|
|
|
|
|
{ ',', 'c' },
|
|
|
|
|
{ '|', 'z' },
|
|
|
|
|
{ '\\', 'y' },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ?????更??二更????
|
|
|
|
|
// ??πㄩ二更?(?????更?????????更??刺?)
|
2020-06-23 15:27:59 +08:00
|
|
|
|
char makeCharFromEscaped(char c)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(escapeChar) / sizeof(escapeChar[0]); i++)
|
|
|
|
|
{
|
|
|
|
|
if (escapeChar[i].escapedchar == c)
|
|
|
|
|
{
|
|
|
|
|
c = escapeChar[i].escapechar;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------
|
2020-06-23 15:53:23 +08:00
|
|
|
|
* makeEscapeString?????更???????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
* ??
|
2020-06-23 15:53:23 +08:00
|
|
|
|
* src char* ????更????????▔??
|
|
|
|
|
* 刺?π
|
|
|
|
|
* src ?刺??(???向??????????)
|
2020-06-23 15:27:59 +08:00
|
|
|
|
----------------------------------------*/
|
|
|
|
|
char *makeStringFromEscaped(char *src)
|
|
|
|
|
{
|
|
|
|
|
int srclen = strlen(src);
|
|
|
|
|
int searchindex = 0;
|
|
|
|
|
for (int i = 0; i < srclen; i++){
|
|
|
|
|
if (IsDBCSLeadByte(src[i])){
|
|
|
|
|
src[searchindex++] = src[i++];
|
|
|
|
|
src[searchindex++] = src[i];
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if (src[i] == '\\'){
|
|
|
|
|
int j;
|
|
|
|
|
i++;
|
|
|
|
|
for (j = 0; j < sizeof(escapeChar) / sizeof(escapeChar[0]); j++)
|
|
|
|
|
if (escapeChar[j].escapedchar == src[i]){
|
|
|
|
|
src[searchindex++] = escapeChar[j].escapechar;
|
|
|
|
|
goto NEXT;
|
|
|
|
|
}
|
|
|
|
|
src[searchindex++] = src[i];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
src[searchindex++] = src[i];
|
|
|
|
|
}
|
|
|
|
|
NEXT:
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
src[searchindex] = '\0';
|
|
|
|
|
return src;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------
|
|
|
|
|
* ????????
|
|
|
|
|
* ??
|
2020-06-23 15:53:23 +08:00
|
|
|
|
* src char* ????更??
|
|
|
|
|
* dest char* ????????更??
|
2020-06-23 15:27:59 +08:00
|
|
|
|
* sizeofdest int dest ? ???
|
2020-06-23 15:53:23 +08:00
|
|
|
|
* 刺?π
|
|
|
|
|
* dest ?刺??(???向??????????)
|
2020-06-23 15:27:59 +08:00
|
|
|
|
----------------------------------------*/
|
|
|
|
|
char *makeEscapeString(char *src, char *dest, int sizeofdest)
|
|
|
|
|
{
|
|
|
|
|
int srclen = strlen(src);
|
|
|
|
|
int destindex = 0;
|
|
|
|
|
for (int i = 0; i < srclen; i++){
|
|
|
|
|
if (destindex + 1 >= sizeofdest)
|
|
|
|
|
break;
|
|
|
|
|
if (IsDBCSLeadByte(src[i])){
|
|
|
|
|
if (destindex + 2 < sizeofdest){
|
|
|
|
|
dest[destindex++] = src[i++];
|
|
|
|
|
dest[destindex++] = src[i];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
BOOL dirty = FALSE;
|
|
|
|
|
char escapechar = '\0';
|
|
|
|
|
for (int j = 0; j < sizeof(escapeChar) / sizeof(escapeChar[0]); j++)
|
|
|
|
|
if (src[i] == escapeChar[j].escapechar){
|
|
|
|
|
dirty = TRUE;
|
|
|
|
|
escapechar = escapeChar[j].escapedchar;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (dirty == TRUE){
|
|
|
|
|
if (destindex + 2 < sizeofdest){
|
|
|
|
|
dest[destindex++] = '\\';
|
|
|
|
|
dest[destindex++] = escapechar;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
dest[destindex++] = src[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dest[destindex] = '\0';
|
|
|
|
|
return dest;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
|
????????? by Jun
|
|
|
|
|
***************************************************************/
|
|
|
|
|
/*
|
2020-06-23 15:53:23 +08:00
|
|
|
|
char *src ????adress
|
|
|
|
|
int srclen ????src?????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
int keystring ????????????
|
2020-06-23 15:53:23 +08:00
|
|
|
|
char *encoded ????????更????宇??????????
|
|
|
|
|
int *encodedlen ????????更?????????????
|
|
|
|
|
int maxencodedlen ????????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
*/
|
|
|
|
|
void jEncode(char *src, int srclen, int key,
|
|
|
|
|
char *encoded, int *encodedlen, int maxencodedlen)
|
|
|
|
|
{
|
|
|
|
|
char sum = 0;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (srclen + 1 > maxencodedlen)
|
|
|
|
|
{
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ?????????? 1 ????
|
|
|
|
|
// ????????????????Μ????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
*encodedlen = maxencodedlen;
|
|
|
|
|
for (i = 0; i < (*encodedlen); i++)
|
|
|
|
|
{
|
|
|
|
|
encoded[i] = src[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (srclen + 1 <= maxencodedlen)
|
|
|
|
|
{
|
|
|
|
|
// ??????????
|
|
|
|
|
*encodedlen = srclen + 1;
|
|
|
|
|
for (i = 0; i < srclen; i++)
|
|
|
|
|
{
|
|
|
|
|
sum = sum + src[i];
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// !卡??7??????2?????????????劫?
|
2020-06-23 15:27:59 +08:00
|
|
|
|
if (((key % 7) == (i % 5)) || ((key % 2) == (i % 2)))
|
|
|
|
|
{
|
|
|
|
|
src[i] = ~src[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < (*encodedlen); i++)
|
|
|
|
|
{
|
|
|
|
|
if (abs((key%srclen)) > i)
|
|
|
|
|
{
|
|
|
|
|
encoded[i] = src[i] + sum*((i*i) % 3); // ?????????
|
|
|
|
|
}
|
|
|
|
|
else
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// key%srclen??ㄅ?「??????????ㄅ?
|
2020-06-23 15:27:59 +08:00
|
|
|
|
if (abs((key%srclen)) == i)
|
|
|
|
|
{
|
|
|
|
|
encoded[i] = sum;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (abs((key%srclen)) < i)
|
|
|
|
|
{
|
|
|
|
|
encoded[i] = src[i - 1] + sum*((i*i) % 7); // ?????????
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
char *src ?????????
|
2020-06-23 15:53:23 +08:00
|
|
|
|
int srclen ????????????????
|
|
|
|
|
int key ????????可???
|
|
|
|
|
char *decoded ???????更????
|
|
|
|
|
int *decodedlen ???????更?????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
*/
|
|
|
|
|
void jDecode(char *src, int srclen, int key, char *decoded, int *decodedlen)
|
|
|
|
|
{
|
|
|
|
|
char sum;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
*decodedlen = srclen - 1;
|
|
|
|
|
sum = src[abs(key % (*decodedlen))];
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < srclen; i++)
|
|
|
|
|
{
|
|
|
|
|
if (abs((key % (*decodedlen))) > i)
|
|
|
|
|
{
|
|
|
|
|
decoded[i] = src[i] - sum*((i*i) % 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (abs((key % (*decodedlen))) < i)
|
|
|
|
|
{
|
|
|
|
|
decoded[i - 1] = src[i] - sum*((i*i) % 7);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < (*decodedlen); i++)
|
|
|
|
|
{
|
|
|
|
|
if (((key % 7) == (i % 5)) || ((key % 2) == (i % 2)))
|
|
|
|
|
{
|
|
|
|
|
decoded[i] = ~decoded[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool GetMacAddress(char *strMac)
|
|
|
|
|
{
|
|
|
|
|
PIP_ADAPTER_INFO pAdapterInfo;
|
|
|
|
|
DWORD AdapterInfoSize;
|
|
|
|
|
TCHAR szMac[32] = { 0 };
|
|
|
|
|
DWORD Err;
|
|
|
|
|
AdapterInfoSize = 0;
|
|
|
|
|
Err = GetAdaptersInfo(NULL, &AdapterInfoSize);
|
|
|
|
|
if ((Err != 0) && (Err != ERROR_BUFFER_OVERFLOW)){
|
2020-06-23 15:53:23 +08:00
|
|
|
|
//TRACE("鳳腕厙縐陓洘囮啖ㄐ");
|
2020-06-23 15:27:59 +08:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// 煦饜厙縐陓洘囀湔
|
2020-06-23 15:27:59 +08:00
|
|
|
|
pAdapterInfo = (PIP_ADAPTER_INFO)GlobalAlloc(GPTR, AdapterInfoSize);
|
|
|
|
|
if (pAdapterInfo == NULL){
|
2020-06-23 15:53:23 +08:00
|
|
|
|
//TRACE("煦饜厙縐陓洘囀湔囮啖");
|
2020-06-23 15:27:59 +08:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (GetAdaptersInfo(pAdapterInfo, &AdapterInfoSize) != 0){
|
2020-06-23 15:53:23 +08:00
|
|
|
|
//TRACE(_T("鳳腕厙縐陓洘囮啖ㄐ\n"));
|
2020-06-23 15:27:59 +08:00
|
|
|
|
GlobalFree(pAdapterInfo);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
sprintf_s(strMac, 64, "%02X-%02X-%02X-%02X-%02X-%02X",
|
|
|
|
|
pAdapterInfo->Address[0],
|
|
|
|
|
pAdapterInfo->Address[1],
|
|
|
|
|
pAdapterInfo->Address[2],
|
|
|
|
|
pAdapterInfo->Address[3],
|
|
|
|
|
pAdapterInfo->Address[4],
|
|
|
|
|
pAdapterInfo->Address[5]);
|
|
|
|
|
|
|
|
|
|
GlobalFree(pAdapterInfo);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|