From 09ad66136d11909c0e6e258a8dc953f2d2b46c41 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 28 Apr 2023 13:54:46 +1000 Subject: [PATCH] clang-format --- src/database/tag_processor.cpp | 81 ++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/src/database/tag_processor.cpp b/src/database/tag_processor.cpp index 5752d61b..13a284f6 100644 --- a/src/database/tag_processor.cpp +++ b/src/database/tag_processor.cpp @@ -1,8 +1,8 @@ #include "tag_processor.hpp" +#include #include #include -#include namespace database { @@ -16,36 +16,41 @@ struct Aux { std::string title; }; -static int read(Tagctx *ctx, void *buf, int cnt) { - Aux *aux = reinterpret_cast(ctx->aux); - UINT bytes_read; - if (f_read(&aux->file, buf, cnt, &bytes_read) != FR_OK) { - return -1; - } - return bytes_read; +static int read(Tagctx* ctx, void* buf, int cnt) { + Aux* aux = reinterpret_cast(ctx->aux); + UINT bytes_read; + if (f_read(&aux->file, buf, cnt, &bytes_read) != FR_OK) { + return -1; + } + return bytes_read; } -static int seek(Tagctx *ctx, int offset, int whence) { - Aux *aux = reinterpret_cast(ctx->aux); - FRESULT res; - if (whence == 0) { - // Seek from the start of the file. This is f_lseek's behaviour. - res = f_lseek(&aux->file, offset); - } else if (whence == 1) { - // Seek from current offset. - res = f_lseek(&aux->file, aux->file.fptr + offset); - } else if (whence == 2) { - // Seek from the end of the file - res = f_lseek(&aux->file, aux->info.fsize + offset); - } else { - return -1; - } - return res; +static int seek(Tagctx* ctx, int offset, int whence) { + Aux* aux = reinterpret_cast(ctx->aux); + FRESULT res; + if (whence == 0) { + // Seek from the start of the file. This is f_lseek's behaviour. + res = f_lseek(&aux->file, offset); + } else if (whence == 1) { + // Seek from current offset. + res = f_lseek(&aux->file, aux->file.fptr + offset); + } else if (whence == 2) { + // Seek from the end of the file + res = f_lseek(&aux->file, aux->info.fsize + offset); + } else { + return -1; + } + return res; } -static void -tag(Tagctx *ctx, int t, const char *k, const char *v, int offset, int size, Tagread f) { - Aux *aux = reinterpret_cast(ctx->aux); +static void tag(Tagctx* ctx, + int t, + const char* k, + const char* v, + int offset, + int size, + Tagread f) { + Aux* aux = reinterpret_cast(ctx->aux); if (t == Ttitle) { aux->title = v; } else if (t == Tartist) { @@ -55,30 +60,30 @@ tag(Tagctx *ctx, int t, const char *k, const char *v, int offset, int size, Tagr } } -static void -toc(Tagctx *ctx, int ms, int offset) {} +static void toc(Tagctx* ctx, int ms, int offset) {} -} // namespace libtags +} // namespace libtags static const std::size_t kBufSize = 1024; static const char* kTag = "TAGS"; auto GetInfo(const std::string& path, FileInfo* out) -> bool { libtags::Aux aux; - if (f_stat(path.c_str(), &aux.info) != FR_OK || f_open(&aux.file, path.c_str(), FA_READ) != FR_OK) { + if (f_stat(path.c_str(), &aux.info) != FR_OK || + f_open(&aux.file, path.c_str(), FA_READ) != FR_OK) { ESP_LOGI(kTag, "failed to open file"); return false; } // Fine to have this on the stack; this is only called on the leveldb task. char buf[kBufSize]; Tagctx ctx; - ctx.read = libtags::read; - ctx.seek = libtags::seek; - ctx.tag = libtags::tag; - ctx.toc = libtags::toc; - ctx.aux = &aux; - ctx.buf = buf; - ctx.bufsz = kBufSize; + ctx.read = libtags::read; + ctx.seek = libtags::seek; + ctx.tag = libtags::tag; + ctx.toc = libtags::toc; + ctx.aux = &aux; + ctx.buf = buf; + ctx.bufsz = kBufSize; int res = tagsget(&ctx); f_close(&aux.file);