Skip to content

Commit

Permalink
- initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
Sascha Volkenandt committed Jan 2, 2007
0 parents commit 48c46df
Show file tree
Hide file tree
Showing 31 changed files with 4,001 additions and 0 deletions.
340 changes: 340 additions & 0 deletions COPYING

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
VDR Plugin 'httpd' Revision History
-----------------------------------

2007-01-01: Version 0.0.1

- Initial revision.
125 changes: 125 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#
# Makefile for a Video Disk Recorder plugin
#
# $Id: Makefile,v 1.1 2007/01/02 19:18:27 lordjaxom Exp $

# The official name of this plugin.
# This name will be used in the '-P...' option of VDR to load the plugin.
# By default the main source file also carries this name.
# IPORTANT: the presence of this macro is important for the Make.config
# file. So it must be defined, even if it is not used here!
#
PLUGIN = live

### The version number of this plugin (taken from the main source file):

VERSION = $(shell grep 'static const char \*VERSION *=' $(PLUGIN).cpp | awk '{ print $$6 }' | sed -e 's/[";]//g')

### The C++ compiler and options:

CXX ?= g++
CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual

ECPPC ?= /usr/local/bin/ecppc
CXXFLAGS += `tntnet-config --cxxflags`

LDFLAGS += `tntnet-config --libs`

### The directory environment:

VDRDIR = ../../..
LIBDIR = ../../lib
TMPDIR = /tmp

### Allow user defined options to overwrite defaults:

-include $(VDRDIR)/Make.config

### The version number of VDR's plugin API (taken from VDR's "config.h"):

APIVERSION = $(shell sed -ne '/define APIVERSION/s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)

### The name of the distribution archive:

ARCHIVE = $(PLUGIN)-$(VERSION)
PACKAGE = vdr-$(ARCHIVE)

### Includes and Defines (add further entries here):

INCLUDES += -I$(VDRDIR)/include -Ihttpd

DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'

SUBDIRS = httpd

LIBS += httpd/libhttpd.a

### The object files (add further files here):

OBJS = $(PLUGIN).o thread.o tntconfig.o setup.o

WEBS = channels.o

### Implicit rules:

%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<

%.cpp: %.ecpp
$(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_CPP) $<

%.cpp: %.gif
$(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_GIF) -b $<

%.cpp: %.jpg
$(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_JPG) -b $<

%.cpp: %.css
$(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_CSS) -b $<

%.cpp: %.js
$(ECPPC) $(ECPPFLAGS) $(ECPPFLAGS_JS) -b $<

# Dependencies:

MAKEDEP = $(CXX) -MM -MG
DEPFILE = .dependencies
$(DEPFILE): Makefile
@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.cpp) > $@

-include $(DEPFILE)

### Targets:

.PHONY: all dist clean SUBDIRS

SUBDIRS:
@for dir in $(SUBDIRS); do \
make -C $$dir CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" lib$$dir.a ; \
done

all: libvdr-$(PLUGIN).so libtnt-$(PLUGIN).so

libvdr-$(PLUGIN).so: $(OBJS) SUBDIRS
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)

