From d8f51eac91f86a1e00a05a5058a8fa9eb8732464 Mon Sep 17 00:00:00 2001 From: SomeDude Date: Wed, 16 Jan 2008 18:34:00 +0100 Subject: [PATCH] version 0.0.1 --- admin/addpeeridentity.php | 51 + admin/config.php | 7 + admin/createidentity.php | 36 + admin/index.php | 17 + admin/introduce.php | 75 + admin/layout_deneva.css | 65 + admin/linkbar.php | 19 + admin/options.php | 58 + admin/showcaptcha.php | 22 + admin/style_deneva.css | 110 + admin/template.php | 44 + include/base64.h | 15 + include/commandthread.h | 27 + include/datetime.h | 92 + include/db/sqlite3db.h | 17 + include/db/sqlite3db/sqlite3db.h | 49 + include/db/sqlite3db/sqlite3recordset.h | 44 + include/db/sqlite3db/sqlite3statement.h | 65 + .../captcha/easybmp/BSD_(revised)_license.txt | 10 + include/freenet/captcha/easybmp/EasyBMP.h | 86 + include/freenet/captcha/easybmp/EasyBMP_BMP.h | 86 + .../captcha/easybmp/EasyBMP_DataStructures.h | 104 + include/freenet/captcha/easybmp/EasyBMP_Font.h | 30 + include/freenet/captcha/easybmp/EasyBMP_Geometry.h | 33 + .../captcha/easybmp/EasyBMP_VariousBMPutilities.h | 43 + include/freenet/captcha/icaptcha.h | 17 + include/freenet/captcha/simplecaptcha.h | 24 + include/freenet/fcpv2.h | 92 + include/freenet/freenetmasterthread.h | 46 + include/freenet/freenetssk.h | 24 + include/freenet/identityinserter.h | 36 + include/freenet/identityintroductioninserter.h | 38 + include/freenet/identityintroductionrequester.h | 43 + include/freenet/identityintroductionxml.h | 25 + include/freenet/identityrequester.h | 43 + include/freenet/identityxml.h | 37 + include/freenet/ifcpconnected.h | 35 + include/freenet/ifcpmessagehandler.h | 20 + include/freenet/ifreenetregistrable.h | 17 + include/freenet/introductionpuzzleinserter.h | 39 + include/freenet/introductionpuzzleremover.h | 28 + include/freenet/introductionpuzzlerequester.h | 43 + include/freenet/introductionpuzzlexml.h | 35 + include/freenet/iperiodicprocessor.h | 16 + include/freenet/unkeyedidcreator.h | 40 + include/hex.h | 15 + include/idatabase.h | 18 + include/identitytestglobal.h | 24 + include/ifmsxmldocument.h | 83 + include/ilogger.h | 18 + include/logfile.h | 64 + include/option.h | 42 + include/pstdint.h | 679 ++++++ include/socketdefines.h | 25 + include/stringfunctions.h | 103 + include/uuidgenerator.h | 23 + include/xyssl/config.h | 278 +++ include/xyssl/sha1.h | 119 ++ src/base64.cpp | 97 + src/commandthread.cpp | 60 + src/datetime.cpp | 420 ++++ src/db/sqlite3db.cpp | 206 ++ src/db/sqlite3recordset.cpp | 85 + src/db/sqlite3statement.cpp | 337 +++ src/freenet/captcha/easybmp/EasyBMP.cpp | 1905 +++++++++++++++++ src/freenet/captcha/easybmp/EasyBMP_Font.cpp | 2178 ++++++++++++++++++++ src/freenet/captcha/easybmp/EasyBMP_Geometry.cpp | 367 ++++ src/freenet/captcha/simplecaptcha.cpp | 93 + src/freenet/fcpv2.cpp | 443 ++++ src/freenet/freenetmasterthread.cpp | 246 +++ src/freenet/freenetssk.cpp | 58 + src/freenet/identityinserter.cpp | 193 ++ src/freenet/identityintroductioninserter.cpp | 156 ++ src/freenet/identityintroductionrequester.cpp | 333 +++ src/freenet/identityintroductionxml.cpp | 68 + src/freenet/identityrequester.cpp | 329 +++ src/freenet/identityxml.cpp | 77 + src/freenet/introductionpuzzleinserter.cpp | 239 +++ src/freenet/introductionpuzzleremover.cpp | 36 + src/freenet/introductionpuzzlerequester.cpp | 313 +++ src/freenet/introductionpuzzlexml.cpp | 87 + src/freenet/unkeyedidcreator.cpp | 122 ++ src/hex.cpp | 49 + src/identitytestglobal.cpp | 255 +++ src/identitytestmain.cpp | 47 + src/logfile.cpp | 238 +++ src/option.cpp | 22 + src/socketdefines.cpp | 26 + src/stringfunctions.cpp | 201 ++ src/uuidgenerator.cpp | 23 + src/xyssl/sha1.c | 496 +++++ 91 files changed, 13199 insertions(+) create mode 100644 admin/addpeeridentity.php create mode 100644 admin/config.php create mode 100644 admin/createidentity.php create mode 100644 admin/index.php create mode 100644 admin/introduce.php create mode 100644 admin/layout_deneva.css create mode 100644 admin/linkbar.php create mode 100644 admin/options.php create mode 100644 admin/showcaptcha.php create mode 100644 admin/style_deneva.css create mode 100644 admin/template.php create mode 100644 include/base64.h create mode 100644 include/commandthread.h create mode 100644 include/datetime.h create mode 100644 include/db/sqlite3db.h create mode 100644 include/db/sqlite3db/sqlite3db.h create mode 100644 include/db/sqlite3db/sqlite3recordset.h create mode 100644 include/db/sqlite3db/sqlite3statement.h create mode 100644 include/freenet/captcha/easybmp/BSD_(revised)_license.txt create mode 100644 include/freenet/captcha/easybmp/EasyBMP.h create mode 100644 include/freenet/captcha/easybmp/EasyBMP_BMP.h create mode 100644 include/freenet/captcha/easybmp/EasyBMP_DataStructures.h create mode 100644 include/freenet/captcha/easybmp/EasyBMP_Font.h create mode 100644 include/freenet/captcha/easybmp/EasyBMP_Geometry.h create mode 100644 include/freenet/captcha/easybmp/EasyBMP_VariousBMPutilities.h create mode 100644 include/freenet/captcha/icaptcha.h create mode 100644 include/freenet/captcha/simplecaptcha.h create mode 100644 include/freenet/fcpv2.h create mode 100644 include/freenet/freenetmasterthread.h create mode 100644 include/freenet/freenetssk.h create mode 100644 include/freenet/identityinserter.h create mode 100644 include/freenet/identityintroductioninserter.h create mode 100644 include/freenet/identityintroductionrequester.h create mode 100644 include/freenet/identityintroductionxml.h create mode 100644 include/freenet/identityrequester.h create mode 100644 include/freenet/identityxml.h create mode 100644 include/freenet/ifcpconnected.h create mode 100644 include/freenet/ifcpmessagehandler.h create mode 100644 include/freenet/ifreenetregistrable.h create mode 100644 include/freenet/introductionpuzzleinserter.h create mode 100644 include/freenet/introductionpuzzleremover.h create mode 100644 include/freenet/introductionpuzzlerequester.h create mode 100644 include/freenet/introductionpuzzlexml.h create mode 100644 include/freenet/iperiodicprocessor.h create mode 100644 include/freenet/unkeyedidcreator.h create mode 100644 include/hex.h create mode 100644 include/idatabase.h create mode 100644 include/identitytestglobal.h create mode 100644 include/ifmsxmldocument.h create mode 100644 include/ilogger.h create mode 100644 include/logfile.h create mode 100644 include/option.h create mode 100644 include/pstdint.h create mode 100644 include/socketdefines.h create mode 100644 include/stringfunctions.h create mode 100644 include/uuidgenerator.h create mode 100644 include/xyssl/config.h create mode 100644 include/xyssl/sha1.h create mode 100644 src/base64.cpp create mode 100644 src/commandthread.cpp create mode 100644 src/datetime.cpp create mode 100644 src/db/sqlite3db.cpp create mode 100644 src/db/sqlite3recordset.cpp create mode 100644 src/db/sqlite3statement.cpp create mode 100644 src/freenet/captcha/easybmp/EasyBMP.cpp create mode 100644 src/freenet/captcha/easybmp/EasyBMP_Font.cpp create mode 100644 src/freenet/captcha/easybmp/EasyBMP_Geometry.cpp create mode 100644 src/freenet/captcha/simplecaptcha.cpp create mode 100644 src/freenet/fcpv2.cpp create mode 100644 src/freenet/freenetmasterthread.cpp create mode 100644 src/freenet/freenetssk.cpp create mode 100644 src/freenet/identityinserter.cpp create mode 100644 src/freenet/identityintroductioninserter.cpp create mode 100644 src/freenet/identityintroductionrequester.cpp create mode 100644 src/freenet/identityintroductionxml.cpp create mode 100644 src/freenet/identityrequester.cpp create mode 100644 src/freenet/identityxml.cpp create mode 100644 src/freenet/introductionpuzzleinserter.cpp create mode 100644 src/freenet/introductionpuzzleremover.cpp create mode 100644 src/freenet/introductionpuzzlerequester.cpp create mode 100644 src/freenet/introductionpuzzlexml.cpp create mode 100644 src/freenet/unkeyedidcreator.cpp create mode 100644 src/hex.cpp create mode 100644 src/identitytestglobal.cpp create mode 100644 src/identitytestmain.cpp create mode 100644 src/logfile.cpp create mode 100644 src/option.cpp create mode 100644 src/socketdefines.cpp create mode 100644 src/stringfunctions.cpp create mode 100644 src/uuidgenerator.cpp create mode 100644 src/xyssl/sha1.c diff --git a/admin/addpeeridentity.php b/admin/addpeeridentity.php new file mode 100644 index 0000000..5d24f0c --- /dev/null +++ b/admin/addpeeridentity.php @@ -0,0 +1,51 @@ +prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey=?;"); + $st->bindParam(1,$_REQUEST["publickey"]); + $st->execute(); + if($record=$st->fetch()) + { + $message="This peer already exists"; + } + else + { + $st2=$db->prepare("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES(?,?);"); + $st2->bindParam(1,$_REQUEST["publickey"]); + $st2->bindParam(2,gmdate('Y-m-d H:i:s')); + $st2->execute(); + $message="Peer added"; + } +?> +

