aboutsummaryrefslogtreecommitdiff
path: root/c/data.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/data.cpp')
-rw-r--r--c/data.cpp16
1 files changed, 11 insertions, 5 deletions
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 <algorithm>
#include <windows.h>
#include <wininet.h>
#include <libxml/HTMLparser.h>
@@ -93,12 +94,12 @@ bool WcharsFromXmlchars(wchar_t (&dst)[N], XmlCharPtr utf8)
return MultiByteToWideChar(CP_UTF8, 0, src, cchNarrow, dst, cchWide);
}
-void FetchData(FileView<ElvDataA>& fvElv, FileView<DlvDataA>& 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<ElvDataA>& fvElv, FileView<DlvDataA>& fvDlv)
printf("%d nodes\n", cNodes);
for (int i = 0; i < cNodes; i++) {
+ extern FileView<ElvDataA> g_fvElv;
+ extern FileView<DlvDataA> 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<ElvDataA>& fvElv, FileView<DlvDataA>& fvDlv)
if (nodeLink)
WcharsFromXmlchars(d.wiki, xmlGetProp(nodeLink, (const xmlChar*)"href"));
}
+
+ *bDone = true;
}