T
*nochmal rauskram*
auch mit ner neuen mysql version, keine chance
der code sieht wie folgt aus:
die funktions deklarationen am anfang hab ich rausgelassen...
nach dem unten stehendem code kommt das mysql query und alles andere.. aber das dürfte ja nicht relevant sein
hab ja auch direkt mal die zugangsdaten in die mysql funktion eingetragen..
#include <windows.h>
#include <vector>
#include <mysql.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstdio>
#include <ctime>
#include <cmath>
#include "timesupport.h"
#include <stdexcept>
#include <Psapi.h>
int main() {
//*********
//SET ALLOWED WORDS FOR LOGTIME FROM SERVER
//********
std::vector<std::string> allowed_words;
allowed_words.push_back("no Tel charges");
allowed_words.push_back("no HSIA charges");
allowed_words.push_back("no glog database available");
allowed_words.push_back("no chlog tel database available");
allowed_words.push_back("no chlog hsia database available");
//********
//READ INI DATA
//********
char filename[500];
char webpath[500];
char host[500];
char username[500];
char password[500];
char database[500];
........
char tmp[500];
char inipathtmp[_MAX_PATH];
DWORD destSize;
destSize = 500;
//GET INI PATH
GetModuleFileNameA(NULL, inipathtmp, _MAX_PATH);
std::string inipath(inipathtmp);
size_t szPos = inipath.rfind("\\");
if(std::string::npos != szPos) {
inipath = inipath.substr(0, szPos);
inipath += "\\statwriter.ini";
}
//GENERAL
GetPrivateProfileStringA("general", "sleeptime" ,"NULL", sleeptime_ms, destSize, inipath.c_str());
GetPrivateProfileStringA("general", "send_intervall" ,"NULL", intervall_from_ini_tmp, destSize, inipath.c_str());
GetPrivateProfileStringA("general", "glog_exception" ,"NULL", glog_exception_tmp, destSize, inipath.c_str());
GetPrivateProfileStringA("general", "chlog_hsia_exception" ,"NULL", chlog_hsia_exception_tmp, destSize, inipath.c_str());
GetPrivateProfileStringA("file_def", "filename" ,"NULL", filename, destSize, inipath.c_str());
GetPrivateProfileStringA("file_def", "webpath" ,"NULL", webpath, destSize, inipath.c_str());
//MYSQL SETTINGS
GetPrivateProfileStringA("mysql", "host" ,"NULL", host, destSize, inipath.c_str());
GetPrivateProfileStringA("mysql", "username" ,"NULL", username, destSize, inipath.c_str());
GetPrivateProfileStringA("mysql", "password" ,"NULL", password, destSize, inipath.c_str());
GetPrivateProfileStringA("mysql", "database" ,"NULL", database, destSize, inipath.c_str());
.................
//intervall conversion ( char to string )
std::string intervall_from_ini;
std::stringstream ivtmp;
ivtmp << intervall_from_ini_tmp;
ivtmp >> intervall_from_ini;
std::string glog_exception;
std::stringstream getmp;
getmp << glog_exception_tmp;
getmp >> glog_exception;
std::string chlog_hsia_exception;
std::stringstream chtmp;
chtmp << chlog_hsia_exception_tmp;
chtmp >> chlog_hsia_exception;
//**********************
// GET SERVERS & CONFIG
//**********************
MYSQL *conn, mysql;
MYSQL_RES *mysql_result;
MYSQL_ROW row;
int server_query_result;
std::string server_query;
//INITIALIZE
conn = mysql_init(&mysql);
//CONNECT
if(!mysql_real_connect (
conn, // pointer to connection handler
host, // host to connect to
username, // user name
password, // password
database, // database to use
0, // port (default 3306)
NULL, // socket or /var/lib/mysql.sock
0 // flags (none)
)) {
std::cout << " GET SEVERS & CONFIG: " << mysql_error(&mysql) << std::endl;
logfile << time_now() << " [Initalization] Error: Couldn't establish MySql Connection (" << mysql_error(&mysql) << ") [" << __LINE__ << "]" << std::endl;
return 1;
} else {
//std::cout << "\nGET SERVERS & CONFIG: MySQL-Verbindung hergestellt!\n";
}