+ +

Add Peer

+
+ + Peer Public Key +
+ The public key must be a valid SSK public key and include the / at the end +
+ +
+ \ No newline at end of file diff --git a/admin/config.php b/admin/config.php new file mode 100644 index 0000000..8f8947e --- /dev/null +++ b/admin/config.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/admin/createidentity.php b/admin/createidentity.php new file mode 100644 index 0000000..b3b76f7 --- /dev/null +++ b/admin/createidentity.php @@ -0,0 +1,36 @@ +prepare("INSERT INTO tblLocalIdentity(Name) VALUES(?);"); + $st->bindParam(1,$_REQUEST["name"]); + $st->execute(); +?> +

Identity Created

+ +

Create Identity

+
+ + Name : + +
+ \ No newline at end of file diff --git a/admin/index.php b/admin/index.php new file mode 100644 index 0000000..12c1653 --- /dev/null +++ b/admin/index.php @@ -0,0 +1,17 @@ + +

Home

+

+ Use these pages to administer your FMS installation. Make sure to set $dblocation correctly in config.php, and that the database is writable to your web service user account. While you should be able to safely use these pages while FMS is running, it is recommended that you shut down FMS prior to make any changes here. +

+ \ No newline at end of file diff --git a/admin/introduce.php b/admin/introduce.php new file mode 100644 index 0000000..29fe5e7 --- /dev/null +++ b/admin/introduce.php @@ -0,0 +1,75 @@ +prepare("SELECT LocalIdentityID, Name FROM tblLocalIdentity ORDER BY Name;"); + $st->execute(); + + print ""; +} + +function content() +{ + global $dblocation; + + $db=new PDO('sqlite:'.$dblocation); + + if(isset($_REQUEST["formaction"]) && $_REQUEST["formaction"]=="announce" && $_REQUEST["localidentityid"]!="") + { + $st=$db->prepare("INSERT INTO tblIdentityIntroductionInserts(LocalIdentityID,Day,UUID,Solution) VALUES(?,?,?,?);"); + + for($i=0; $ibindParam(1,$_REQUEST["localidentityid"]); + $st->bindParam(2,$_REQUEST["day"][$i]); + $st->bindParam(3,$_REQUEST["uuid"][$i]); + $st->bindParam(4,$_REQUEST["solution"][$i]); + $st->execute(); + } + } + } + + ?> +

Announce Identity

