Documentation

Generated on Thu Aug 31 00:02:28 2006

 

Configuration.h

Go to the documentation of this file.
00001 
00002 //  $Id: Configuration.h,v 1.55 2005/08/23 19:34:02 klas Exp $
00003 //
00004 //  Usage: Configure class, reading the config file and holding
00005 //           configurish variables.
00006 //
00007 //  A part of babyftpd, licensed under the GNU GPL, see the file                
00008 //    LICENSE for complete information.                                         
00010 
00011 
00012 #ifndef CONFIGURATION_H
00013 #define CONFIGURATION_H
00014 
00015 #ifdef CONFIGURATION_CPP
00016 #include "generic.h"
00017 #include "StringTokenizer.h"
00018 #include "Utilities.h"
00019 #include "Log.h"
00020 extern void exit_baby(int, enum exits);
00021 const char *VERSION = "CVS: "__DATE__; // remember to change on release.
00022 #endif
00023 
00024 struct log_stru
00025 {
00026   int log_level;
00027   bool xferlog;
00028   string xferlog_file;
00029   string authlog;
00030   string infolog;
00031   string debuglog;
00032   bool thread_id;
00033   string time_format;
00034 };
00035 
00036 struct users_stru
00037 {
00038   string id;
00039   int sim_data;
00040   int idle;
00041   bool noftp;
00042   bool only_home;
00043   bool only_passive;
00044   int user_limit;
00045 #ifdef USE_TLS
00046   int encryption;
00047 #endif // USE_TLS
00048 };
00049 
00050 struct general_stru
00051 {
00052   int connection_limit;
00053   int port;
00054   int data_port;
00055   bool no_daemon;
00056   string os;
00057   string admin_email;
00058   string welcome_msg;
00059   int lifebeat_tick;
00060   uid_t user;
00061   gid_t group;
00062   string pid_file;
00063   bool readonly;
00064   int anonymous;
00065 #ifdef USE_TLS  
00066   string tls_key;
00067   string tls_cert;
00068   string tls_ca;
00069   string tls_crl;
00070   int dh_regenerate;
00071   string verify_client;
00072 #endif
00073 };
00074 
00075 enum sect { USER, LOG, GENERAL };
00076 
00077 class Configuration
00078 {
00079   private:
00080     vector<users_stru> users;
00081     int num_users;
00082     bool parsed;
00083     int count_users(vector<string>, string&);
00084     bool fill_buff(vector<string>&, string);
00085     string get_variables(vector<string>&, const char*, int);
00086     bool set_structs(string, enum sect, void*);
00087   public:
00088     bool parse_config_file();
00089     bool parse_command_line(int argc, char **argv);
00090     string conf_file;
00091     struct log_stru logger;
00092     struct general_stru general;
00093     struct users_stru general_user;
00094     Configuration(void);
00095     struct users_stru &get_user(string);
00096     ~Configuration(void);
00097 };
00098 
00099 extern class Configuration *config;
00100 
00101 enum conf
00102 {
00103   CONF_INT, CONF_BOOL, CONF_STRING, CONF_LOGF, CONF_ENC,
00104   CONF_USER, CONF_TIMEF, CONF_TIME, CONF_ANON
00105 };
00106 
00107 struct config_entry
00108 {
00109   string name;
00110   enum conf type;
00111   void *variabel;
00112   config_entry(const string t_name, const enum conf t_type, void *t_vari)
00113   {
00114     name = t_name;
00115     type = t_type;
00116     variabel = t_vari;
00117   }
00118 };
00119 
00120 typedef struct config_entry config_entry;
00121 
00122 // constants for the anonymous variable.
00123 enum anon { A_DISABLE, A_ENABLE, A_ONLY };
00124 
00125 #ifdef USE_TLS
00126 enum encr { ALLOW, FORCE, DENY, FORCE_CERT };
00127 #endif // USE_TLS
00128 #endif