You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
773 B
C++

#include "GeneralModule.h"
#include "GlobalDef.h"
int isnumer(char cChar)
{
if ((cChar >= 0x30) && (cChar <= 0x39))
{
return 0;
}
else
{
return -1;
}
}
int isIpAddr(char * ptr)
{
int iLen;
iLen = strlen(ptr);
if ((iLen<MIN_IPLEN) || (iLen>MAX_IPLEN))
{
return -1;
}
for (int i = 0; i<iLen; i++)
{
if ((0 == isnumer(ptr[i])) || ('.' == ptr[i]))
{
continue;
}
else
{
return -2;
}
}
return 0;
}
int isIpAddrAndPort(char * ptr)
{
int iLen;
if (!ptr)
{
return -1;
}
iLen = strlen(ptr);
if ((iLen<MIN_IPPORTLEN) || (iLen>MAX_IPPORTLEN))
{
return -2;
}
for (int i = 0; i<iLen; i++)
{
if ((0 == isnumer(ptr[i])) || ('.' == ptr[i]) || (':' == ptr[i]))
{
continue;
}
else
{
return -3;
}
}
return 0;
}