diff options
author | Viktor Szakats <commit@vsz.me> | 2024-12-20 02:00:22 +0100 |
---|---|---|
committer | Viktor Szakats <commit@vsz.me> | 2024-12-20 17:56:35 +0100 |
commit | 37fb50a858921846a7bbb4428cc4b2bb66e182af (patch) | |
tree | b0581e0407c7e2343e7cfee70b86da2da0504b50 /docs/examples/htmltitle.cpp | |
parent | fa0ccd9f1fbbbd77bf50b26e3ba231ea6c729474 (diff) |
examples/complicated: fix warnings, bump deprecated callback, tidy up
Also: make them C89, add consts.
Closes #15785
Diffstat (limited to 'docs/examples/htmltitle.cpp')
-rw-r--r-- | docs/examples/htmltitle.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/docs/examples/htmltitle.cpp b/docs/examples/htmltitle.cpp index ee3e023a2..f8a463a78 100644 --- a/docs/examples/htmltitle.cpp +++ b/docs/examples/htmltitle.cpp @@ -43,7 +43,7 @@ // Case-insensitive string comparison // -#ifdef _MSC_VER +#ifdef _WIN32 #define COMPARE(a, b) (!_stricmp((a), (b))) #else #define COMPARE(a, b) (!strcasecmp((a), (b))) @@ -71,8 +71,8 @@ static std::string buffer; // libcurl write callback function // -static int writer(char *data, size_t size, size_t nmemb, - std::string *writerData) +static size_t writer(char *data, size_t size, size_t nmemb, + std::string *writerData) { if(writerData == NULL) return 0; @@ -86,7 +86,7 @@ static int writer(char *data, size_t size, size_t nmemb, // libcurl connection initialization // -static bool init(CURL *&conn, char *url) +static bool init(CURL *&conn, const char *url) { CURLcode code; @@ -140,7 +140,7 @@ static void StartElement(void *voidContext, { Context *context = static_cast<Context *>(voidContext); - if(COMPARE(reinterpret_cast<char *>(name), "TITLE")) { + if(COMPARE(reinterpret_cast<const char *>(name), "TITLE")) { context->title = ""; context->addTitle = true; } @@ -156,7 +156,7 @@ static void EndElement(void *voidContext, { Context *context = static_cast<Context *>(voidContext); - if(COMPARE(reinterpret_cast<char *>(name), "TITLE")) + if(COMPARE(reinterpret_cast<const char *>(name), "TITLE")) context->addTitle = false; } @@ -169,7 +169,8 @@ static void handleCharacters(Context *context, int length) { if(context->addTitle) - context->title.append(reinterpret_cast<char *>(chars), length); + context->title.append(reinterpret_cast<const char *>(chars), + (unsigned long)length); } // @@ -230,6 +231,11 @@ static htmlSAXHandler saxHandler = NULL, NULL, cdata, + NULL, + 0, + 0, + 0, + 0, NULL }; @@ -246,7 +252,7 @@ static void parseHtml(const std::string &html, ctxt = htmlCreatePushParserCtxt(&saxHandler, &context, "", 0, "", XML_CHAR_ENCODING_NONE); - htmlParseChunk(ctxt, html.c_str(), html.size(), 0); + htmlParseChunk(ctxt, html.c_str(), (int)html.size(), 0); htmlParseChunk(ctxt, "", 0, 1); htmlFreeParserCtxt(ctxt); |