conf.h File Reference


Detailed Description

Configuration file reader.

Definition in file conf.h.

#include <string>

Include dependency graph for conf.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

string conf_getvar (string var)
 Gets variable from conf.txt configuration file. If init == false, it calls conf_init() to load file into keys variable.
bool conf_init ()
 Loads conf.txt configuration file into keys variable and sets init to true.
void conf_rehash ()
 Rehashes, and re-reads conf.txt configuration file into keys variable and sets init to true.
bool conf_ssl_init ()
 Loads ssl.txt configuration file.


Function Documentation

string conf_getvar string  var  ) 
 

Gets variable from conf.txt configuration file. If init == false, it calls conf_init() to load file into keys variable.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
var Key string to find in configuration file
Returns:
Value of key (var)

Definition at line 131 of file conf.cpp.

References conf_init(), init, and keys.

Referenced by botnet_loop(), dcc_check_limit(), dcc_file_has_been_read(), dcc_loop(), dcc_loop_msg(), filesys_dcc_add_message(), filesys_dcc_set_file_attrs(), init_echoes(), irc_connect(), irc_loop_putserv(), irc_putserv(), irc_quoted_callback(), irc_rehashed(), irc_remove_redundant_mode(), irc_remove_redundant_mode2(), logic_ctcp(), logic_exec(), logic_exec_script(), logic_find_user(), logic_load_conf(), logic_loop(), and logic_process_script_output().

00132 {
00133     if(!init)
00134         conf_init();
00135     map<string,string>::iterator i;
00136     for(i=keys.begin(); i!=keys.end(); i++) {
00137         if((*i).first==var)
00138             return (*i).second;
00139     }
00140     return "";
00141 }

Here is the call graph for this function:

bool conf_init  ) 
 

Loads conf.txt configuration file into keys variable and sets init to true.

Author:
VooDooMan
Version:
1
Date:
2004
Return values:
true For error
false Okay.

Definition at line 69 of file conf.cpp.

References init, and keys.

Referenced by conf_getvar(), conf_rehash(), and main().

00070 {
00071     FILE* f=fopen("conf.txt","r");
00072     if(f==NULL)
00073         return true;
00074 
00075     char ln[10240+1];
00076     while(!feof(f)) {
00077         if(fgets(ln,1024*10-1,f)==NULL)
00078             break;
00079         ln[10240]=0;
00080         if(ln[strlen(ln)-1]=='\r')
00081             ln[strlen(ln)-1]=0;
00082         if(ln[strlen(ln)-1]=='\n')
00083             ln[strlen(ln)-1]=0;
00084         if(ln[strlen(ln)-1]=='\r')
00085             ln[strlen(ln)-1]=0;
00086         if(ln[strlen(ln)-1]=='\n')
00087             ln[strlen(ln)-1]=0;
00088         string id_, val_;
00089         int pos=0;
00090         for(unsigned int i1=0; i1<strlen(ln); i1++) {
00091             if(pos==0 && ln[i1]=='=') {
00092                 pos++;
00093                 continue;
00094             }
00095             if(pos==0)
00096                 id_+=ln[i1];
00097             if(pos==1)
00098                 val_+=ln[i1];
00099         }
00100         pair<string,string> p;
00101         p.first=id_;
00102         p.second=val_;
00103         keys.insert(p);
00104     }
00105     fclose(f);
00106     init=true;
00107 
00108     return false;
00109 }

void conf_rehash  ) 
 

Rehashes, and re-reads conf.txt configuration file into keys variable and sets init to true.

Author:
VooDooMan
Version:
1
Date:
2004

Definition at line 117 of file conf.cpp.

References conf_init(), and keys.

Referenced by dcc_loop().

00118 {
00119     keys.clear();
00120     conf_init();
00121 }

Here is the call graph for this function:

bool conf_ssl_init  ) 
 

Loads ssl.txt configuration file.

Author:
VooDooMan
Version:
1
Date:
2004
Return values:
true For error
false Okay.

Definition at line 151 of file conf.cpp.

