예제 #1
0
파일: cli_lib.c 프로젝트: Undrizzle/apps
ULONG  _VerifyAndCvtDwordH (char  * szNum, ULONG  dwLow, ULONG  dwHigh, ULONG  *
pdwValue)
{
    ULONG  dwData;
    char  *pTemp;

    if((szNum == NULL) || (pdwValue == NULL))
    {
        MT_ERRLOG(0);
        return TBS_FAILED;
    }

    pTemp = _btrim(szNum);

    if (!strlen (pTemp) || _isxdecstr (pTemp) != 0)
        return TBS_FAILED;

    //如果范围越界,直接返回失败
    if ((strlen(pTemp) > 10)
     || (*(pTemp+1) != 'x' && (strlen(pTemp) > 8)))
        return TBS_FAILED;

    dwData = (ULONG ) _strtol (pTemp, 16);

    if ((dwData < dwLow) || (dwData > dwHigh))
         return TBS_FAILED;
    *pdwValue = dwData;

    return TBS_SUCCESS;
}
예제 #2
0
int main(int argc, char *argv[])
{
	char str[1024];
	int i;

	for (i = 0; i < 10; i++)
	{
		sprintf(str, "this is test #%d\r\n", i);
		Cconws(str);
	}

	for (i = 0; i < 10; i++)
	{
		sprintf(str, "this is test #%f\r\n", (float) i);
		Cconws(str);
	}

	sprintf(str, "This %s %d complex %s%s", "is", 1, "test", "\r\n");
	Cconws(str);
	printf("little test: %x, %d, %f\r\n", 0xff, 12345, 3.1415926);
	
	char *endp;
	#define	_strtol(v) do{ printf("strtol(\"" v "\") => %x", strtol(v,&endp,0)); printf(*endp ? " Rest:%s\n\r":"\n\r", endp); } while(0)
	#define	_strtoul(v) do{ printf("strtoul(\"" v "\") => %x", strtoul(v,&endp,0)); printf(*endp ? " Rest:%s\n\r":"\n\r", endp); } while(0)
	_strtol("0x5050");
	_strtol("0b1010");
	_strtol("077");
	_strtol("-0x5050");
	_strtol("0xDEADBEEF");
	_strtol("10kg");

	_strtoul("0x5050");
	_strtoul("0b1010");
	_strtoul("077");
	_strtoul("-0x5050");
	_strtoul("0xDEADBEEF");
	_strtoul("10kg");
	
	
	Cconws("press a key to return to desktop\r\n");
	Cconin();
}
예제 #3
0
파일: wrappers.c 프로젝트: emlyn/chdk
long strtol(const char *nptr, char **endptr, int base) {
    return _strtol(nptr, endptr, base);
}