Source

quechua / modules / logger / dionaealogger / dionaealogger.h

Full commit
/* 
 * Quechua - the lightweight data mining framework
 *
 * Copyright (C) 2012 Marek Denis <quechua@octogan.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef POSTPROCLOG_H
#define POSTPROCLOG_H

#include "../../../include/types.h"
#include "../../../include/interface-common.h"
#include "../../../include/interface-logger.h"
#include "../../data/types.h"
#include "../../data/dionaeaconnections.h"
#include "../../data/indextransactions.h"
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>

using std::exception;
using std::nothrow;


class DionaeaLogger : public Logger {
    struct credentials_s {
        string_t user;
        string_t password;
        string_t hostname;
        string_t database;
    };
 protected: 
        dbconnection_t* connection;
        credentials_s credentials;
        static char buf[1024];
        /* internal methods */
        char* quotize(char* dst, size_t n, const char* src);
        inline bool check_connection(const dbconnection_t* c);
        inline bool check_and_complain_connection(const dbconnection_t* c);
        bool exec_query(dbwork_t& w,dbresult_t& r, const char* q,bool commit = false);
        index_t get_oid(dbwork_t* w);
        bool insert_into_operation(dbwork_t* w, index_t& oid, const string_t& from, const string_t& to);
        bool insert_into_freq_itemsets(dbwork_t* w,index_t& oid,DionaeaConnections::unindexedTransaction* txn);
 public:
    DionaeaLogger();
    virtual ~DionaeaLogger();

    bool load_misc_conf(const setting_t& misc);
   
    bool prepare();
    bool stop();
    void logwork(datapack_ptr data);

}; // DionaeaLogger

extern "C" Logger* create_logger() {
    return new DionaeaLogger();
};

#endif