From ccb7d14a8b1ad6d80308c14a3f0b209d66c3c88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 24 Aug 2022 03:01:10 +0200 Subject: Add FetchScreenwriters. Improve thread communication. --- c/data.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'c/data.h') diff --git a/c/data.h b/c/data.h index 14e8920..bf45511 100644 --- a/c/data.h +++ b/c/data.h @@ -10,8 +10,11 @@ #include "win.h" /* Fetch data from the web. */ -void FetchData(); -void WaitFetchData(bool* bDone) noexcept; +void FetchData(unsigned char* sig); +void FetchScreenwriters(unsigned char* sig); + +/* Wait for thread. */ +void WaitFor(void (*f)(unsigned char*)); /* The structs ending with A are written as-is to disk. As such, they * should be regarded as immutable. If the format needs to be changed @@ -54,7 +57,7 @@ struct CfgA unsigned short cEp = 4096; unsigned short iFocus = 0; unsigned short heightDlv = 0; - wchar_t limitScreenwriter[64] = {0}; + wchar_t limitScreenwriter[64] = {0}; /* TODO: 64 -> 48 */ wchar_t root[260] = {0}; wchar_t glob[64] = {0}; wchar_t url[192] = {0}; @@ -76,6 +79,11 @@ constexpr inline bool HasVersion = true; template struct FileView { + HANDLE hf; + HANDLE hm; + T* view; + size_t c; + static FileView Initialized(const wchar_t* filename, size_t c, size_t cInit = 0) { bool bExisting = GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES; @@ -150,6 +158,9 @@ struct FileView return t; } + T* begin() { return *view; } + T* end() { return view[c-1]; } + inline operator T*() noexcept { return view; @@ -159,11 +170,6 @@ struct FileView { return view; } - - HANDLE hf; - HANDLE hm; - T* view; - size_t c; }; inline int FromWeb(const int iEp, ElvDataA& e, DlvDataA& d) noexcept -- cgit v1.2.3