├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── Makefile.am ├── NEWS ├── README ├── README.git ├── README.md ├── configure.ac ├── cxxtools.spec ├── demo ├── .gitignore ├── Makefile.am ├── README ├── arg-set.cpp ├── arg.cpp ├── async │ ├── Makefile.am │ ├── README.md │ ├── log.properties │ └── server.cpp ├── commandoutput.cpp ├── cxxlog.cpp ├── deserialization.cpp ├── dir.cpp ├── dlloader.cpp ├── dynamiccall.cpp ├── dynamicrpc.cpp ├── execLs.cpp ├── future.cpp ├── getini.cpp ├── hd.cpp ├── httpclient.cpp ├── httprequest.cpp ├── httpserver.cpp ├── iconv.cpp ├── insrv.cpp ├── json.cpp ├── jsonbeautify.cpp ├── log.cpp ├── logsh.cpp ├── md5sum.cpp ├── mime.cpp ├── mime2json.cpp ├── mimeextract.cpp ├── mimemultipart.cpp ├── msg.h ├── msgclient.cpp ├── msgserver.cpp ├── multifstream.cpp ├── netcat.cpp ├── netio.cpp ├── netmsg.cpp ├── pipestream.cpp ├── pool.cpp ├── regex.cpp ├── rpcaddclient.cpp ├── rpcasyncaddclient.cpp ├── rpcechoclient.cpp ├── rpcgenericclient.cpp ├── rpcparallelecho.cpp ├── rpcproxy.cpp ├── rpcserver.cpp ├── saml2.cpp ├── serialization.cpp ├── signals.cpp ├── splitter.cpp ├── ssl │ ├── Makefile.am │ ├── rpcJecho.cpp │ ├── rpcJserver.cpp │ ├── rpcbecho.cpp │ ├── rpcbserver.cpp │ ├── rpcjecho.cpp │ ├── rpcjserver.cpp │ ├── rpcxecho.cpp │ └── rpcxserver.cpp ├── sslshowcert.cpp ├── tcpsocket.cpp ├── timer-lambda.cpp ├── timer.cpp ├── uuencode.cpp ├── xmlmsgclient.cpp ├── xmlmsgserver.cpp └── xmlreader.cpp ├── doc ├── Doxyfile ├── Makefile.am ├── argument-parsing-howto.markdown ├── asyncronousIO.md ├── binaryrpc-howto.markdown ├── binserialization.txt ├── connection.md ├── csv-howto.markdown ├── json-howto.markdown ├── jsonquick-howto.markdown ├── jsonrpc-howto.markdown ├── logging-howto.markdown ├── propertiesquick-howto.markdown ├── rpc-howto.markdown ├── serialization-howto.markdown ├── timezone-howto.markdown └── xmlrpc-howto.markdown ├── include ├── Makefile.am └── cxxtools │ ├── application.h │ ├── arg.h │ ├── argin.h │ ├── argout.h │ ├── base64codec.h │ ├── base64stream.h │ ├── bin │ ├── bin.h │ ├── deserializer.h │ ├── formatter.h │ ├── parser.h │ ├── rpcclient.h │ ├── rpcserver.h │ └── serializer.h │ ├── byteorder.h │ ├── cache.h │ ├── callable.h │ ├── callable.tpp │ ├── cgi.h │ ├── char.h │ ├── charmapcodec.h │ ├── clock.h │ ├── composer.h │ ├── config.h.in │ ├── connectable.h │ ├── connection.h │ ├── constmethod.h │ ├── constmethod.tpp │ ├── conversionerror.h │ ├── convert.h │ ├── csv.h │ ├── csvdeserializer.h │ ├── csvparser.h │ ├── csvserializer.h │ ├── date.h │ ├── datetime.h │ ├── decomposer.h │ ├── delegate.h │ ├── delegate.tpp │ ├── deserializer.h │ ├── destructionsentry.h │ ├── directory.h │ ├── dlloader.h │ ├── doxygen.cfg │ ├── envsubst.h │ ├── event.h │ ├── eventloop.h │ ├── eventsink.h │ ├── eventsource.h │ ├── facets.h │ ├── fdstream.h │ ├── file.h │ ├── filedevice.h │ ├── fileinfo.h │ ├── formatter.h │ ├── function.h │ ├── function.tpp │ ├── hdstream.h │ ├── hexdump.h │ ├── hmac.h │ ├── http │ ├── client.h │ ├── messageheader.h │ ├── reply.h │ ├── replyheader.h │ ├── request.h │ ├── requestheader.h │ ├── responder.h │ ├── server.h │ └── service.h │ ├── ini.h │ ├── inideserializer.h │ ├── inifile.h │ ├── iniparser.h │ ├── iniserializer.h │ ├── invokable.h │ ├── invokable.tpp │ ├── iodevice.h │ ├── ioerror.h │ ├── iostream.h │ ├── iso8859_10codec.h │ ├── iso8859_11codec.h │ ├── iso8859_13codec.h │ ├── iso8859_14codec.h │ ├── iso8859_15codec.h │ ├── iso8859_16codec.h │ ├── iso8859_1codec.h │ ├── iso8859_2codec.h │ ├── iso8859_3codec.h │ ├── iso8859_4codec.h │ ├── iso8859_5codec.h │ ├── iso8859_6codec.h │ ├── iso8859_7codec.h │ ├── iso8859_8codec.h │ ├── iso8859_9codec.h │ ├── join.h │ ├── json.h │ ├── json │ ├── httpclient.h │ ├── httpservice.h │ ├── request.h │ ├── responder.h │ ├── rpcclient.h │ └── rpcserver.h │ ├── jsondeserializer.h │ ├── jsonformatter.h │ ├── jsonparser.h │ ├── jsonserializer.h │ ├── library.h │ ├── limitstream.h │ ├── log.h │ ├── log │ └── cxxtools.h │ ├── loginit.h │ ├── lrucache.h │ ├── main.h │ ├── md5.h │ ├── md5stream.h │ ├── method.h │ ├── method.tpp │ ├── mime.h │ ├── multifstream.h │ ├── net │ ├── addrinfo.h │ ├── bufferedsocket.h │ ├── net.h │ ├── tcpserver.h │ ├── tcpsocket.h │ ├── tcpstream.h │ ├── udp.h │ ├── udpstream.h │ └── uri.h │ ├── pipe.h │ ├── pool.h │ ├── posix │ ├── commandinput.h │ ├── commandoutput.h │ ├── daemonize.h │ ├── exec.h │ ├── fork.h │ ├── pipe.h │ └── pipestream.h │ ├── properties.h │ ├── propertiesdeserializer.h │ ├── propertiesfile.h │ ├── propertiesparser.h │ ├── propertiesserializer.h │ ├── ptrstream.h │ ├── ptrstreambuf.h │ ├── query_params.h │ ├── queue.h │ ├── quotedprintablecodec.h │ ├── quotedprintablestream.h │ ├── refcounted.h │ ├── regex.h │ ├── remoteclient.h │ ├── remoteexception.h │ ├── remoteprocedure.h │ ├── remoteprocedure.tpp │ ├── remoteprocedureva.h │ ├── remoteresult.h │ ├── resetter.h │ ├── scopedincrement.h │ ├── selectable.h │ ├── selector.h │ ├── serializationerror.h │ ├── serializationinfo.h │ ├── serviceprocedure.h │ ├── serviceprocedure.tpp │ ├── serviceregistry.h │ ├── settings.h │ ├── signal.h │ ├── signal.tpp │ ├── slot.h │ ├── slot.tpp │ ├── sourceinfo.h │ ├── split.h │ ├── sslcertificate.h │ ├── sslctx.h │ ├── stddevice.h │ ├── stdstream.h │ ├── streambuffer.h │ ├── streamcounter.h │ ├── string.h │ ├── string.tpp │ ├── stringstream.h │ ├── systemerror.h │ ├── tee.h │ ├── textbuffer.h │ ├── textcodec.h │ ├── textstream.h │ ├── time.h │ ├── timer.h │ ├── timespan.h │ ├── trim.h │ ├── typetraits.h │ ├── tz.h │ ├── unit │ ├── application.h │ ├── assertion.h │ ├── jsonreporter.h │ ├── registertest.h │ ├── reporter.h │ ├── test.h │ ├── testcase.h │ ├── testcontext.h │ ├── testfixture.h │ ├── testmain.h │ ├── testmethod.h │ ├── testprotocol.h │ └── testsuite.h │ ├── utf8.h │ ├── utf8codec.h │ ├── uuencode.h │ ├── void.h │ ├── win1252codec.h │ ├── xml │ ├── attribute.h │ ├── characters.h │ ├── comment.h │ ├── doctypedeclaration.h │ ├── enddocument.h │ ├── endelement.h │ ├── entityresolver.h │ ├── namespace.h │ ├── namespacecontext.h │ ├── node.h │ ├── processinginstruction.h │ ├── startelement.h │ ├── xml.h │ ├── xmldeserializer.h │ ├── xmlerror.h │ ├── xmlformatter.h │ ├── xmlreader.h │ ├── xmlserializer.h │ └── xmlwriter.h │ └── xmlrpc │ ├── client.h │ ├── errorcodes.h │ ├── formatter.h │ ├── httpclient.h │ ├── responder.h │ ├── scanner.h │ └── service.h ├── lgpl++.txt ├── m4 ├── acx_pthread.m4 ├── ax_check_compile_flag.m4 ├── ax_compiler_vendor.m4 ├── ax_cxx_compile_stdcxx_11.m4 └── iconv.m4 ├── pkgconfig ├── cxxtools-bin.pc.in ├── cxxtools-http.pc.in ├── cxxtools-json.pc.in ├── cxxtools-unit.pc.in ├── cxxtools-xmlrpc.pc.in └── cxxtools.pc.in ├── src ├── Makefile.am ├── Makefile.mingw ├── Makefile.win32 ├── addrinfo.cpp ├── addrinfoimpl.cpp ├── addrinfoimpl.h ├── application.cpp ├── applicationimpl.cpp ├── applicationimpl.h ├── base64codec.cpp ├── bin │ ├── Makefile.am │ ├── deserializer.cpp │ ├── formatter.cpp │ ├── parser.cpp │ ├── responder.cpp │ ├── responder.h │ ├── rpcclient.cpp │ ├── rpcclientimpl.cpp │ ├── rpcclientimpl.h │ ├── rpcserver.cpp │ ├── rpcserverimpl.cpp │ ├── rpcserverimpl.h │ ├── scanner.cpp │ ├── scanner.h │ ├── serializer.cpp │ ├── socket.cpp │ ├── socket.h │ ├── worker.cpp │ └── worker.h ├── bufferedsocket.cpp ├── cgi.cpp ├── char.cpp ├── charmapcodec.cpp ├── clock.cpp ├── clockimpl.cpp ├── clockimpl.h ├── connectable.cpp ├── connection.cpp ├── conversionerror.cpp ├── convert.cpp ├── csvdeserializer.cpp ├── csvparser.cpp ├── csvserializer.cpp ├── date.cpp ├── datetime.cpp ├── dateutils.cpp ├── dateutils.h ├── decomposer.cpp ├── deserializer.cpp ├── directory.cpp ├── directoryimpl.cpp ├── directoryimpl.h ├── envsubst.cpp ├── error.cpp ├── error.h ├── eventloop.cpp ├── eventsink.cpp ├── eventsource.cpp ├── facets.cpp ├── fdstream.cpp ├── file.cpp ├── filedevice.cpp ├── filedeviceimpl.cpp ├── filedeviceimpl.h ├── fileimpl.cpp ├── fileimpl.h ├── fileinfo.cpp ├── formatter.cpp ├── hdstream.cpp ├── http │ ├── Makefile.am │ ├── chunkedreader.cpp │ ├── chunkedreader.h │ ├── client.cpp │ ├── clientimpl.cpp │ ├── clientimpl.h │ ├── mapper.cpp │ ├── mapper.h │ ├── messageheader.cpp │ ├── notauthenticatedresponder.cpp │ ├── notauthenticatedresponder.h │ ├── notauthenticatedservice.cpp │ ├── notauthenticatedservice.h │ ├── notfoundresponder.cpp │ ├── notfoundresponder.h │ ├── notfoundservice.cpp │ ├── notfoundservice.h │ ├── parser.cpp │ ├── parser.h │ ├── request.cpp │ ├── responder.cpp │ ├── server.cpp │ ├── serverimpl.cpp │ ├── serverimpl.h │ ├── serverimplbase.h │ ├── service.cpp │ ├── socket.cpp │ ├── socket.h │ ├── worker.cpp │ └── worker.h ├── inideserializer.cpp ├── inifile.cpp ├── iniparser.cpp ├── iniserializer.cpp ├── iodevice.cpp ├── iodeviceimpl.cpp ├── iodeviceimpl.h ├── ioerror.cpp ├── iostream.cpp ├── iso8859_codec.cpp ├── json │ ├── Makefile.am │ ├── httpclient.cpp │ ├── httpclientimpl.cpp │ ├── httpclientimpl.h │ ├── httpresponder.cpp │ ├── httpresponder.h │ ├── httpservice.cpp │ ├── responder.cpp │ ├── responder.h │ ├── rpcclient.cpp │ ├── rpcclientimpl.cpp │ ├── rpcclientimpl.h │ ├── rpcserver.cpp │ ├── rpcserverimpl.cpp │ ├── rpcserverimpl.h │ ├── scanner.cpp │ ├── scanner.h │ ├── socket.cpp │ ├── socket.h │ ├── worker.cpp │ └── worker.h ├── jsondeserializer.cpp ├── jsonformatter.cpp ├── jsonparser.cpp ├── library.cpp ├── libraryimpl.cpp ├── libraryimpl.h ├── log.cpp ├── md5.c ├── md5.h ├── md5stream.cpp ├── mime.cpp ├── multifstream.cpp ├── net.cpp ├── pipe.cpp ├── pipeimpl.cpp ├── pipeimpl.h ├── posix │ ├── commandinput.cpp │ ├── commandoutput.cpp │ ├── daemonize.cpp │ ├── fork.cpp │ ├── pipestream.cpp │ └── posixpipe.cpp ├── propertiesdeserializer.cpp ├── propertiesfile.cpp ├── propertiesparser.cpp ├── propertiesserializer.cpp ├── query_params.cpp ├── quotedprintablecodec.cpp ├── regex.cpp ├── remoteclient.cpp ├── selectable.cpp ├── selectableimpl.h ├── selector.cpp ├── selectorimpl.cpp ├── selectorimpl.h ├── serializationerror.cpp ├── serializationinfo.cpp ├── serviceregistry.cpp ├── settings.cpp ├── settingsreader.cpp ├── settingsreader.h ├── settingswriter.cpp ├── settingswriter.h ├── signal.cpp ├── sslcertificate.cpp ├── sslcertificateimpl.cpp ├── sslcertificateimpl.h ├── sslctx.cpp ├── sslctximpl.cpp ├── sslctximpl.h ├── stddevice.cpp ├── streambuffer.cpp ├── string.cpp ├── stringstream.cpp ├── systemerror.cpp ├── tcpserver.cpp ├── tcpserverimpl.cpp ├── tcpserverimpl.h ├── tcpsocket.cpp ├── tcpsocketimpl.cpp ├── tcpsocketimpl.h ├── tcpstream.cpp ├── tee.cpp ├── textbuffer.cpp ├── textcodec.cpp ├── textstream.cpp ├── time.cpp ├── timer.cpp ├── timespan.cpp ├── tz.cpp ├── udp.cpp ├── udpstream.cpp ├── unicode.h ├── unit │ ├── Makefile.am │ ├── application.cpp │ ├── assertion.cpp │ ├── jsonreporter.cpp │ ├── reporter.cpp │ ├── test.cpp │ ├── testcase.cpp │ ├── testcontext.cpp │ ├── testprotocol.cpp │ └── testsuite.cpp ├── uri.cpp ├── utf8codec.cpp ├── uuencode.cpp ├── win1252codec.cpp ├── xml │ ├── characters.cpp │ ├── endelement.cpp │ ├── entityresolver.cpp │ ├── namespacecontext.cpp │ ├── startelement.cpp │ ├── xmldeserializer.cpp │ ├── xmlerror.cpp │ ├── xmlformatter.cpp │ ├── xmlreader.cpp │ ├── xmlserializer.cpp │ └── xmlwriter.cpp └── xmlrpc │ ├── Makefile.am │ ├── client.cpp │ ├── clientimpl.cpp │ ├── clientimpl.h │ ├── formatter.cpp │ ├── httpclient.cpp │ ├── httpclientimpl.cpp │ ├── httpclientimpl.h │ ├── responder.cpp │ ├── scanner.cpp │ └── service.cpp ├── test ├── .gitignore ├── Makefile.am ├── MyApp.pm ├── arg-test.cpp ├── base64-test.cpp ├── binrpc-test.cpp ├── binserializer-test.cpp ├── cache-test.cpp ├── cgitest.cpp ├── char-test.cpp ├── clock-test.cpp ├── color.h ├── convert-test.cpp ├── csvdeserializer-test.cpp ├── csvserializer-test.cpp ├── date-test.cpp ├── datetime-test.cpp ├── directory-test.cpp ├── envsubst-test.cpp ├── eventloop-test.cpp ├── file-test.cpp ├── fileinfo-test.cpp ├── inifile-test.cpp ├── iniparser-test.cpp ├── iniserialization-test.cpp ├── iso8859_1-test.cpp ├── iso8859_15-test.cpp ├── join-test.cpp ├── json-test.cpp ├── jsondeserializer-test.cpp ├── jsonechoclient.pl ├── jsonechoserver.pl ├── jsonrpc-test.cpp ├── jsonrpchttp-test.cpp ├── jsonserializer-test.cpp ├── limitstream-test.cpp ├── logbench.cpp ├── logconfiguration-test.cpp ├── lrucache-test.cpp ├── md5-test.cpp ├── mime-test.cpp ├── net-test.cpp ├── pool-test.cpp ├── properties-test.cpp ├── propertiesserializer-test.cpp ├── ptrstream-test.cpp ├── query_params-test.cpp ├── query_params_test.cpp ├── quotedprintable-test.cpp ├── regex-test.cpp ├── rpcbenchasyncclient.cpp ├── rpcbenchclient.cpp ├── rpcbenchserver.cpp ├── scopedincrement-test.cpp ├── serialization-test.cpp ├── serializationinfo-test.cpp ├── serializer-bench.cpp ├── sipath-test.cpp ├── split-test.cpp ├── string-test.cpp ├── tcpsockettest.cpp ├── test-main.cpp ├── time-test.cpp ├── timespan-test.cpp ├── trim-test.cpp ├── tz-test.cpp ├── uri-test.cpp ├── utf8-test.cpp ├── win1252-test.cpp ├── xmldeserializer-test.cpp ├── xmlreader-test.cpp ├── xmlrpc-test.cpp ├── xmlrpccallback-test.cpp └── xmlserializer-test.cpp ├── tools ├── Makefile.am ├── cxxtz.cpp └── siconvert.cpp └── utils ├── function-tpp.pl ├── git2changelog.pl ├── remoteprocedure.pl ├── rpcservice.pl ├── serviceprocedure.pl ├── setLicense.pl └── signal-tpp.pl /.gitignore: -------------------------------------------------------------------------------- 1 | # Files generated by autoconf, automake and libtool 2 | 3 | /INSTALL 4 | /aclocal.m4 5 | /autom4te.cache 6 | /compile 7 | /config.guess 8 | /config.sub 9 | /configure 10 | /depcomp 11 | /install-sh 12 | /ltmain.sh 13 | /missing 14 | /build 15 | /.vscode 16 | 17 | /m4/*.m4 18 | !/m4/acx_pthread.m4 19 | !/m4/ax_check_compile_flag.m4 20 | !/m4/ax_compiler_vendor.m4 21 | !/m4/ax_cxx_compile_stdcxx_11.m4 22 | 23 | **/src/config.h 24 | **/src/config.h.in 25 | **/include/cxxtools/config.h 26 | 27 | Makefile.in 28 | Makefile 29 | config.log 30 | config.status 31 | libtool 32 | stamp-h1 33 | 34 | .deps 35 | .libs 36 | 37 | # Files generated or compiled in the build process 38 | 39 | cxxtools-config 40 | 41 | **/tools/siconvert 42 | **/tools/cxxtz 43 | 44 | *.l[ao] 45 | *.o 46 | *.pc 47 | *.swp 48 | 49 | # Other 50 | 51 | *~ 52 | .dirstamp 53 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Tommi Mäkitalo 2 | Marc Boris Dürner 3 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maekitalo/cxxtools/01f47a335ba4765677256ea6067b6bcb989e46d4/ChangeLog -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | if MAKE_DEMOS 4 | DEMO_DIR = demo demo/async demo/ssl 5 | endif 6 | 7 | if MAKE_UNITTEST 8 | UNITTEST_DIR = test 9 | endif 10 | 11 | SUBDIRS = src \ 12 | src/unit \ 13 | src/http \ 14 | src/xmlrpc \ 15 | src/bin \ 16 | src/json \ 17 | include \ 18 | tools \ 19 | doc \ 20 | $(DEMO_DIR) $(UNITTEST_DIR) 21 | 22 | pkgconfigdir = $(libdir)/pkgconfig/ 23 | 24 | pkgconfig_DATA = pkgconfig/cxxtools-bin.pc \ 25 | pkgconfig/cxxtools-http.pc \ 26 | pkgconfig/cxxtools-json.pc \ 27 | pkgconfig/cxxtools.pc \ 28 | pkgconfig/cxxtools-unit.pc \ 29 | pkgconfig/cxxtools-xmlrpc.pc 30 | 31 | EXTRA_DIST = README.md 32 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maekitalo/cxxtools/01f47a335ba4765677256ea6067b6bcb989e46d4/NEWS -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | see README.md 2 | -------------------------------------------------------------------------------- /README.git: -------------------------------------------------------------------------------- 1 | Installation from git 2 | ===================== 3 | 4 | In the git-repository there is no configure-script, but configure.ac, 5 | which is the source for configure. You need autoconf, automake and libtool 6 | to create configure. 7 | 8 | Run `autoreconf -i` to generate a configure script. 9 | -------------------------------------------------------------------------------- /cxxtools.spec: -------------------------------------------------------------------------------- 1 | Name: cxxtools 2 | Summary: some useful C++-classes 3 | Version: 1.4.4 4 | Release: 1 5 | License: GPL 6 | Group: Development/Languages/C and C++ 7 | Url: http://www.tntnet.org 8 | Source: http://www.tntnet.org/download/cxxtools-%{version}.tar.gz 9 | BuildRoot: %{_tmppath}/%{name}-%{version}-build 10 | 11 | %description 12 | some useful C++-casses: 13 | arg - template-class for argc/argv-parsing 14 | tcp::Stream - socket-library with std::iostream-interface 15 | dlloader - C++-interface for dlopen/dlsym 16 | query_params - CGI-parameter-class with parser 17 | thread - C++-pthread-wrapper 18 | tee - doubles a ostream-output 19 | hdstream - ostream-hexdumper 20 | iconvstream - ostream-interface to iconv(3) (codeset conversion) 21 | md5stream - ostream for md5-calculation 22 | dynbuffer - dynamic buffer 23 | 24 | Authors: 25 | -------- 26 | Tommi Maekitalo 27 | 28 | %package devel 29 | Summary: Include Files and Libraries mandatory for Development. 30 | Group: Development/Languages/C and C++ 31 | Requires: cxxtools = %{version} 32 | 33 | %description devel 34 | This package contains all necessary include files and libraries needed 35 | to develop applications that require the provided includes and 36 | libraries. 37 | 38 | Authors: 39 | -------- 40 | Tommi Maekitalo 41 | 42 | %prep 43 | %setup 44 | 45 | %build 46 | CFLAGS="$RPM_OPT_FLAGS" \ 47 | ./configure --prefix=%{_prefix} --libdir=%{_libdir} --sysconfdir=/etc --disable-final 48 | make 49 | 50 | 51 | %install 52 | make MANDIR=%{buildroot}%{_mandir} \ 53 | BINDIR=%{buildroot}%{_sbindir} \ 54 | DESTDIR=$RPM_BUILD_ROOT \ 55 | install 56 | rm %{buildroot}%{_libdir}/libcxxtools.la 57 | 58 | %clean 59 | rm -rf $RPM_BUILD_ROOT 60 | 61 | %files 62 | %defattr(-,root,root) 63 | %{_libdir}/lib*.so* 64 | 65 | %files devel 66 | %{_libdir}/lib*.a 67 | %{_includedir}/cxxtools/*.h 68 | %{_includedir}/cxxtools/log/*.h 69 | 70 | %changelog 71 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | arg 2 | arg-set 3 | commandoutput 4 | cxxlog 5 | deserialization 6 | dir 7 | dlloader 8 | execLs 9 | getini 10 | hd 11 | httpclient 12 | httprequest 13 | httpserver 14 | insrv 15 | json 16 | jsonbeautify 17 | log 18 | logsh 19 | md5sum 20 | mime 21 | mime2json 22 | mimeextract 23 | mimemultipart 24 | msgclient 25 | msgserver 26 | multifstream 27 | netcat 28 | netio 29 | netmsg 30 | pipestream 31 | pool 32 | regex 33 | rpcaddclient 34 | rpcasyncaddclient 35 | rpcechoclient 36 | rpcparallelecho 37 | rpcserver 38 | saml2 39 | serialization 40 | signals 41 | splitter 42 | sslshowcert 43 | tcpsocket 44 | timer 45 | timer-lambda 46 | uuencode 47 | xmlmsgclient 48 | xmlmsgserver 49 | xmlreader 50 | ssl/rpcbserver 51 | ssl/rpcjserver 52 | ssl/rpcJserver 53 | ssl/rpcxserver 54 | ssl/rpcbecho 55 | ssl/rpcjecho 56 | ssl/rpcJecho 57 | ssl/rpcxecho 58 | async/server 59 | dynamicrpc 60 | dynamiccall 61 | rpcproxy 62 | -------------------------------------------------------------------------------- /demo/async/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = \ 2 | server 3 | 4 | server_SOURCES = \ 5 | server.cpp 6 | 7 | server_LDADD = $(top_builddir)/src/libcxxtools.la 8 | 9 | AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/include -I$(top_srcdir)/include 10 | -------------------------------------------------------------------------------- /demo/async/README.md: -------------------------------------------------------------------------------- 1 | Server 2 | ====== 3 | 4 | This demo implements a server, which can handle multiple simultaneous clients. 5 | It handles all input and output asynchronously in a single thread. 6 | 7 | This server just echos all input back to the client. 8 | 9 | You can test it using the nc tool like this: 10 | 11 | nc localhost 7000 30 | #include 31 | 32 | // example for starting a sub process and reading its output through a stream 33 | // 34 | int main(int argc, char* argv[]) 35 | { 36 | try 37 | { 38 | // create a class of type CommandOutput 39 | cxxtools::posix::CommandOutput ls("ls"); 40 | 41 | // add some parameters 42 | ls.push_back("-l"); 43 | ls.push_back("/bin"); 44 | 45 | // run the process 46 | ls.run(); 47 | 48 | // read the output of the process (copy it to std::cout here) 49 | std::cout << ls.rdbuf(); 50 | } 51 | catch (const std::exception& e) 52 | { 53 | std::cerr << e.what() << std::endl; 54 | } 55 | } 56 | 57 | -------------------------------------------------------------------------------- /demo/dynamiccall.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | try 10 | { 11 | log_init(argc, argv); 12 | 13 | cxxtools::Arg ip(argc, argv, 'i'); 14 | cxxtools::Arg port(argc, argv, 'p', 7003); 15 | 16 | cxxtools::bin::RpcClient client(ip, port); 17 | cxxtools::RemoteProcedureVa proc(client, "proc"); 18 | 19 | proc(17, 24); 20 | proc("Hi"); 21 | proc("Hello", "World"); 22 | proc("A value", 3.14159); 23 | } 24 | catch (const std::exception& e) 25 | { 26 | std::cerr << e.what() << std::endl; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /demo/execLs.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include 30 | #include 31 | 32 | int main(int argc, char* argv[]) 33 | { 34 | try 35 | { 36 | cxxtools::posix::Exec e("ls"); 37 | e.push_back("-l"); 38 | e.exec(); 39 | 40 | /* 41 | * may be written even shorter: 42 | 43 | cxxtools::posix::Exec("ls") 44 | .push_back("-l") 45 | .exec(); 46 | */ 47 | } 48 | catch (const std::exception& e) 49 | { 50 | std::cerr << e.what() << std::endl; 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /demo/jsonbeautify.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include 30 | #include 31 | 32 | int main(int argc, char* argv[]) 33 | { 34 | try 35 | { 36 | // SerializationInfo is a generic structure, which can hold json data 37 | cxxtools::SerializationInfo si; 38 | 39 | // We read json from std::cin into our SerializationInfo 40 | std::cin >> cxxtools::Json(si); 41 | 42 | // ... and output it to std::cout with beautification set to true 43 | std::cout << cxxtools::Json(si).beautify(true); 44 | } 45 | catch (const std::exception& e) 46 | { 47 | std::cerr << e.what() << std::endl; 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /demo/md5sum.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | int main(int argc, char* argv[]) 34 | { 35 | cxxtools::Md5stream s; 36 | for (int i = 1; i < argc; ++i) 37 | { 38 | std::ifstream in(argv[i]); 39 | if (in) 40 | { 41 | // copy file to md5stream: 42 | s << in.rdbuf(); 43 | std::cout << s.getHexDigest() << " " << argv[i] << std::endl; 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /demo/msg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef MSG_H 30 | #define MSG_H 31 | 32 | #include 33 | 34 | struct Msg 35 | { 36 | int value; 37 | std::string str; 38 | 39 | Msg() { } 40 | Msg(int v, const std::string& s) 41 | : value(v), 42 | str(s) 43 | { } 44 | }; 45 | 46 | inline void operator<<= (cxxtools::SerializationInfo& si, const Msg& msg) 47 | { 48 | si.setTypeName("Msg"); 49 | si.addMember("value") <<= msg.value; 50 | si.addMember("str") <<= msg.str; 51 | } 52 | 53 | inline void operator>>= (const cxxtools::SerializationInfo& si, Msg& msg) 54 | { 55 | si.getMember("value") >>= msg.value; 56 | si.getMember("str") >>= msg.str; 57 | } 58 | 59 | #endif // MSG_H 60 | 61 | -------------------------------------------------------------------------------- /demo/multifstream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | 30 | #include 31 | #include 32 | 33 | int main(int argc, char* argv[]) 34 | { 35 | try 36 | { 37 | cxxtools::multi_ifstream in; 38 | for (int a = 1; a < argc; ++a) 39 | in.add_pattern(argv[a]); 40 | 41 | std::cout << in.rdbuf(); 42 | } 43 | catch (const std::exception& e) 44 | { 45 | std::cerr << e.what() << std::endl; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /demo/regex.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include 30 | #include 31 | 32 | int main(int argc, char* argv[]) 33 | { 34 | try 35 | { 36 | static cxxtools::Regex checkIpV4("^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)$"); 37 | for (int a = 1; a < argc; ++a) 38 | { 39 | cxxtools::RegexSMatch m; 40 | if (checkIpV4.match(argv[a], m)) 41 | { 42 | std::cout << argv[a] << " is a ipv4 address with components " << m[1] << " . " << m[2] << " . " << m[3] << " . " << m[4] << std::endl; 43 | } 44 | else 45 | { 46 | std::cout << argv[a] << " is not a ipv4 address" << std::endl; 47 | } 48 | } 49 | } 50 | catch (const std::exception& e) 51 | { 52 | std::cerr << e.what() << std::endl; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /demo/rpcgenericclient.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int main(int argc, char* argv[]) 10 | { 11 | try 12 | { 13 | log_init(argc, argv); 14 | 15 | cxxtools::Arg ip(argc, argv, 'i'); 16 | cxxtools::Arg port(argc, argv, 'p', 7003); 17 | cxxtools::Arg ssl(argc, argv, 's'); 18 | cxxtools::Arg secureSsl(argc, argv, 'S'); 19 | cxxtools::Arg json(argc, argv, 'j'); 20 | cxxtools::Arg ciphers(argc, argv, 'C'); 21 | cxxtools::Arg domain(argc, argv, 'D'); 22 | 23 | if (argc <= 1) 24 | { 25 | std::cerr << "usage: " << argv[0] << " {option} function {parameters}\n" 26 | "Options:\n" 27 | " -j pass parameters in json format\n"; 28 | return 1; 29 | } 30 | 31 | cxxtools::SslCtx sslCtx; 32 | if (secureSsl) 33 | sslCtx = cxxtools::SslCtx::secure(); 34 | else if (ssl) 35 | sslCtx = cxxtools::SslCtx::standard(); 36 | 37 | cxxtools::bin::RpcClient client(ip, port, sslCtx); 38 | client.domain(domain); 39 | 40 | auto function = argv[1]; 41 | 42 | std::vector parameters; 43 | for (int a = 2; a < argc; ++a) 44 | { 45 | parameters.emplace_back(); 46 | if (json) 47 | { 48 | std::istringstream p(argv[a]); 49 | p >> cxxtools::Json(parameters.back()); 50 | } 51 | else 52 | { 53 | parameters.back() <<= argv[a]; 54 | } 55 | } 56 | 57 | cxxtools::RemoteProcedureVa proc(client, function); 58 | auto result = proc(parameters); 59 | std::cout << cxxtools::Json(result).beautify(true) << std::endl; 60 | } 61 | catch (const std::exception& e) 62 | { 63 | std::cerr << e.what() << std::endl; 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /demo/ssl/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_PROGRAMS = rpcbserver rpcjserver rpcJserver rpcxserver rpcbecho rpcjecho rpcJecho rpcxecho 2 | rpcbserver_SOURCES = rpcbserver.cpp 3 | rpcbserver_LDADD=$(top_builddir)/src/libcxxtools.la $(top_builddir)/src/bin/libcxxtools-bin.la 4 | 5 | rpcjserver_SOURCES = rpcjserver.cpp 6 | rpcjserver_LDADD=$(top_builddir)/src/libcxxtools.la $(top_builddir)/src/http/libcxxtools-http.la $(top_builddir)/src/json/libcxxtools-json.la 7 | 8 | rpcJserver_SOURCES = rpcJserver.cpp 9 | rpcJserver_LDADD=$(top_builddir)/src/libcxxtools.la $(top_builddir)/src/http/libcxxtools-http.la $(top_builddir)/src/json/libcxxtools-json.la 10 | 11 | rpcxserver_SOURCES = rpcxserver.cpp 12 | rpcxserver_LDADD=$(top_builddir)/src/libcxxtools.la $(top_builddir)/src/http/libcxxtools-http.la $(top_builddir)/src/xmlrpc/libcxxtools-xmlrpc.la 13 | 14 | rpcbecho_SOURCES = rpcbecho.cpp 15 | rpcbecho_LDADD=$(top_builddir)/src/libcxxtools.la $(top_builddir)/src/bin/libcxxtools-bin.la 16 | 17 | rpcjecho_SOURCES = rpcjecho.cpp 18 | rpcjecho_LDADD=$(top_builddir)/src/libcxxtools.la $(top_builddir)/src/http/libcxxtools-http.la $(top_builddir)/src/json/libcxxtools-json.la 19 | 20 | rpcJecho_SOURCES = rpcJecho.cpp 21 | rpcJecho_LDADD=$(top_builddir)/src/libcxxtools.la $(top_builddir)/src/http/libcxxtools-http.la $(top_builddir)/src/json/libcxxtools-json.la 22 | 23 | rpcxecho_SOURCES = rpcxecho.cpp 24 | rpcxecho_LDADD=$(top_builddir)/src/libcxxtools.la $(top_builddir)/src/http/libcxxtools-http.la $(top_builddir)/src/xmlrpc/libcxxtools-xmlrpc.la 25 | 26 | AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/include -I$(top_srcdir)/include 27 | -------------------------------------------------------------------------------- /demo/ssl/rpcJecho.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | //////////////////////////////////////////////////////////////////////// 9 | // main 10 | // 11 | int main(int argc, char* argv[]) 12 | { 13 | try 14 | { 15 | log_init(argc, argv); 16 | 17 | cxxtools::Arg ip(argc, argv, 'i'); 18 | cxxtools::Arg port(argc, argv, 'p', 7002); 19 | cxxtools::Arg cert(argc, argv, 'c'); 20 | cxxtools::Arg ca(argc, argv, 'C'); 21 | 22 | cxxtools::SslCtx sslCtx; 23 | 24 | if (cert.isSet()) 25 | sslCtx.loadCertificateFile(cert); 26 | 27 | if (ca.isSet()) 28 | sslCtx.setVerify(cxxtools::SslCtx::VERIFY_LEVEL::REQUIRE, ca); 29 | 30 | cxxtools::json::HttpClient client(ip, port, "/jsonrpc", sslCtx); 31 | 32 | cxxtools::RemoteProcedure echo(client, "echo"); 33 | 34 | for (int a = 1; a < argc; ++a) 35 | { 36 | std::string v = echo(argv[a]); 37 | std::cout << v << '\n'; 38 | } 39 | } 40 | catch (const std::exception& e) 41 | { 42 | std::cerr << e.what() << std::endl; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /demo/ssl/rpcJserver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Tommi Maekitalo 3 | * 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | bool doAccept(const cxxtools::SslCertificate& cert) 16 | { 17 | std::cout << "cert \"" << cert.getSubject() << "\" accepted" << std::endl; 18 | return true; 19 | } 20 | 21 | bool noAccept(const cxxtools::SslCertificate& cert) 22 | { 23 | std::cout << "cert \"" << cert.getSubject() << "\" not accepted" << std::endl; 24 | return false; 25 | } 26 | 27 | std::string echo(const std::string& msg) 28 | { 29 | return msg; 30 | } 31 | 32 | int add(int a, int b) 33 | { 34 | return a + b; 35 | } 36 | 37 | int main(int argc, char* argv[]) 38 | { 39 | try 40 | { 41 | log_init(argc, argv); 42 | cxxtools::Arg ip(argc, argv, 'i'); 43 | cxxtools::Arg port(argc, argv, 'j', 7002); 44 | cxxtools::Arg cert(argc, argv, 'c'); 45 | cxxtools::Arg ca(argc, argv, 'C', "ca.crt"); 46 | cxxtools::Arg deny(argc, argv, 'd'); 47 | cxxtools::Arg nodeny(argc, argv, 'D'); 48 | 49 | cxxtools::EventLoop loop; 50 | 51 | cxxtools::SslCtx sslCtx; 52 | 53 | if (cert.isSet()) 54 | sslCtx.loadCertificateFile(cert); 55 | 56 | sslCtx.setVerify(cxxtools::SslCtx::VERIFY_LEVEL::REQUIRE, ca); 57 | 58 | cxxtools::http::Server server(loop, ip, port, sslCtx); 59 | 60 | cxxtools::json::HttpService service; 61 | service.registerFunction("echo", echo); 62 | service.registerFunction("add", add); 63 | 64 | server.addService("/jsonrpc", service); 65 | 66 | if (deny) 67 | cxxtools::connect(server.acceptSslCertificate(), noAccept); 68 | else if (nodeny) 69 | cxxtools::connect(server.acceptSslCertificate(), doAccept); 70 | 71 | loop.run(); 72 | } 73 | catch (const std::exception& e) 74 | { 75 | std::cerr << e.what() << std::endl; 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /demo/ssl/rpcbecho.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | //////////////////////////////////////////////////////////////////////// 9 | // main 10 | // 11 | int main(int argc, char* argv[]) 12 | { 13 | try 14 | { 15 | log_init(argc, argv); 16 | 17 | cxxtools::Arg ip(argc, argv, 'i'); 18 | cxxtools::Arg port(argc, argv, 'p', 7003); 19 | cxxtools::Arg cert(argc, argv, 'c'); 20 | cxxtools::Arg ca(argc, argv, 'C'); 21 | 22 | cxxtools::SslCtx sslCtx; 23 | 24 | if (cert.isSet()) 25 | sslCtx.loadCertificateFile(cert); 26 | 27 | if (ca.isSet()) 28 | sslCtx.setVerify(cxxtools::SslCtx::VERIFY_LEVEL::REQUIRE, ca); 29 | 30 | cxxtools::bin::RpcClient client(ip, port, sslCtx); 31 | 32 | cxxtools::RemoteProcedure echo(client, "echo"); 33 | 34 | for (int a = 1; a < argc; ++a) 35 | { 36 | std::string v = echo(argv[a]); 37 | std::cout << v << '\n'; 38 | } 39 | } 40 | catch (const std::exception& e) 41 | { 42 | std::cerr << e.what() << std::endl; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /demo/ssl/rpcbserver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Tommi Maekitalo 3 | * 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | bool doAccept(const cxxtools::SslCertificate& cert) 15 | { 16 | std::cout << "cert \"" << cert.getSubject() << "\" accepted" << std::endl; 17 | return true; 18 | } 19 | 20 | bool noAccept(const cxxtools::SslCertificate& cert) 21 | { 22 | std::cout << "cert \"" << cert.getSubject() << "\" not accepted" << std::endl; 23 | return false; 24 | } 25 | 26 | std::string echo(const std::string& msg) 27 | { 28 | return msg; 29 | } 30 | 31 | int add(int a, int b) 32 | { 33 | return a + b; 34 | } 35 | 36 | int main(int argc, char* argv[]) 37 | { 38 | try 39 | { 40 | log_init(argc, argv); 41 | cxxtools::Arg ip(argc, argv, 'i'); 42 | cxxtools::Arg port(argc, argv, 'j', 7003); 43 | cxxtools::Arg cert(argc, argv, 'c'); 44 | cxxtools::Arg ca(argc, argv, 'C', "ca.crt"); 45 | cxxtools::Arg deny(argc, argv, 'd'); 46 | cxxtools::Arg nodeny(argc, argv, 'D'); 47 | 48 | cxxtools::EventLoop loop; 49 | 50 | cxxtools::SslCtx sslCtx; 51 | 52 | if (cert.isSet()) 53 | sslCtx.loadCertificateFile(cert); 54 | 55 | sslCtx.setVerify(cxxtools::SslCtx::VERIFY_LEVEL::REQUIRE, ca); 56 | 57 | cxxtools::bin::RpcServer server(loop, ip, port, sslCtx); 58 | server.registerFunction("echo", echo); 59 | server.registerFunction("add", add); 60 | 61 | if (deny) 62 | cxxtools::connect(server.acceptSslCertificate(), noAccept); 63 | else if (nodeny) 64 | cxxtools::connect(server.acceptSslCertificate(), doAccept); 65 | 66 | loop.run(); 67 | } 68 | catch (const std::exception& e) 69 | { 70 | std::cerr << e.what() << std::endl; 71 | } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /demo/ssl/rpcjecho.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | //////////////////////////////////////////////////////////////////////// 9 | // main 10 | // 11 | int main(int argc, char* argv[]) 12 | { 13 | try 14 | { 15 | log_init(argc, argv); 16 | 17 | cxxtools::Arg ip(argc, argv, 'i'); 18 | cxxtools::Arg port(argc, argv, 'p', 7004); 19 | cxxtools::Arg cert(argc, argv, 'c'); 20 | cxxtools::Arg ca(argc, argv, 'C'); 21 | 22 | cxxtools::SslCtx sslCtx; 23 | 24 | if (cert.isSet()) 25 | sslCtx.loadCertificateFile(cert); 26 | 27 | if (ca.isSet()) 28 | sslCtx.setVerify(cxxtools::SslCtx::VERIFY_LEVEL::REQUIRE, ca); 29 | 30 | cxxtools::json::RpcClient client(ip, port, sslCtx); 31 | 32 | cxxtools::RemoteProcedure echo(client, "echo"); 33 | 34 | for (int a = 1; a < argc; ++a) 35 | { 36 | std::string v = echo(argv[a]); 37 | std::cout << v << '\n'; 38 | } 39 | } 40 | catch (const std::exception& e) 41 | { 42 | std::cerr << e.what() << std::endl; 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /demo/ssl/rpcjserver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Tommi Maekitalo 3 | * 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | bool doAccept(const cxxtools::SslCertificate& cert) 15 | { 16 | std::cout << "cert \"" << cert.getSubject() << "\" accepted" << std::endl; 17 | return true; 18 | } 19 | 20 | bool noAccept(const cxxtools::SslCertificate& cert) 21 | { 22 | std::cout << "cert \"" << cert.getSubject() << "\" not accepted" << std::endl; 23 | return false; 24 | } 25 | 26 | std::string echo(const std::string& msg) 27 | { 28 | return msg; 29 | } 30 | 31 | int add(int a, int b) 32 | { 33 | return a + b; 34 | } 35 | 36 | int main(int argc, char* argv[]) 37 | { 38 | try 39 | { 40 | log_init(argc, argv); 41 | cxxtools::Arg ip(argc, argv, 'i'); 42 | cxxtools::Arg port(argc, argv, 'j', 7004); 43 | cxxtools::Arg cert(argc, argv, 'c'); 44 | cxxtools::Arg ca(argc, argv, 'C', "ca.crt"); 45 | cxxtools::Arg deny(argc, argv, 'd'); 46 | cxxtools::Arg nodeny(argc, argv, 'D'); 47 | 48 | cxxtools::EventLoop loop; 49 | 50 | cxxtools::SslCtx sslCtx; 51 | 52 | if (cert.isSet()) 53 | sslCtx.loadCertificateFile(cert); 54 | 55 | sslCtx.setVerify(cxxtools::SslCtx::VERIFY_LEVEL::REQUIRE, ca); 56 | 57 | cxxtools::json::RpcServer server(loop, ip, port, sslCtx); 58 | server.registerFunction("echo", echo); 59 | server.registerFunction("add", add); 60 | 61 | if (deny) 62 | cxxtools::connect(server.acceptSslCertificate(), noAccept); 63 | else if (nodeny) 64 | cxxtools::connect(server.acceptSslCertificate(), doAccept); 65 | 66 | loop.run(); 67 | } 68 | catch (const std::exception& e) 69 | { 70 | std::cerr << e.what() << std::endl; 71 | } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /demo/ssl/rpcxecho.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | //////////////////////////////////////////////////////////////////////// 9 | // main 10 | // 11 | int main(int argc, char* argv[]) 12 | { 13 | try 14 | { 15 | log_init(argc, argv); 16 | 17 | cxxtools::Arg ip(argc, argv, 'i'); 18 | cxxtools::Arg port(argc, argv, 'p', 7002); 19 | cxxtools::Arg cert(argc, argv, 'c'); 20 | cxxtools::Arg ca(argc, argv, 'C'); 21 | 22 | cxxtools::SslCtx sslCtx; 23 | 24 | if (cert.isSet()) 25 | sslCtx.loadCertificateFile(cert); 26 | 27 | if (ca.isSet()) 28 | sslCtx.setVerify(cxxtools::SslCtx::VERIFY_LEVEL::REQUIRE, ca); 29 | 30 | cxxtools::xmlrpc::HttpClient client(ip, port, "/xmlrpc", sslCtx); 31 | 32 | cxxtools::RemoteProcedure echo(client, "echo"); 33 | 34 | for (int a = 1; a < argc; ++a) 35 | { 36 | std::string v = echo(argv[a]); 37 | std::cout << v << '\n'; 38 | } 39 | } 40 | catch (const std::exception& e) 41 | { 42 | std::cerr << e.what() << std::endl; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /demo/ssl/rpcxserver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Tommi Maekitalo 3 | * 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | bool doAccept(const cxxtools::SslCertificate& cert) 16 | { 17 | std::cout << "cert \"" << cert.getSubject() << "\" accepted" << std::endl; 18 | return true; 19 | } 20 | 21 | bool noAccept(const cxxtools::SslCertificate& cert) 22 | { 23 | std::cout << "cert \"" << cert.getSubject() << "\" not accepted" << std::endl; 24 | return false; 25 | } 26 | 27 | std::string echo(const std::string& msg) 28 | { 29 | return msg; 30 | } 31 | 32 | int add(int a, int b) 33 | { 34 | return a + b; 35 | } 36 | 37 | int main(int argc, char* argv[]) 38 | { 39 | try 40 | { 41 | log_init(argc, argv); 42 | cxxtools::Arg ip(argc, argv, 'i'); 43 | cxxtools::Arg port(argc, argv, 'j', 7002); 44 | cxxtools::Arg cert(argc, argv, 'c'); 45 | cxxtools::Arg ca(argc, argv, 'C', "ca.crt"); 46 | cxxtools::Arg deny(argc, argv, 'd'); 47 | cxxtools::Arg nodeny(argc, argv, 'D'); 48 | 49 | cxxtools::EventLoop loop; 50 | 51 | cxxtools::SslCtx sslCtx; 52 | 53 | if (cert.isSet()) 54 | sslCtx.loadCertificateFile(cert); 55 | 56 | sslCtx.setVerify(cxxtools::SslCtx::VERIFY_LEVEL::REQUIRE, ca); 57 | 58 | cxxtools::http::Server server(loop, ip, port, sslCtx); 59 | 60 | cxxtools::xmlrpc::Service service; 61 | service.registerFunction("echo", echo); 62 | service.registerFunction("add", add); 63 | 64 | server.addService("/xmlrpc", service); 65 | 66 | if (deny) 67 | cxxtools::connect(server.acceptSslCertificate(), noAccept); 68 | else if (nodeny) 69 | cxxtools::connect(server.acceptSslCertificate(), doAccept); 70 | 71 | loop.run(); 72 | } 73 | catch (const std::exception& e) 74 | { 75 | std::cerr << e.what() << std::endl; 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /demo/sslshowcert.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | int main(int argc, char* argv[]) 34 | { 35 | try 36 | { 37 | log_init(argc, argv); 38 | for (int a = 1; a < argc; ++a) 39 | { 40 | cxxtools::SslCertificate cert(argv[a]); 41 | std::cout << "subject: " << cert.getSubject() << "\n" 42 | "serial: " << cert.getSerial() << "\n" 43 | "valid: " << cert.getNotBefore().toString() << " - " 44 | << cert.getNotAfter().toString() << std::endl; 45 | } 46 | } 47 | catch (const std::exception& e) 48 | { 49 | std::cerr << e.what() << std::endl; 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /demo/uuencode.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | int main(int argc, char* argv[]) 34 | { 35 | try 36 | { 37 | cxxtools::Arg fname(argc, argv, 'f'); 38 | cxxtools::Arg mode(argc, argv, 'm', 0644); 39 | 40 | cxxtools::UuencodeOstream out(std::cout); 41 | 42 | if (fname) 43 | out.begin(fname.getValue(), mode); 44 | 45 | out << std::cin.rdbuf(); 46 | } 47 | catch (const std::exception& e) 48 | { 49 | std::cerr << e.what() << std::endl; 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | argument-parsing-howto.markdown \ 3 | binaryrpc-howto.markdown \ 4 | binserialization.txt \ 5 | connection.md \ 6 | csv-howto.markdown \ 7 | json-howto.markdown \ 8 | jsonquick-howto.markdown \ 9 | jsonrpc-howto.markdown \ 10 | logging-howto.markdown \ 11 | propertiesquick-howto.markdown \ 12 | rpc-howto.markdown \ 13 | serialization-howto.markdown \ 14 | timezone-howto.markdown \ 15 | xmlrpc-howto.markdown 16 | -------------------------------------------------------------------------------- /doc/asyncronousIO.md: -------------------------------------------------------------------------------- 1 | Asyncronous I/O with cxxtools {#asyncronousIO} 2 | ============================= 3 | -------------------------------------------------------------------------------- /doc/connection.md: -------------------------------------------------------------------------------- 1 | Handling connections in cxxtools {#connection} 2 | ================================ 3 | 4 | There are several classes, which implements higher level protocols on top of 5 | TCP/IP. They are: 6 | 7 | * `cxxtools::http::Client` 8 | * `cxxtools::xmlrpc::HttpClient` 9 | * `cxxtools::json::RpcClient` 10 | * `cxxtools::json::HttpClient` 11 | * `cxxtools::bin::RpcClient` 12 | 13 | All classes handle the connection to the server the same way. 14 | 15 | To connect to a server all need at least a IP address and a port. The classes 16 | all can be either default constructed or initialized with the constructor. When 17 | default constructed the user have to call the `connect` method before they are 18 | usable. For each `connect` variant there is a constructor, which calls `connect` 19 | on initialization. 20 | 21 | By default the `connect` method do not actually do a network connection. Hence 22 | the method never fails (except on memory overflow). The method just stores the 23 | connection parameters for later use. 24 | 25 | When a actual request is to be done, the class checks, whether it has already a 26 | network connection. When not, it connects to the remote site before sending the 27 | actual request. If the connection fails, the request throws an exception. 28 | 29 | The connection is kept open until the class is destroyed or the `connect` method 30 | is called to change the connection parameters. 31 | 32 | If it has already a connection, it just uses it. If the request fails, it tries 33 | to reconnect once. 34 | 35 | All `connect` methods have a additional parameter of type `bool` named 36 | `realConnect`. It defaults to `false` but when explicitly set to `true`, the 37 | `connect` method already connects to the server. If the connection fails, a 38 | exception is thrown. That is a good way to check, if the server is available. 39 | 40 | Note that the new connection parameters are still stored so to make the client 41 | usable you have to either change the connection parameters by calling the 42 | `connect` method or just fix the problem by e.g. starting the server. 43 | -------------------------------------------------------------------------------- /doc/timezone-howto.markdown: -------------------------------------------------------------------------------- 1 | Timezone howto 2 | ============== 3 | 4 | Cxxtools offers a class for handling time zones. The main task 5 | is to convert a datetime from UTC to a time zone or back. 6 | 7 | Cxxtools has already a class cxxtools:DateTime, which represents 8 | obviously a date and a time. From that 2 classes LocalDateTime 9 | and UtcDateTime are derived, which do not add any functionality 10 | but offsers a little safety. In addition a class TzDateTime, 11 | which is derived from LocalDateTime adds the time zone information 12 | to the class. 13 | 14 | The class cxxtools cxxtools::Tz uses the system time zone database 15 | to convert the datetimes between UTC and time zone. 16 | 17 | The default constructor of Tz initializes it with the system 18 | time zone. Optionally a different time zone can be passed as 19 | a parameter. 20 | 21 | The most important methods in Tz are toLocal and toUtc. 22 | 23 | A very simple example is here: 24 | 25 | cxxtools::Tz myTimezone; 26 | cxxtools::Tz nauruTimezone("Pacific/Nauru"); 27 | 28 | auto localtime = cxxtools::DateTime::localtime(); 29 | std::cout << "current local time " << localtime.toString() << std::endl; 30 | auto utctime = myTimezone.toUtc(localtime); 31 | std::cout << "current utc time " << utctime.toString() << std::endl; 32 | 33 | auto naurutime = nauruTimezone.toLocal(utctime); 34 | std::cuot << "time at nauru: " << naurutime.toString() << std::endl; 35 | -------------------------------------------------------------------------------- /include/cxxtools/callable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2008 by Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef cxxtools_Callable_h 29 | #define cxxtools_Callable_h 30 | 31 | #include 32 | 33 | namespace cxxtools { 34 | 35 | #include 36 | 37 | } // namespace cxxtools 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /include/cxxtools/config.h.in: -------------------------------------------------------------------------------- 1 | /** defines, whether c++ locales are supported */ 2 | #define @CXXTOOLS_STD_LOCALE@ 3 | 4 | /** defines, whether type long long exists */ 5 | #define @HAVE_LONG_LONG@ 6 | 7 | /** defines, whether type unsigned long long exists */ 8 | #define @HAVE_UNSIGNED_LONG_LONG@ 9 | 10 | /* defined if std::reverse_iterator is defined */ 11 | #define @HAVE_REVERSE_ITERATOR@ 12 | 13 | /* defined if std::reverse_iterator is defined */ 15 | #define @HAVE_REVERSE_ITERATOR_4@ 16 | -------------------------------------------------------------------------------- /include/cxxtools/constmethod.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2007 by Dr. Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef cxxtools_ConstMethod_h 29 | #define cxxtools_ConstMethod_h 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | namespace cxxtools { 36 | 37 | #include 38 | 39 | } // !namespace cxxtools 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/cxxtools/conversionerror.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004-2007 by Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_CONVERSINERROR_H 29 | #define CXXTOOLS_CONVERSINERROR_H 30 | 31 | #include 32 | #include 33 | 34 | namespace cxxtools 35 | { 36 | 37 | class ConversionError : public std::runtime_error 38 | { 39 | public: 40 | explicit ConversionError(const std::string& msg); 41 | 42 | ~ConversionError() throw() 43 | {} 44 | 45 | static void doThrow(const char* typeto, const char* typefrom); 46 | static void doThrow(const char* typeto, const char* typefrom, const char* valuefrom); 47 | 48 | }; 49 | 50 | } // namespace cxxtools 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /include/cxxtools/dlloader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef CXXTOOLS_DLLOADER_H 30 | #define CXXTOOLS_DLLOADER_H 31 | 32 | #include 33 | 34 | namespace cxxtools 35 | { 36 | /// @deprecated 37 | namespace dl 38 | { 39 | using cxxtools::Library; 40 | using cxxtools::Symbol; 41 | } 42 | } 43 | 44 | #endif // CXXTOOLS_DLLOADER_H 45 | 46 | -------------------------------------------------------------------------------- /include/cxxtools/function.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 by Dr. Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef cxxtools_Function_h 29 | #define cxxtools_Function_h 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | namespace cxxtools { 37 | 38 | #include 39 | 40 | } // !namespace cxxtools 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/cxxtools/invokable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2007 by Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef cxxtools_Invokable_h 30 | #define cxxtools_Invokable_h 31 | 32 | #include 33 | 34 | namespace cxxtools { 35 | 36 | #include 37 | 38 | } // namespace cxxtools 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_10codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_10CODEC_H 29 | #define CXXTOOLS_ISO8859_10CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_10Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_10Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_11codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_11CODEC_H 29 | #define CXXTOOLS_ISO8859_11CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_11Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_11Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_13codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_13CODEC_H 29 | #define CXXTOOLS_ISO8859_13CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_13Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_13Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_14codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_14CODEC_H 29 | #define CXXTOOLS_ISO8859_14CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_14Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_14Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_1codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_1CODEC_H 29 | #define CXXTOOLS_ISO8859_1CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_1Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_1Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_2codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_2CODEC_H 29 | #define CXXTOOLS_ISO8859_2CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_2Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_2Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_3codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_3CODEC_H 29 | #define CXXTOOLS_ISO8859_3CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_3Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_3Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_4codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_4CODEC_H 29 | #define CXXTOOLS_ISO8859_4CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_4Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_4Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_5codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_5CODEC_H 29 | #define CXXTOOLS_ISO8859_5CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_5Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_5Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_6codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_6CODEC_H 29 | #define CXXTOOLS_ISO8859_6CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_6Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_6Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_7codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_7CODEC_H 29 | #define CXXTOOLS_ISO8859_7CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_7Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_7Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_8codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_8CODEC_H 29 | #define CXXTOOLS_ISO8859_8CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_8Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_8Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/iso8859_9codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_ISO8859_9CODEC_H 29 | #define CXXTOOLS_ISO8859_9CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Iso8859_9Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Iso8859_9Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | 52 | } //namespace cxxtools 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/cxxtools/json/httpservice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 by Tommi Meakitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_JSON_SERVICE_H 29 | #define CXXTOOLS_JSON_SERVICE_H 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | namespace cxxtools 36 | { 37 | 38 | namespace json 39 | { 40 | 41 | class HttpService : public http::Service, public ServiceRegistry 42 | { 43 | friend class Responder; 44 | 45 | public: 46 | HttpService() 47 | { } 48 | 49 | virtual ~HttpService(); 50 | 51 | protected: 52 | virtual http::Responder* createResponder(const http::Request&); 53 | 54 | virtual void releaseResponder(http::Responder* resp); 55 | 56 | }; 57 | 58 | } 59 | 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/cxxtools/json/request.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef CXXTOOLS_JSON_REQUEST_H 30 | #define CXXTOOLS_JSON_REQUEST_H 31 | 32 | namespace cxxtools 33 | { 34 | namespace json 35 | { 36 | class Request 37 | { 38 | friend void operator<<= (SerializationInfo& si, const Request& r); 39 | friend void operator>>= (const SerializationInfo& si, Request& r); 40 | 41 | public: 42 | Request(); 43 | 44 | private: 45 | std::string _method; 46 | std::string _id; 47 | }; 48 | 49 | void operator<<= (SerializationInfo& si, const Request& r); 50 | void operator>>= (const SerializationInfo& si, Request& r); 51 | 52 | } 53 | } 54 | 55 | #endif // CXXTOOLS_JSON_REQUEST_H 56 | -------------------------------------------------------------------------------- /include/cxxtools/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef CXXTOOLS_LOG_H 30 | #define CXXTOOLS_LOG_H 31 | 32 | #include 33 | 34 | #endif // CXXTOOLS_LOG_H 35 | -------------------------------------------------------------------------------- /include/cxxtools/loginit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef CXXTOOLS_LOGINIT_H 30 | #define CXXTOOLS_LOGINIT_H 31 | 32 | #include 33 | 34 | #endif // CXXTOOLS_LOGINIT_H 35 | -------------------------------------------------------------------------------- /include/cxxtools/method.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 by Dr. Marc Boris Drner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef cxxtools_Method_h 29 | #define cxxtools_Method_h 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | namespace cxxtools { 36 | 37 | #include 38 | 39 | } // !namespace cxxtools 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /include/cxxtools/posix/daemonize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef CXXTOOLS_POSIX_DAEMONIZE_H 30 | #define CXXTOOLS_POSIX_DAEMONIZE_H 31 | 32 | #include 33 | 34 | namespace cxxtools 35 | { 36 | namespace posix 37 | { 38 | /// This function makes a background daemon process out of the current 39 | /// process. The current process is forked twice and the 2 parents are exited, 40 | /// so that only the single child is kept. The standard input, standard output 41 | /// and standard error output are redirected to /dev/null. 42 | /// When a pidfile is passed, the pid of the child is written to that file 43 | /// and a signal handler is installed, which removes the file, when the process 44 | /// is terminated unsing SIGTERM. 45 | void daemonize(const std::string& pidfile = std::string()); 46 | } 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/cxxtools/ptrstreambuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef CXXTOOLS_PTRSTREAMBUF_H 30 | #define CXXTOOLS_PTRSTREAMBUF_H 31 | 32 | #include 33 | 34 | namespace cxxtools 35 | { 36 | 37 | template 38 | class BasicPtrStreamBuf : public std::basic_streambuf 39 | { 40 | public: 41 | BasicPtrStreamBuf(CharT* begin, CharT* end) 42 | { 43 | this->setg(begin, begin, end); 44 | this->setp(begin, end); 45 | } 46 | 47 | BasicPtrStreamBuf(CharT* begin, size_t size) 48 | { 49 | this->setg(begin, begin, begin + size); 50 | this->setp(begin, begin + size); 51 | } 52 | 53 | CharT* begin() const { return std::basic_streambuf::pbase(); } 54 | CharT* end() const { return std::basic_streambuf::pptr(); } 55 | }; 56 | 57 | typedef BasicPtrStreamBuf PtrStreamBuf; 58 | 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /include/cxxtools/slot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef cxxtools_Slot_h 29 | #define cxxtools_Slot_h 30 | 31 | #include 32 | 33 | namespace cxxtools { 34 | 35 | class Connection; 36 | 37 | class Slot { 38 | public: 39 | virtual ~Slot() {} 40 | 41 | virtual Slot* clone() const = 0; 42 | 43 | virtual const void* callable() const = 0; 44 | 45 | virtual void onConnect(const Connection& c) = 0; 46 | 47 | virtual void onDisconnect(const Connection& c) = 0; 48 | 49 | virtual bool equals(const Slot& slot) const = 0; 50 | }; 51 | 52 | #include 53 | 54 | } 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /include/cxxtools/slot.tpp: -------------------------------------------------------------------------------- 1 | // BEGIN_BasicSlot 10 2 | /** 3 | BasicSlot is a base type for various "slot" types. 4 | */ 5 | template < typename R, typename A1 = Void, typename A2 = Void, typename A3 = Void, typename A4 = Void, typename A5 = Void, typename A6 = Void, typename A7 = Void, typename A8 = Void, typename A9 = Void, typename A10 = Void> 6 | class BasicSlot : public Slot { 7 | public: 8 | /** 9 | Creates a copy of this object and returns it. The caller 10 | owns the returned object. 11 | */ 12 | virtual Slot* clone() const = 0; 13 | }; 14 | // END_BasicSlot 10 15 | -------------------------------------------------------------------------------- /include/cxxtools/unit/testcontext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2008 by Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_UNIT_TESTCONTEXT_H 29 | #define CXXTOOLS_UNIT_TESTCONTEXT_H 30 | 31 | #include 32 | #include 33 | 34 | namespace cxxtools { 35 | 36 | namespace unit { 37 | 38 | class Test; 39 | class TestFixture; 40 | 41 | class TestContext 42 | { 43 | public: 44 | virtual ~TestContext(); 45 | 46 | std::string testName() const; 47 | 48 | void run(); 49 | 50 | protected: 51 | TestContext(TestFixture& fixture, Test& test); 52 | 53 | virtual void exec() = 0; 54 | 55 | private: 56 | TestFixture& _fixture; 57 | Test& _test; 58 | bool _setUp; 59 | }; 60 | 61 | } // namespace unit 62 | 63 | } // namespace cxxtools 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /include/cxxtools/void.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2007 Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef cxxtools_void_h 30 | #define cxxtools_void_h 31 | 32 | namespace cxxtools { 33 | 34 | struct Void 35 | {}; 36 | 37 | } // namespace cxxtools 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /include/cxxtools/win1252codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_WIN1252CODEC_H 29 | #define CXXTOOLS_WIN1252CODEC_H 30 | 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class Win1252Codec : public CharMapCodec 37 | { 38 | public: 39 | explicit Win1252Codec(size_t ref = 0); 40 | 41 | static String decode(const char* data, unsigned size) 42 | { return cxxtools::decode(data, size); } 43 | static String decode(const std::string& data) 44 | { return cxxtools::decode(data); } 45 | static std::string encode(const Char* data, unsigned size) 46 | { return cxxtools::encode(data, size); } 47 | static std::string encode(const String& data) 48 | { return cxxtools::encode(data); } 49 | }; 50 | 51 | typedef Win1252Codec Win1252Codec; 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /include/cxxtools/xmlrpc/errorcodes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 by Tommi Meakitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_XMLRPC_ERRORCODES_H 29 | #define CXXTOOLS_XMLRPC_ERRORCODES_H 30 | 31 | namespace cxxtools 32 | { 33 | 34 | namespace xmlrpc 35 | { 36 | 37 | namespace ErrorCodes 38 | { 39 | static const int parseError = -32700; 40 | static const int unsupportedEncoding = -32701; 41 | static const int invalidCharacterForEncoding = -32702; 42 | static const int invalidXmlRpc = -32600; 43 | static const int methodNotFound = -32601; 44 | static const int invalidMethodParameters = -32602; 45 | static const int internalXmlRpcError = -32603; 46 | static const int applicationError = -32500; 47 | static const int systemError = -32400; 48 | static const int transportError = -32300; 49 | 50 | } 51 | 52 | } 53 | 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /include/cxxtools/xmlrpc/service.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 by Dr. Marc Boris Duerner 3 | * Copyright (C) 2009 by Tommi Meakitalo 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * As a special exception, you may use this file as part of a free 11 | * software library without restriction. Specifically, if other files 12 | * instantiate templates or use macros or inline functions from this 13 | * file, or you compile this file and link it with other files to 14 | * produce an executable, this file does not by itself cause the 15 | * resulting executable to be covered by the GNU General Public 16 | * License. This exception does not however invalidate any other 17 | * reasons why the executable file might be covered by the GNU Library 18 | * General Public License. 19 | * 20 | * This library is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * Lesser General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU Lesser General Public 26 | * License along with this library; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 28 | */ 29 | #ifndef cxxtools_xmlrpc_Service_h 30 | #define cxxtools_xmlrpc_Service_h 31 | 32 | #include 33 | #include 34 | 35 | namespace cxxtools { 36 | 37 | namespace xmlrpc 38 | { 39 | 40 | class Service : public http::Service, public ServiceRegistry 41 | { 42 | friend class XmlRpcResponder; 43 | 44 | public: 45 | Service() 46 | { } 47 | 48 | virtual ~Service(); 49 | 50 | protected: 51 | virtual http::Responder* createResponder(const http::Request&); 52 | 53 | virtual void releaseResponder(http::Responder* resp); 54 | 55 | }; 56 | 57 | } 58 | 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /lgpl++.txt: -------------------------------------------------------------------------------- 1 | This library is free software; you can redistribute it and/or 2 | modify it under the terms of the GNU Lesser General Public 3 | License as published by the Free Software Foundation; either 4 | version 2.1 of the License, or (at your option) any later version. 5 | 6 | As a special exception, you may use this file as part of a free 7 | software library without restriction. Specifically, if other files 8 | instantiate templates or use macros or inline functions from this 9 | file, or you compile this file and link it with other files to 10 | produce an executable, this file does not by itself cause the 11 | resulting executable to be covered by the GNU General Public 12 | License. This exception does not however invalidate any other 13 | reasons why the executable file might be covered by the GNU Library 14 | General Public License. 15 | 16 | This library is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General Public 22 | License along with this library; if not, write to the Free Software 23 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 24 | -------------------------------------------------------------------------------- /pkgconfig/cxxtools-bin.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: cxxtools-bin 7 | Description: A toolbox with reusable C++ components - binary RPC package 8 | Version: @PACKAGE_VERSION@ 9 | Requires: cxxtools 10 | Libs: -L${libdir} -lcxxtools-bin 11 | -------------------------------------------------------------------------------- /pkgconfig/cxxtools-http.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: cxxtools-http 7 | Description: A toolbox with reusable C++ components - HTTP protocol implementation 8 | Version: @PACKAGE_VERSION@ 9 | Requires: cxxtools 10 | Libs: -L${libdir} -lcxxtools-http 11 | -------------------------------------------------------------------------------- /pkgconfig/cxxtools-json.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: cxxtools-json 7 | Description: A toolbox with reusable C++ components - JSON package 8 | Version: @PACKAGE_VERSION@ 9 | Requires: cxxtools cxxtools-http 10 | Libs: -L${libdir} -lcxxtools-json 11 | -------------------------------------------------------------------------------- /pkgconfig/cxxtools-unit.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: cxxtools-unit 7 | Description: A toolbox with reusable C++ components - testing library 8 | Version: @PACKAGE_VERSION@ 9 | Requires: cxxtools 10 | Libs: -L${libdir} -lcxxtools-unit 11 | -------------------------------------------------------------------------------- /pkgconfig/cxxtools-xmlrpc.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: cxxtools-xmlrpc 7 | Description: A toolbox with reusable C++ components - XMLRPC package 8 | Version: @PACKAGE_VERSION@ 9 | Requires: cxxtools cxxtools-http 10 | Libs: -L${libdir} -lcxxtools-xmlrpc 11 | -------------------------------------------------------------------------------- /pkgconfig/cxxtools.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: cxxtools 7 | Description: A toolbox with reusable C++ components 8 | Version: @PACKAGE_VERSION@ 9 | Libs: -L${libdir} -lcxxtools 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /src/Makefile.mingw: -------------------------------------------------------------------------------- 1 | CC=i586-mingw32msvc-gcc 2 | CXX=i586-mingw32msvc-g++ 3 | CFLAGS=-I../include 4 | CXXFLAGS=-I../include -DCXXTOOLS_API_EXPORT 5 | LINK=$(CXX) 6 | LDFLAGS=-shared -Wl,--enable-runtime-pseudo-reloc 7 | 8 | SOURCES_CPP= \ 9 | any.cpp \ 10 | base64stream.cpp \ 11 | cgi.cpp \ 12 | connectable.cpp \ 13 | connection.cpp \ 14 | fdstream.cpp \ 15 | file.cpp \ 16 | filesystemnode.cpp \ 17 | directory.cpp \ 18 | hdstream.cpp \ 19 | inifile.cpp \ 20 | iniparser.cpp \ 21 | md5stream.cpp \ 22 | properties.cpp \ 23 | query_params.cpp \ 24 | syserror.cpp \ 25 | tee.cpp \ 26 | xmltag.cpp 27 | 28 | SOURCES_C= \ 29 | md5.c 30 | 31 | OBJS= $(SOURCES_CPP:.cpp=.obj) $(SOURCES_C:.c=.obj) 32 | 33 | %.obj : %.c 34 | $(CC) -c -o $@ $(CFLAGS) $< 35 | 36 | %.obj : %.cpp 37 | $(CXX) -c -o $@ $(CXXFLAGS) $< 38 | 39 | all: cxxtools.dll 40 | 41 | cxxtools.dll: $(OBJS) 42 | $(LINK) -o $@ $(LDFLAGS) $^ 43 | -------------------------------------------------------------------------------- /src/Makefile.win32: -------------------------------------------------------------------------------- 1 | # 2 | # To be run from VC build shell with envvar PLATFORMSDK set to 3 | # platform SDK installation directory. 4 | # nmake /f Makefile.win32 [clean|all] 5 | # 6 | CC = cl /nologo 7 | LINK = link /nologo 8 | AR = lib /nologo 9 | 10 | LINKFLAGS = /DEBUG 11 | CPPFLAGS = /MDd /Zi /RTC1 /Od /EHsc /GR /FD /I../include /I$(VCINSTALLDIR)\include /I$(PLATFORMSDK)/include 12 | 13 | OBJS = any.obj atomicity.obj base64stream.obj connectable.obj connection.obj iniparser.obj properties.obj syserror.obj xmltag.obj 14 | 15 | cxxtools.lib : $(OBJS) 16 | $(AR) /out:cxxtools.lib $(OBJS) 17 | 18 | ..\demo\signals.obj : ..\demo\signals.cpp 19 | $(CC) /c $(CPPFLAGS) /Fo..\demo\signals.obj /Tp ..\demo\signals.cpp 20 | 21 | ..\demo\signals.exe : cxxtools.lib ..\demo\signals.obj 22 | $(LINK) $(LINKFLAGS) /out:..\demo\signals.exe ..\demo\signals.obj cxxtools.lib 23 | 24 | all : ..\demo\signals.exe cxxtools.lib 25 | 26 | clean : 27 | del $(OBJS) cxxtools.lib ..\demo\signals.exe ..\demo\signals.obj -------------------------------------------------------------------------------- /src/applicationimpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * As a special exception, you may use this file as part of a free 8 | * software library without restriction. Specifically, if other files 9 | * instantiate templates or use macros or inline functions from this 10 | * file, or you compile this file and link it with other files to 11 | * produce an executable, this file does not by itself cause the 12 | * resulting executable to be covered by the GNU General Public 13 | * License. This exception does not however invalidate any other 14 | * reasons why the executable file might be covered by the GNU Library 15 | * General Public License. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public 23 | * License along with this library; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | #ifndef CXXTOOLS_APPLICATION_IMPL_H 27 | #define CXXTOOLS_APPLICATION_IMPL_H 28 | 29 | namespace cxxtools { 30 | 31 | class SelectorBase; 32 | 33 | class ApplicationImpl 34 | { 35 | public: 36 | ApplicationImpl(); 37 | 38 | virtual ~ApplicationImpl(); 39 | 40 | void init(SelectorBase& s); 41 | 42 | bool catchSystemSignal(int sig); 43 | 44 | bool raiseSystemSignal(int sig); 45 | 46 | //int signalFd() const; 47 | 48 | }; 49 | 50 | } // namespace cxxtools 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/bin/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/include -I$(top_srcdir)/include 2 | 3 | lib_LTLIBRARIES = libcxxtools-bin.la 4 | 5 | noinst_HEADERS = \ 6 | responder.h \ 7 | rpcclientimpl.h \ 8 | rpcserverimpl.h \ 9 | scanner.h \ 10 | socket.h \ 11 | worker.h 12 | 13 | libcxxtools_bin_la_SOURCES = \ 14 | deserializer.cpp \ 15 | formatter.cpp \ 16 | responder.cpp \ 17 | socket.cpp \ 18 | rpcclient.cpp \ 19 | rpcclientimpl.cpp \ 20 | rpcserver.cpp \ 21 | rpcserverimpl.cpp \ 22 | serializer.cpp \ 23 | scanner.cpp \ 24 | parser.cpp \ 25 | worker.cpp 26 | 27 | libcxxtools_bin_la_LIBADD = $(top_builddir)/src/libcxxtools.la 28 | 29 | libcxxtools_bin_la_LDFLAGS = -version-info @sonumber@ @SHARED_LIB_FLAG@ 30 | 31 | -------------------------------------------------------------------------------- /src/bin/worker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef CXXTOOLS_BIN_WORKER_H 30 | #define CXXTOOLS_BIN_WORKER_H 31 | 32 | #include 33 | 34 | namespace cxxtools 35 | { 36 | namespace bin 37 | { 38 | 39 | class RpcServerImpl; 40 | 41 | class Worker 42 | { 43 | public: 44 | explicit Worker(RpcServerImpl& server); 45 | ~Worker(); 46 | 47 | void join() { _thread.join(); } 48 | 49 | private: 50 | void run(); 51 | 52 | RpcServerImpl& _server; 53 | std::thread _thread; 54 | }; 55 | 56 | } 57 | } 58 | 59 | #endif // CXXTOOLS_BIN_WORKER_H 60 | 61 | -------------------------------------------------------------------------------- /src/cgi.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include "cxxtools/cgi.h" 30 | #include 31 | 32 | namespace cxxtools 33 | { 34 | 35 | Cgi::Cgi() 36 | { 37 | char* q = getenv("QUERY_STRING"); 38 | 39 | if (q) 40 | parse_url(q); 41 | 42 | parse_url(std::cin); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/clockimpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * As a special exception, you may use this file as part of a free 8 | * software library without restriction. Specifically, if other files 9 | * instantiate templates or use macros or inline functions from this 10 | * file, or you compile this file and link it with other files to 11 | * produce an executable, this file does not by itself cause the 12 | * resulting executable to be covered by the GNU General Public 13 | * License. This exception does not however invalidate any other 14 | * reasons why the executable file might be covered by the GNU Library 15 | * General Public License. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public 23 | * License along with this library; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | #include "cxxtools/datetime.h" 27 | #include "cxxtools/timespan.h" 28 | #include "cxxtools/refcounted.h" 29 | #include 30 | #include 31 | #include "config.h" 32 | 33 | namespace cxxtools 34 | { 35 | 36 | class ClockImpl : public RefCounted 37 | { 38 | public: 39 | Timespan start(); 40 | 41 | Timespan stop() const; 42 | 43 | static UtcDateTime getSystemTime(); 44 | 45 | static LocalDateTime getLocalTime(); 46 | 47 | static Timespan getSystemTicks(); 48 | 49 | private: 50 | #ifdef HAVE_CLOCK_GETTIME 51 | struct timespec _startTime; 52 | #else 53 | struct timeval _startTime; 54 | #endif 55 | }; 56 | 57 | } // namespace cxxtools 58 | 59 | -------------------------------------------------------------------------------- /src/conversionerror.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2007 by Dr. Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include "cxxtools/conversionerror.h" 30 | 31 | namespace cxxtools 32 | { 33 | 34 | ConversionError::ConversionError(const std::string& msg) 35 | : std::runtime_error(msg) 36 | { 37 | } 38 | 39 | void ConversionError::doThrow(const char* typeto, const char* typefrom) 40 | { 41 | std::string msg = "conversion from type "; 42 | msg += typefrom; 43 | msg += " to type "; 44 | msg += typeto; 45 | msg += " failed"; 46 | throw ConversionError(msg); 47 | } 48 | 49 | void ConversionError::doThrow(const char* typeto, const char* typefrom, const char* valuefrom) 50 | { 51 | std::string msg = "conversion from type "; 52 | msg += typefrom; 53 | msg += " (\""; 54 | msg += valuefrom; 55 | msg += "\") to type "; 56 | msg += typeto; 57 | msg += " failed"; 58 | throw ConversionError(msg); 59 | } 60 | 61 | } 62 | 63 | -------------------------------------------------------------------------------- /src/error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | * 28 | */ 29 | 30 | 31 | #ifndef ERROR_H 32 | #define ERROR_H 33 | 34 | #include 35 | #include 36 | 37 | namespace cxxtools 38 | { 39 | std::string getErrnoString(int err, const char* fn); 40 | std::string getErrnoString(int err); 41 | void throwCurrentErrno(const char* fn, const std::string& path); 42 | 43 | inline std::string getErrnoString(const char* fn) 44 | { 45 | return getErrnoString(errno, fn); 46 | } 47 | 48 | inline std::string getErrnoString() 49 | { 50 | return getErrnoString(errno); 51 | } 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/filedeviceimpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006-2007 Laurentiu-Gheorghe Crisan 3 | * Copyright (C) 2006-2007 Marc Boris Duerner 4 | * Copyright (C) 2006-2007 PTV AG 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * As a special exception, you may use this file as part of a free 12 | * software library without restriction. Specifically, if other files 13 | * instantiate templates or use macros or inline functions from this 14 | * file, or you compile this file and link it with other files to 15 | * produce an executable, this file does not by itself cause the 16 | * resulting executable to be covered by the GNU General Public 17 | * License. This exception does not however invalidate any other 18 | * reasons why the executable file might be covered by the GNU Library 19 | * General Public License. 20 | * 21 | * This library is distributed in the hope that it will be useful, 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 | * Lesser General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU Lesser General Public 27 | * License along with this library; if not, write to the Free Software 28 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 29 | */ 30 | #include "cxxtools/ioerror.h" 31 | #include "cxxtools/filedevice.h" 32 | #include "cxxtools/iodevice.h" 33 | #include "iodeviceimpl.h" 34 | 35 | namespace cxxtools 36 | { 37 | 38 | class FileDeviceImpl : public IODeviceImpl 39 | { 40 | public: 41 | typedef FileDevice::pos_type pos_type; 42 | typedef FileDevice::off_type off_type; 43 | 44 | public: 45 | FileDeviceImpl(FileDevice& device); 46 | 47 | ~FileDeviceImpl(); 48 | 49 | bool seekable() const; 50 | 51 | pos_type seek(off_type offset, std::ios::seekdir sd); 52 | 53 | void resize(off_type size); 54 | 55 | size_t size() const; 56 | 57 | size_t peek(char* buffer, size_t count); 58 | 59 | void sync() const; 60 | }; 61 | 62 | } //namespace cxxtools 63 | -------------------------------------------------------------------------------- /src/fileimpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2008 by Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #include 29 | 30 | namespace cxxtools { 31 | 32 | class FileImpl 33 | { 34 | public: 35 | FileImpl(); 36 | 37 | ~FileImpl(); 38 | 39 | static std::size_t size(const std::string& path); 40 | 41 | static void resize(const std::string& path, std::size_t n); 42 | 43 | static void remove(const std::string& path); 44 | 45 | static void move(const std::string& path, const std::string& to); 46 | 47 | static void link(const std::string& path, const std::string& to); 48 | 49 | static void symlink(const std::string& path, const std::string& to); 50 | 51 | static void copy(const std::string& path, const std::string& to); 52 | 53 | static void create(const std::string& path); 54 | }; 55 | 56 | } // namespace cxxtools 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/http/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/include -I$(top_srcdir)/include 2 | 3 | lib_LTLIBRARIES = libcxxtools-http.la 4 | 5 | libcxxtools_http_la_SOURCES = \ 6 | chunkedreader.cpp \ 7 | client.cpp \ 8 | clientimpl.cpp \ 9 | mapper.cpp \ 10 | messageheader.cpp \ 11 | notauthenticatedresponder.cpp \ 12 | notauthenticatedservice.cpp \ 13 | notfoundresponder.cpp \ 14 | notfoundservice.cpp \ 15 | parser.cpp \ 16 | server.cpp \ 17 | serverimpl.cpp \ 18 | service.cpp \ 19 | socket.cpp \ 20 | request.cpp \ 21 | responder.cpp \ 22 | worker.cpp 23 | 24 | noinst_HEADERS = \ 25 | chunkedreader.h \ 26 | clientimpl.h \ 27 | mapper.h \ 28 | notauthenticatedresponder.h \ 29 | notauthenticatedservice.h \ 30 | notfoundresponder.h \ 31 | notfoundservice.h \ 32 | parser.h \ 33 | serverimpl.h \ 34 | serverimplbase.h \ 35 | socket.h \ 36 | worker.h 37 | 38 | libcxxtools_http_la_LIBADD = $(top_builddir)/src/libcxxtools.la 39 | 40 | libcxxtools_http_la_LDFLAGS = -version-info @sonumber@ @SHARED_LIB_FLAG@ 41 | 42 | -------------------------------------------------------------------------------- /src/http/notauthenticatedresponder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include "notauthenticatedresponder.h" 30 | #include 31 | 32 | namespace cxxtools 33 | { 34 | namespace http 35 | { 36 | 37 | void NotAuthenticatedResponder::reply(std::ostream& out, Request& /*request*/, Reply& reply) 38 | { 39 | reply.setHeader("WWW-Authenticate", ("Basic realm=\"" + _realm + '"').c_str()); 40 | 41 | reply.httpReturn(401, "not authorized"); 42 | 43 | if (_content.empty()) 44 | out << "

