Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Config Class Reference

#include <Config.h>

List of all members.

Public Types

enum  { inetd, standalone }
enum  { LogINN = 0x1, LogName = 0x2, LogAddr = 0x4 }

Public Member Functions

 Config ()
 Config (const char *fn)
void init (void)
void read (const char *fn)
MPListEntryserver (const char *group)
AccessEntryclient (const char *name, struct in_addr addr)
void printParameters (std::ostream *pOut)

Public Attributes

char Username [256]
char Groupname [256]
char Admin [512]
int ServerType
char Hostname [MAXHOSTNAMELEN]
char CachePort [256]
char ListenTo [MAXHOSTNAMELEN]
char LogDirectory [MAXPATHLEN]
int LogStyle
char SpoolDirectory [MAXPATHLEN]
int SpoolSize
char PrefetchFile [MAXPATHLEN]
char PidFile [MAXPATHLEN]
int ClientTimeout
int MaxConnections
time_t ttl_list
time_t ttl_desc
int NiceServer
int NiceClient
int NiceClean
AccessList clnts
MPList srvrs


Detailed Description

Author:
Thomas Gschwind

Bug:
Documentation is missing.

Definition at line 22 of file Config.h.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
inetd 
standalone 

Definition at line 28 of file Config.h.

00028 { inetd, standalone };

anonymous enum
 

Enumeration values:
LogINN 
LogName 
LogAddr 

Definition at line 35 of file Config.h.

00035              {
00036                 LogINN = 0x1,
00037                 LogName = 0x2,
00038                 LogAddr = 0x4
00039         };


Constructor & Destructor Documentation

Config::Config  ) 
 

Definition at line 37 of file Config.cc.

References init().

00038 {
00039         init();
00040 }

Config::Config const char *  fn  ) 
 

Definition at line 42 of file Config.cc.

References init(), and read().

00043 {
00044         init();
00045         read(fn);
00046 }


Member Function Documentation

AccessEntry * Config::client const char *  name,
struct in_addr  addr
 

Definition at line 85 of file Config.cc.

References AccessList::client(), and clnts.

00086 {
00087         return clnts.client(name, addr);
00088 }

void Config::init void   ) 
 

Definition at line 48 of file Config.cc.

References Admin, CachePort, ClientTimeout, clnts, getfqdn(), Groupname, Hostname, MPList::init(), AccessList::init(), ListenTo, LogAddr, LogDirectory, LogName, LogStyle, MaxConnections, NiceClean, NiceClient, NiceServer, PidFile, PrefetchFile, ServerType, SpoolDirectory, SpoolSize, srvrs, standalone, ttl_desc, ttl_list, and Username.

Referenced by catchsighup(), and Config().

00049 {
00050 
00051         Username[0] = Groupname[0] = '\0';
00052         strcpy(Admin, "notset");
00053 
00054         ServerType = standalone;
00055         strcpy(Hostname, getfqdn());
00056         CachePort[0] = '\0';
00057         strcpy (ListenTo, "DEFAULT");
00058 
00059         LogDirectory[0] = '\0';
00060         LogStyle = LogName + LogAddr;
00061         strcpy(SpoolDirectory, "/var/cache/newscache");
00062         SpoolSize = 1024 * 1024;
00063         PrefetchFile[0] = PidFile[0] = '\0';
00064 
00065         ClientTimeout = 1200;
00066         MaxConnections = 32;
00067 
00068         NiceServer = 0;
00069         NiceClient = 10;
00070         NiceClean = 3;
00071 
00072         ttl_list = 3600;        /* 1hr */
00073         ttl_desc = 3600;        /* 1hr */
00074 
00075         clnts.init();
00076         srvrs.init();
00077 
00078 }

void Config::printParameters std::ostream *  pOut  ) 
 

Definition at line 178 of file Config.cc.

References Admin, CachePort, ClientTimeout, clnts, Groupname, inetd, ListenTo, LogAddr, LogDirectory, LogINN, LogName, LogStyle, MaxConnections, NiceClean, NiceClient, NiceServer, PidFile, PrefetchFile, MPList::printParameters(), AccessList::printParameters(), ServerType, SpoolDirectory, SpoolSize, srvrs, standalone, ttl_desc, ttl_list, and Username.

Referenced by main(), and ns_xdebug().

