mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
src/nhttpd: clean code
This commit is contained in:
@@ -34,16 +34,16 @@
|
||||
#include <system/configure_network.h>
|
||||
#include <cs_api.h>
|
||||
#include <global.h>
|
||||
#include "gui/plugins.h"//for relodplugins
|
||||
#include <gui/plugins.h>//for relodplugins
|
||||
#include <neutrino.h>
|
||||
#include <driver/screenshot.h>
|
||||
#include "gui/rc_lock.h"
|
||||
#include <gui/rc_lock.h>
|
||||
|
||||
// yhttpd
|
||||
#include "yhttpd.h"
|
||||
#include "ytypes_globals.h"
|
||||
#include "ylogging.h"
|
||||
#include "helper.h"
|
||||
#include <yhttpd.h>
|
||||
#include <ytypes_globals.h>
|
||||
#include <ylogging.h>
|
||||
#include <helper.h>
|
||||
// nhttpd
|
||||
#include "neutrinoapi.h"
|
||||
#include "controlapi.h"
|
||||
@@ -220,7 +220,6 @@ const CControlAPI::TyCgiCall CControlAPI::yCgiCallList[]=
|
||||
void CControlAPI::Execute(CyhookHandler *hh)
|
||||
{
|
||||
int index = -1;
|
||||
std::string yresult;
|
||||
std::string filename = hh->UrlData["filename"];
|
||||
|
||||
log_level_printf(4,"ControlAPI.Execute filename:(%s)\n",filename.c_str());
|
||||
@@ -892,7 +891,6 @@ void CControlAPI::ChannellistCGI(CyhookHandler *hh)
|
||||
std::string CControlAPI::_GetBouquetActualEPGItem(CyhookHandler *hh, CZapitChannel * channel) {
|
||||
std::string result, firstEPG, secondEPG = "";
|
||||
t_channel_id current_channel = CZapit::getInstance()->GetCurrentChannelID();
|
||||
int percentage = 100;
|
||||
std::string timestr;
|
||||
|
||||
CSectionsdClient::responseGetCurrentNextInfoChannelID currentNextInfo;
|
||||
@@ -900,6 +898,7 @@ std::string CControlAPI::_GetBouquetActualEPGItem(CyhookHandler *hh, CZapitChann
|
||||
event = NeutrinoAPI->ChannelListEvents[channel->channel_id];
|
||||
|
||||
if (event) {
|
||||
int percentage = 100;
|
||||
if (event->duration > 0)
|
||||
percentage = 100 * (time(NULL) - event->startTime) / event->duration;
|
||||
CEitManager::getInstance()->getCurrentNextServiceKey(channel->channel_id, currentNextInfo);
|
||||
@@ -1366,7 +1365,7 @@ void CControlAPI::EpgCGI(CyhookHandler *hh) {
|
||||
else if (hh->ParamList.empty() || hh->ParamList["1"] == "ext") {
|
||||
hh->SetHeader(HTTP_OK, "text/plain; charset=UTF-8");
|
||||
bool isExt = (hh->ParamList["1"] == "ext");
|
||||
CChannelEvent *event;
|
||||
CChannelEvent *event = NULL;
|
||||
NeutrinoAPI->GetChannelEvents();
|
||||
|
||||
int mode = NeutrinoAPI->Zapit->getMode();
|
||||
@@ -1389,7 +1388,7 @@ void CControlAPI::EpgCGI(CyhookHandler *hh) {
|
||||
// query details for given eventid
|
||||
else if (hh->ParamList["eventid"] != "") {
|
||||
//special epg query
|
||||
uint64_t epgid;
|
||||
uint64_t epgid = 0;
|
||||
sscanf(hh->ParamList["eventid"].c_str(), "%llu", &epgid);
|
||||
CShortEPGData epg;
|
||||
if (CEitManager::getInstance()->getEPGidShort(epgid, &epg)) {
|
||||
@@ -1400,8 +1399,8 @@ void CControlAPI::EpgCGI(CyhookHandler *hh) {
|
||||
}
|
||||
else if (hh->ParamList["eventid2fsk"] != "") {
|
||||
if (hh->ParamList["starttime"] != "") {
|
||||
uint64_t epgid;
|
||||
time_t starttime;
|
||||
uint64_t epgid = 0;
|
||||
time_t starttime = 0;
|
||||
sscanf(hh->ParamList["fskid"].c_str(), "%llu", &epgid);
|
||||
sscanf(hh->ParamList["starttime"].c_str(), "%lu", &starttime);
|
||||
CEPGData longepg;
|
||||
@@ -1414,7 +1413,7 @@ void CControlAPI::EpgCGI(CyhookHandler *hh) {
|
||||
}
|
||||
// list EPG for channel id
|
||||
else if (!(hh->ParamList["id"].empty())) {
|
||||
t_channel_id channel_id;
|
||||
t_channel_id channel_id = 0;
|
||||
sscanf(hh->ParamList["id"].c_str(), SCANF_CHANNEL_ID_TYPE, &channel_id);
|
||||
CEitManager::getInstance()->getEventsServiceKey(channel_id, NeutrinoAPI->eList);
|
||||
CChannelEventList::iterator eventIterator;
|
||||
@@ -1431,7 +1430,7 @@ void CControlAPI::EpgCGI(CyhookHandler *hh) {
|
||||
// list EPG for channelID 64Bit
|
||||
else {
|
||||
//eventlist for a chan
|
||||
t_channel_id channel_id;
|
||||
t_channel_id channel_id = 0;
|
||||
sscanf(hh->ParamList["1"].c_str(), SCANF_CHANNEL_ID_TYPE, &channel_id);
|
||||
SendEventList(hh, channel_id);
|
||||
}
|
||||
@@ -2006,10 +2005,9 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh)
|
||||
void CControlAPI::YWebCGI(CyhookHandler *hh)
|
||||
{
|
||||
bool status=true;
|
||||
int para;
|
||||
if (hh->ParamList["video_stream_pids"] != "")
|
||||
{
|
||||
para=0;
|
||||
int para=0;
|
||||
sscanf( hh->ParamList["video_stream_pids"].c_str(), "%d", ¶);
|
||||
YWeb_SendVideoStreamingPids(hh, para);
|
||||
}
|
||||
@@ -2072,7 +2070,7 @@ std::string CControlAPI::YexecuteScript(CyhookHandler *, std::string cmd)
|
||||
// get file
|
||||
std::string fullfilename;
|
||||
script += ".sh"; //add script extention
|
||||
char cwd[255];
|
||||
char cwd[255]={0};
|
||||
getcwd(cwd, 254);
|
||||
|
||||
for (unsigned int i=0; i<PLUGIN_DIR_COUNT && !found; i++)
|
||||
@@ -2121,7 +2119,6 @@ void CControlAPI::doNewTimer(CyhookHandler *hh)
|
||||
alarmTimeT = 0,
|
||||
tnull = 0;
|
||||
unsigned int repCount = 0;
|
||||
int alHour=0;
|
||||
|
||||
// if alarm given then in parameters im time_t format
|
||||
if(hh->ParamList["alarm"] != "")
|
||||
@@ -2145,7 +2142,7 @@ void CControlAPI::doNewTimer(CyhookHandler *hh)
|
||||
// Alarm Time - Format exact! HH:MM
|
||||
if(hh->ParamList["alTime"] != "")
|
||||
strptime(hh->ParamList["alTime"].c_str(), "%H:%M", alarmTime);
|
||||
alHour = alarmTime->tm_hour;
|
||||
int alHour = alarmTime->tm_hour;
|
||||
|
||||
correctTime(alarmTime);
|
||||
alarmTimeT = mktime(alarmTime);
|
||||
@@ -2389,10 +2386,8 @@ void CControlAPI::moveBouquetCGI(CyhookHandler *hh)
|
||||
//-------------------------------------------------------------------------
|
||||
void CControlAPI::deleteBouquetCGI(CyhookHandler *hh)
|
||||
{
|
||||
int selected = -1;
|
||||
|
||||
if (hh->ParamList["selected"] != "") {
|
||||
selected = atoi(hh->ParamList["selected"].c_str());
|
||||
int selected = atoi(hh->ParamList["selected"].c_str());
|
||||
NeutrinoAPI->Zapit->deleteBouquet(selected - 1);
|
||||
hh->SendOk();
|
||||
}
|
||||
@@ -2479,7 +2474,7 @@ void CControlAPI::updateBouquetCGI(CyhookHandler *hh)
|
||||
// host : (optional) ip of dbox
|
||||
void CControlAPI::build_live_url(CyhookHandler *hh)
|
||||
{
|
||||
std::string xpids,port,yresult;
|
||||
std::string xpids;
|
||||
int mode = NeutrinoAPI->Zapit->getMode();
|
||||
|
||||
if ( mode == CZapitClient::MODE_TV)
|
||||
@@ -2735,18 +2730,13 @@ void CControlAPI::FileCGI(CyhookHandler *hh) {
|
||||
|
||||
if (hh->ParamList["action"] == "list") { // directory list: action=list&path=<path>
|
||||
DIR *dirp;
|
||||
struct dirent*entry;
|
||||
struct stat statbuf;
|
||||
struct passwd *pwd;
|
||||
struct group *grp;
|
||||
struct tm *tm;
|
||||
char datestring[256];
|
||||
|
||||
TOutType outType = hh->outStart();
|
||||
|
||||
std::string path = hh->ParamList["path"];
|
||||
if ((dirp = opendir(path.c_str()))) {
|
||||
bool isFirstLine = true;
|
||||
struct dirent *entry;
|
||||
while ((entry = readdir(dirp))) {
|
||||
std::string item = "";
|
||||
item += hh->outPair("name",
|
||||
@@ -2767,6 +2757,7 @@ void CControlAPI::FileCGI(CyhookHandler *hh) {
|
||||
std::string fullname = path + entry->d_name;
|
||||
item += hh->outPair("fullname", hh->outValue(fullname), true);
|
||||
|
||||
struct stat statbuf;
|
||||
if (stat(fullname.c_str(), &statbuf) != -1) {
|
||||
item
|
||||
+= hh->outPair(
|
||||
@@ -2780,6 +2771,7 @@ void CControlAPI::FileCGI(CyhookHandler *hh) {
|
||||
string_printf("%d", statbuf.st_nlink), true);
|
||||
|
||||
/* Print out owner's name if it is found using getpwuid(). */
|
||||
struct passwd *pwd;
|
||||
if ((pwd = getpwuid(statbuf.st_uid)) != NULL) {
|
||||
item += hh->outPair("user", pwd->pw_name, true);
|
||||
}
|
||||
@@ -2788,6 +2780,7 @@ void CControlAPI::FileCGI(CyhookHandler *hh) {
|
||||
string_printf("%d", statbuf.st_uid), true);
|
||||
}
|
||||
/* Print out group name if it is found using getgrgid(). */
|
||||
struct group *grp;
|
||||
if ((grp = getgrgid(statbuf.st_gid)) != NULL)
|
||||
item += hh->outPair("group", grp->gr_name, true);
|
||||
else {
|
||||
@@ -2798,7 +2791,8 @@ void CControlAPI::FileCGI(CyhookHandler *hh) {
|
||||
item += hh->outPair("size",
|
||||
string_printf("%jd", (intmax_t) statbuf.st_size),
|
||||
true);
|
||||
tm = localtime(&statbuf.st_mtime);
|
||||
struct tm *tm = localtime(&statbuf.st_mtime);
|
||||
char datestring[256] = {0};
|
||||
/* Get localized date string. */
|
||||
strftime(datestring, sizeof(datestring),
|
||||
nl_langinfo(D_T_FMT), tm);
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
// yhttpd
|
||||
#include <zapit/channel.h>
|
||||
#include "yhook.h"
|
||||
#include <yhook.h>
|
||||
|
||||
// forward declaration
|
||||
class CNeutrinoAPI;
|
||||
|
@@ -50,7 +50,7 @@ extern CRemoteControl *g_RemoteControl; /* neutrino.cpp */
|
||||
extern CZapitClient::SatelliteList satList;
|
||||
|
||||
// yhttpd
|
||||
#include "ylogging.h"
|
||||
#include <ylogging.h>
|
||||
|
||||
// nhttpd
|
||||
#include "neutrinoapi.h"
|
||||
@@ -266,7 +266,7 @@ bool CNeutrinoAPI::GetChannelEvents(void)
|
||||
if (eList.begin() == eList.end())
|
||||
return false;
|
||||
|
||||
for (eventIterator = eList.begin(); eventIterator != eList.end(); eventIterator++)
|
||||
for (eventIterator = eList.begin(); eventIterator != eList.end(); ++eventIterator)
|
||||
ChannelListEvents[(*eventIterator).get_channel_id()] = &(*eventIterator);
|
||||
|
||||
return true;
|
||||
@@ -457,14 +457,13 @@ std::string CNeutrinoAPI::getAudioInfoAsString(void) {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
std::string CNeutrinoAPI::getCryptInfoAsString(void) {
|
||||
unsigned short i;
|
||||
std::stringstream out;
|
||||
std::string casys[11]= {"Irdeto:","Betacrypt:","Seca:","Viaccess:","Nagra:","Conax: ","Cryptoworks:","Videoguard:","EBU:","XCrypt:","PowerVU:"};
|
||||
int caids[] = { 0x600, 0x1700, 0x0100, 0x0500, 0x1800, 0xB00, 0xD00, 0x900, 0x2600, 0x4a00, 0x0E00 };
|
||||
|
||||
CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel();
|
||||
if(channel) {
|
||||
for (i = 0; i < 11; i++) {
|
||||
for (unsigned short i = 0; i < 11; i++) {
|
||||
for(casys_map_iterator_t it = channel->camap.begin(); it != channel->camap.end(); ++it) {
|
||||
int caid = (*it) & 0xFF00;
|
||||
if(caid == caids[i])
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#include <zapit/client/zapitclient.h>
|
||||
|
||||
// nhttpd
|
||||
#include "helper.h"
|
||||
#include <helper.h>
|
||||
#include "neutrinoyparser.h"
|
||||
#include "controlapi.h"
|
||||
|
||||
|
@@ -13,9 +13,9 @@
|
||||
#include <netinet/in.h> //ntohs
|
||||
#include <inttypes.h> //ntohs
|
||||
// yhttpd
|
||||
#include "yhttpd.h"
|
||||
#include "ytypes_globals.h"
|
||||
#include "mod_yparser.h"
|
||||
#include <yhttpd.h>
|
||||
#include <ytypes_globals.h>
|
||||
#include <mod_yparser.h>
|
||||
// tuxbox
|
||||
#include <zapit/client/zapittools.h> //timer list
|
||||
// nhttpd
|
||||
@@ -209,7 +209,7 @@ std::string CNeutrinoYParser::func_mount_set_values(CyhookHandler *hh, std::str
|
||||
//-------------------------------------------------------------------------
|
||||
std::string CNeutrinoYParser::func_get_bouquets_as_dropdown(CyhookHandler *, std::string para)
|
||||
{
|
||||
std::string ynr, yresult, sel, nr_str, do_show_hidden;
|
||||
std::string yresult, sel, nr_str, do_show_hidden;
|
||||
int nr=1;
|
||||
|
||||
ySplitString(para," ",nr_str, do_show_hidden);
|
||||
@@ -268,7 +268,7 @@ std::string CNeutrinoYParser::func_get_actual_bouquet_number(CyhookHandler *, s
|
||||
//-------------------------------------------------------------------------
|
||||
std::string CNeutrinoYParser::func_get_channels_as_dropdown(CyhookHandler *, std::string para)
|
||||
{
|
||||
std::string abouquet, achannel_id, yresult, sel, sid;
|
||||
std::string abouquet, achannel_id, yresult, sel;
|
||||
|
||||
int bnumber = 1;
|
||||
int mode = NeutrinoAPI->Zapit->getMode();
|
||||
@@ -596,7 +596,7 @@ std::string CNeutrinoYParser::func_get_audio_pids_as_dropdown(CyhookHandler *,
|
||||
//-------------------------------------------------------------------------
|
||||
std::string CNeutrinoYParser::func_unmount_get_list(CyhookHandler *, std::string)
|
||||
{
|
||||
std::string ysel, ymount, ylocal_dir, yfstype, ynr, yresult, mounts;
|
||||
std::string ysel, ymount, ylocal_dir, yfstype, yresult, mounts;
|
||||
|
||||
std::ifstream in;
|
||||
in.open("/proc/mounts", std::ifstream::in);
|
||||
@@ -832,7 +832,7 @@ std::string CNeutrinoYParser::func_get_timer_list(CyhookHandler *, std::string
|
||||
yresult += string_printf(para.c_str(), classname, zAlarmTime, zStopTime, zRep.c_str(), zRepCount.c_str(),
|
||||
zType.c_str(), sAddData.c_str(),timer->eventID,timer->eventID);
|
||||
}
|
||||
classname = (i++&1)?'a':'b';
|
||||
//classname = (i++&1)?'a':'b';
|
||||
|
||||
return yresult;
|
||||
}
|
||||
|
@@ -9,9 +9,9 @@
|
||||
// c++
|
||||
#include <string>
|
||||
// yhttpd
|
||||
#include "yhttpd.h"
|
||||
#include "ytypes_globals.h"
|
||||
#include "mod_yparser.h"
|
||||
#include <yhttpd.h>
|
||||
#include <ytypes_globals.h>
|
||||
#include <mod_yparser.h>
|
||||
|
||||
// forward declaration
|
||||
class CNeutrinoAPI;
|
||||
|
@@ -34,28 +34,28 @@ CStringList Cyhttpd::ConfigList;
|
||||
//=============================================================================
|
||||
|
||||
#ifdef Y_CONFIG_USE_AUTHHOOK
|
||||
#include "mod_auth.h"
|
||||
#include <mod_auth.h>
|
||||
static CmAuth *auth = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef Y_CONFIG_USE_WEBLOG
|
||||
#include "mod_weblog.h"
|
||||
#include <mod_weblog.h>
|
||||
static CmWebLog *weblog = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef Y_CONFIG_USE_SENDFILE
|
||||
#include "mod_sendfile.h"
|
||||
#include <mod_sendfile.h>
|
||||
static CmodSendfile *mod_sendfile = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef Y_CONFIG_USE_CACHE
|
||||
#include "mod_cache.h"
|
||||
#include <mod_cache.h>
|
||||
static CmodCache mod_cache; // static instance
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#if defined(CONFIG_SYSTEM_TUXBOX) || defined(CONFIG_SYSTEM_TUXBOX_COOLSTREAM)
|
||||
#include "neutrinoapi.h"
|
||||
#include <neutrinoapi.h>
|
||||
static CNeutrinoAPI *NeutrinoAPI;
|
||||
#endif
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#include <iomanip>
|
||||
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include <yconfig.h>
|
||||
#include "ytypes_globals.h"
|
||||
#include "helper.h"
|
||||
#include "ylogging.h"
|
||||
@@ -220,10 +220,10 @@ std::string encodeString(std::string decodedString) {
|
||||
unsigned int len = sizeof(char) * decodedString.length() * 5 + 1;
|
||||
std::string result(len, '\0');
|
||||
char *newString = (char *) result.c_str();
|
||||
char *dstring = (char *) decodedString.c_str();
|
||||
char one_char;
|
||||
if (len == result.length()) // got memory needed
|
||||
{
|
||||
char *dstring = (char *) decodedString.c_str();
|
||||
while ((one_char = *dstring++)) /* use the null character as a loop terminator */
|
||||
{
|
||||
if (isalnum(one_char))
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include <errno.h>
|
||||
#include <cstring>
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include <yconfig.h>
|
||||
#include "ytypes_globals.h"
|
||||
#include "ywebserver.h"
|
||||
#include "yconnection.h"
|
||||
@@ -44,6 +44,7 @@ CWebserverConnection::CWebserverConnection(CWebserver *pWebserver) {
|
||||
//-------------------------------------------------------------------------
|
||||
CWebserverConnection::CWebserverConnection() {
|
||||
// aprintf("test CWebserverConnection::CWebserverConnection()\n");
|
||||
Method = M_UNKNOWN;
|
||||
sock = 0;
|
||||
RequestCanceled = 0;
|
||||
keep_alive = 0;
|
||||
|
@@ -14,7 +14,7 @@
|
||||
// c++
|
||||
#include <string>
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include <yconfig.h>
|
||||
#include "ytypes_globals.h"
|
||||
#include "ywebserver.h"
|
||||
#include "yrequest.h"
|
||||
|
@@ -51,7 +51,7 @@
|
||||
#include <string>
|
||||
#include <list>
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include <yconfig.h>
|
||||
#include "ytypes_globals.h"
|
||||
#include "ylogging.h"
|
||||
// tuxbox
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
CStringList HookVarList; // Variables in Hook-Handling passing to other Hooks
|
||||
THttp_Method Method; // HTTP Method (requested)
|
||||
// constructor & deconstructor
|
||||
CyhookHandler(){ContentLength = 0; keep_alive = 0; _outIndent = 0;};
|
||||
CyhookHandler(){ContentLength = 0; keep_alive = 0; _outIndent = 0;status = HANDLED_NONE;Method = M_UNKNOWN;httpStatus = HTTP_NIL;outType = plain;};
|
||||
virtual ~CyhookHandler(){};
|
||||
|
||||
// hook slot handler
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <configfile.h>
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include <yconfig.h>
|
||||
#include "ytypes_globals.h"
|
||||
#include "ywebserver.h"
|
||||
|
||||
|
@@ -116,7 +116,7 @@ bool CWebserverRequest::HandleRequest(void) {
|
||||
// Split URL into path, filename, fileext .. UrlData[]
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CWebserverRequest::ParseStartLine(std::string start_line) {
|
||||
std::string method, url, http, tmp;
|
||||
std::string method, url, tmp;
|
||||
|
||||
log_level_printf(8, "<ParseStartLine>: line: %s\n", start_line.c_str());
|
||||
if (ySplitString(start_line, " ", method, tmp)) {
|
||||
|
@@ -15,8 +15,8 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include "yhttpd.h"
|
||||
#include <yconfig.h>
|
||||
#include <yhttpd.h>
|
||||
#include "ytypes_globals.h"
|
||||
#include "ylogging.h"
|
||||
#include "ywebserver.h"
|
||||
|
@@ -9,7 +9,7 @@
|
||||
// c++
|
||||
#include <string>
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include <yconfig.h>
|
||||
#include "ytypes_globals.h"
|
||||
#include "yhook.h"
|
||||
|
||||
@@ -42,8 +42,8 @@ public:
|
||||
void printf(const char *fmt, ...);
|
||||
bool Write(char const *text);
|
||||
bool WriteLn(char const *text);
|
||||
bool Write(const std::string text) { return Write(text.c_str()); }
|
||||
bool WriteLn(const std::string text) { return WriteLn(text.c_str()); }
|
||||
bool Write(const std::string &text) { return Write(text.c_str()); }
|
||||
bool WriteLn(const std::string &text) { return WriteLn(text.c_str()); }
|
||||
|
||||
// Headers
|
||||
void SendError(HttpResponseType responseType) {SendHeader(responseType, false, "text/html");}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
// yhttpd
|
||||
#include "yhttpd.h"
|
||||
#include <yhttpd.h>
|
||||
#include "ysocket.h"
|
||||
#include "ylogging.h"
|
||||
// system
|
||||
@@ -64,6 +64,7 @@ CySocket::~CySocket() {
|
||||
// initialize
|
||||
//-----------------------------------------------------------------------------
|
||||
void CySocket::init(void) {
|
||||
BytesSend = 0;
|
||||
handling = false;
|
||||
isOpened = false;
|
||||
isValid = true;
|
||||
@@ -194,8 +195,8 @@ CySocket* CySocket::accept() {
|
||||
#else
|
||||
set_tcp_nodelay();
|
||||
#endif
|
||||
}
|
||||
new_ySocket->isOpened = true;
|
||||
}
|
||||
// handling = true;
|
||||
return new_ySocket;
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#include <configfile.h>
|
||||
|
||||
// yhttpd
|
||||
#include "yhttpd.h"
|
||||
#include <yhttpd.h>
|
||||
#include "ytypes_globals.h"
|
||||
#include "ywebserver.h"
|
||||
#include "ylogging.h"
|
||||
@@ -241,7 +241,6 @@ bool CWebserver::run(void) {
|
||||
int CWebserver::AcceptNewConnectionSocket() {
|
||||
int slot = -1;
|
||||
CySocket *connectionSock = NULL;
|
||||
int newfd;
|
||||
|
||||
if (!(connectionSock = listenSocket.accept())) // Blocking wait
|
||||
{
|
||||
@@ -265,7 +264,7 @@ int CWebserver::AcceptNewConnectionSocket() {
|
||||
SocketList[slot] = connectionSock; // put it to list
|
||||
fcntl(connectionSock->get_socket(), F_SETFD, O_NONBLOCK); // set non-blocking
|
||||
open_connections++; // count open connectins
|
||||
newfd = connectionSock->get_socket();
|
||||
int newfd = connectionSock->get_socket();
|
||||
if (newfd > fdmax) // keep track of the maximum fd
|
||||
fdmax = newfd;
|
||||
}
|
||||
@@ -377,7 +376,7 @@ bool CWebserver::CheckKeepAliveAllowedByIP(std::string client_ip) {
|
||||
while (it != conf_no_keep_alive_ips.end()) {
|
||||
if (trim(*it) == client_ip)
|
||||
do_keep_alive = false;
|
||||
it++;
|
||||
++it;
|
||||
}
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return do_keep_alive;
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include "mod_auth.h"
|
||||
#include "helper.h"
|
||||
#include <helper.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HOOK: response_hook
|
||||
@@ -65,11 +65,11 @@ bool CmAuth::CheckAuth(CyhookHandler *hh) {
|
||||
// decode Base64 buffer to String
|
||||
//-----------------------------------------------------------------------------
|
||||
std::string CmAuth::decodeBase64(const char *b64buffer) {
|
||||
char *newString, *org_newString; //shorter then b64buffer
|
||||
char *newString; //shorter then b64buffer
|
||||
std::string result;
|
||||
if ((newString = (char *) malloc(sizeof(char) * strlen(b64buffer) + 1))
|
||||
!= NULL) {
|
||||
org_newString = newString;
|
||||
char *org_newString = newString;
|
||||
int i = 0;
|
||||
unsigned long c = 0;
|
||||
|
||||
|
@@ -5,11 +5,12 @@
|
||||
#ifndef __yhttpd_mod_auth_h__
|
||||
#define __yhttpd_mod_auth_h__
|
||||
|
||||
#include "yhook.h"
|
||||
#include <yhook.h>
|
||||
class CmAuth: public Cyhook {
|
||||
public:
|
||||
bool authenticate;
|
||||
CmAuth() {
|
||||
authenticate = false;
|
||||
}
|
||||
;
|
||||
~CmAuth() {
|
||||
|
@@ -8,9 +8,9 @@
|
||||
#include <pthread.h>
|
||||
#include <sys/stat.h>
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include "ytypes_globals.h"
|
||||
#include "helper.h"
|
||||
#include <yconfig.h>
|
||||
#include <ytypes_globals.h>
|
||||
#include <helper.h>
|
||||
#include "mod_cache.h"
|
||||
|
||||
//=============================================================================
|
||||
@@ -128,7 +128,7 @@ void CmodCache::AddToCache(CyhookHandler *, std::string url,
|
||||
CacheList[url].mime_type = mime_type;
|
||||
CacheList[url].category = category;
|
||||
CacheList[url].created = time(NULL);
|
||||
std::string test = CacheList[url].filename;
|
||||
// std::string test = CacheList[url].filename;
|
||||
}
|
||||
fflush(fd); // flush and close file
|
||||
fclose(fd);
|
||||
@@ -154,7 +154,7 @@ void CmodCache::RemoveCategoryFromCache(std::string category) {
|
||||
do {
|
||||
restart = false;
|
||||
TCacheList::iterator i = CacheList.begin();
|
||||
for (; i != CacheList.end(); i++) {
|
||||
for (; i != CacheList.end(); ++i) {
|
||||
TCache *item = &((*i).second);
|
||||
if (item->category == category) {
|
||||
CacheList.erase(((*i).first));
|
||||
@@ -198,7 +198,7 @@ void CmodCache::yshowCacheInfo(CyhookHandler *hh) {
|
||||
"<tr><td>URL</td><td>Mime</td><td>Filename</td><td>Category</td><td>Created</td><td>Remove</td></tr>\n");
|
||||
pthread_mutex_lock(&mutex);
|
||||
TCacheList::iterator i = CacheList.begin();
|
||||
for (; i != CacheList.end(); i++) {
|
||||
for (; i != CacheList.end(); ++i) {
|
||||
TCache *item = &((*i).second);
|
||||
char timeStr[80];
|
||||
strftime(timeStr, sizeof(timeStr), RFC1123FMT, gmtime(&(item->created)));
|
||||
|
@@ -11,9 +11,9 @@
|
||||
// c++
|
||||
#include <string>
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include "ytypes_globals.h"
|
||||
#include "yhook.h"
|
||||
#include <yconfig.h>
|
||||
#include <ytypes_globals.h>
|
||||
#include <yhook.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef struct {
|
||||
|
@@ -47,9 +47,9 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include "ytypes_globals.h"
|
||||
#include "helper.h"
|
||||
#include <yconfig.h>
|
||||
#include <ytypes_globals.h>
|
||||
#include <helper.h>
|
||||
#include "mod_sendfile.h"
|
||||
|
||||
//=============================================================================
|
||||
@@ -64,7 +64,6 @@ CStringList CmodSendfile::sendfileTypes;
|
||||
THandleStatus CmodSendfile::Hook_PrepareResponse(CyhookHandler *hh) {
|
||||
hh->status = HANDLED_NONE;
|
||||
|
||||
int filed;
|
||||
log_level_printf(4, "mod_sendfile prepare hook start url:%s\n", hh->UrlData["fullurl"].c_str());
|
||||
std::string mime = sendfileTypes[hh->UrlData["fileext"]];
|
||||
if (((mime != "") || (hh->WebserverConfigList["mod_sendfile.sendAll"] == "true"))
|
||||
@@ -73,7 +72,7 @@ THandleStatus CmodSendfile::Hook_PrepareResponse(CyhookHandler *hh) {
|
||||
// build filename
|
||||
std::string fullfilename = GetFileName(hh, hh->UrlData["path"],
|
||||
hh->UrlData["filename"]);
|
||||
|
||||
int filed;
|
||||
if ((filed = OpenFile(hh, fullfilename)) != -1) //can access file?
|
||||
{
|
||||
struct stat statbuf;
|
||||
@@ -180,7 +179,6 @@ std::string CmodSendfile::GetFileName(CyhookHandler *hh, std::string path, std::
|
||||
//-----------------------------------------------------------------------------
|
||||
int CmodSendfile::OpenFile(CyhookHandler *, std::string fullfilename) {
|
||||
int fd = -1;
|
||||
std::string tmpstring;
|
||||
if (fullfilename.length() > 0) {
|
||||
fd = open(fullfilename.c_str(), O_RDONLY | O_LARGEFILE);
|
||||
if (fd <= 0) {
|
||||
|
@@ -11,9 +11,9 @@
|
||||
// c++
|
||||
#include <string>
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include "ytypes_globals.h"
|
||||
#include "yhook.h"
|
||||
#include <yconfig.h>
|
||||
#include <ytypes_globals.h>
|
||||
#include <yhook.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class CmodSendfile : public Cyhook
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#define TESTHOOK_H_
|
||||
|
||||
|
||||
#include "yhook.h"
|
||||
#include <yhook.h>
|
||||
class CTesthook : public Cyhook
|
||||
{
|
||||
public:
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mod_weblog.h"
|
||||
#include "helper.h"
|
||||
#include <helper.h>
|
||||
|
||||
//=============================================================================
|
||||
// Initialization of static variables
|
||||
@@ -97,8 +97,8 @@ bool CmWebLog::printf(const char *fmt, ...) {
|
||||
if (!OpenLogFile())
|
||||
return false;
|
||||
bool success = false;
|
||||
char buffer[bufferlen];
|
||||
if (WebLogFile != NULL) {
|
||||
char buffer[bufferlen]={0};
|
||||
pthread_mutex_lock(&WebLog_mutex); // yeah, its mine
|
||||
va_list arglist;
|
||||
va_start(arglist, fmt);
|
||||
@@ -130,6 +130,8 @@ bool CmWebLog::printf(const char *fmt, ...) {
|
||||
//-----------------------------------------------------------------------------
|
||||
void CmWebLog::AddLogEntry_CLF(CyhookHandler *hh)
|
||||
{
|
||||
#if 0
|
||||
//never used
|
||||
std::string cs_method;
|
||||
switch (hh->Method)
|
||||
{
|
||||
@@ -141,6 +143,7 @@ void CmWebLog::AddLogEntry_CLF(CyhookHandler *hh)
|
||||
cs_method = "unknown";
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
std::string c_ip = hh->UrlData["clientaddr"].c_str();
|
||||
std::string request_startline = hh->UrlData["startline"].c_str();
|
||||
int s_status = hh->httpStatus;
|
||||
@@ -315,7 +318,6 @@ void CmWebLog::AddLogEntry_ELF(CyhookHandler *hh)
|
||||
std::string c_ip = hh->UrlData["clientaddr"].c_str();
|
||||
std::string request_startline = hh->UrlData["startline"].c_str();
|
||||
std::string cs_uri = hh->UrlData["fullurl"];
|
||||
std::string cs_uri_stem = hh->UrlData["url"];
|
||||
int sc_status = hh->httpStatus;
|
||||
int bytes = hh->GetContentLength();
|
||||
int cached = (hh->HookVarList["CacheCategory"].empty()) ? 0 : 1;
|
||||
|
@@ -5,8 +5,8 @@
|
||||
#ifndef __yhttpd_mod_weblog_h__
|
||||
#define __yhttpd_mod_weblog_h__
|
||||
|
||||
#include "yconfig.h"
|
||||
#include "yhook.h"
|
||||
#include <yconfig.h>
|
||||
#include <yhook.h>
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defaults
|
||||
#ifndef LOG_FILE
|
||||
|
@@ -18,12 +18,12 @@
|
||||
// tuxbox
|
||||
#include <configfile.h>
|
||||
// yhttpd
|
||||
#include "yconfig.h"
|
||||
#include "ytypes_globals.h"
|
||||
#include "helper.h"
|
||||
#include "ylogging.h"
|
||||
#include <yconfig.h>
|
||||
#include <ytypes_globals.h>
|
||||
#include <helper.h>
|
||||
#include <ylogging.h>
|
||||
#include "mod_yparser.h"
|
||||
#include "ylanguage.h"
|
||||
#include <ylanguage.h>
|
||||
|
||||
//=============================================================================
|
||||
// Initialization of static variables
|
||||
@@ -111,7 +111,7 @@ void CyParser::Execute(CyhookHandler *hh) {
|
||||
if (CLogging::getInstance()->getDebug()) {
|
||||
dprintf("Execute CGI : %s\n", filename.c_str());
|
||||
for (CStringList::iterator it = hh->ParamList.begin(); it
|
||||
!= hh->ParamList.end(); it++)
|
||||
!= hh->ParamList.end(); ++it)
|
||||
dprintf(" Parameter %s : %s\n", it->first.c_str(),
|
||||
it->second.c_str());
|
||||
}
|
||||
@@ -156,7 +156,6 @@ void CyParser::Execute(CyhookHandler *hh) {
|
||||
// mini cgi Engine (Entry for ycgi)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CyParser::cgi(CyhookHandler *hh) {
|
||||
bool ydebug = false;
|
||||
std::string htmlfilename, yresult, ycmd;
|
||||
|
||||
if ( !hh->ParamList.empty() ) {
|
||||
@@ -164,6 +163,7 @@ void CyParser::cgi(CyhookHandler *hh) {
|
||||
htmlfilename = hh->ParamList["tmpl"];
|
||||
else
|
||||
htmlfilename = hh->ParamList["1"];
|
||||
bool ydebug = false;
|
||||
if (hh->ParamList["debug"] != "") // switch debug on
|
||||
ydebug = true;
|
||||
|
||||
@@ -171,7 +171,6 @@ void CyParser::cgi(CyhookHandler *hh) {
|
||||
{
|
||||
ycmd = hh->ParamList["execute"];
|
||||
ycmd = YPARSER_ESCAPE_START + ycmd + YPARSER_ESCAPE_END;
|
||||
ycmd = ycmd;
|
||||
yresult = cgi_cmd_parsing(hh, ycmd, ydebug); // parsing engine
|
||||
}
|
||||
// parsing given file
|
||||
@@ -471,7 +470,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) {
|
||||
pthread_mutex_unlock(&yParser_mutex);
|
||||
}
|
||||
} else if (ycmd_type == "file-action") {
|
||||
std::string filename, actionname, content, tmp, ydefault;
|
||||
std::string filename, actionname, content, tmp;
|
||||
if (ySplitString(ycmd_name, ";", filename, tmp)) {
|
||||
ySplitString(tmp, ";", actionname, content);
|
||||
replace(content, "\r\n", "\n");
|
||||
@@ -522,7 +521,6 @@ std::string CyParser::YWeb_cgi_get_ini(CyhookHandler *, std::string filename,
|
||||
//-------------------------------------------------------------------------
|
||||
void CyParser::YWeb_cgi_set_ini(CyhookHandler *, std::string filename,
|
||||
std::string varname, std::string varvalue, std::string yaccess) {
|
||||
std::string result;
|
||||
if ((yaccess == "open") || (yaccess == "")) {
|
||||
yConfig->clear();
|
||||
yConfig->loadConfig(filename);
|
||||
@@ -738,11 +736,11 @@ std::string CyParser::func_get_languages_as_dropdown(CyhookHandler *,
|
||||
std::string para) {
|
||||
std::string yresult, sel;
|
||||
DIR *d;
|
||||
struct dirent *dir;
|
||||
|
||||
std::string act_language = CLanguage::getInstance()->language;
|
||||
d = opendir((CLanguage::getInstance()->language_dir).c_str());
|
||||
if (d != NULL) {
|
||||
struct dirent *dir;
|
||||
while ((dir = readdir(d))) {
|
||||
if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0)
|
||||
continue;
|
||||
|
@@ -16,10 +16,10 @@
|
||||
|
||||
#include <configfile.h>
|
||||
// yhttpd
|
||||
#include "helper.h"
|
||||
#include "yconfig.h"
|
||||
#include "ytypes_globals.h"
|
||||
#include "yhook.h"
|
||||
#include <helper.h>
|
||||
#include <yconfig.h>
|
||||
#include <ytypes_globals.h>
|
||||
#include <yhook.h>
|
||||
|
||||
// forward declaration
|
||||
class CWebserverConnection;
|
||||
|
Reference in New Issue
Block a user