References s_ssl_conf::accept_ca_certs, s_ssl_bot::botname, s_ssl_bot::cert, s_ssl_conf::client_cert, s_ssl_conf::client_key, s_ssl_conf::server_cert, s_ssl_conf::server_key, s_ssl_conf::ssl_bots, and ssl_init_.

Referenced by main().

00152 {
00153     if(ssl_init_)
00154         return false;
00155 
00156     FILE* f=fopen("ssl.txt","r");
00157     if(f==NULL)
00158         return true;
00159 
00160     ssl_conf.accept_ca_certs="";
00161     ssl_conf.server_cert="";
00162     ssl_conf.server_key="";
00163     ssl_conf.client_cert="";
00164     ssl_conf.client_key="";
00165     ssl_conf.ssl_bots.clear();
00166 
00167     s_ssl_bot bot;
00168     bot.botname="";
00169     bot.cert="";
00170 
00171     bool in_general=false;
00172     string in_bot="";
00173 
00174 
00175     char ln[10240+1];
00176     while(!feof(f)) {
00177         if(fgets(ln,1024*10-1,f)==NULL)
00178             break;
00179         ln[10240]=0;
00180         if(ln[strlen(ln)-1]=='\r')
00181             ln[strlen(ln)-1]=0;
00182         if(ln[strlen(ln)-1]=='\n')
00183             ln[strlen(ln)-1]=0;
00184         if(ln[strlen(ln)-1]=='\r')
00185             ln[strlen(ln)-1]=0;
00186         if(ln[strlen(ln)-1]=='\n')
00187             ln[strlen(ln)-1]=0;
00188         if(strlen(ln) && ln[0]=='[') {
00189             if(!strcmp(ln,"[general]")) {
00190                 in_general=true;
00191                 in_bot="";
00192                 bot.botname="";
00193                 bot.cert="";
00194                 continue;
00195             }
00196             if(!in_bot.empty()) {
00197                 ssl_conf.ssl_bots.push_back(bot);
00198                 bot.botname="";
00199                 bot.cert="";
00200             }
00201             in_bot=ln;
00202             if(in_bot.length() && in_bot[0]=='[')
00203                 in_bot.erase(0,1);
00204             if(in_bot.length() && in_bot[in_bot.length()-1]==']')
00205                 in_bot.erase(in_bot.length()-1,1);
00206             bot.botname=in_bot;
00207             in_general=false;
00208             continue;
00209         }
00210         string id_, val_;
00211         int pos=0;
00212         for(unsigned int i1=0; i1<strlen(ln); i1++) {
00213             if(pos==0 && ln[i1]=='=') {
00214                 pos++;
00215                 continue;
00216             }
00217             if(pos==0)
00218                 id_+=ln[i1];
00219             if(pos==1)
00220                 val_+=ln[i1];
00221         }
00222         if(in_general && !id_.compare("accept_ca_certs")) {
00223             ssl_conf.accept_ca_certs=val_;
00224             continue;
00225         }
00226         if(in_general && !id_.compare("server_cert")) {
00227             ssl_conf.server_cert=val_;
00228             continue;
00229         }
00230         if(in_general && !id_.compare("server_key")) {
00231             ssl_conf.server_key=val_;
00232             continue;
00233         }
00234         if(in_general && !id_.compare("client_cert")) {
00235             ssl_conf.client_cert=val_;
00236             continue;
00237         }
00238         if(in_general && !id_.compare("client_key")) {
00239             ssl_conf.client_key=val_;
00240             continue;
00241         }
00242         if(!in_bot.empty() && !id_.compare("cert")) {
00243             bot.cert=val_;
00244             continue;
00245         }
00246     }
00247     fclose(f);
00248     if(!in_bot.empty()) {
00249         ssl_conf.ssl_bots.push_back(bot);
00250         bot.botname="";
00251         bot.cert="";
00252     }
00253     ssl_init_=true;
00254 
00255     return false;
00256 }


Generated on Sun Jul 10 03:42:44 2005 for VooDoo cIRCle by doxygen 1.4.3

Hosted by SourceForge.net Logo