Skip to content

Commit

Permalink
WebAPI: Use c_str for printf logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
dufernst committed Jan 21, 2023
1 parent 9b19ee2 commit 666a98e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/tools/web_api/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,10 @@ void printReqData(const httplib::Request& req)
{
printf("Did get the following parameters:");
for (const auto& param: req.params)
printf("%s:%s", param.first, param.second);
printf("%s:%s", param.first.c_str(), param.second.c_str());
printf("Did get the following headers:");
for (const auto& header: req.headers)
printf("%s:%s", header.first, header.second);
printf("%s:%s", header.first.c_str(), header.second.c_str());
}

void handleVoteCallback(const VoteWebsiteData& voteWebsite, const httplib::Request& req, const unsigned char* k)
Expand All @@ -637,15 +637,15 @@ void handleVoteCallback(const VoteWebsiteData& voteWebsite, const httplib::Reque
{
if (voteWebsite.callbackHostname == "")
{
printf("Vote callback for website: %s, came in from unexpected IP: %s", voteWebsite.name, req.remote_addr);
printf("Vote callback for website: %s, came in from unexpected IP: %s", voteWebsite.name.c_str(), req.remote_addr.c_str());
return;
}

std::vector<std::string> foundIps;
httplib::hosted_at(voteWebsite.callbackHostname, foundIps);
if (std::find(foundIps.begin(), foundIps.end(), req.remote_addr) == foundIps.end())
{
printf("Vote callback for website: %s, came in from unexpected IP: %s", voteWebsite.name, req.remote_addr);
printf("Vote callback for website: %s, came in from unexpected IP: %s", voteWebsite.name.c_str(), req.remote_addr.c_str());
return;
}
}
Expand All @@ -654,7 +654,7 @@ void handleVoteCallback(const VoteWebsiteData& voteWebsite, const httplib::Reque
{
if (!req.has_param(voteWebsite.checkKeyName) && !req.has_header(voteWebsite.checkKeyName))
{
printf("Vote callback for website: %s, came in without the expected parameter or header value.", voteWebsite.name);
printf("Vote callback for website: %s, came in without the expected parameter or header value.", voteWebsite.name.c_str());
printReqData(req);
return;
}
Expand Down

0 comments on commit 666a98e

Please sign in to comment.