diff options
Diffstat (limited to 'pagelib')
-rw-r--r-- | pagelib/Makefile | 33 | ||||
-rw-r--r-- | pagelib/tools.cpp | 40 | ||||
-rw-r--r-- | pagelib/tools.h | 31 |
3 files changed, 0 insertions, 104 deletions
diff --git a/pagelib/Makefile b/pagelib/Makefile deleted file mode 100644 index 78389da..0000000 --- a/pagelib/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -CXX ?= g++ -AR ?= ar - -CXXFLAGS ?= -O2 -Woverloaded-virtual -Wall -fPIC - -INCLUDES += -I.. -I$(VDRDIR)/include - -### The directory environment: - -VDRDIR ?= ../../../.. - -### The object files (add further files here): - -OBJS = tools.o - -### Default rules: - -.PHONY: all clean - -all: libpagelib.a - -### Implicit rules: - -%.o: %.cpp - $(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $< - -### Targets: - -libpagelib.a: $(OBJS) - $(AR) r $@ $^ - -clean: - @rm -f *~ *.o core* libpagelib.a diff --git a/pagelib/tools.cpp b/pagelib/tools.cpp deleted file mode 100644 index e1d9a03..0000000 --- a/pagelib/tools.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include <sstream> -#include <stdexcept> -#include "live.h" -#include "setup.h" -#include "tools.h" - -namespace vdrlive { - -using namespace std; - -string FormatDateTime( char const* format, time_t time ) -{ - struct tm tm_r; - if ( localtime_r( &time, &tm_r ) == 0 ) { - ostringstream builder; - builder << "cannot represent timestamp " << time << " as local time"; - throw runtime_error( builder.str() ); - } - - char result[ 256 ]; - if ( strftime( result, sizeof( result ), format, &tm_r ) == 0 ) { - ostringstream builder; - builder << "representation of timestamp " << time << " exceeds " << sizeof( result ) << " bytes"; - throw runtime_error( builder.str() ); - } - return result; -} - -string StringReplace( string const& text, string const& substring, string const& replacement ) -{ - string result = text; - string::size_type pos = 0; - while ( ( pos = result.find( substring, pos ) ) != string::npos ) { - result.replace( pos, substring.length(), replacement ); - pos += replacement.length(); - } - return result; -} - -} diff --git a/pagelib/tools.h b/pagelib/tools.h deleted file mode 100644 index c39075b..0000000 --- a/pagelib/tools.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef VDR_LIVE_TOOLS_H -#define VDR_LIVE_TOOLS_H - -#include <ctime> -#include <string> -#include <vdr/thread.h> - -namespace vdrlive { - -std::string FormatDateTime( char const* format, time_t time ); -std::string StringReplace( std::string const& text, std::string const& substring, std::string const& replacement ); - -class ReadLock -{ -public: - ReadLock( cRwLock& lock, int timeout = 100 ): m_lock( lock ), m_locked( false ) { if ( m_lock.Lock( false, timeout ) ) m_locked = true; } - ~ReadLock() { if ( m_locked ) m_lock.Unlock(); } - - operator bool() { return m_locked; } - bool operator!() { return !m_locked; } - -private: - ReadLock( ReadLock const& ); - - cRwLock& m_lock; - bool m_locked; -}; - -} // namespace vdrlive - -#endif // VDR_LIVE_TOOLS_H |