not authorized

"; 45 | else 46 | out << _content; 47 | 48 | } 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/http/notauthenticatedresponder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef CXXTOOLS_HTTP_NOTAUTHENTICATEDRESPONDER_H 30 | #define CXXTOOLS_HTTP_NOTAUTHENTICATEDRESPONDER_H 31 | 32 | #include 33 | #include 34 | 35 | namespace cxxtools 36 | { 37 | namespace http 38 | { 39 | 40 | class NotAuthenticatedResponder : public Responder 41 | { 42 | std::string _realm; 43 | std::string _content; 44 | 45 | public: 46 | explicit NotAuthenticatedResponder(Service& service, const std::string& realm, const std::string& content) 47 | : Responder(service), 48 | _realm(realm), 49 | _content(content) 50 | { } 51 | 52 | void reply(std::ostream&, Request& request, Reply& reply); 53 | }; 54 | 55 | } 56 | } 57 | 58 | #endif // CXXTOOLS_HTTP_NOTAUTHENTICATEDRESPONDER_H 59 | -------------------------------------------------------------------------------- /src/http/notauthenticatedservice.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include "notauthenticatedservice.h" 30 | #include "notauthenticatedresponder.h" 31 | 32 | namespace cxxtools 33 | { 34 | namespace http 35 | { 36 | 37 | Responder* NotAuthenticatedService::createResponder(const Request& request) 38 | { 39 | return createResponder(request, std::string(), std::string()); 40 | } 41 | 42 | Responder* NotAuthenticatedService::createResponder(const Request& /*request*/, const std::string& realm, const std::string& authContent) 43 | { 44 | return new NotAuthenticatedResponder(*this, realm, authContent); 45 | } 46 | 47 | void NotAuthenticatedService::releaseResponder(Responder* responder) 48 | { 49 | delete responder; 50 | } 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/http/notauthenticatedservice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | 30 | #ifndef CXXTOOLS_HTTP_NOTAUTHENTICATEDSERVICE_H 31 | #define CXXTOOLS_HTTP_NOTAUTHENTICATEDSERVICE_H 32 | 33 | #include 34 | 35 | namespace cxxtools 36 | { 37 | namespace http 38 | { 39 | 40 | class NotAuthenticatedService : public Service 41 | { 42 | public: 43 | NotAuthenticatedService() 44 | { } 45 | 46 | Responder* createResponder(const Request&); 47 | 48 | Responder* createResponder(const Request&, const std::string& realm, const std::string& authContent); 49 | 50 | void releaseResponder(Responder* responder); 51 | 52 | }; 53 | 54 | } 55 | } 56 | 57 | #endif // CXXTOOLS_HTTP_NOTAUTHENTICATEDSERVICE_H 58 | -------------------------------------------------------------------------------- /src/http/notfoundresponder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include "notfoundresponder.h" 30 | #include 31 | 32 | namespace cxxtools 33 | { 34 | namespace http 35 | { 36 | 37 | void NotFoundResponder::reply(std::ostream& /*out*/, Request& /*request*/, Reply& reply) 38 | { 39 | reply.httpReturn(404, "Not found"); 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/http/notfoundresponder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef CXXTOOLS_HTTP_NOTFOUNDRESPONDER_H 30 | #define CXXTOOLS_HTTP_NOTFOUNDRESPONDER_H 31 | 32 | #include 33 | 34 | namespace cxxtools 35 | { 36 | namespace http 37 | { 38 | 39 | class NotFoundResponder : public Responder 40 | { 41 | public: 42 | explicit NotFoundResponder(Service& service) 43 | : Responder(service) 44 | { } 45 | 46 | void reply(std::ostream&, Request& request, Reply& reply); 47 | }; 48 | 49 | } 50 | } 51 | 52 | #endif // CXXTOOLS_HTTP_NOTFOUNDRESPONDER_H 53 | -------------------------------------------------------------------------------- /src/http/notfoundservice.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include "notfoundservice.h" 30 | 31 | namespace cxxtools 32 | { 33 | namespace http 34 | { 35 | 36 | Responder* NotFoundService::createResponder(const Request&) 37 | { 38 | return &_responder; 39 | } 40 | 41 | void NotFoundService::releaseResponder(Responder*) 42 | { } 43 | 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/http/notfoundservice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | 30 | #ifndef CXXTOOLS_HTTP_NOTFOUNDSERVICE_H 31 | #define CXXTOOLS_HTTP_NOTFOUNDSERVICE_H 32 | 33 | #include 34 | #include "notfoundresponder.h" 35 | 36 | namespace cxxtools 37 | { 38 | namespace http 39 | { 40 | 41 | class NotFoundService : public Service 42 | { 43 | public: 44 | NotFoundService() 45 | : _responder(*this) 46 | { } 47 | 48 | Responder* createResponder(const Request&); 49 | void releaseResponder(Responder*); 50 | 51 | private: 52 | NotFoundResponder _responder; 53 | }; 54 | 55 | } 56 | } 57 | 58 | #endif // CXXTOOLS_HTTP_NOTFOUNDSERVICE_H 59 | -------------------------------------------------------------------------------- /src/http/request.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 by Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | namespace cxxtools { 35 | 36 | namespace http { 37 | 38 | Request::Auth Request::auth() const 39 | { 40 | Auth ret; 41 | 42 | const char* sp = getHeader("Authorization"); 43 | if (!sp) 44 | return ret; 45 | 46 | std::string s = sp; 47 | std::string::size_type p = s.find(' '); 48 | if (p == std::string::npos) 49 | return ret; 50 | 51 | std::istringstream in(s); 52 | in.ignore(p + 1); 53 | 54 | cxxtools::BasicTextIStream b(in, new cxxtools::Base64Codec()); 55 | std::getline(b, ret.user, ':'); 56 | std::getline(b, ret.password); 57 | 58 | return ret; 59 | } 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/http/worker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef CXXTOOLS_HTTP_WORKER_H 30 | #define CXXTOOLS_HTTP_WORKER_H 31 | 32 | #include 33 | 34 | namespace cxxtools 35 | { 36 | namespace http 37 | { 38 | 39 | class ServerImpl; 40 | 41 | class Worker 42 | { 43 | public: 44 | explicit Worker(ServerImpl& server); 45 | 46 | void join() { _thread.join(); } 47 | 48 | private: 49 | void run(); 50 | 51 | ServerImpl& _server; 52 | std::thread _thread; 53 | }; 54 | 55 | } 56 | } 57 | 58 | #endif // CXXTOOLS_HTTP_WORKER_H 59 | 60 | -------------------------------------------------------------------------------- /src/json/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/include -I$(top_srcdir)/include 2 | 3 | lib_LTLIBRARIES = libcxxtools-json.la 4 | 5 | noinst_HEADERS = \ 6 | httpclientimpl.h \ 7 | httpresponder.h \ 8 | responder.h \ 9 | rpcclientimpl.h \ 10 | rpcserverimpl.h \ 11 | scanner.h \ 12 | socket.h \ 13 | worker.h 14 | 15 | libcxxtools_json_la_SOURCES = \ 16 | httpclient.cpp \ 17 | httpclientimpl.cpp \ 18 | httpresponder.cpp \ 19 | httpservice.cpp \ 20 | rpcclient.cpp \ 21 | rpcclientimpl.cpp \ 22 | responder.cpp \ 23 | rpcserver.cpp \ 24 | rpcserverimpl.cpp \ 25 | scanner.cpp \ 26 | socket.cpp \ 27 | worker.cpp 28 | 29 | libcxxtools_json_la_LIBADD = $(top_builddir)/src/libcxxtools.la $(top_builddir)/src/http/libcxxtools-http.la 30 | 31 | libcxxtools_json_la_LDFLAGS = -version-info @sonumber@ @SHARED_LIB_FLAG@ 32 | 33 | -------------------------------------------------------------------------------- /src/json/httpresponder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 by Tommi Meakitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #ifndef CXXTOOLS_JSON_HTTPRESPONDER_H 29 | #define CXXTOOLS_JSON_HTTPRESPONDER_H 30 | 31 | #include 32 | #include "responder.h" 33 | 34 | namespace cxxtools 35 | { 36 | 37 | namespace json 38 | { 39 | 40 | class HttpService; 41 | 42 | class HttpResponder : public http::Responder 43 | { 44 | 45 | public: 46 | explicit HttpResponder(HttpService& service); 47 | 48 | ~HttpResponder(); 49 | 50 | void beginRequest(net::TcpSocket& socket, std::istream& in, http::Request& request); 51 | 52 | std::size_t readBody(std::istream& is); 53 | 54 | void reply(std::ostream& os, http::Request& request, http::Reply& reply); 55 | 56 | private: 57 | json::Responder _responder; 58 | }; 59 | 60 | } 61 | 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/json/worker.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef CXXTOOLS_JSON_WORKER_H 30 | #define CXXTOOLS_JSON_WORKER_H 31 | 32 | #include 33 | 34 | namespace cxxtools 35 | { 36 | namespace json 37 | { 38 | 39 | class RpcServerImpl; 40 | 41 | class Worker 42 | { 43 | public: 44 | explicit Worker(RpcServerImpl& server); 45 | ~Worker(); 46 | 47 | void join() { _thread.join(); } 48 | 49 | private: 50 | void run(); 51 | 52 | RpcServerImpl& _server; 53 | std::thread _thread; 54 | }; 55 | 56 | } 57 | } 58 | 59 | #endif // CXXTOOLS_JSON_WORKER_H 60 | 61 | -------------------------------------------------------------------------------- /src/md5stream.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maekitalo/cxxtools/01f47a335ba4765677256ea6067b6bcb989e46d4/src/md5stream.cpp -------------------------------------------------------------------------------- /src/pipe.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include "cxxtools/pipe.h" 30 | #include "pipeimpl.h" 31 | 32 | namespace cxxtools 33 | { 34 | Pipe::Pipe(OpenMode mode, bool inherit) 35 | { 36 | _impl = new PipeImpl(mode & IODevice::Async, inherit); 37 | } 38 | 39 | 40 | Pipe::~Pipe() 41 | { 42 | delete _impl; 43 | } 44 | 45 | 46 | IODevice& Pipe::out() 47 | { 48 | return _impl->out(); 49 | } 50 | 51 | const IODevice& Pipe::out() const 52 | { 53 | return _impl->out(); 54 | } 55 | 56 | IODevice& Pipe::in() 57 | { 58 | return _impl->in(); 59 | } 60 | 61 | const IODevice& Pipe::in() const 62 | { 63 | return _impl->in(); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/posix/commandinput.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | namespace posix 36 | { 37 | void CommandInput::run() 38 | { 39 | _fork.fork(); 40 | if (_fork.child()) 41 | { 42 | streambuf.redirectStdin(); 43 | streambuf.closeWriteFd(); 44 | 45 | child(); 46 | 47 | try 48 | { 49 | _exec.exec(); 50 | } 51 | catch (const SystemError&) 52 | { 53 | ::_exit(-1); 54 | } 55 | } 56 | 57 | streambuf.closeReadFd(); 58 | } 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/posix/commandoutput.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | namespace cxxtools 34 | { 35 | namespace posix 36 | { 37 | void CommandOutput::run(bool combineStderr) 38 | { 39 | _fork.fork(); 40 | if (_fork.child()) 41 | { 42 | streambuf.redirectStdout(); 43 | if (combineStderr) 44 | streambuf.redirectStderr(false); 45 | 46 | streambuf.closeReadFd(); 47 | 48 | child(); 49 | 50 | try 51 | { 52 | _exec.exec(); 53 | } 54 | catch (const SystemError&) 55 | { 56 | ::_exit(-1); 57 | } 58 | } 59 | 60 | streambuf.closeWriteFd(); 61 | } 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/posix/fork.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | namespace cxxtools 37 | { 38 | namespace posix 39 | { 40 | 41 | void Fork::fork() 42 | { 43 | pid = ::fork(); 44 | 45 | if (pid < 0) 46 | throw SystemError("fork"); 47 | 48 | if (pid == 0) 49 | { 50 | // disable logging in child process to prevent deadlock if another 51 | // hold the lock for logging 52 | cxxtools::LogManager::disable(); 53 | } 54 | } 55 | 56 | int Fork::wait(int options) 57 | { 58 | int status; 59 | ::waitpid(pid, &status, options); 60 | pid = 0; 61 | return status; 62 | } 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/remoteclient.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include 30 | 31 | namespace cxxtools 32 | { 33 | const std::size_t RemoteClient::WaitInfinite; 34 | } 35 | -------------------------------------------------------------------------------- /src/selectableimpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006-2007 Laurentiu-Gheorghe Crisan 3 | * Copyright (C) 2006-2007 Marc Boris Duerner 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * As a special exception, you may use this file as part of a free 11 | * software library without restriction. Specifically, if other files 12 | * instantiate templates or use macros or inline functions from this 13 | * file, or you compile this file and link it with other files to 14 | * produce an executable, this file does not by itself cause the 15 | * resulting executable to be covered by the GNU General Public 16 | * License. This exception does not however invalidate any other 17 | * reasons why the executable file might be covered by the GNU Library 18 | * General Public License. 19 | * 20 | * This library is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * Lesser General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU Lesser General Public 26 | * License along with this library; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 28 | */ 29 | #ifndef CXXTOOLS_SELECTABLEIMPL_H 30 | #define CXXTOOLS_SELECTABLEIMPL_H 31 | 32 | #include 33 | 34 | struct pollfd; 35 | 36 | namespace cxxtools 37 | { 38 | 39 | class Timespan; 40 | 41 | class SelectableImpl 42 | { 43 | public: 44 | virtual ~SelectableImpl() = default; 45 | 46 | virtual void close() = 0; 47 | 48 | virtual bool wait(Timespan timeout)= 0; 49 | 50 | virtual std::size_t pollSize() const = 0; 51 | 52 | virtual std::size_t initializePoll(pollfd* pfd, std::size_t pollSize) = 0; 53 | 54 | virtual bool checkPollEvent() = 0; 55 | }; 56 | 57 | } //namespace cxxtools 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/settings.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2007 by Dr. Marc Boris Duerner 3 | * Copyright (C) 2005 Stephan Beal 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * As a special exception, you may use this file as part of a free 11 | * software library without restriction. Specifically, if other files 12 | * instantiate templates or use macros or inline functions from this 13 | * file, or you compile this file and link it with other files to 14 | * produce an executable, this file does not by itself cause the 15 | * resulting executable to be covered by the GNU General Public 16 | * License. This exception does not however invalidate any other 17 | * reasons why the executable file might be covered by the GNU Library 18 | * General Public License. 19 | * 20 | * This library is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * Lesser General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU Lesser General Public 26 | * License along with this library; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 28 | */ 29 | 30 | #include "cxxtools/settings.h" 31 | #include "settingsreader.h" 32 | #include "settingswriter.h" 33 | 34 | namespace cxxtools { 35 | 36 | SettingsError::SettingsError(const std::string& what, unsigned line) 37 | : SerializationError(what) 38 | , _line(line) 39 | {} 40 | 41 | 42 | Settings::Settings() 43 | {} 44 | 45 | 46 | void Settings::load(std::basic_istream& is) 47 | { 48 | SettingsReader reader(is); 49 | reader.parse(*this); 50 | } 51 | 52 | 53 | void Settings::save(std::basic_ostream& os ) const 54 | { 55 | SettingsWriter writer(os); 56 | writer.write(*this); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/sslcertificateimpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #ifndef SSLCERTIFICATEIMPL_H 30 | #define SSLCERTIFICATEIMPL_H 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace cxxtools 38 | { 39 | class SslCertificateImpl : public AtomicRefCounted 40 | { 41 | X509* _cert; 42 | 43 | SslCertificateImpl(const SslCertificateImpl&) { } 44 | SslCertificateImpl& operator=(const SslCertificateImpl&) { return *this; } 45 | 46 | public: 47 | explicit SslCertificateImpl(X509* cert) 48 | : _cert(cert) 49 | { } 50 | 51 | ~SslCertificateImpl(); 52 | 53 | String getSubject() const; 54 | String getIssuer() const; 55 | DateTime getNotBefore() const; 56 | DateTime getNotAfter() const; 57 | std::string getSerial() const; 58 | }; 59 | 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/textbuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2004-2009 Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #include "cxxtools/textbuffer.h" 29 | 30 | namespace cxxtools { 31 | 32 | TextBuffer::TextBuffer(std::ios* s, Codec* codec) 33 | : BasicTextBuffer(s, codec) 34 | { } 35 | 36 | } // namespace cxxtools 37 | -------------------------------------------------------------------------------- /src/textcodec.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2006-2008 Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #include "cxxtools/textcodec.h" 29 | 30 | #ifdef CXXTOOLS_WITH_STD_LOCALE 31 | 32 | namespace std { 33 | 34 | // 35 | // codecvt facet for Char/char 36 | // 37 | std::locale::id codecvt::id; 38 | 39 | 40 | codecvt::codecvt(size_t ref) 41 | : locale::facet(ref) 42 | {} 43 | 44 | 45 | codecvt::~codecvt() 46 | {} 47 | 48 | // 49 | // codecvt facet for char/char 50 | // 51 | std::locale::id codecvt::id; 52 | 53 | 54 | codecvt::codecvt(size_t ref) 55 | : locale::facet(ref) 56 | {} 57 | 58 | 59 | codecvt::~codecvt() 60 | {} 61 | 62 | } // namespace std 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/unit/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/include -I$(top_srcdir)/include 2 | 3 | lib_LTLIBRARIES = libcxxtools-unit.la 4 | 5 | libcxxtools_unit_la_SOURCES = \ 6 | application.cpp \ 7 | assertion.cpp \ 8 | jsonreporter.cpp \ 9 | reporter.cpp \ 10 | testcase.cpp \ 11 | testcontext.cpp \ 12 | test.cpp \ 13 | testprotocol.cpp \ 14 | testsuite.cpp 15 | 16 | libcxxtools_unit_la_LIBADD = $(top_builddir)/src/libcxxtools.la 17 | 18 | libcxxtools_unit_la_LDFLAGS = -version-info @sonumber@ @SHARED_LIB_FLAG@ 19 | 20 | -------------------------------------------------------------------------------- /src/unit/assertion.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2008 by Dr. Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #include 29 | #include 30 | 31 | namespace cxxtools { 32 | 33 | namespace unit { 34 | 35 | Assertion::Assertion(const std::string& what, const SourceInfo& si) 36 | : _sourceInfo(si) 37 | , _what(what) 38 | { 39 | } 40 | 41 | 42 | const SourceInfo& Assertion::sourceInfo() const 43 | { 44 | return _sourceInfo; 45 | } 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/unit/testcase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2008 by Dr. Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #include "cxxtools/unit/testcase.h" 29 | #include "cxxtools/unit/testcontext.h" 30 | 31 | namespace cxxtools { 32 | 33 | namespace unit { 34 | 35 | TestCase::TestCase(const std::string& name) 36 | : Test(name) 37 | { 38 | } 39 | 40 | 41 | void TestCase::run() 42 | { 43 | Context ctx(*this, *this); 44 | ctx.run(); 45 | } 46 | 47 | 48 | void TestCase::setUp() 49 | { 50 | } 51 | 52 | 53 | void TestCase::tearDown() 54 | { 55 | } 56 | 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/unit/testprotocol.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2006 by Dr. Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #include "cxxtools/unit/testprotocol.h" 29 | #include "cxxtools/unit/testsuite.h" 30 | 31 | namespace cxxtools { 32 | 33 | namespace unit { 34 | 35 | void TestProtocol::run(TestSuite& suite) 36 | { 37 | suite.runAll(); 38 | } 39 | 40 | } // namespace Unit 41 | 42 | } // namespace cxxtools 43 | -------------------------------------------------------------------------------- /src/xml/characters.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * As a special exception, you may use this file as part of a free 8 | * software library without restriction. Specifically, if other files 9 | * instantiate templates or use macros or inline functions from this 10 | * file, or you compile this file and link it with other files to 11 | * produce an executable, this file does not by itself cause the 12 | * resulting executable to be covered by the GNU General Public 13 | * License. This exception does not however invalidate any other 14 | * reasons why the executable file might be covered by the GNU Library 15 | * General Public License. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public 23 | * License along with this library; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | #include "cxxtools/xml/characters.h" 27 | 28 | namespace cxxtools { 29 | 30 | namespace xml { 31 | 32 | 33 | bool Characters::operator==(const Node& node) const 34 | { 35 | const Characters* chars = dynamic_cast(&node); 36 | if (!chars) 37 | return false; 38 | 39 | return ( chars->content() == content() ); 40 | } 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/xml/endelement.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * As a special exception, you may use this file as part of a free 8 | * software library without restriction. Specifically, if other files 9 | * instantiate templates or use macros or inline functions from this 10 | * file, or you compile this file and link it with other files to 11 | * produce an executable, this file does not by itself cause the 12 | * resulting executable to be covered by the GNU General Public 13 | * License. This exception does not however invalidate any other 14 | * reasons why the executable file might be covered by the GNU Library 15 | * General Public License. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public 23 | * License along with this library; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | #include "cxxtools/xml/endelement.h" 27 | 28 | namespace cxxtools { 29 | 30 | namespace xml { 31 | 32 | 33 | bool EndElement::operator==(const Node& node) const 34 | { 35 | const EndElement* e = dynamic_cast(&node); 36 | if(!e) return false; 37 | 38 | return ( e->name() == this->name() ); 39 | } 40 | 41 | 42 | } // namespace xml 43 | 44 | } // namespace cxxtools 45 | -------------------------------------------------------------------------------- /src/xml/xmlerror.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * As a special exception, you may use this file as part of a free 8 | * software library without restriction. Specifically, if other files 9 | * instantiate templates or use macros or inline functions from this 10 | * file, or you compile this file and link it with other files to 11 | * produce an executable, this file does not by itself cause the 12 | * resulting executable to be covered by the GNU General Public 13 | * License. This exception does not however invalidate any other 14 | * reasons why the executable file might be covered by the GNU Library 15 | * General Public License. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public 23 | * License along with this library; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | #include "cxxtools/xml/xmlerror.h" 27 | 28 | namespace cxxtools { 29 | 30 | namespace xml { 31 | 32 | XmlError::XmlError(const std::string& what, unsigned line) 33 | : std::runtime_error(what) 34 | , _line(line) 35 | { 36 | } 37 | 38 | } // namespace Xml 39 | 40 | } // namespace cxxtools 41 | -------------------------------------------------------------------------------- /src/xml/xmlserializer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 by Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #include "cxxtools/xml/xmlserializer.h" 29 | 30 | namespace cxxtools 31 | { 32 | 33 | namespace xml 34 | { 35 | 36 | 37 | XmlSerializer::XmlSerializer() 38 | { 39 | } 40 | 41 | 42 | XmlSerializer::XmlSerializer(std::ostream& os) 43 | : _formatter(os) 44 | { 45 | } 46 | 47 | 48 | XmlSerializer::XmlSerializer(XmlWriter* writer) 49 | : _formatter(writer) 50 | { 51 | } 52 | 53 | 54 | XmlSerializer::~XmlSerializer() 55 | { 56 | finish(); 57 | } 58 | 59 | 60 | void XmlSerializer::attach(std::ostream& os) 61 | { 62 | _formatter.attach(os); 63 | } 64 | 65 | 66 | void XmlSerializer::attach(XmlWriter& writer) 67 | { 68 | _formatter.attach(writer); 69 | } 70 | 71 | 72 | void XmlSerializer::detach() 73 | { 74 | _formatter.detach(); 75 | } 76 | 77 | 78 | } // namespace xml 79 | 80 | } // namespace cxxtools 81 | -------------------------------------------------------------------------------- /src/xmlrpc/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/include -I$(top_srcdir)/include 2 | 3 | lib_LTLIBRARIES = libcxxtools-xmlrpc.la 4 | 5 | libcxxtools_xmlrpc_la_SOURCES = \ 6 | client.cpp \ 7 | clientimpl.cpp \ 8 | httpclient.cpp \ 9 | httpclientimpl.cpp \ 10 | formatter.cpp \ 11 | responder.cpp \ 12 | scanner.cpp \ 13 | service.cpp 14 | 15 | noinst_HEADERS = \ 16 | clientimpl.h \ 17 | httpclientimpl.h 18 | 19 | libcxxtools_xmlrpc_la_LIBADD = $(top_builddir)/src/libcxxtools.la $(top_builddir)/src/http/libcxxtools-http.la 20 | 21 | libcxxtools_xmlrpc_la_LDFLAGS = -version-info @sonumber@ @SHARED_LIB_FLAG@ 22 | 23 | -------------------------------------------------------------------------------- /src/xmlrpc/service.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 by Dr. Marc Boris Duerner 3 | * Copyright (C) 2009 by Tommi Meakitalo 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * As a special exception, you may use this file as part of a free 11 | * software library without restriction. Specifically, if other files 12 | * instantiate templates or use macros or inline functions from this 13 | * file, or you compile this file and link it with other files to 14 | * produce an executable, this file does not by itself cause the 15 | * resulting executable to be covered by the GNU General Public 16 | * License. This exception does not however invalidate any other 17 | * reasons why the executable file might be covered by the GNU Library 18 | * General Public License. 19 | * 20 | * This library is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * Lesser General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU Lesser General Public 26 | * License along with this library; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 28 | */ 29 | #include "cxxtools/xmlrpc/service.h" 30 | #include "cxxtools/xmlrpc/responder.h" 31 | #include "cxxtools/http/request.h" 32 | 33 | namespace cxxtools 34 | { 35 | 36 | namespace xmlrpc 37 | { 38 | 39 | Service::~Service() 40 | { 41 | } 42 | 43 | 44 | http::Responder* Service::createResponder(const http::Request& req) 45 | { 46 | if (req.header().isHeaderValue("Content-Type", "text/xml")) 47 | return new XmlRpcResponder(*this); 48 | 49 | return 0; 50 | } 51 | 52 | 53 | void Service::releaseResponder(http::Responder* resp) 54 | { 55 | delete resp; 56 | } 57 | 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | alltests 2 | rpcbenchclient 3 | rpcbenchasyncclient 4 | rpcbenchserver 5 | serializer-bench 6 | logbench 7 | -------------------------------------------------------------------------------- /test/MyApp.pm: -------------------------------------------------------------------------------- 1 | package MyApp; 2 | 3 | use base qw(JSON::RPC::Procedure); # Perl 5.6 or more than 4 | 5 | sub echo : Public { # new version style. called by clients 6 | # first argument is JSON::RPC::Server object. 7 | return $_[1]; 8 | } 9 | 10 | sub add : Public(a:num, b:num) { # sets value into object member a, b. 11 | my ($s, $obj) = @_; 12 | # return a scalar value or a hashref or an arryaref. 13 | return $obj->{a} + $obj->{b}; 14 | } 15 | 16 | 1; 17 | -------------------------------------------------------------------------------- /test/cgitest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This library is free software; you can redistribute it and/or 3 | * modify it under the terms of the GNU Lesser General Public 4 | * License as published by the Free Software Foundation; either 5 | * version 2.1 of the License, or (at your option) any later version. 6 | * 7 | * As a special exception, you may use this file as part of a free 8 | * software library without restriction. Specifically, if other files 9 | * instantiate templates or use macros or inline functions from this 10 | * file, or you compile this file and link it with other files to 11 | * produce an executable, this file does not by itself cause the 12 | * resulting executable to be covered by the GNU General Public 13 | * License. This exception does not however invalidate any other 14 | * reasons why the executable file might be covered by the GNU Library 15 | * General Public License. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public 23 | * License along with this library; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | #include "cxxtools/query_params.h" 27 | #include 28 | 29 | int main(int argc, char* argv) 30 | { 31 | std::string query_string = "uhu&blah&ttt=t1&qqq=q&ttt=t2"; 32 | query_params q; 33 | q.parse_url(query_string); 34 | 35 | using std::cout; 36 | using std::endl; 37 | 38 | cout << "query_string=" << query_string << endl; 39 | cout << "q[\"uhu\"]=" << q["uhu"] << endl; 40 | cout << "q[\"ttt\"]=" << q["ttt"] << endl; 41 | cout << "q.param(\"ttt\", 0)=" << q.param("ttt", 0) << endl; 42 | cout << "q.param(\"ttt\", 1)=" << q.param("ttt", 1) << endl; 43 | } 44 | -------------------------------------------------------------------------------- /test/color.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | 30 | #ifndef CXXTOOLS_COLOR_H 31 | #define CXXTOOLS_COLOR_H 32 | 33 | #include 34 | 35 | struct Color 36 | { 37 | int red; 38 | int green; 39 | int blue; 40 | }; 41 | 42 | inline void operator >>=(const cxxtools::SerializationInfo& si, Color& color) 43 | { 44 | si.getMember("red") >>= color.red; 45 | si.getMember("green") >>= color.green; 46 | si.getMember("blue") >>= color.blue; 47 | } 48 | 49 | inline void operator <<=(cxxtools::SerializationInfo& si, const Color& color) 50 | { 51 | si.setTypeName("color"); 52 | si.addMember("red") <<= color.red; 53 | si.addMember("green") <<= color.green; 54 | si.addMember("blue") <<= color.blue; 55 | } 56 | 57 | #endif // CXXTOOLS_COLOR_H 58 | -------------------------------------------------------------------------------- /test/directory-test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | class DirectoryTest : public cxxtools::unit::TestSuite 6 | { 7 | public: 8 | DirectoryTest() 9 | : cxxtools::unit::TestSuite("directory") 10 | { 11 | registerMethod("createDirectory", *this, &DirectoryTest::createDirectory); 12 | registerMethod("updir", *this, &DirectoryTest::updir); 13 | } 14 | 15 | void createDirectory() 16 | { 17 | CXXTOOLS_UNIT_ASSERT(!cxxtools::Directory::exists("foo")); 18 | 19 | cxxtools::Directory::create("foo/bar/baz", true); 20 | CXXTOOLS_UNIT_ASSERT(cxxtools::Directory::exists("foo/bar/baz")); 21 | 22 | cxxtools::Directory("foo/bar/baz").remove(); 23 | CXXTOOLS_UNIT_ASSERT(!cxxtools::Directory::exists("foo/bar/baz")); 24 | CXXTOOLS_UNIT_ASSERT(cxxtools::Directory::exists("foo/bar")); 25 | 26 | cxxtools::Directory("foo/bar").remove(); 27 | CXXTOOLS_UNIT_ASSERT(!cxxtools::Directory::exists("foo/bar")); 28 | CXXTOOLS_UNIT_ASSERT(cxxtools::Directory::exists("foo")); 29 | 30 | cxxtools::Directory("foo").remove(); 31 | CXXTOOLS_UNIT_ASSERT(!cxxtools::Directory::exists("foo")); 32 | } 33 | 34 | void updir() 35 | { 36 | cxxtools::Directory libdir("/usr/lib"); 37 | 38 | cxxtools::Directory usrdir = libdir.updir(); 39 | 40 | CXXTOOLS_UNIT_ASSERT(!usrdir.isRoot()); 41 | CXXTOOLS_UNIT_ASSERT_EQUALS(usrdir.path(), "/usr"); 42 | 43 | cxxtools::Directory rootdir = usrdir.updir(); 44 | CXXTOOLS_UNIT_ASSERT(rootdir.isRoot()); 45 | CXXTOOLS_UNIT_ASSERT_EQUALS(rootdir.path(), "/"); 46 | } 47 | }; 48 | 49 | cxxtools::unit::RegisterTest register_DirectoryTest; 50 | -------------------------------------------------------------------------------- /test/jsonechoclient.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | =head1 NAME 4 | 5 | =head1 SYNOPSIS 6 | 7 | =head1 DESCRIPTION 8 | 9 | =head1 OPTIONS 10 | 11 | =head1 AUTHOR 12 | 13 | Tommi MEkitalo, Tntnet.org 14 | 15 | =cut 16 | 17 | use strict; 18 | use JSON::RPC::Client; 19 | 20 | my $client = new JSON::RPC::Client; 21 | 22 | my $uri = 'http://localhost:7002/jsonrpc'; 23 | my $obj = { 24 | method => 'add', # or 'MyApp.sum' 25 | params => [10, 20], 26 | }; 27 | 28 | my $res = $client->call( $uri, $obj ); 29 | 30 | if($res){ 31 | if ($res->is_error) { 32 | print "Error : ", $res->error_message; 33 | } 34 | else { 35 | print $res->result; 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /test/jsonechoserver.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | =head1 NAME 4 | 5 | =head1 SYNOPSIS 6 | 7 | =head1 DESCRIPTION 8 | 9 | =head1 OPTIONS 10 | 11 | =head1 AUTHOR 12 | 13 | Tommi MEkitalo, Tntnet.org 14 | 15 | =cut 16 | 17 | use strict; 18 | use JSON::RPC::Server::Daemon; 19 | 20 | JSON::RPC::Server::Daemon->new(LocalPort => 8080) 21 | ->dispatch({'/jsonrpc' => 'MyApp'}) 22 | ->handle(); 23 | 24 | 25 | -------------------------------------------------------------------------------- /test/net-test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005-2009 by Marc Boris Duerner 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | #include "cxxtools/unit/testsuite.h" 29 | #include "cxxtools/unit/testmain.h" 30 | 31 | class NetTest : public cxxtools::unit::TestSuite 32 | { 33 | public: 34 | NetTest() 35 | : cxxtools::unit::TestSuite("net-test") 36 | { 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /test/test-main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Tommi Maekitalo 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * As a special exception, you may use this file as part of a free 10 | * software library without restriction. Specifically, if other files 11 | * instantiate templates or use macros or inline functions from this 12 | * file, or you compile this file and link it with other files to 13 | * produce an executable, this file does not by itself cause the 14 | * resulting executable to be covered by the GNU General Public 15 | * License. This exception does not however invalidate any other 16 | * reasons why the executable file might be covered by the GNU Library 17 | * General Public License. 18 | * 19 | * This library is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 | * Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public 25 | * License along with this library; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 | */ 28 | 29 | #include "cxxtools/unit/testmain.h" 30 | -------------------------------------------------------------------------------- /tools/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = \ 2 | siconvert \ 3 | cxxtz 4 | 5 | siconvert_SOURCES = siconvert.cpp 6 | cxxtz_SOURCES = cxxtz.cpp 7 | 8 | BASE_LIBS = $(top_builddir)/src/libcxxtools.la 9 | HTTP_LIBS = $(BASE_LIBS) $(top_builddir)/src/http/libcxxtools-http.la 10 | XMLRPC_LIBS = $(HTTP_LIBS) $(top_builddir)/src/xmlrpc/libcxxtools-xmlrpc.la 11 | BIN_LIBS = $(BASE_LIBS) $(top_builddir)/src/bin/libcxxtools-bin.la 12 | JSON_LIBS = $(HTTP_LIBS) $(top_builddir)/src/json/libcxxtools-json.la 13 | 14 | AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/include -I$(top_srcdir)/include 15 | LDADD = $(top_builddir)/src/libcxxtools.la 16 | 17 | siconvert_LDADD = $(BIN_LIBS) 18 | cxxtz_LDADD = $(BASE_LIBS) 19 | -------------------------------------------------------------------------------- /utils/git2changelog.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | =head1 NAME 4 | 5 | =head1 SYNOPSIS 6 | 7 | =head1 DESCRIPTION 8 | 9 | =head1 OPTIONS 10 | 11 | =head1 AUTHOR 12 | 13 | Tommi MEkitalo, Tntnet.org 14 | 15 | =cut 16 | 17 | use strict; 18 | 19 | my $author; 20 | my $date = ''; 21 | my %month = ( 22 | Jan => 1, 23 | Feb => 2, 24 | Mar => 3, 25 | Apr => 4, 26 | May => 5, 27 | Jun => 6, 28 | Jul => 7, 29 | Aug => 8, 30 | Sep => 9, 31 | Oct => 10, 32 | Nov => 11, 33 | Dec => 12 34 | ); 35 | 36 | my $content = ''; 37 | 38 | my $firstline; 39 | 40 | while (<>) 41 | { 42 | next if /^commit/ || /^\s*$/; 43 | 44 | if (/^Author:\s*(.+)/) 45 | { 46 | $author = $1; 47 | } 48 | elsif (my ($month, $day, $year) = /^Date:\s+\w+\s+(\w+)\s(\d+)\s\S+\s*(\d+)/) 49 | { 50 | $month = $month{$month} or die "invalid month $month"; 51 | my $newdate = sprintf('%04d-%02d-%02d', $year, $month, $day); 52 | if ($newdate ne $date) 53 | { 54 | $date = $newdate; 55 | print "\n$date $author\n\n"; 56 | } 57 | 58 | $firstline = 1; 59 | } 60 | else 61 | { 62 | s/^ //; 63 | if ($firstline) 64 | { 65 | print " - "; 66 | undef($firstline); 67 | } 68 | else 69 | { 70 | print " "; 71 | } 72 | 73 | print; 74 | } 75 | } 76 | --------------------------------------------------------------------------------