+
+ + Select Identity to announce + Type answers for a few puzzles and submit
"; + + + $st=$db->prepare("SELECT UUID,Day FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND Day>='".gmdate('Y-m-d',strtotime('-1 day'))."' AND Found='true';"); + $st->execute(); + + while($record=$st->fetch()) + { + print ""; + print ""; + print ""; + print ""; + print "
"; + } + ?> + +
+ \ No newline at end of file diff --git a/admin/layout_deneva.css b/admin/layout_deneva.css new file mode 100644 index 0000000..f3a8172 --- /dev/null +++ b/admin/layout_deneva.css @@ -0,0 +1,65 @@ +body { + width: auto; + margin: 1em; +} +p, div { + margin: 0em 0em 0em 0em; + padding: 0em; +} +h1, h2, h3, h4, h5, h6 { + margin: 0em 0em .2em 0em; + padding: 0em 0em .1em 0em; +} + +.banner { + margin: 0em; + padding: .5em; + +} +.navigation { + margin: 0em 0em 0em 0em; + padding: .3em; +} + +.content_main { + margin: 0em; + padding: 0em; +} + +.content_left { + float: left; + width: 200px; + margin: 1em 0em 0em 0em; + padding: 0em; +} +.content_left .box { + margin: 0em 0em 1em 0em; +} +.content_left .box .header { + padding: .5em; +} +.content_left .box p { + padding: 0em .3em 0em .3em; + margin: .0em 0em .5em 0em; +} + +.content_right { + position:absolute; + left:220px; + margin: 0px 0px 0px 0px; + padding: 1em; +} + +.meta-info { + text-align: right; +} + +.footer { + clear: both; + padding: 1em; + margin: 0em; +} + +.paragraph { + margin-bottom:.5em; + } \ No newline at end of file diff --git a/admin/linkbar.php b/admin/linkbar.php new file mode 100644 index 0000000..8876cf0 --- /dev/null +++ b/admin/linkbar.php @@ -0,0 +1,19 @@ + + + \ No newline at end of file diff --git a/admin/options.php b/admin/options.php new file mode 100644 index 0000000..b4f3757 --- /dev/null +++ b/admin/options.php @@ -0,0 +1,58 @@ +prepare("UPDATE tblOption SET OptionValue=? WHERE Option=?;"); + foreach($_REQUEST as $key=>$val) + { + $st->bindParam(1,$val); + $st->bindParam(2,$key); + $st->execute(); + } + } + +function content() +{ + global $dblocation; + $db=new PDO('sqlite:'.$dblocation); + + $rs=$db->query("SELECT Option, OptionValue, OptionDescription FROM tblOption;"); + +?> +

Options

+
+ + + + + + + + fetch()) + { + print ''; + print ''; + print ''; + print ''; + print ''; + } + ?> + + + +
OptionValueDescription
'.$record[0].''.$record[2].'
+
+ +
+
+ \ No newline at end of file diff --git a/admin/showcaptcha.php b/admin/showcaptcha.php new file mode 100644 index 0000000..81a01dd --- /dev/null +++ b/admin/showcaptcha.php @@ -0,0 +1,22 @@ +prepare("SELECT MimeType,PuzzleData FROM tblIntroductionPuzzleRequests WHERE UUID=?;"); + $st->bindParam(1,$_REQUEST['UUID']); + $st->execute(); + + if($record=$st->fetch()) + { + $data=base64_decode($record[1]); + header("Content-type: ".$record[0]); + header("Content-Length: ".strlen($data)); + print $data; + } + } + +?> \ No newline at end of file diff --git a/admin/style_deneva.css b/admin/style_deneva.css new file mode 100644 index 0000000..ffe4673 --- /dev/null +++ b/admin/style_deneva.css @@ -0,0 +1,110 @@ +body { + background-color: #FFF; + color: #000; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 90%; +} +a, a:link, a:active { color: #0000FF; text-decoration: none; } +a:visited { color: #003399; text-decoration: none; } +a:hover { color: #990000; text-decoration: underline; } +p {} +div { +} +h1 {} +h2 { color: #003366;} +h3 { color: #336699; border-bottom: 1px solid #336699;} +h4 { color: #6699CC; border-bottom: 1px solid #6699CC;} +h5 { color: #99CCFF;} + +ul { + padding:0px; + margin-top:5px; + margin-bottom:5px; + margin-left:25px; + } + +.banner { + background-color: #003366; + color: #FFFFFF; + font-weight: bolder; +} +.navigation { + background-color: #CCDDEE; + border: 1px solid #999999; + font-size: 80%; +} +.content_main { background-color: #FFFFFF;} +.content_left { + font-size: 90%; +} +.content_left .box { + border: 1px solid #336699; + background-color: #DDEEFF; + font-size: 85%; +} +.content_left .box .header { + background-color: #003366; + color: #FFFFFF; + font-weight: bold; + font-size: 1em; +} +.content_left .box p { +} +.content_right { +} +.footer { + color: #999; + font-size: smaller; + text-align: center; + border-top: 1px dashed #CCCCCC; +} +.meta-info { + font-size: 80%; +} +.paragraph { + line-height: 1.4em; +} + +.smaller { font-size: 65%; } +.darkest { background-color: #003366; } +.darker { background-color: #336699; } +.dark { background-color: #6699CC; } +.light { background-color: #99CCFF; } +.lighter { background-color: #DDEEFF; } +.lightest { background-color: #FFFFFF; } + +.xml1-attributename { color: #800000; } +.xml1-attributevalue { color: #FF0000; } +.xml1-cdatasection { color: #808000; } +.xml1-comment { color: #808080; font-style: italic; } +.xml1-currentline { color: #000000; } +.xml1-doctypesection { color: #008080; } +.xml1-elementname { color: #000080; } +.xml1-entityreference { color: #0000FF; } +.xml1-matchedbraces { color: #FF0000; } +.xml1-namespaceattributename { color: #008000; } +.xml1-namespaceattributevalue { color: #0000FF; } +.xml1-processinginstruction { color: #000080; } +.xml1-rightedge { color: #C0C0C0; } +.xml1-selection { color: #FFFFFF; } +.xml1-symbol { color: #808080; } +.xml1-text { color: #000000; } +.xml1-whitespace { color: #FFFFFF; } + +.calcheading { + font-weight:bold; + } + +.calcheading td { + padding-left:10px; + padding-right:10px; + } + +.calcrow td { + background-color:#EEEEEE; + text-align:right; + } + +.totalrow td { + text-align:right; + } \ No newline at end of file diff --git a/admin/template.php b/admin/template.php new file mode 100644 index 0000000..91f308d --- /dev/null +++ b/admin/template.php @@ -0,0 +1,44 @@ + + + FMS : Freenet Message System + + + + + + + + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + + diff --git a/include/base64.h b/include/base64.h new file mode 100644 index 0000000..276f7da --- /dev/null +++ b/include/base64.h @@ -0,0 +1,15 @@ +#ifndef _base64_ +#define _base64_ + +#include +#include + +namespace Base64 +{ + +const bool Encode(const std::vector &data, std::string &encoded); +const bool Decode(const std::string &encoded, std::vector &data); + +} // namespace + +#endif _base64_ diff --git a/include/commandthread.h b/include/commandthread.h new file mode 100644 index 0000000..0d51366 --- /dev/null +++ b/include/commandthread.h @@ -0,0 +1,27 @@ +#ifndef _commandthread_ +#define _commandthread_ + +#include "ilogger.h" +#include "idatabase.h" + +#include + +class CommandThread:public ZThread::Runnable,public ILogger, public IDatabase +{ +public: + + void run(); + +private: + + void HandleInput(const std::string &input); + + // methods to handle commands + void HandleHelpCommand(); + void HandleQuit(); + + bool m_running; + +}; + +#endif // _commandthread_ diff --git a/include/datetime.h b/include/datetime.h new file mode 100644 index 0000000..032fe5d --- /dev/null +++ b/include/datetime.h @@ -0,0 +1,92 @@ +#ifndef _date_time_ +#define _date_time_ + +#include +#include + +/* + Year actual year + Month 1=Jan,2=Feb,etc + Day 1 to last day of month + Hour 0 to 23 + Minute 0 to 59 + Second 0 to 59 + + WeekDay 0=Sunday,1=Monday,etc + YearDay 1=Jan 1st, 2=Jan 2nd, etc + +*/ + +class DateTime +{ +public: + DateTime(); + DateTime(const time_t &timet); + DateTime(const struct tm *stm); + ~DateTime() {} + + void Add(const int seconds=0, const int minutes=0, const int hours=0, const int days=0, const int months=0, const int years=0); + + void Set(const int year=1970, const int month=1, const int day=1, const int hour=0, const int minute=0, const int second=0); + void Set(const time_t &timet); + void Set(const struct tm *stm); + void Set(const std::string &datestring); // method only will work with a select few basic input formats + + void SetToLocalTime(); + void SetToGMTime(); + + const int GetYear() const { return m_tm.tm_year+1900; } + void SetYear(const int year) { m_tm.tm_year=year-1900; } + const int GetMonth() const { return m_tm.tm_mon+1; } + void SetMonth(const int month) { m_tm.tm_mon=month-1; } + const int GetDay() const { return m_tm.tm_mday; } + void SetDay(const int day) { m_tm.tm_mday=day; } + const int GetWeekDay() const { return m_tm.tm_wday; } + void SetWeekDay(const int weekday) { m_tm.tm_wday=weekday; } + const int GetYearDay() const { return m_tm.tm_yday+1; } + void SetYearDay(const int yearday) { m_tm.tm_yday=yearday-1; } + const int GetHour() const { return m_tm.tm_hour; } + void SetHour(const int hour) { m_tm.tm_hour=hour; } + const int GetMinute() const { return m_tm.tm_min; } + void SetMinute(const int minute) { m_tm.tm_min=minute; } + const int GetSecond() const { return m_tm.tm_sec; } + void SetSecond(const int second) { m_tm.tm_sec=second; } + const int GetIsDaylightTime() const { return m_tm.tm_isdst; } + void SetIsDaylightTime(const int daylighttime) { m_tm.tm_isdst=daylighttime; } + + void Normalize(); // normalizes any date changes that were made + + std::string Format(const std::string &formatstring) const; + + DateTime operator+(const double &rhs); + DateTime operator+(const DateTime &rhs); + DateTime &operator+=(const double &rhs); + DateTime &operator+=(const DateTime &rhs); + DateTime operator-(const double &rhs); + DateTime operator-(const DateTime &rhs); + DateTime &operator-=(const double &rhs); + DateTime &operator-=(const DateTime &rhs); + + const bool operator==(const DateTime &rhs) const { return m_timet==rhs.m_timet; } + const bool operator==(const time_t &rhs) const { return m_timet==rhs; } + const bool operator==(const struct tm &rhs) const; + + const bool operator<(const DateTime &rhs) const { return (m_timet(const DateTime &rhs) const { return (m_timet>rhs.m_timet); } + const bool operator>(const time_t &rhs) const { return (m_timet>rhs); } + + const bool operator>=(const DateTime &rhs) const { return (*this>rhs || *this==rhs); } + const bool operator>=(const time_t &rhs) const { return (m_timet>=rhs); } + +private: + + time_t m_timet; + struct tm m_tm; +}; + +#endif // _date_time_ diff --git a/include/db/sqlite3db.h b/include/db/sqlite3db.h new file mode 100644 index 0000000..5e3b63d --- /dev/null +++ b/include/db/sqlite3db.h @@ -0,0 +1,17 @@ +#ifndef _sqlite3db_base_ +#define _sqlite3db_base_ + +namespace SQLite3DB +{ + +class DB; +class Recordset; +class Statement; + +} // namespace + +#include "sqlite3db/sqlite3db.h" +#include "sqlite3db/sqlite3recordset.h" +#include "sqlite3db/sqlite3statement.h" + +#endif // _sqlite3db_base_ diff --git a/include/db/sqlite3db/sqlite3db.h b/include/db/sqlite3db/sqlite3db.h new file mode 100644 index 0000000..24c4a3a --- /dev/null +++ b/include/db/sqlite3db/sqlite3db.h @@ -0,0 +1,49 @@ +#ifndef _sqlite3db_ +#define _sqlite3db_ + +#include +#include +#include +#include + +#include "../sqlite3db.h" + +namespace SQLite3DB +{ + +class DB:public ZThread::Singleton +{ +public: + DB(); + DB(std::string filename); + ~DB(); + + const bool Open(const std::string &filename); + const bool Close(); + + const int GetLastResult() { return m_lastresult; } // gets result of last action taken - standard sqlite3 return codes + const int GetLastError(std::string &errormessage); // gets last error of this database + + const bool IsOpen(); + + const bool Execute(const std::string &sql); // executes a statement returing true if successful + const bool ExecuteInsert(const std::string &sql, long &insertid); // call when inserting data and the insertid of the row inserted is needed, otherwise Execute can be called if the row id is not needed + Recordset Query(const std::string &sql); // executes a statement returning a recordset + Statement Prepare(const std::string &sql); // prepares a statement returning the statement object + + const int SetBusyTimeout(const int ms); // sets busy timeout in ms. SQLite will wait for a lock up to this many ms before returning SQLITE_BUSY + + sqlite3 *GetDB() { return m_db; } + + ZThread::Mutex m_mutex; // public so that recordset and statment can lock this mutex themselves + +private: + void Initialize(); + + sqlite3 *m_db; + int m_lastresult; +}; + +} // namespace + +#endif // _sqlite3db_ diff --git a/include/db/sqlite3db/sqlite3recordset.h b/include/db/sqlite3db/sqlite3recordset.h new file mode 100644 index 0000000..69ad5e5 --- /dev/null +++ b/include/db/sqlite3db/sqlite3recordset.h @@ -0,0 +1,44 @@ +#ifndef _sqlite3recordset_ +#define _sqlite3recordset_ + +#include "sqlite3db.h" + +namespace SQLite3DB +{ + +class Recordset +{ +public: + Recordset(); + Recordset(char **rs, int rows, int cols); + virtual ~Recordset(); + + virtual void Free() { if(m_rs) { sqlite3_free_table(m_rs); m_rs=NULL; } } + virtual const bool Empty() { return (m_rs==NULL || m_rows==0) ? true : false ; } + + virtual const int Count() { return m_rows; } + virtual const bool AtBeginning() { return m_currentrow==0; } + virtual const bool AtEnd() { return m_currentrow>=m_rows; } + + virtual const bool Next() { if(m_currentrow=0) { m_currentrow--; return true; } else { return false; } } + virtual void Beginning() { m_currentrow=0; } + + virtual const char *Get(const int row, const int field); + virtual const char *GetField(const int field); + virtual const int GetInt(const int field); + virtual const double GetDouble(const int field); + + virtual void Open(const std::string &sql, DB *db); + +private: + char **m_rs; + int m_rows; + int m_cols; + int m_currentrow; + +}; // class Recordset + +} // namespace + +#endif // _sqlite3recordset_ diff --git a/include/db/sqlite3db/sqlite3statement.h b/include/db/sqlite3db/sqlite3statement.h new file mode 100644 index 0000000..835d359 --- /dev/null +++ b/include/db/sqlite3db/sqlite3statement.h @@ -0,0 +1,65 @@ +#ifndef _sqlite3dbstatement_ +#define _sqlite3dbstatement_ + +#include "sqlite3db.h" + +#include +#include + +namespace SQLite3DB +{ + +class Statement +{ +public: + Statement(); + Statement(sqlite3_stmt *statement); + Statement(Statement &rhs); + virtual ~Statement(); + + virtual const int ParameterCount() { return m_parametercount; } + virtual const int ResultColumnCount() { return m_resultcolumncount; } + + virtual const bool Valid(); + + virtual void Finalize(); + + virtual const bool Reset(); + virtual const bool Step(const bool saveinsertrowid=false); + + virtual const bool RowReturned() { return m_rowreturned; } + + virtual const long GetLastInsertRowID() { return m_lastinsertrowid; } + + // both Bind and Result have column index starting at 0 + // Blob results are not copied, user must make a copy in memory if it needs to be used in the future + + virtual const bool Bind(const int column); + virtual const bool Bind(const int column, const int value); + virtual const bool Bind(const int column, const double value); + virtual const bool Bind(const int column, const std::string &value); + virtual const bool Bind(const int column, const void *data, const int length); + + virtual const bool ResultNull(const int column); + virtual const bool ResultInt(const int column, int &result); + virtual const bool ResultDouble(const int column, double &result); + virtual const bool ResultText(const int column, std::string &result); + virtual const bool ResultBlob(const int column, void *data, int &length); + + Statement &operator=(const Statement &rhs); + +private: + sqlite3_stmt *m_statement; + int m_parametercount; + int m_resultcolumncount; + bool m_rowreturned; + long m_lastinsertrowid; + + static std::map m_statementcount; + std::vector textptrs; + +}; //class + +} // namespace + +#endif // _sqlite3dbstatement_ diff --git a/include/freenet/captcha/easybmp/BSD_(revised)_license.txt b/include/freenet/captcha/easybmp/BSD_(revised)_license.txt new file mode 100644 index 0000000..6785262 --- /dev/null +++ b/include/freenet/captcha/easybmp/BSD_(revised)_license.txt @@ -0,0 +1,10 @@ +Copyright (c) 2005, The EasyBMP Project (http://easybmp.sourceforge.net) +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/include/freenet/captcha/easybmp/EasyBMP.h b/include/freenet/captcha/easybmp/EasyBMP.h new file mode 100644 index 0000000..ead98c1 --- /dev/null +++ b/include/freenet/captcha/easybmp/EasyBMP.h @@ -0,0 +1,86 @@ +/************************************************* +* * +* EasyBMP Cross-Platform Windows Bitmap Library * +* * +* Author: Paul Macklin * +* email: macklin01@users.sourceforge.net * +* support: http://easybmp.sourceforge.net * +* * +* file: EasyBMP.h * +* date added: 01-31-2005 * +* date modified: 12-01-2006 * +* version: 1.06 * +* * +* License: BSD (revised/modified) * +* Copyright: 2005-6 by the EasyBMP Project * +* * +* description: Main include file * +* * +*************************************************/ + +#ifdef _MSC_VER +// MS Visual Studio gives warnings when using +// fopen. But fopen_s is not going to work well +// with most compilers, and fopen_s uses different +// syntax than fopen. (i.e., a macro won't work) +// So, we'lll use this: +#define _CRT_SECURE_NO_DEPRECATE +#endif + +#include +#include +#include +#include + +#ifndef EasyBMP +#define EasyBMP + +#ifdef __BCPLUSPLUS__ +// The Borland compiler must use this because something +// is wrong with their cstdio file. +#include +#else +#include +#endif + +#ifdef __GNUC__ +// If g++ specific code is ever required, this is +// where it goes. +#endif + +#ifdef __INTEL_COMPILER +// If Intel specific code is ever required, this is +// where it goes. +#endif + +#ifndef _DefaultXPelsPerMeter_ +#define _DefaultXPelsPerMeter_ +#define DefaultXPelsPerMeter 3780 +// set to a default of 96 dpi +#endif + +#ifndef _DefaultYPelsPerMeter_ +#define _DefaultYPelsPerMeter_ +#define DefaultYPelsPerMeter 3780 +// set to a default of 96 dpi +#endif + +#include "EasyBMP_DataStructures.h" +#include "EasyBMP_BMP.h" +#include "EasyBMP_VariousBMPutilities.h" + +#ifndef _EasyBMP_Version_ +#define _EasyBMP_Version_ 1.06 +#define _EasyBMP_Version_Integer_ 106 +#define _EasyBMP_Version_String_ "1.06" +#endif + +#ifndef _EasyBMPwarnings_ +#define _EasyBMPwarnings_ +#endif + +void SetEasyBMPwarningsOff( void ); +void SetEasyBMPwarningsOn( void ); +bool GetEasyBMPwarningState( void ); + +#endif diff --git a/include/freenet/captcha/easybmp/EasyBMP_BMP.h b/include/freenet/captcha/easybmp/EasyBMP_BMP.h new file mode 100644 index 0000000..819a976 --- /dev/null +++ b/include/freenet/captcha/easybmp/EasyBMP_BMP.h @@ -0,0 +1,86 @@ +/************************************************* +* * +* EasyBMP Cross-Platform Windows Bitmap Library * +* * +* Author: Paul Macklin * +* email: macklin01@users.sourceforge.net * +* support: http://easybmp.sourceforge.net * +* * +* file: EasyBMP_VariousBMPutilities.h * +* date added: 05-02-2005 * +* date modified: 12-01-2006 * +* version: 1.06 * +* * +* License: BSD (revised/modified) * +* Copyright: 2005-6 by the EasyBMP Project * +* * +* description: Defines BMP class * +* * +*************************************************/ + +#ifndef _EasyBMP_BMP_h_ +#define _EasyBMP_BMP_h_ + +bool SafeFread( char* buffer, int size, int number, FILE* fp ); +bool EasyBMPcheckDataSize( void ); + +class BMP +{private: + + int BitDepth; + int Width; + int Height; + RGBApixel** Pixels; + RGBApixel* Colors; + int XPelsPerMeter; + int YPelsPerMeter; + + ebmpBYTE* MetaData1; + int SizeOfMetaData1; + ebmpBYTE* MetaData2; + int SizeOfMetaData2; + + bool Read32bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Read24bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Read8bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Read4bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Read1bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + + bool Write32bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Write24bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Write8bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Write4bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Write1bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + + ebmpBYTE FindClosestColor( RGBApixel& input ); + + public: + + int TellBitDepth( void ); + int TellWidth( void ); + int TellHeight( void ); + int TellNumberOfColors( void ); + void SetDPI( int HorizontalDPI, int VerticalDPI ); + int TellVerticalDPI( void ); + int TellHorizontalDPI( void ); + + BMP(); + BMP( BMP& Input ); + ~BMP(); + RGBApixel* operator()(int i,int j); + + RGBApixel GetPixel( int i, int j ) const; + bool SetPixel( int i, int j, RGBApixel NewPixel ); + + bool CreateStandardColorTable( void ); + + bool SetSize( int NewWidth, int NewHeight ); + bool SetBitDepth( int NewDepth ); + bool WriteToFile( const char* FileName ); + bool ReadFromFile( const char* FileName ); + + RGBApixel GetColor( int ColorNumber ); + bool SetColor( int ColorNumber, RGBApixel NewColor ); +}; + +#endif diff --git a/include/freenet/captcha/easybmp/EasyBMP_DataStructures.h b/include/freenet/captcha/easybmp/EasyBMP_DataStructures.h new file mode 100644 index 0000000..82b6179 --- /dev/null +++ b/include/freenet/captcha/easybmp/EasyBMP_DataStructures.h @@ -0,0 +1,104 @@ +/************************************************* +* * +* EasyBMP Cross-Platform Windows Bitmap Library * +* * +* Author: Paul Macklin * +* email: macklin01@users.sourceforge.net * +* support: http://easybmp.sourceforge.net * +* * +* file: EasyBMP_DataStructures.h * +* date added: 05-02-2005 * +* date modified: 12-01-2006 * +* version: 1.06 * +* * +* License: BSD (revised/modified) * +* Copyright: 2005-6 by the EasyBMP Project * +* * +* description: Defines basic data structures for * +* the BMP class * +* * +*************************************************/ + +#ifndef _EasyBMP_Custom_Math_Functions_ +#define _EasyBMP_Custom_Math_Functions_ +inline double Square( double number ) +{ return number*number; } + +inline int IntSquare( int number ) +{ return number*number; } +#endif + +int IntPow( int base, int exponent ); + +#ifndef _EasyBMP_Defined_WINGDI +#define _EasyBMP_Defined_WINGDI + typedef unsigned char ebmpBYTE; + typedef unsigned short ebmpWORD; + typedef unsigned int ebmpDWORD; +#endif + +#ifndef _EasyBMP_DataStructures_h_ +#define _EasyBMP_DataStructures_h_ + +inline bool IsBigEndian() +{ + short word = 0x0001; + if((*(char *)& word) != 0x01 ) + { return true; } + return false; +} + +inline ebmpWORD FlipWORD( ebmpWORD in ) +{ return ( (in >> 8) | (in << 8) ); } + +inline ebmpDWORD FlipDWORD( ebmpDWORD in ) +{ + return ( ((in&0xFF000000)>>24) | ((in&0x000000FF)<<24) | + ((in&0x00FF0000)>>8 ) | ((in&0x0000FF00)<<8 ) ); +} + +// it's easier to use a struct than a class +// because we can read/write all four of the bytes +// at once (as we can count on them being continuous +// in memory + +typedef struct RGBApixel { + ebmpBYTE Blue; + ebmpBYTE Green; + ebmpBYTE Red; + ebmpBYTE Alpha; +} RGBApixel; + +class BMFH{ +public: + ebmpWORD bfType; + ebmpDWORD bfSize; + ebmpWORD bfReserved1; + ebmpWORD bfReserved2; + ebmpDWORD bfOffBits; + + BMFH(); + void display( void ); + void SwitchEndianess( void ); +}; + +class BMIH{ +public: + ebmpDWORD biSize; + ebmpDWORD biWidth; + ebmpDWORD biHeight; + ebmpWORD biPlanes; + ebmpWORD biBitCount; + ebmpDWORD biCompression; + ebmpDWORD biSizeImage; + ebmpDWORD biXPelsPerMeter; + ebmpDWORD biYPelsPerMeter; + ebmpDWORD biClrUsed; + ebmpDWORD biClrImportant; + + BMIH(); + void display( void ); + void SwitchEndianess( void ); +}; + +#endif diff --git a/include/freenet/captcha/easybmp/EasyBMP_Font.h b/include/freenet/captcha/easybmp/EasyBMP_Font.h new file mode 100644 index 0000000..067903e --- /dev/null +++ b/include/freenet/captcha/easybmp/EasyBMP_Font.h @@ -0,0 +1,30 @@ +/************************************************* +* * +* EasyBMP Cross-Platform Windows Bitmap Library * +* * +* Author: Paul Macklin * +* email: pmacklin@math.uci.edu * +* * +* file: EasyBMP_Font.h * +* date: 2-21-2005 * +* version: 1.05.00 * +* * +* License: BSD (revised) * +* Copyright: 2005-2006 by the EasyBMP Project * +* * +* description: draw a simple font * +* * +*************************************************/ + +#include "EasyBMP.h" + +#ifndef COPYRIGHT_SYMBOL +#define COPYRIGHT_SYMBOL -100 +#endif + +int PrintCopyright( BMP& Image, int TopLeftX, int TopLeftY , int Height , + RGBApixel Color ); +int PrintLetter( BMP& Image, char Letter , int TopLeftX, int TopLeftY, int Height , + RGBApixel Color ); +int PrintString( BMP& Image, char* String , int TopLeftX, int TopLeftY , int Height , + RGBApixel Color ); diff --git a/include/freenet/captcha/easybmp/EasyBMP_Geometry.h b/include/freenet/captcha/easybmp/EasyBMP_Geometry.h new file mode 100644 index 0000000..cc97365 --- /dev/null +++ b/include/freenet/captcha/easybmp/EasyBMP_Geometry.h @@ -0,0 +1,33 @@ +/************************************************* +* * +* EasyBMP Cross-Platform Windows Bitmap Library * +* * +* Author: Paul Macklin * +* email: pmacklin@math.uci.edu * +* * +* file: EasyBMP_Geometry.h * +* date: 2-21-2005 * +* version: 1.05.00 * +* * +* License: BSD (revised) * +* Copyright: 2005-2006 by the EasyBMP Project * +* * +* description: draw simple geometric objects * +* * +*************************************************/ + +#include "EasyBMP.h" + +int ebmpRound( double input ); +double InverseAngle( double Xdir, double Ydir ); +double LineFunction( double SlopeX , double SlopeY, + int StartX, int StartY, double TestX, double TestY ); +void DrawAALine( BMP &Image , int FromX, int FromY, + int ToX, int ToY , RGBApixel Color ); +void DrawFastLine( BMP &Image , int FromX, int FromY, + int ToX, int ToY , RGBApixel Color ); +void DrawArc( BMP &Image , double CenterX, double CenterY , double Radius, + double FromTheta, double ToTheta , RGBApixel Color ); +void DrawLine( BMP &Image , int FromX , int FromY, + int ToX, int ToY, RGBApixel Color ); + diff --git a/include/freenet/captcha/easybmp/EasyBMP_VariousBMPutilities.h b/include/freenet/captcha/easybmp/EasyBMP_VariousBMPutilities.h new file mode 100644 index 0000000..349dda6 --- /dev/null +++ b/include/freenet/captcha/easybmp/EasyBMP_VariousBMPutilities.h @@ -0,0 +1,43 @@ +/************************************************* +* * +* EasyBMP Cross-Platform Windows Bitmap Library * +* * +* Author: Paul Macklin * +* email: macklin01@users.sourceforge.net * +* support: http://easybmp.sourceforge.net * +* * +* file: EasyBMP_VariousBMPutilities.h * +* date added: 05-02-2005 * +* date modified: 12-01-2006 * +* version: 1.06 * +* * +* License: BSD (revised/modified) * +* Copyright: 2005-6 by the EasyBMP Project * +* * +* description: Various utilities. * +* * +*************************************************/ + +#ifndef _EasyBMP_VariousBMPutilities_h_ +#define _EasyBMP_VariousBMPutilities_h_ + +BMFH GetBMFH( const char* szFileNameIn ); +BMIH GetBMIH( const char* szFileNameIn ); +void DisplayBitmapInfo( const char* szFileNameIn ); +int GetBitmapColorDepth( const char* szFileNameIn ); +void PixelToPixelCopy( BMP& From, int FromX, int FromY, + BMP& To, int ToX, int ToY); +void PixelToPixelCopyTransparent( BMP& From, int FromX, int FromY, + BMP& To, int ToX, int ToY, + RGBApixel& Transparent ); +void RangedPixelToPixelCopy( BMP& From, int FromL , int FromR, int FromB, int FromT, + BMP& To, int ToX, int ToY ); +void RangedPixelToPixelCopyTransparent( + BMP& From, int FromL , int FromR, int FromB, int FromT, + BMP& To, int ToX, int ToY , + RGBApixel& Transparent ); +bool CreateGrayscaleColorTable( BMP& InputImage ); + +bool Rescale( BMP& InputImage , char mode, int NewDimension ); + +#endif diff --git a/include/freenet/captcha/icaptcha.h b/include/freenet/captcha/icaptcha.h new file mode 100644 index 0000000..a3a23b4 --- /dev/null +++ b/include/freenet/captcha/icaptcha.h @@ -0,0 +1,17 @@ +#ifndef _icaptcha_ +#define _icaptcha_ + +#include + +class ICaptcha +{ +public: + + virtual void Generate()=0; + + virtual const bool GetPuzzle(std::vector &puzzle)=0; + virtual const bool GetSolution(std::vector &solution)=0; + +}; + +#endif // _icaptcha_ diff --git a/include/freenet/captcha/simplecaptcha.h b/include/freenet/captcha/simplecaptcha.h new file mode 100644 index 0000000..4dec4dc --- /dev/null +++ b/include/freenet/captcha/simplecaptcha.h @@ -0,0 +1,24 @@ +#ifndef _simple_captcha_ +#define _simple_captcha_ + +#include "icaptcha.h" + +class SimpleCaptcha:public ICaptcha +{ +public: + + void Generate(); + + const bool GetPuzzle(std::vector &puzzle); + const bool GetSolution(std::vector &solution); + +private: + const std::string GenerateRandomString(const int len); + void ReadPuzzleData(const std::string &filename); + + std::vector m_puzzle; + std::vector m_solution; + +}; + +#endif // _simple_captcha_ diff --git a/include/freenet/fcpv2.h b/include/freenet/fcpv2.h new file mode 100644 index 0000000..864b14f --- /dev/null +++ b/include/freenet/fcpv2.h @@ -0,0 +1,92 @@ +/* + + FCPv2 C++ library + + link with ws2_32.lib in Windows + +*/ + +#ifndef _fcpv2_ +#define _fcpv2_ + +#ifdef _WIN32 + #include + #include +#else + #include + #include + #include + #include +#endif + +#include +#include +#include + + +class FCPMessage:public std::map +{ +public: + FCPMessage() {}; + FCPMessage(const std::string &name) {m_name=name;} + + const std::string GetName() const { return m_name; } + void SetName(const std::string &name) { m_name=name; } + + void Reset() { m_name=""; clear(); } + +protected: + std::string m_name; +}; + +class FCPv2 +{ +public: + FCPv2(); + ~FCPv2(); + + const bool Connect(const char *host, const int port); + const bool Disconnect(); + + const bool Connected() const { return m_serversocket!=-1 ? true : false ; } + + const bool Update(const long waittime); + + const int SendMessage(const char *messagename, const int fieldcount, ...); + const int SendMessage(FCPMessage &message); + const int SendRaw(const char *data, const int datalen); + const std::vector::size_type SendBufferSize() const { return m_sendbuffer.size(); } + + FCPMessage ReceiveMessage(); + const long ReceiveRaw(char *data, long &datalen); // data must be preallocated, with datalen being max length of data. Returns length of data received + const std::vector::size_type ReceiveBufferSize() const { return m_receivebuffer.size(); } + +private: + + void SocketReceive(); + void SocketSend(); + + void SendBufferedText(const char *text); // puts text on send buffer + void SendBufferedRaw(const char *data, const long len); // puts raw data on send buffer + + int FindOnReceiveBuffer(const char *text); // finds text string on receive buffer and returns index to first char position, -1 if not found + + +#ifdef _WIN32 + static bool m_wsastartup; +#endif + + int m_serversocket; + + char *m_tempbuffer; // temp buffer used for recv + + std::vector m_sendbuffer; + std::vector m_receivebuffer; + + fd_set m_readfs; + fd_set m_writefs; + struct timeval m_timeval; + +}; + +#endif // _fcpv2_ diff --git a/include/freenet/freenetmasterthread.h b/include/freenet/freenetmasterthread.h new file mode 100644 index 0000000..f84acc1 --- /dev/null +++ b/include/freenet/freenetmasterthread.h @@ -0,0 +1,46 @@ +#ifndef _freenetmasterthread_ +#define _freenetmasterthread_ + +#include "../ilogger.h" +#include "ifreenetregistrable.h" +#include "ifcpmessagehandler.h" +#include "ifcpconnected.h" +#include "iperiodicprocessor.h" + +#include + +// forward declaration +class IFreenetRegistrable; + +class FreenetMasterThread:public ZThread::Runnable,public ILogger, public IFCPMessageHandler +{ +public: + FreenetMasterThread(); + ~FreenetMasterThread(); + + const bool HandleMessage(FCPMessage &message); + + void run(); + + // registration methods for children objects + void RegisterPeriodicProcessor(IPeriodicProcessor *obj); + void RegisterFCPConnected(IFCPConnected *obj); + void RegisterFCPMessageHandler(IFCPMessageHandler *obj); + +private: + const bool FCPConnect(); + void Setup(); + void Shutdown(); + + std::string m_fcphost; + long m_fcpport; + FCPv2 m_fcp; + std::vector m_registrables; + std::vector m_processors; + std::vector m_fcpconnected; + std::vector m_fcpmessagehandlers; + bool m_receivednodehello; + +}; + +#endif // _freenetmasterthread_ diff --git a/include/freenet/freenetssk.h b/include/freenet/freenetssk.h new file mode 100644 index 0000000..d7829f8 --- /dev/null +++ b/include/freenet/freenetssk.h @@ -0,0 +1,24 @@ +#ifndef _freenetssk_ +#define _freenetssk_ + +#include + +class FreenetSSK +{ +public: + + const bool ValidBaseKey(const std::string &key) const; + const bool ValidPublicKey() const; + const bool ValidPrivateKey() const; + + const bool SetPublicKey(const std::string &publickey); + const bool SetPrivateKey(const std::string &privatekey); + +private: + + std::string m_publickey; + std::string m_privatekey; + +}; + +#endif // _freenetssk_ diff --git a/include/freenet/identityinserter.h b/include/freenet/identityinserter.h new file mode 100644 index 0000000..9c5e328 --- /dev/null +++ b/include/freenet/identityinserter.h @@ -0,0 +1,36 @@ +#ifndef _identity_inserter_ +#define _identity_inserter_ + +#include "../idatabase.h" +#include "../ilogger.h" +#include "../datetime.h" +#include "ifreenetregistrable.h" +#include "ifcpconnected.h" +#include "ifcpmessagehandler.h" +#include "iperiodicprocessor.h" + +class IdentityInserter:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger +{ +public: + IdentityInserter(); + IdentityInserter(FCPv2 *fcp); + + void FCPConnected(); + void FCPDisconnected(); + + const bool HandleMessage(FCPMessage &message); + + void Process(); + + void RegisterWithThread(FreenetMasterThread *thread); + +private: + void Initialize(); + void CheckForNeededInsert(); + void StartInsert(const long localidentityid); + + DateTime m_lastchecked; + +}; + +#endif // _identity_inserter_ diff --git a/include/freenet/identityintroductioninserter.h b/include/freenet/identityintroductioninserter.h new file mode 100644 index 0000000..d975104 --- /dev/null +++ b/include/freenet/identityintroductioninserter.h @@ -0,0 +1,38 @@ +#ifndef _identityintroductioninserter_ +#define _identityintroductioninserter_ + +#include "../idatabase.h" +#include "../datetime.h" +#include "../ilogger.h" +#include "ifreenetregistrable.h" +#include "ifcpconnected.h" +#include "ifcpmessagehandler.h" +#include "iperiodicprocessor.h" + +class IdentityIntroductionInserter:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger +{ +public: + IdentityIntroductionInserter(); + IdentityIntroductionInserter(FCPv2 *fcp); + + void FCPConnected(); + void FCPDisconnected(); + + const bool HandleMessage(FCPMessage &message); + + void Process(); + + void RegisterWithThread(FreenetMasterThread *thread); + +private: + void Initialize(); + void CheckForNewInserts(); + void StartInsert(const long localidentityid, const std::string &day, const std::string &UUID, const std::string &solution); + + std::string m_messagebase; + DateTime m_lastchecked; + bool m_inserting; + +}; + +#endif // _identityintroductioninserter_ diff --git a/include/freenet/identityintroductionrequester.h b/include/freenet/identityintroductionrequester.h new file mode 100644 index 0000000..a7b236f --- /dev/null +++ b/include/freenet/identityintroductionrequester.h @@ -0,0 +1,43 @@ +#ifndef _identityintroduction_requester_ +#define _identityintroduction_requester_ + +#include "../idatabase.h" +#include "../ilogger.h" +#include "../datetime.h" +#include "ifreenetregistrable.h" +#include "ifcpconnected.h" +#include "ifcpmessagehandler.h" +#include "iperiodicprocessor.h" + +class IdentityIntroductionRequester:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger +{ +public: + IdentityIntroductionRequester(); + IdentityIntroductionRequester(FCPv2 *fcp); + + void FCPDisconnected(); + void FCPConnected(); + const bool HandleMessage(FCPMessage &message); + + void Process(); + + void RegisterWithThread(FreenetMasterThread *thread); + +private: + void Initialize(); + void StartRequests(const long localidentityid); + void StartRequest(const std::string &UUID); + void PopulateIDList(); + void RemoveFromRequestList(const std::string &UUID); + const bool HandleGetFailed(FCPMessage &message); + const bool HandleAllData(FCPMessage &message); + + DateTime m_tempdate; + std::map m_ids; + std::vector m_requesting; + std::string m_messagebase; + long m_maxrequests; + +}; + +#endif // _identityintroduction_requester_ diff --git a/include/freenet/identityintroductionxml.h b/include/freenet/identityintroductionxml.h new file mode 100644 index 0000000..0f2a827 --- /dev/null +++ b/include/freenet/identityintroductionxml.h @@ -0,0 +1,25 @@ +#ifndef _identityintroductionxml_ +#define _identityintroductionxml_ + +#include "../ifmsxmldocument.h" + +class IdentityIntroductionXML:public IFMSXMLDocument +{ +public: + IdentityIntroductionXML(); + + std::string GetXML(); + + const bool ParseXML(const std::string &xml); + + const std::string GetIdentity() const { return m_identity; } + void SetIdentity(const std::string &identity) { m_identity=identity; } + +private: + void Initialize(); + + std::string m_identity; + +}; + +#endif // _identityintroductionxml_ diff --git a/include/freenet/identityrequester.h b/include/freenet/identityrequester.h new file mode 100644 index 0000000..ebea425 --- /dev/null +++ b/include/freenet/identityrequester.h @@ -0,0 +1,43 @@ +#ifndef _identity_requester_ +#define _identity_requester_ + +#include "../idatabase.h" +#include "../ilogger.h" +#include "../datetime.h" +#include "ifreenetregistrable.h" +#include "ifcpconnected.h" +#include "ifcpmessagehandler.h" +#include "iperiodicprocessor.h" + +class IdentityRequester:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger +{ +public: + IdentityRequester(); + IdentityRequester(FCPv2 *fcp); + + void FCPConnected(); + void FCPDisconnected(); + + const bool HandleMessage(FCPMessage &message); + + void Process(); + + void RegisterWithThread(FreenetMasterThread *thread); + +private: + void Initialize(); + void PopulateIDList(); // clear and re-populate m_ids with identities we want to query + void StartRequest(const long identityid); + const bool HandleAllData(FCPMessage &message); + const bool HandleGetFailed(FCPMessage &message); + void RemoveFromRequestList(const long identityid); + + DateTime m_tempdate; + std::string m_messagebase; + long m_maxrequests; + std::vector m_requesting; // list of ids we are currently requesting from + std::map m_ids; // map of all ids we know and whether we have requested file from them yet + +}; + +#endif // _identity_requester_ diff --git a/include/freenet/identityxml.h b/include/freenet/identityxml.h new file mode 100644 index 0000000..cc37c76 --- /dev/null +++ b/include/freenet/identityxml.h @@ -0,0 +1,37 @@ +#ifndef _identityxml_ +#define _identityxml_ + +#include "../ifmsxmldocument.h" + +class IdentityXML:public IFMSXMLDocument +{ +public: + + IdentityXML(); + + std::string GetXML(); + const bool ParseXML(const std::string &xml); + + const std::string GetName() { return m_name; } + void SetName(const std::string &name) { m_name=name; } + + const bool GetPublishTrustList() { return m_publishtrustlist; } + void SetPublishTrustList(const bool publish) { m_publishtrustlist=publish; } + + const bool GetPublishBoardList() { return m_publishboardlist; } + void SetPublishBoardList(const bool publish) { m_publishboardlist=publish; } + + const bool GetSingleUse() { return m_singleuse; } + void SetSingleUse(const bool singleuse) { m_singleuse=singleuse; } + +private: + void Initialize(); + + std::string m_name; + bool m_publishtrustlist; + bool m_publishboardlist; + bool m_singleuse; + +}; + +#endif // _identityxml_ diff --git a/include/freenet/ifcpconnected.h b/include/freenet/ifcpconnected.h new file mode 100644 index 0000000..19bea17 --- /dev/null +++ b/include/freenet/ifcpconnected.h @@ -0,0 +1,35 @@ +#ifndef _ifcpconnected_ +#define _ifcpconnected_ + +#include "fcpv2.h" + +/** + \brief Defines interface for classes that use an existing FCP Connection +*/ +class IFCPConnected +{ +public: + IFCPConnected():m_fcp(NULL) {} + IFCPConnected(FCPv2 *fcp):m_fcp(fcp) {} + + virtual void SetFCPConnection(FCPv2 *fcp) { m_fcp=fcp; } + virtual FCPv2 *GetFCPConnection() { return m_fcp; } + + /** + \brief called when the FCP connection becomes disconnected + + Parent object is responsible for calling this whenever the FCP connection becomes disconnected + */ + virtual void FCPDisconnected()=0; + /** + \brief called when the FCP connection becomes connected + + Parent object is responsible for calling this whenever the FCP connection is established + */ + virtual void FCPConnected()=0; + +protected: + FCPv2 *m_fcp; +}; + +#endif // _ifcpconnected_ diff --git a/include/freenet/ifcpmessagehandler.h b/include/freenet/ifcpmessagehandler.h new file mode 100644 index 0000000..01525d7 --- /dev/null +++ b/include/freenet/ifcpmessagehandler.h @@ -0,0 +1,20 @@ +#ifndef _ifcpmessagehandler_ +#define _ifcpmessagehandler_ + +#include "fcpv2.h" + +/** + \brief Defines interface for classes that handle FCP messages +*/ +class IFCPMessageHandler +{ +public: + /** + \brief Handles an FCP message + \param message FCP message to handle + \return true if the message was handled, false if it was not + */ + virtual const bool HandleMessage(FCPMessage &message)=0; +}; + +#endif // _ifcpmessagehandler_ diff --git a/include/freenet/ifreenetregistrable.h b/include/freenet/ifreenetregistrable.h new file mode 100644 index 0000000..78e4508 --- /dev/null +++ b/include/freenet/ifreenetregistrable.h @@ -0,0 +1,17 @@ +#ifndef _freenet_registrable_ +#define _freenet_registrable_ + +#include "freenetmasterthread.h" + +// forward declaration +class FreenetMasterThread; + +class IFreenetRegistrable +{ +public: + + virtual void RegisterWithThread(FreenetMasterThread *thread)=0; + +}; + +#endif // _freenet_registrable_ diff --git a/include/freenet/introductionpuzzleinserter.h b/include/freenet/introductionpuzzleinserter.h new file mode 100644 index 0000000..af66a50 --- /dev/null +++ b/include/freenet/introductionpuzzleinserter.h @@ -0,0 +1,39 @@ +#ifndef _introductionpuzzle_inserter_ +#define _introductionpuzzle_inserter_ + +#include "../idatabase.h" +#include "../ilogger.h" +#include "../datetime.h" +#include "ifreenetregistrable.h" +#include "ifcpconnected.h" +#include "ifcpmessagehandler.h" +#include "iperiodicprocessor.h" + +class IntroductionPuzzleInserter:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger +{ +public: + IntroductionPuzzleInserter(); + IntroductionPuzzleInserter(FCPv2 *fcp); + + void FCPConnected(); + void FCPDisconnected(); + + const bool HandleMessage(FCPMessage &message); + + void Process(); + + void RegisterWithThread(FreenetMasterThread *thread); + +private: + void Initialize(); + void CheckForNeededInsert(); + void StartInsert(const long localidentityid); + void GenerateCaptcha(std::string &encodeddata, std::string &solution); + const bool HandlePutSuccessful(FCPMessage &message); + const bool HandlePutFailed(FCPMessage &message); + + DateTime m_lastchecked; + +}; + +#endif // _introductionpuzzle_inserter_ diff --git a/include/freenet/introductionpuzzleremover.h b/include/freenet/introductionpuzzleremover.h new file mode 100644 index 0000000..65fa39d --- /dev/null +++ b/include/freenet/introductionpuzzleremover.h @@ -0,0 +1,28 @@ +#ifndef _introductionpuzzleremover_ +#define _introductionpuzzleremover_ + +#include "../idatabase.h" +#include "../ilogger.h" +#include "../datetime.h" +#include "ifreenetregistrable.h" +#include "iperiodicprocessor.h" + +/** + \brief Removes stale IntroductionPuzzles from database +*/ +class IntroductionPuzzleRemover:public IFreenetRegistrable,public IPeriodicProcessor,public IDatabase,public ILogger +{ +public: + IntroductionPuzzleRemover(); + + void Process(); + + void RegisterWithThread(FreenetMasterThread *thread); + +private: + + DateTime m_lastchecked; + +}; + +#endif // _introductionpuzzleremover_ diff --git a/include/freenet/introductionpuzzlerequester.h b/include/freenet/introductionpuzzlerequester.h new file mode 100644 index 0000000..9d7e3ab --- /dev/null +++ b/include/freenet/introductionpuzzlerequester.h @@ -0,0 +1,43 @@ +#ifndef _introductionpuzzlerequester_ +#define _introductionpuzzlerequester_ + +#include "../idatabase.h" +#include "../ilogger.h" +#include "../datetime.h" +#include "ifreenetregistrable.h" +#include "ifcpconnected.h" +#include "ifcpmessagehandler.h" +#include "iperiodicprocessor.h" + +class IntroductionPuzzleRequester:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IPeriodicProcessor,public IDatabase,public ILogger +{ +public: + IntroductionPuzzleRequester(); + IntroductionPuzzleRequester(FCPv2 *fcp); + + void FCPDisconnected(); + void FCPConnected(); + + const bool HandleMessage(FCPMessage &message); + + void RegisterWithThread(FreenetMasterThread *thread); + + void Process(); + +private: + void Initialize(); + void RemoveFromRequestList(const long identityid); + void StartRequest(const long identityid); + void PopulateIDList(); // clear and re-populate m_ids with identities we want to query + const bool HandleAllData(FCPMessage &message); + const bool HandleGetFailed(FCPMessage &message); + + DateTime m_tempdate; + std::string m_messagebase; + long m_maxrequests; + std::vector m_requesting; // list of ids we are currently requesting from + std::map m_ids; // map of all ids we know and whether we have requested file from them yet + +}; + +#endif // _introductionpuzzlerequester_ diff --git a/include/freenet/introductionpuzzlexml.h b/include/freenet/introductionpuzzlexml.h new file mode 100644 index 0000000..3d2428d --- /dev/null +++ b/include/freenet/introductionpuzzlexml.h @@ -0,0 +1,35 @@ +#ifndef _introductionpuzzlexml_ +#define _introductionpuzzlexml_ + +#include "../ifmsxmldocument.h" + +class IntroductionPuzzleXML:public IFMSXMLDocument +{ +public: + IntroductionPuzzleXML(); + + std::string GetXML(); + + const bool ParseXML(const std::string &xml); + + void SetType(const std::string &type) { m_type=type; } + void SetUUID(const std::string &uuid) { m_uuid=uuid; } + void SetPuzzleData(const std::string &puzzledata) { m_puzzledata=puzzledata; } + void SetMimeType(const std::string &mimetype) { m_mimetype=mimetype; } + + const std::string GetType() const { return m_type; } + const std::string GetUUID() const { return m_uuid; } + const std::string GetPuzzleData() const { return m_puzzledata; } + const std::string GetMimeType() const { return m_mimetype; } + +private: + void Initialize(); + + std::string m_type; + std::string m_uuid; + std::string m_puzzledata; + std::string m_mimetype; + +}; + +#endif // _introductionpuzzlexml_ diff --git a/include/freenet/iperiodicprocessor.h b/include/freenet/iperiodicprocessor.h new file mode 100644 index 0000000..0856c38 --- /dev/null +++ b/include/freenet/iperiodicprocessor.h @@ -0,0 +1,16 @@ +#ifndef _iperiodicprocessor_ +#define _iperiodicprocessor_ + +/** + \brief Defines interface for classes that are periodically processed +*/ +class IPeriodicProcessor +{ +public: + /** + \brief Lets class do any needed processing + */ + virtual void Process()=0; +}; + +#endif // _iperiodicprocessor_ diff --git a/include/freenet/unkeyedidcreator.h b/include/freenet/unkeyedidcreator.h new file mode 100644 index 0000000..7f9fb15 --- /dev/null +++ b/include/freenet/unkeyedidcreator.h @@ -0,0 +1,40 @@ +#ifndef _unkeyedidcreator_ +#define _unkeyedidcreatorr_ + +#include "../ilogger.h" +#include "../datetime.h" +#include "../idatabase.h" +#include "ifreenetregistrable.h" +#include "ifcpconnected.h" +#include "ifcpmessagehandler.h" +#include "iperiodicprocessor.h" + + +/** + \brief Looks for any unkeyed Local Identities and requests SSK keys for them +*/ +class UnkeyedIDCreator:public IFreenetRegistrable,public IFCPConnected,public IFCPMessageHandler,public IDatabase,public IPeriodicProcessor,public ILogger +{ +public: + UnkeyedIDCreator(); + UnkeyedIDCreator(FCPv2 *fcp); + + const bool HandleMessage(FCPMessage &message); + + void FCPDisconnected(); + void FCPConnected(); + + void Process(); + + void RegisterWithThread(FreenetMasterThread *thread); + +private: + void Initialize(); + void CheckForUnkeyedID(); + void SaveKeys(const long localidentityid, const std::string &publickey, const std::string &privatekey); + + DateTime m_lastchecked; + bool m_waiting; +}; + +#endif // _unkeyedidcreator_ diff --git a/include/hex.h b/include/hex.h new file mode 100644 index 0000000..a57bf6e --- /dev/null +++ b/include/hex.h @@ -0,0 +1,15 @@ +#ifndef _hex_funcs_ +#define _hex_funcs_ + +#include +#include + +namespace Hex +{ + +const bool Encode(const std::vector &data, std::string &encoded); +const bool Decode(const std::string &encoded, std::vector &data); + +}; + +#endif _hex_funcs_ diff --git a/include/idatabase.h b/include/idatabase.h new file mode 100644 index 0000000..6138d08 --- /dev/null +++ b/include/idatabase.h @@ -0,0 +1,18 @@ +#ifndef _idatabase_ +#define _idatabase_ + +#include "db/sqlite3db.h" + +/** + \brief Base class for classes that need to access the Singleton SQLite 3 database object +*/ +class IDatabase +{ +public: + IDatabase():m_db(SQLite3DB::DB::instance()) {} + +protected: + SQLite3DB::DB *m_db; +}; + +#endif // _idatabase_ diff --git a/include/identitytestglobal.h b/include/identitytestglobal.h new file mode 100644 index 0000000..eff73b9 --- /dev/null +++ b/include/identitytestglobal.h @@ -0,0 +1,24 @@ +#ifndef _global_ +#define _global_ + +#include +#include + +#define FMS_VERSION "0.0.1" + +// opens database and creates tables and initial inserts if necessary +void SetupDB(); +// inserts default options into the database +void SetupDefaultOptions(); +// opens logfile and sets it up +void SetupLogFile(); + +void StartThreads(std::vector &threads); +void ShutdownThreads(std::vector &threads); + +// needed for Windows to setup network +void SetupNetwork(); +// cleanup network on Windows +void ShutdownNetwork(); + +#endif // _global_ diff --git a/include/ifmsxmldocument.h b/include/ifmsxmldocument.h new file mode 100644 index 0000000..24484ec --- /dev/null +++ b/include/ifmsxmldocument.h @@ -0,0 +1,83 @@ +#ifndef _ifmsxmldocument_ +#define _ifmsxmldocument_ + +#include +#include + +/** + \brief Interface for objects that represent an XML document +*/ +class IFMSXMLDocument +{ +public: + + /** + \brief Returns xml document represented by this object + + \return xml document + */ + virtual std::string GetXML()=0; + + /** + \brief Parses an xml document into this object + + \return true if the document was parsed successfully, false if it was not + */ + virtual const bool ParseXML(const std::string &xml)=0; + +protected: + /** + \brief Creates and returns an element with a boolean value + */ + virtual TiXmlElement *XMLCreateBooleanElement(const std::string &name, const bool value) + { + TiXmlText *txt=new TiXmlText(value ? "true" : "false"); + TiXmlElement *el=new TiXmlElement(name); + el->LinkEndChild(txt); + return el; + } + + /** + \brief Creates and returns an element with a CDATA value + */ + virtual TiXmlElement *XMLCreateCDATAElement(const std::string &name, const std::string &data) + { + TiXmlText *txt=new TiXmlText(data); + txt->SetCDATA(true); + TiXmlElement *el=new TiXmlElement(name); + el->LinkEndChild(txt); + return el; + } + + /** + \brief Creates and returns a text element + */ + virtual TiXmlElement *XMLCreateTextElement(const std::string &name, const std::string &data) + { + TiXmlText *txt=new TiXmlText(data); + TiXmlElement *el=new TiXmlElement(name); + el->LinkEndChild(txt); + return el; + } + + virtual const bool XMLGetBooleanElement(TiXmlElement *parent, const std::string &name) + { + TiXmlHandle hnd(parent); + TiXmlText *txt=hnd.FirstChild(name).FirstChild().ToText(); + if(txt) + { + if(txt->ValueStr()=="true") + { + return true; + } + else + { + return false; + } + } + return false; + } + +}; + +#endif // _ifmsxmldocument_ diff --git a/include/ilogger.h b/include/ilogger.h new file mode 100644 index 0000000..797c024 --- /dev/null +++ b/include/ilogger.h @@ -0,0 +1,18 @@ +#ifndef _ilogger_ +#define _ilogger_ + +#include "logfile.h" + +/** + \brief Base class for classes that want to use the singleton LogFile object +*/ +class ILogger +{ +public: + ILogger():m_log(LogFile::instance()) {} + +protected: + LogFile *m_log; +}; + +#endif // _ilogger_ diff --git a/include/logfile.h b/include/logfile.h new file mode 100644 index 0000000..a076d65 --- /dev/null +++ b/include/logfile.h @@ -0,0 +1,64 @@ +#ifndef _logfile_ +#define _logfile_ + +#include +#include + +class LogFile:public ZThread::Singleton +{ +public: + LogFile(); + LogFile(const std::string &filename); + ~LogFile(); + + enum LogLevel + { + LOGLEVEL_FATAL=0, + LOGLEVEL_ERROR=1, + LOGLEVEL_WARNING=2, + LOGLEVEL_INFO=3, + LOGLEVEL_DEBUG=4 + }; + + bool OpenFile(); + bool CloseFile(); + + std::string GetFileName() { return m_filename; } + void SetFileName(std::string filename) { m_filename=filename; } + + const bool GetWriteDate() { return m_writedate; } + void SetWriteDate(const bool writedate) { m_writedate=writedate; } + + const bool GetWriteLogLevel() { return m_writeloglevel; } + void SetWriteLogLevel(const bool writeloglevel) { m_writeloglevel=writeloglevel; } + + const LogLevel GetLogLevel() { return m_loglevel; } + void SetLogLevel(const LogLevel loglevel) { m_loglevel=loglevel; } + + const bool GetWriteNewLine() { return m_writenewline; } + void SetWriteNewLine(const bool writenewline) { m_writenewline=writenewline; } + + void WriteLog(const char *format, ...); + void WriteLog(const std::string &text); + void WriteLog(const LogLevel level, const char *format, ...); + void WriteLog(const LogLevel level, const std::string &text); + + void WriteNewLine(); + +private: + void WriteDate(); + void WriteLogLevel(LogLevel level); + + FILE *m_fileptr; + std::string m_filename; + LogLevel m_loglevel; + bool m_writedate; + bool m_writeloglevel; + bool m_writenewline; + char *m_datebuffer; + + ZThread::Mutex m_logmutex; + +}; + +#endif // _logfile_ diff --git a/include/option.h b/include/option.h new file mode 100644 index 0000000..abe1a58 --- /dev/null +++ b/include/option.h @@ -0,0 +1,42 @@ +#ifndef _option_ +#define _option_ + +#include "db/sqlite3db.h" + +#include +#include + +//just a wrapper around the database for the options table +class Option:public ZThread::Singleton