From 07bde9f8575701bd0db60baf71aca2465361ff64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sun, 21 Aug 2022 02:04:15 +0200 Subject: Reimplement WaitFor. --- c/data.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'c/data.cpp') diff --git a/c/data.cpp b/c/data.cpp index 0e747f1..4bded44 100644 --- a/c/data.cpp +++ b/c/data.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -93,12 +94,12 @@ bool WcharsFromXmlchars(wchar_t (&dst)[N], XmlCharPtr utf8) return MultiByteToWideChar(CP_UTF8, 0, src, cchNarrow, dst, cchWide); } -void FetchData(FileView& fvElv, FileView& fvDlv) +void FetchData(bool* bDone) { LIBXML_TEST_VERSION; - //InternetFile inf{L"https://www.detectiveconanworld.com/wiki/Anime"}; - InternetFile inf{L"file://C:/Users/John/Desktop/dcw.html"}; + InternetFile inf{L"https://www.detectiveconanworld.com/wiki/Anime"}; + //InternetFile inf{L"file://C:/Users/John/Desktop/dcw.html"}; char buf[1024]; HtmlParserCtxtPtr ctxt = htmlCreatePushParserCtxt(nullptr, nullptr, @@ -124,12 +125,15 @@ void FetchData(FileView& fvElv, FileView& fvDlv) printf("%d nodes\n", cNodes); for (int i = 0; i < cNodes; i++) { + extern FileView g_fvElv; + extern FileView g_fvDlv; + const xmlNodePtr node = nodes->nodeTab[i]; if (xmlChildElementCount(node) != 8) throw std::runtime_error("unexpected remote data format"); - ElvDataA& e = fvElv.At(i); - DlvDataA& d = fvDlv.At(i); + ElvDataA& e = g_fvElv.At(i); + DlvDataA& d = g_fvDlv.At(i); /* Get cells. */ const xmlNodePtr nodeEp = xmlFirstElementChild(node); @@ -151,4 +155,6 @@ void FetchData(FileView& fvElv, FileView& fvDlv) if (nodeLink) WcharsFromXmlchars(d.wiki, xmlGetProp(nodeLink, (const xmlChar*)"href")); } + + *bDone = true; } -- cgit v1.2.3