<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Config auswerten]]></title><description><![CDATA[<p>Habe ein kleine funktion geschrieben:</p>
<pre><code class="language-cpp">/*Written by Jan Koester realease under lgpl*/
#include &lt;iostream&gt; 
#include &lt;fstream&gt; 
#include &lt;string&gt; 
#include &quot;easyc++.h&quot;

using namespace std; 

string readconf(char* filename, string confkey)
{ 

        ifstream  file(filename); 
        string buf, key; 
        size_t n; 

        while(file.good()) { 
                getline(file, buf, '\n'); 
                n=buf.find(confkey); 
                if(n != string::npos) { 
                        n += confkey.length();
                        key=buf.substr(n,buf.length()); 
                        break; 
                } else { 
                        continue; 
                } 
        } 

file.close();
        if(key.length() &gt; 0) { 
                return key;
        } else { 
                return &quot;error key not found&quot;;
        }

}
</code></pre>
<p>Welche anhand eines Keywords Parameter auslesen kann nun möchte ich nicht jedes mal die Datei auslesen sondern in den Arbeitsspeicher auslagern und global von meinem Modulen drauf zugreifen können, die sich in verschiedenen Klassen sich befinden, die Module werden mit dlopen geladen.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/207439/config-auswerten</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 06:59:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/207439.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 07 Mar 2008 15:05:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Config auswerten on Fri, 07 Mar 2008 15:12:51 GMT]]></title><description><![CDATA[<p>Habe ein kleine funktion geschrieben:</p>
<pre><code class="language-cpp">/*Written by Jan Koester realease under lgpl*/
#include &lt;iostream&gt; 
#include &lt;fstream&gt; 
#include &lt;string&gt; 
#include &quot;easyc++.h&quot;

using namespace std; 

string readconf(char* filename, string confkey)
{ 

        ifstream  file(filename); 
        string buf, key; 
        size_t n; 

        while(file.good()) { 
                getline(file, buf, '\n'); 
                n=buf.find(confkey); 
                if(n != string::npos) { 
                        n += confkey.length();
                        key=buf.substr(n,buf.length()); 
                        break; 
                } else { 
                        continue; 
                } 
        } 

file.close();
        if(key.length() &gt; 0) { 
                return key;
        } else { 
                return &quot;error key not found&quot;;
        }

}
</code></pre>
<p>Welche anhand eines Keywords Parameter auslesen kann nun möchte ich nicht jedes mal die Datei auslesen sondern in den Arbeitsspeicher auslagern und global von meinem Modulen drauf zugreifen können, die sich in verschiedenen Klassen sich befinden, die Module werden mit dlopen geladen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1470081</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1470081</guid><dc:creator><![CDATA[Tuxist]]></dc:creator><pubDate>Fri, 07 Mar 2008 15:12:51 GMT</pubDate></item><item><title><![CDATA[Reply to Config auswerten on Fri, 07 Mar 2008 15:18:39 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Ja dann mach das doch.<br />
Oder hast du noch eine Frage?</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1470093</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1470093</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Fri, 07 Mar 2008 15:18:39 GMT</pubDate></item><item><title><![CDATA[Reply to Config auswerten on Fri, 07 Mar 2008 15:34:16 GMT]]></title><description><![CDATA[<p>Hauptprogramm:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;map&gt;
#include &lt;fstream&gt;
#include &quot;tuxcms.h&quot;
#include &lt;vector&gt;
#include &lt;html.h&gt;
#include &lt;cgi.h&gt;
#include &quot;modul/module.h&quot;
#include &lt;easyc++.h&gt;

/*Under Construction*/

using namespace std;

string core::getconfig(string input)
{
string out;
out = readconf(&quot;tuxcms.conf&quot;,input);
return out;
}

void core::test()
{
cgi maincgi;
	maincgi.request();
	maincgi.urlencode();

	string inhalt = maincgi.getcgidata(&quot;nav&quot;);
	extern bool modul(string modulpath);
	modul(inhalt);

}

void core::login()
{
html loginhtml;
	loginhtml.createlayer(&quot;login&quot;,&quot;main&quot;);
		loginhtml.startform(&quot;post&quot;, &quot;loginform&quot;);
			cout &lt;&lt; &quot;&lt;p&gt;&lt;/p&gt;&quot; &lt;&lt; endl;
		loginhtml.input( &quot;Username&quot;, &quot;text&quot;);
			cout &lt;&lt; &quot;&lt;p&gt;&lt;/p&gt;&quot; &lt;&lt; endl;
		loginhtml.input( &quot;Username&quot;, &quot;password&quot;);
			cout &lt;&lt; &quot;&lt;p&gt;&lt;/p&gt;&quot; &lt;&lt; endl;
		loginhtml.input( &quot;Login&quot;, &quot;submit&quot;);
			cout &lt;&lt; &quot;&lt;p&gt;&lt;/p&gt;&quot; &lt;&lt; endl;
		loginhtml.link(&quot;Regristieren&quot;, &quot;&quot;);
	loginhtml.endform();
loginhtml.endlayer();
}

void core::style()
{
	string style = &quot;dark&quot;;
	html stylehtml;

	cout &lt;&lt; &quot;&lt;link rel=\&quot;icon\&quot; type=\&quot;image/png\&quot; href=\&quot;style/&quot;&lt;&lt; style &lt;&lt;&quot;/images/icon.png\&quot; /&gt;&quot; &lt;&lt; endl,
	cout &lt;&lt; &quot;&lt;link rel=\&quot;stylesheet\&quot; type=\&quot;text/css\&quot; href=\&quot;style/&quot;&lt;&lt; style &lt;&lt;&quot;/main.css\&quot;/&gt;&quot; &lt;&lt; endl;

	stylehtml.bodystart();

	stylehtml.createlayer(&quot;logo&quot;,&quot;main&quot;);
		string imgtmp =&quot;style/&quot;;
		imgtmp += style;
		imgtmp += &quot;/images/logo.png&quot;;

		stylehtml.img(&quot;logo1&quot;, imgtmp);
		stylehtml.endlayer();
}

int main()
{
html mainhtml;
core mainprog;

sitename = mainprog.getconfig(&quot;sitename:&quot;);
sqloptions = mainprog.getconfig(&quot;database:&quot;);

mainhtml.starthtml();

	mainprog.style();

	mainprog.login();

		mainhtml.createlayer(&quot;navbar&quot;,&quot;main&quot;);
			mainhtml.link(&quot;News&quot;,&quot;?+nav=module/news.so&quot;);
			mainhtml.link(&quot;Video&quot;,&quot;?+nav=video&quot;);
			mainhtml.link(&quot;Projects&quot;,&quot;?+nav=module/projects.so&quot;);
			mainhtml.link(&quot;Downloads&quot;,&quot;?+nav=module/filebrowser.so&quot;);
			mainhtml.link(&quot;Sysinfo&quot;,&quot;?+nav=sysinfo&quot;);
		mainhtml.endlayer();

	mainprog.test();

	mainhtml.bodyend();

mainhtml.endhtml();
}
</code></pre>
<p>Header hauptprogramm:</p>
<pre><code class="language-cpp">#include &lt;vector&gt;
#include &lt;string&gt;

static std::string sqloptions;
static std::string sitename;

class core
{
public:
std::string getconfig(std::string input);
void login();
void test();
void style();
};
</code></pre>
<p>Modulloader:</p>
<pre><code class="language-cpp">/*
Writen by Jan Koster releade under lgpl

*/
#include &lt;iostream&gt;
#include &lt;dlfcn.h&gt;
#include &lt;string&gt;
#include &lt;easyc++.h&gt;
#include &quot;module.h&quot;

using namespace std;

bool modul(string modulpath){

char* tmp = stringtochar(modulpath);

using std::cout;
using std::cerr;

void* modul = dlopen(tmp, RTLD_LAZY);
if (!modul) {
        cerr &lt;&lt; &quot;Cannot load library: &quot; &lt;&lt; dlerror() &lt;&lt; '\n';
        return 1;
}

dlerror();

create_t* create_modul = (create_t*) dlsym(modul, &quot;create&quot;);
const char* dlsym_error = dlerror();
	if (dlsym_error) {
        	cerr &lt;&lt; &quot;Cannot load symbol create: &quot; &lt;&lt; dlsym_error &lt;&lt; '\n';
		return 1;
    	}

destroy_t* destroy_modul = (destroy_t*) dlsym(modul, &quot;destroy&quot;);
dlsym_error = dlerror();
	if (dlsym_error) {
        	cerr &lt;&lt; &quot;Cannot load symbol destroy: &quot; &lt;&lt; dlsym_error &lt;&lt; '\n';
        	return 1;
	}

    module* module = create_modul();

    module-&gt;htmlout();

    destroy_modul(module);

    dlclose(modul);

	return 0;

}
</code></pre>
<p>Modulloader header:</p>
<pre><code class="language-cpp">#ifndef module_H
#define module_H

class module {
protected:

public:
virtual ~module() {}
virtual void htmlout(){};
};

typedef module* create_t();
typedef void destroy_t(module*);

#endif

bool modul(std::string modulpath);
</code></pre>
<p>Ein modul:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;pqxx/connection&gt;
#include &lt;pqxx/transaction&gt;
#include &lt;pqxx/result&gt;
#include &quot;news.h&quot;
#include &lt;html.h&gt;
#include &lt;vector&gt;
#include &lt;map&gt;
#include &lt;easyc++.h&gt;

using namespace std;
using namespace PGSTD;
using namespace pqxx;

void news::getnews(int row)
{
	News news;
	result R;

        connection *conn = new connection(sqloptions);

        work T(*conn);

        R = T.exec(&quot;SELECT * FROM NEWS&quot;);
        T.commit();

        if(R.size() &gt; 0)
        {
		news.insert(NewsPair(R[row][&quot;n_id&quot;].as&lt;int&gt;(), R[row][&quot;titel&quot;].as&lt;std::string&gt;()));
		news.insert(NewsPair(R[row][&quot;n_id&quot;].as&lt;int&gt;(), R[row][&quot;autor&quot;].as&lt;std::string&gt;()));
		news.insert(NewsPair(R[row][&quot;n_id&quot;].as&lt;int&gt;(), R[row][&quot;datum&quot;].as&lt;std::string&gt;()));
		news.insert(NewsPair(R[row][&quot;n_id&quot;].as&lt;int&gt;(), R[row][&quot;zeit&quot;].as&lt;std::string&gt;()));
		news.insert(NewsPair(R[row][&quot;n_id&quot;].as&lt;int&gt;(), R[row][&quot;inhalt&quot;].as&lt;std::string&gt;()));
        }
        else
        {
                cout &lt;&lt; &quot;Datenbank hat keine Daten&quot; &lt;&lt; endl;
        }

	html newshtml;
	News::iterator pos;

	newshtml.createlayer(&quot;inhalt&quot;,&quot;main&quot;);

		for (pos = news.begin(); pos != news.end(); ++pos) {
			std::cout &lt;&lt; pos-&gt;second &lt;&lt;&quot;&lt;p&gt;&lt;/p&gt;&quot; &lt;&lt; endl;
			}
	newshtml.endlayer();	

        conn-&gt;disconnect();
        delete conn;
}

void news::newsrows()
{
	result R;
        connection *conn = new connection(sqloptions);

        work T(*conn);

        R = T.exec(&quot;select count(*) from news&quot;);
	T.commit();
	R[0][0].to(rows);
	conn-&gt;disconnect();
        delete conn;

	do
	{
	rows--;
	getnews(rows);
	}
	while(rows&gt;=0);

}

void news::writenews()
{

};
</code></pre>
<p>modul header:</p>
<pre><code class="language-cpp">#include &lt;map&gt;
#include &quot;../../modul/module.h&quot;
#include &quot;../../tuxcms.h&quot;

class news : public module
{
private:
int rows;
typedef std::multimap&lt;int, std::string&gt; News;
typedef std::pair&lt;int, std::string&gt; NewsPair;
void getnews(int row);
void newsrows();
void writenews();

public:

void htmlout()
{
	newsrows();
}

};

extern &quot;C&quot; module* create() {
    return new news;
}

extern &quot;C&quot; void destroy(module* p) {
    delete p;
}
</code></pre>
<p>variable daten werden nicht übertragen habe es mit cout ausprobiert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1470108</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1470108</guid><dc:creator><![CDATA[Tuxist]]></dc:creator><pubDate>Fri, 07 Mar 2008 15:34:16 GMT</pubDate></item><item><title><![CDATA[Reply to Config auswerten on Fri, 07 Mar 2008 15:38:11 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Glaubst du wirklich das sich jemand deine 100e Zeilen Code anschaut ohne auch nur zu wissen was das Problem ist? &quot;Klappt nicht&quot; ist keine ausreichende Fehlerbeschreibung! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1470113</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1470113</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Fri, 07 Mar 2008 15:38:11 GMT</pubDate></item></channel></rss>