sdutil Write DOS Master Boot Record
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m7s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m7s
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
c += string.c
|
||||
c += string.c \
|
||||
strconv.c
|
||||
|
||||
o += string.o
|
||||
o += string.o \
|
||||
strconv.o
|
||||
|
||||
15
libstring/strconv.c
Normal file
15
libstring/strconv.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include <stdint.h>
|
||||
|
||||
uint64_t str_to_uint64 (const char* s) {
|
||||
uint64_t r = 0;
|
||||
|
||||
if (!s)
|
||||
return 0;
|
||||
|
||||
while (*s >= '0' && *s <= '9') {
|
||||
r = r * 10 + (*s - '0');
|
||||
s++;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
12
libstring/strconv.h
Normal file
12
libstring/strconv.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef _LIBSTRING_STRCONV_H
|
||||
#define _LIBSTRING_STRCONV_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define str_to_uint32(s) ((uint32_t)str_to_uint64 ((s)))
|
||||
#define str_to_uint16(s) ((uint16_t)str_to_uint64 ((s)))
|
||||
#define str_to_uint8(s) ((uint8_t)str_to_uint64 ((s)))
|
||||
|
||||
uint64_t str_to_uint64 (const char* s);
|
||||
|
||||
#endif // _LIBSTRING_STRCONV_H
|
||||
Reference in New Issue
Block a user