|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Book-format classification by file extension (long-name aware, #633). More...
#include <stddef.h>#include <stdint.h>#include <string.h>Go to the source code of this file.
Enumerations | |
| enum | sh_book_fmt_t : uint8_t { k_sh_fmt_rabook = 0U , k_sh_fmt_epub = 1U , k_sh_fmt_cbz = 2U , k_sh_fmt_cbr = 3U , k_sh_fmt_cbt = 4U } |
| Book container format behind a shelf entry / the open book. More... | |
Functions | |
| static bool | sh_fmt_is_comic (sh_book_fmt_t fmt) |
True if fmt is a comic-archive container (CBZ, CBR, or CBT). | |
| static char | sh_ascii_lower (char c) |
| Fold one ASCII letter to lower case (non-letters returned unchanged). | |
| static bool | sh_ext_match (const char *name, const char *ext) |
Case-insensitive test that name ends in the extension ext. | |
| static bool | sh_book_classify (const char *name, sh_book_fmt_t *out_fmt) |
| Classify a root file name into a book format; true if it is a book. | |
Book-format classification by file extension (long-name aware, #633).
The shelf scans the FAT root and decides which files are books and in what container format. Since #600 gave ra8_fs VFAT long-name write, the card carries real extensions (.rabook, .epub) rather than the 8.3 truncations (.RBK, .EPB) the tools used to emit, so the classifier matches BOTH: the long forms and, so existing 8.3-named cards still resolve, the legacy short forms. Matching is case-insensitive because FAT hands back 8.3 names upper-cased while long names keep their authored case.
This header is board-free (string logic only), so sh_sd.c and the host classification test share one implementation instead of a copy.
Definition in file sh_classify.h.
| enum sh_book_fmt_t : uint8_t |
Book container format behind a shelf entry / the open book.
Both text formats render through the same screens via the sh_book.c backend: .rabook is the pre-parsed book blob, demand-paged through the chunked reader (baked or on SD); .epub is parsed on-device by epub (SD only). The three comic containers route through sh_comic.c as image-page readers.
Definition at line 37 of file sh_classify.h.
|
inlinestatic |
Fold one ASCII letter to lower case (non-letters returned unchanged).
| [in] | c | Byte to fold. |
c unchanged when it is not A..Z. | char | Case-folded byte. |
c is a single byte. Definition at line 74 of file sh_classify.h.
Referenced by sh_ext_match().
|
inlinestatic |
Classify a root file name into a book format; true if it is a book.
Recognises the long extensions the tools now write (.rabook, .epub) and, so existing 8.3-named cards keep resolving, their legacy 8.3 truncations (.rbk, .epb). Comics already had 3-char extensions, so .cbz / .cbr / .cbt never truncated. Matching is case-insensitive (sh_ext_match).
| [in] | name | NUL-terminated root file name (non-NULL). |
| [out] | out_fmt | Receives the container format when name is a book. |
name names a book this shelf can open. | true | name matched a known book extension; *out_fmt is set. |
| false | name is not a book; *out_fmt is untouched. |
name and out_fmt are non-NULL. name is a single root directory entry name. out_fmt. Definition at line 129 of file sh_classify.h.
References k_sh_fmt_cbr, k_sh_fmt_cbt, k_sh_fmt_cbz, k_sh_fmt_epub, k_sh_fmt_rabook, and sh_ext_match().
Referenced by sh_sd_listdir_cb().
|
inlinestatic |
Case-insensitive test that name ends in the extension ext.
Requires at least one character before ext, so a name that is only the extension (e.g. .epub) is not a book. Folds both sides to lower case, so .EPB matches .epb and Book.EPUB matches .epub.
| [in] | name | NUL-terminated file name (non-NULL). |
| [in] | ext | NUL-terminated extension including its dot, e.g. .rabook. |
name ends in ext with a non-empty stem. | true | name is longer than ext and its tail case-matches ext. |
| false | name is not longer than ext or the tail differs. |
name and ext are non-NULL and NUL-terminated. ext is a file extension leading with .. Definition at line 95 of file sh_classify.h.
References sh_ascii_lower(), and strlen().
Referenced by sh_book_classify().
|
inlinestatic |
True if fmt is a comic-archive container (CBZ, CBR, or CBT).
Both route through sh_comic.c (::comic) rather than the text-book screens, so this predicate is the single dispatch test the shelf/open path branches on.
| [in] | fmt | Container format from a shelf entry / the open book. |
| true | fmt is a comic archive (image-page reader). |
| false | fmt is a text book (rabook / epub). |
fmt is a valid sh_book_fmt_t. Definition at line 59 of file sh_classify.h.
References k_sh_fmt_cbr, k_sh_fmt_cbt, and k_sh_fmt_cbz.
Referenced by sh_book_open(), sh_comic_open(), and sh_select_book().