simple_stroul

unsigned long simple_stroul(const char *cp,char **endp,unsigned int base);

解析字符串cp 中 8,10,16 进制数字  ,返回值是解析的数字,endp 指向字符串起始处,base :进制
看看 内核中的函数:proc_scsi_write 就知道了。
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
{
        unsigned long result = 0,value;

        if (!base) {
                base = 10;
                if (*cp == '0') {
                        base = 8;
                        cp++;
                        if ((*cp == 'x') && isxdigit(cp[1])) {
                                cp++;
                                base = 16;
                        }
                }
        }
        while (isxdigit(*cp) &&
               (value = isdigit(*cp) ? *cp-'0' : toupper(*cp)-'A'+10) < base) {
                result = result*base + value;
                cp++;
        }
        if (endp)
                *endp = (char *)cp;
        return result;
}


你可能感兴趣的:(simple_stroul)