Google
Web alhem.net
Main Page | Alphabetical List | Class List | File List | Class Members | File Members

config.cpp File Reference

#include <stdio.h>
#include "Parse.h"
#include "config.h"

Include dependency graph for config.cpp:

Include dependency graph

Go to the source code of this file.

Defines

#define C   slask[strlen(slask) - 1]

Functions

void read_config (const std::string &filename)
void write_config ()
void parse_config (int argc, char *argv[], const std::string &filename)

Variables

config_m config
std::string config_filename


Define Documentation

#define C   slask[strlen(slask) - 1]
 

File ......... config.cpp Published .... 2004-04-18 Author ....... grymse@alhem.net

Definition at line 31 of file config.cpp.

Referenced by read_config().


Function Documentation

void parse_config int  argc,
char *  argv[],
const std::string &  filename
 

Definition at line 81 of file config.cpp.

References config, read_config(), and write_config().

Referenced by main().

00082 {
00083         read_config( filename );
00084         for (int i = 1; i < argc; i++)
00085                 if (argv[i][0] == '-' && i < argc - 1)
00086                 {
00087                         config[argv[i] + 1] = argv[i + 1];
00088                         i++;
00089                 }
00090         write_config(); // filename );
00091 }

void read_config const std::string &  filename  )  [static]
 

Definition at line 38 of file config.cpp.

References C, config, and config_filename.

Referenced by parse_config().

00039 {
00040         FILE *fil = fopen(filename.c_str(),"rt");
00041         config_filename = filename;
00042         if (fil)
00043         {
00044                 char slask[1000];
00045                 std::string key;
00046                 std::string value;
00047                 fgets(slask,1000,fil);
00048                 while (!feof(fil))
00049                 {
00050                         while (strlen(slask) && (C == 13 || C == 10))
00051                                 C = 0;
00052                         Parse pa(slask);
00053                         pa.getword(key);
00054                         pa.getrest(value);
00055                         config[key] = value;
00056                         //
00057                         fgets(slask,1000,fil);
00058                 }
00059                 fclose(fil);
00060         }
00061 }

void write_config  ) 
 

Definition at line 64 of file config.cpp.

References config, and config_filename.

Referenced by parse_config(), and MyHandler::reg_host().

00065 {
00066         FILE *fil = fopen(config_filename.c_str(),"wt");
00067         if (fil)
00068         {
00069                 for (config_m::iterator it = config.begin(); it != config.end(); it++)
00070                 {
00071                         std::string key = (*it).first;
00072                         std::string value = (*it).second;
00073                         if (key[0] != '.')
00074                                 fprintf(fil,"%s %s\n",key.c_str(),value.c_str());
00075                 }
00076                 fclose(fil);
00077         }
00078 }


Variable Documentation

config_m config
 

Definition at line 34 of file config.cpp.

Referenced by main(), MyTcpSocket::OnLine(), parse_config(), read_config(), MyHandler::reg_host(), and write_config().

std::string config_filename [static]
 

Definition at line 35 of file config.cpp.

Referenced by read_config(), and write_config().


Generated on Tue Oct 3 23:47:05 2006 for The Minder by doxygen 1.3.6