controlapi.cpp: remove deprecated ftime(), use helpers

Origin commit data
------------------
Branch: ni/coolstream
Commit: 829b47c0f4
Author: GetAway <get-away@t-online.de>
Date: 2020-07-08 (Wed, 08 Jul 2020)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
GetAway
2020-07-08 20:49:35 +02:00
committed by vanhofen
parent 030db508a3
commit d24e836f20
2 changed files with 5 additions and 18 deletions

View File

@@ -641,19 +641,13 @@ void CControlAPI::RCCGI(CyhookHandler *hh)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Get actual Date // Get actual Date
// security: strftime has buffer-overflow limit. ok!
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void CControlAPI::GetDateCGI(CyhookHandler *hh) void CControlAPI::GetDateCGI(CyhookHandler *hh)
{ {
if (hh->ParamList.empty()) if (hh->ParamList.empty())
{ {
//paramlos std::string timestr = getNowTimeStr("%d.%m.%Y\n");
char *timestr = new char[50];
struct timeb tm;
ftime(&tm);
strftime(timestr, 20, "%d.%m.%Y\n", localtime(&tm.time) );
hh->Write(timestr); hh->Write(timestr);
delete[] timestr;
} }
else else
hh->SendError(); hh->SendError();
@@ -661,23 +655,19 @@ void CControlAPI::GetDateCGI(CyhookHandler *hh)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Get actual Time // Get actual Time
// security: strftime has buffer-overflow limit. ok!
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void CControlAPI::GetTimeCGI(CyhookHandler *hh) void CControlAPI::GetTimeCGI(CyhookHandler *hh)
{ {
time_t now = time(NULL);
if (hh->ParamList.empty()) if (hh->ParamList.empty())
{ {
//paramlos std::string timestr = getNowTimeStr("%H:%M:%S\n");
char *timestr = new char[50];
struct tm *tm = localtime(&now);
strftime(timestr, 20, "%H:%M:%S\n", tm );
hh->Write(timestr); hh->Write(timestr);
delete[] timestr;
} }
else if (hh->ParamList["1"].compare("rawtime") == 0) else if (hh->ParamList["1"].compare("rawtime") == 0)
{
time_t now = time(0);
hh->printf("%ld\n",now); hh->printf("%ld\n",now);
}
else else
hh->SendError(); hh->SendError();
} }

View File

@@ -5,9 +5,6 @@
#ifndef __yhttpd_helper_h__ #ifndef __yhttpd_helper_h__
#define __yhttpd_helper_h__ #define __yhttpd_helper_h__
// c
#include <ctime>
#include <sys/timeb.h>
// c++ // c++
#include <string> #include <string>
#include <vector> #include <vector>