Implement storedevs, prepare to port littlefs
This commit is contained in:
15
kernel/util/util.c
Normal file
15
kernel/util/util.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include "util.h"
|
||||
|
||||
char *util_get_filename(char *path) {
|
||||
char *lastslash = path;
|
||||
char *p = path;
|
||||
|
||||
while (*p) {
|
||||
if (*p == '/') {
|
||||
lastslash = p + 1;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return lastslash;
|
||||
}
|
||||
|
@ -6,4 +6,34 @@
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define LEN(X) (sizeof(X)/sizeof(X[0]))
|
||||
|
||||
#define LL_APPEND(head, new) \
|
||||
do { \
|
||||
if ((head) != NULL) { \
|
||||
typeof((head)) __tmp; \
|
||||
(new)->next = NULL; \
|
||||
__tmp = (head); \
|
||||
while (__tmp->next != NULL) { \
|
||||
__tmp = __tmp->next; \
|
||||
} \
|
||||
__tmp->next = (new); \
|
||||
} else { \
|
||||
(head) = (new); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define LL_REMOVE(head, ele) \
|
||||
do { \
|
||||
typeof((head)) __cur = (head); \
|
||||
typeof((head)) __prev = NULL; \
|
||||
while (__cur != (ele)) { \
|
||||
__prev = __cur; \
|
||||
__cur = __cur->next; \
|
||||
} \
|
||||
if (__prev != NULL) { \
|
||||
__prev->next = __cur->next; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
char *util_get_filename(char *path);
|
||||
|
||||
#endif // UTIL_UTIL_H_
|
||||
|
Reference in New Issue
Block a user