00179 {
00180         if (Username[0] != '\0') {
00181                 *pOut << "Username " << Username << endl;
00182         }
00183         if (Groupname[0] != '\0') {
00184                 *pOut << "Groupname " << Groupname << endl;
00185         }
00186         *pOut << "Admin " << Admin << endl;
00187         *pOut << "ServerType ";
00188         if (ServerType == inetd) {
00189                 *pOut << "inetd" << endl;
00190         } else if (ServerType == standalone) {
00191                 *pOut << "standalone" << endl;
00192         } else {
00193                 *pOut << "UNDEFINED!" << endl;
00194         }
00195         if (CachePort[0] != '\0') {
00196                 *pOut << "CachePort " << CachePort << endl;
00197         }
00198         *pOut << "ListenTo " << ListenTo << endl;
00199         if (LogDirectory[0] != '\0') {
00200                 *pOut << "LogDirectory " << LogDirectory << endl;
00201         }
00202         *pOut << "SpoolDirectory " << SpoolDirectory << endl;
00203         *pOut << "LogStyle";
00204         if (LogStyle & LogINN) {
00205                 *pOut << " strict-inn";
00206         }
00207         if (LogStyle & LogName) {
00208                 *pOut << " hostname";
00209         }
00210         if (LogStyle & LogAddr) {
00211                 *pOut << " ip-address";
00212         }
00213         *pOut << endl;
00214         *pOut << "SpoolSize " << SpoolSize << endl;
00215         if (PrefetchFile[0] != '\0') {
00216                 *pOut << "PrefetchFile " << PrefetchFile << endl;
00217         }
00218         if (PidFile[0] != '\0') {
00219                 *pOut << "PidFile " << PidFile << endl;
00220         }
00221         *pOut << "ClientTimeout " << ClientTimeout << endl;
00222         *pOut << "MaxConnections " << MaxConnections << endl;
00223         *pOut << "Timeouts " << ttl_list << " " << ttl_desc << endl;
00224         *pOut << "NiceServer " << NiceServer << endl;
00225         *pOut << "NiceClient " << NiceClient << endl;
00226         *pOut << "NiceClean " << NiceClean << endl;
00227 
00228         clnts.printParameters (pOut);
00229         srvrs.printParameters (pOut);
00230 }

void Config::read const char *  fn  ) 
 

Definition at line 90 of file Config.cc.

References Admin, CachePort, ClientTimeout, clnts, Lexer::eof(), ERROR_LOCATION, Lexer::getToken(), Groupname, HANDLEINTARG, HANDLESTRGARG, Hostname, inetd, ListenTo, LogAddr, LogDirectory, LogINN, LogName, LogStyle, MaxConnections, NiceClean, NiceClient, NiceServer, PidFile, PrefetchFile, Lexer::putbackToken(), AccessList::read(), MPList::read(), ServerType, SpoolDirectory, SpoolSize, srvrs, standalone, ttl_desc, ttl_list, and Username.

Referenced by catchsighup(), Config(), and main().

00091 {
00092         Lexer lex(fn);
00093         string tok, a1, a2, a3;
00094 
00095         for (;;) {
00096                 tok = lex.getToken();
00097                 if (lex.eof())
00098                         break;
00099 
00100                 HANDLESTRGARG(SpoolDirectory)
00101                     else
00102                         HANDLESTRGARG(LogDirectory)
00103                             else
00104                         HANDLESTRGARG(PrefetchFile)
00105                             else
00106                         HANDLESTRGARG(Username)
00107                             else
00108                         HANDLESTRGARG(Groupname)
00109                             else
00110                         HANDLESTRGARG(CachePort)
00111                             else
00112                         HANDLESTRGARG(ListenTo)
00113                             else
00114                         HANDLESTRGARG(Admin)
00115                             else
00116                         HANDLESTRGARG(PidFile)
00117                             else
00118                         HANDLESTRGARG(Hostname)
00119                             else
00120                         HANDLEINTARG(SpoolSize)
00121                             else
00122                         HANDLEINTARG(ClientTimeout)
00123                             else
00124                         HANDLEINTARG(MaxConnections)
00125                             else
00126                         HANDLEINTARG(NiceServer)
00127                             else
00128                         HANDLEINTARG(NiceClient)
00129                             else
00130                         HANDLEINTARG(NiceClean)
00131                             else
00132                 if (tok == "LogStyle") {
00133                         LogStyle = 0;
00134                         for (;;) {
00135                                 a1 = lex.getToken();
00136                                 if (a1 == "strict-inn")
00137                                         LogStyle |= LogINN;
00138                                 else if (a1 == "hostname")
00139                                         LogStyle |= LogName;
00140                                 else if (a1 == "ip-address")
00141                                         LogStyle |= LogAddr;
00142                                 else
00143                                         break;
00144                         }
00145                         lex.putbackToken(a1);
00146                 } else if (tok == "ServerType") {
00147                         a1 = lex.getToken();
00148                         if (a1 == "inetd")
00149                                 ServerType = inetd;
00150                         else if (a1 == "standalone")
00151                                 ServerType = standalone;
00152                         else
00153                                 throw SyntaxError(lex,
00154                                                   "illegal ServerType",
00155                                                   ERROR_LOCATION);
00156                 } else if (tok == "ConfigVersion") {
00157                         a1 = lex.getToken();
00158                         if (atoi(a1.c_str()) != 5)
00159                                 throw SyntaxError(lex,
00160                                                   "expecting ConfigVersion 5",
00161                                                   ERROR_LOCATION);
00162                 } else if (tok == "NewsServerList") {
00163                         srvrs.read(lex);
00164                 } else if (tok == "AccessList") {
00165                         clnts.read(lex);
00166                 } else if (tok == "Timeouts") {
00167                         a1 = lex.getToken();
00168                         a2 = lex.getToken();
00169                         ttl_list = atoi(a1.c_str());
00170                         ttl_desc = atoi(a2.c_str());
00171                 } else {
00172                         throw SyntaxError(lex, "unknown keyword",
00173                                           ERROR_LOCATION);
00174                 }
00175         }
00176 }