libtnt-$(PLUGIN).so: $(WEBS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared -o $@ $^
@cp --remove-destination $@ $(LIBDIR)/$@

dist: clean $(WEBS:%.o=%.cpp)
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@mkdir $(TMPDIR)/$(ARCHIVE)
@cp -a * $(TMPDIR)/$(ARCHIVE)
@tar czf $(PACKAGE).tgz -C $(TMPDIR) $(ARCHIVE)
@-rm -rf $(TMPDIR)/$(ARCHIVE)
@echo Distribution package created as $(PACKAGE).tgz

clean:
@-rm -f $(OBJS) $(WEBS) $(DEPFILE) *.so *.tgz core* *~
@for dir in $(SUBDIRS); do \
make -C $$dir clean ; \
done


11 changes: 11 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This is a "plugin" for the Video Disk Recorder (VDR).

Written by: Your Name <[email protected]>

Project's homepage: URL

Latest version available at: URL

See the file COPYING for license information.

Description:
22 changes: 22 additions & 0 deletions channels.ecpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%pre>
#include <vdr/channels.h>
</%pre>
<html>
<head>
<title>ecpp-application testproject</title>
</head>
<body>
<{

for (cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) {
if (!channel->GroupSep() && *channel->Name()) {
}>
<$ channel->Name() $>
<{
}
}


}>
</body>
</html>
33 changes: 33 additions & 0 deletions httpd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
CXX ?= g++
AR ?= ar

CXXFLAGS ?= -O2 -Woverloaded-virtual -Wall -fPIC

INCLUDES += -I.

OBJS = dispatcher.o job.o regex.o worker.o \
listener.o poller.o tntnet.o

### Implicit rules:

%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) -o $@ $<

# Dependencies:

MAKEDEP = $(CXX) -MM -MG
DEPFILE = .dependencies
$(DEPFILE): Makefile
@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.cpp) > $@

-include $(DEPFILE)

### Targets:

all: libhttpd.a

libhttpd.a: $(OBJS)
$(AR) r $@ $^

clean:
rm -f *.o core* libproctools.a proctest $(DEPFILE)
109 changes: 109 additions & 0 deletions httpd/dispatcher.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/* dispatcher.cpp
* Copyright (C) 2003-2005 Tommi Maekitalo
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* is provided AS IS, WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, and
* NON-INFRINGEMENT. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

#include "tnt/dispatcher.h"
#include <tnt/httperror.h>
#include <functional>
#include <iterator>
#include <algorithm>
#include <cxxtools/log.h>

log_define("tntnet.dispatcher")

namespace tnt
{

void Dispatcher::addUrlMapEntry(const std::string& url, const CompidentType& ci)
{
cxxtools::WrLock lock(rwlock);

urlmap.push_back(urlmap_type::value_type(regex(url), ci));
}

Compident Dispatcher::mapComp(const std::string& compUrl) const
{
urlmap_type::const_iterator pos = urlmap.begin();
return mapCompNext(compUrl, pos);
}

namespace {
class regmatch_formatter : public std::unary_function<const std::string&, std::string>
{
public:
regex_smatch what;
std::string operator() (const std::string& s) const
{ return what.format(s); }
};
}

Dispatcher::urlMapCacheType::size_type Dispatcher::maxUrlMapCache = 8192;

Dispatcher::CompidentType Dispatcher::mapCompNext(const std::string& compUrl,
Dispatcher::urlmap_type::const_iterator& pos) const
{
// check cache
urlMapCacheType::key_type cacheKey = urlMapCacheType::key_type(compUrl, pos);
urlMapCacheType::const_iterator um = urlMapCache.find(cacheKey);
if (um != urlMapCache.end())
return um->second;

// no cache hit
regmatch_formatter formatter;

for (; pos != urlmap.end(); ++pos)
{
if (pos->first.match(compUrl, formatter.what))
{
const CompidentType& src = pos->second;

CompidentType ci;
ci.libname = formatter(src.libname);
ci.compname = formatter(src.compname);
if (src.hasPathInfo())
ci.setPathInfo(formatter(src.getPathInfo()));
std::transform(src.getArgs().begin(), src.getArgs().end(),
std::back_inserter(ci.getArgsRef()), formatter);

// clear cache after maxUrlMapCache distict requests
if (urlMapCache.size() >= maxUrlMapCache)
{
log_warn("clear url-map-cache");
urlMapCache.clear();
}

urlMapCache.insert(urlMapCacheType::value_type(cacheKey, ci));

return ci;
}
}

throw NotFoundException(compUrl);
}

Dispatcher::CompidentType Dispatcher::PosType::getNext()
{
if (first)
first = false;
else
++pos;

return dis.mapCompNext(url, pos);
}

}
Loading

0 comments on commit 48c46df

Please sign in to comment.