mirror of
https://github.com/Karaka-Management/oms-OnlineResourceWatcher.git
synced 2026-02-14 23:18:40 +00:00
draft basics
This commit is contained in:
parent
e04f1c06c2
commit
67d101074f
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -3,4 +3,6 @@ obj/
|
||||||
*.cache
|
*.cache
|
||||||
.directory
|
.directory
|
||||||
bin/Debug
|
bin/Debug
|
||||||
x64/Debug
|
x64/Debug
|
||||||
|
app/server/Libraries
|
||||||
|
.vscode
|
||||||
|
|
@ -2,5 +2,10 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
project( OnlineResourceWatcherServerApp )
|
project( OnlineResourceWatcherServerApp )
|
||||||
add_executable( OnlineResourceWatcherServerApp main.cpp )
|
add_executable( OnlineResourceWatcherServerApp main.cpp )
|
||||||
|
|
||||||
|
# SQLite3
|
||||||
|
include_directories( /usr/include )
|
||||||
|
link_directories( /usr/lib )
|
||||||
|
target_link_libraries( OnlineResourceWatcherServerApp sqlite3 )
|
||||||
|
|
||||||
# cmake -DCMAKE_BUILD_TYPE=Debug -DOMS_DEBUG=true
|
# cmake -DCMAKE_BUILD_TYPE=Debug -DOMS_DEBUG=true
|
||||||
# cmake -DCMAKE_BUILD_TYPE=Release -DOMS_DEMO=true
|
# cmake -DCMAKE_BUILD_TYPE=Release -DOMS_DEMO=true
|
||||||
26
app/server/Models/Db.h
Normal file
26
app/server/Models/Db.h
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
/**
|
||||||
|
* Karaka
|
||||||
|
*
|
||||||
|
* @package Models
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://karaka.app
|
||||||
|
*/
|
||||||
|
#ifndef MODELS_DB_H
|
||||||
|
#define MODELS_DB_H
|
||||||
|
|
||||||
|
namespace Models {
|
||||||
|
class Db {
|
||||||
|
private:
|
||||||
|
|
||||||
|
public:
|
||||||
|
static inline
|
||||||
|
int setup_connection (char *cfg)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
0
app/server/Models/File.h
Normal file
0
app/server/Models/File.h
Normal file
7
app/server/build/install.sh
Normal file
7
app/server/build/install.sh
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sudo apt-get install sqlite3 libsqlite3-dev
|
||||||
|
sudo apt install default-libmysqlclient-dev
|
||||||
|
sudo apt-get install libxml2-dev
|
||||||
|
|
||||||
|
# install maria db https://mariadb.com/docs/connect/programming-languages/cpp/install/
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit cd71fb74b146e1fffefafe6f8f053ec4ef4a1096
|
Subproject commit 6f9f0c03aa5edab86b7c9eec9efa69367997b0d9
|
||||||
0
app/server/config.json
Normal file
0
app/server/config.json
Normal file
|
|
@ -9,8 +9,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <mysql.h>
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
#include "cOMS/Utils/ArrayUtils.h"
|
#include "cOMS/Utils/ArrayUtils.h"
|
||||||
|
#include "cOMS/Utils/FileUtils.h"
|
||||||
|
#include "cOMS/Hash/MeowHash.h"
|
||||||
|
#include "cOMS/Utils/Parser/Json.h"
|
||||||
|
|
||||||
|
#include "Models/Db.h"
|
||||||
|
|
||||||
#ifndef OMS_DEMO
|
#ifndef OMS_DEMO
|
||||||
#define OMS_DEMO false
|
#define OMS_DEMO false
|
||||||
|
|
@ -33,19 +42,74 @@ void printVersion()
|
||||||
printf("Version: 1.0.0\n");
|
printf("Version: 1.0.0\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void parseConfigFile()
|
||||||
|
{
|
||||||
|
FILE *fp = fopen("config.json");
|
||||||
|
|
||||||
|
nlohmann::json config = nlohmann::json::parse(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isResourceModified(char *filename, time_t last_change)
|
||||||
|
{
|
||||||
|
return oms_abs(Utils::FileUtils::last_modification(filename) - last_change) > 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasResourceContentChanged(char *filename1, char *filename2)
|
||||||
|
{
|
||||||
|
Utils::FileUtils::file_body f1 = Utils::FileUtils::read_file(filename1);
|
||||||
|
Utils::FileUtils::file_body f2 = Utils::FileUtils::read_file(filename2);
|
||||||
|
|
||||||
|
Hash::Meow::meow_u128 h1 = Hash::Meow::MeowHash(Hash::Meow::MeowDefaultSeed, f1.size, f1.content);
|
||||||
|
Hash::Meow::meow_u128 h2 = Hash::Meow::MeowHash(Hash::Meow::MeowDefaultSeed, f2.size, f2.content);
|
||||||
|
|
||||||
|
bool areHashesEqual = Hash::Meow::MeowHashesAreEqual(h1, h2);
|
||||||
|
|
||||||
|
free(f1.content);
|
||||||
|
free(f2.content);
|
||||||
|
|
||||||
|
return areHashesEqual;
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveResourceChange()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
MYSQL *con = null;
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
bool hasHelpCmd = Utils::ArrayUtils::has_arg("-h", argv, argc);
|
bool hasHelpCmd = Utils::ArrayUtils::has_arg("-h", argv, argc);
|
||||||
if (hasHelpCmd) {
|
if (hasHelpCmd) {
|
||||||
printHelp();
|
printHelp();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasVersionCmd = Utils::ArrayUtils::has_arg("-v", argv, argc);
|
bool hasVersionCmd = Utils::ArrayUtils::has_arg("-v", argv, argc);
|
||||||
if (hasVersionCmd) {
|
if (hasVersionCmd) {
|
||||||
printVersion();
|
printVersion();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Utils::FileUtils::file_exists("config.json")) {
|
||||||
|
printf("No config file available.");
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long resourceId = (unsigned long) Utils::ArrayUtils::get_arg("-r", argv, argc);
|
||||||
|
|
||||||
|
|
||||||
|
// read config file
|
||||||
|
// create database connection (either mariadb or sqlite)
|
||||||
|
// @todo create wrapper for sqlite, mysql and postgresql
|
||||||
|
|
||||||
|
con = mysql_init(NULL);
|
||||||
|
if (mysql_real_connect(con, "localhost", "root", "root_passwd", NULL, 0, NULL, 0) == NULL) {
|
||||||
|
fprintf(stderr, "%s\n", mysql_error(con));
|
||||||
|
mysql_close(con);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -303,6 +303,11 @@
|
||||||
"type": "VARCHAR(255)",
|
"type": "VARCHAR(255)",
|
||||||
"null": false
|
"null": false
|
||||||
},
|
},
|
||||||
|
"resource_xpath": {
|
||||||
|
"name": "resource_xpath",
|
||||||
|
"type": "VARCHAR(255)",
|
||||||
|
"null": false
|
||||||
|
},
|
||||||
"resource_hash": {
|
"resource_hash": {
|
||||||
"name": "resource_hash",
|
"name": "resource_hash",
|
||||||
"type": "BLOB(64)",
|
"type": "BLOB(64)",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user