MPListEntry * Config::server const char *  group  ) 
 

Definition at line 80 of file Config.cc.

References MPList::server(), and srvrs.

00081 {
00082         return srvrs.server(group);
00083 }


Member Data Documentation

char Config::Admin[512]
 

Definition at line 26 of file Config.h.

Referenced by init(), ns_help(), printParameters(), and read().

char Config::CachePort[256]
 

Definition at line 31 of file Config.h.

Referenced by init(), nntpd(), printParameters(), and read().

int Config::ClientTimeout
 

Definition at line 47 of file Config.h.

Referenced by init(), nnrpd(), printParameters(), and read().

AccessList Config::clnts
 

Definition at line 57 of file Config.h.

Referenced by client(), init(), nnrpd(), printParameters(), and read().

char Config::Groupname[256]
 

Definition at line 25 of file Config.h.

Referenced by init(), main(), nntpd(), printParameters(), and read().

char Config::Hostname[MAXHOSTNAMELEN]
 

Definition at line 30 of file Config.h.

Referenced by init(), main(), and read().

char Config::ListenTo[MAXHOSTNAMELEN]
 

Definition at line 32 of file Config.h.

Referenced by init(), nntpd(), printParameters(), and read().

char Config::LogDirectory[MAXPATHLEN]
 

Definition at line 40 of file Config.h.

Referenced by init(), main(), printParameters(), and read().

int Config::LogStyle
 

Definition at line 41 of file Config.h.

Referenced by init(), nnrpd(), printParameters(), and read().

int Config::MaxConnections
 

Definition at line 48 of file Config.h.

Referenced by init(), nntpd(), printParameters(), and read().

int Config::NiceClean
 

Definition at line 55 of file Config.h.

Referenced by init(), printParameters(), and read().

int Config::NiceClient
 

Definition at line 54 of file Config.h.

Referenced by init(), printParameters(), and read().

int Config::NiceServer
 

Definition at line 53 of file Config.h.

Referenced by init(), main(), nnrpd(), nntpd(), printParameters(), and read().

char Config::PidFile[MAXPATHLEN]
 

Definition at line 45 of file Config.h.

Referenced by init(), nntpd(), printParameters(), and read().

char Config::PrefetchFile[MAXPATHLEN]
 

Definition at line 44 of file Config.h.

Referenced by init(), printParameters(), read(), and update().

int Config::ServerType
 

Definition at line 29 of file Config.h.

Referenced by init(), main(), printParameters(), and read().

char Config::SpoolDirectory[MAXPATHLEN]
 

Definition at line 42 of file Config.h.

Referenced by clean(), init(), main(), nnrpd(), ns_list(), printParameters(), read(), and update().

int Config::SpoolSize
 

Definition at line 43 of file Config.h.

Referenced by init(), main(), printParameters(), and read().

MPList Config::srvrs
 

Definition at line 58 of file Config.h.

Referenced by init(), main(), nnrpd(), printParameters(), read(), server(), and update().

time_t Config::ttl_desc
 

Definition at line 50 of file Config.h.

Referenced by init(), nnrpd(), printParameters(), read(), and update().

time_t Config::ttl_list
 

Definition at line 49 of file Config.h.

Referenced by init(), nnrpd(), printParameters(), read(), and update().

char Config::Username[256]
 

Definition at line 24 of file Config.h.

Referenced by init(), main(), nntpd(), printParameters(), and read().


The documentation for this class was generated from the following files:
Generated on Fri Aug 20 10:58:10 2004 for NewsCache by doxygen 1.3.6-20040222