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

67 lines
2.3 KiB

/*
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
* FilePath: strto.h
* Date: 2022-02-10 14:53:42
* LastEditTime: 2022-02-18 09:25:08
* Description:  This files is for definition of common string function not include in standard c library
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
* 1.0 zhugengyu 2021/10/06 first release
*/
#ifndef LIB_LIBC_STRTO_H
#define LIB_LIBC_STRTO_H
#ifdef __cplusplus
extern "C"
{
#endif
#include "ftypes.h"
/**
* strict_strtoul - convert a string to an unsigned long strictly
* @param cp The string to be converted
* @param base The number base to use
* @param res The converted result value
* @return 0 if conversion is successful and *res is set to the converted
* value, otherwise it returns -EINVAL and *res is set to 0.
*
* strict_strtoul converts a string to an unsigned long only if the
* string is really an unsigned long string, any string containing
* any invalid char at the tail will be rejected and -EINVAL is returned,
* only a newline char at the tail is acceptible because people generally
* change a module parameter in the following way:
*
* echo 1024 > /sys/module/e1000/parameters/copybreak
*
* echo will append a newline to the tail.
*
* simple_strtoul just ignores the successive invalid characters and
* return the converted value of prefix part of the string.
*
* Copied this function from Linux 2.6.38 commit ID:
* 521cb40b0c44418a4fd36dc633f575813d59a43d
*
*/
int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
unsigned long simple_strtoul(const char *cp, char **endp,
unsigned int base);
#ifdef __cplusplus
}
#endif
#endif // !