diff options
Diffstat (limited to 'src/commonlib')
-rw-r--r-- | src/commonlib/Makefile.mk | 4 | ||||
-rw-r--r-- | src/commonlib/bsd/include/commonlib/bsd/string.h | 10 | ||||
-rw-r--r-- | src/commonlib/bsd/string.c | 15 |
3 files changed, 29 insertions, 0 deletions
diff --git a/src/commonlib/Makefile.mk b/src/commonlib/Makefile.mk index 30aaddf2cc..00f3629c1e 100644 --- a/src/commonlib/Makefile.mk +++ b/src/commonlib/Makefile.mk @@ -65,3 +65,7 @@ decompressor-y += bsd/gcd.c all-y += bsd/gcd.c all-y += bsd/ipchksum.c + +decompressor-y += bsd/string.c +smm-y += bsd/string.c +all-y += bsd/string.c diff --git a/src/commonlib/bsd/include/commonlib/bsd/string.h b/src/commonlib/bsd/include/commonlib/bsd/string.h new file mode 100644 index 0000000000..bbd4754800 --- /dev/null +++ b/src/commonlib/bsd/include/commonlib/bsd/string.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef _COMMONLIB_BSD_STRING_H_ +#define _COMMONLIB_BSD_STRING_H_ + +#include <stdint.h> + +unsigned int skip_atoi(char **ptr); + +#endif /* _COMMONLIB_BSD_STRING_H_ */ diff --git a/src/commonlib/bsd/string.c b/src/commonlib/bsd/string.c new file mode 100644 index 0000000000..3286d41b1c --- /dev/null +++ b/src/commonlib/bsd/string.c @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#include <commonlib/bsd/string.h> +#include <ctype.h> + +unsigned int skip_atoi(char **ptr) +{ + unsigned int result = 0; + char *str; + + for (str = *ptr; isdigit(str[0]); str++) + result = result * 10 + (str[0] - '0'); + *ptr = str; + return result; +} |