ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
mkbookimg_names.h
Go to the documentation of this file.
1
20#pragma once
21
22#include <stddef.h>
23#include <stdint.h>
24#include <string.h>
25
34typedef enum : uint32_t {
37
61static inline const char* mkbookimg_basename(const char* path)
62{
63 size_t start = 0U;
64 size_t i = 0U;
65 for (; path[i] != '\0'; ++i) {
66 if (path[i] == '/') {
67 start = i + 1U;
68 }
69 }
70 return &path[start];
71}
72
99static inline bool mkbookimg_dest_name(const char* path, char* out, size_t cap)
100{
101 if ((path == nullptr) || (out == nullptr) || (cap == 0U)) {
102 return false;
103 }
104 const char* base = mkbookimg_basename(path);
105 const size_t n = strlen(base);
106 if ((n == 0U) || (n >= cap)) {
107 return false;
108 }
109 memcpy(out, base, n);
110 out[n] = '\0';
111 return true;
112}
static bool mkbookimg_dest_name(const char *path, char *out, size_t cap)
Derive the on-card destination name for a source book path.
mkbookimg_name_limit_t
Bound on a derived on-card file name.
@ k_mkbookimg_name_cap
Destination-name buffer bytes incl.
static const char * mkbookimg_basename(const char *path)
Return the basename of path: the run after its last '/'.
size_t strlen(const char *s)
Calculate string length.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.