mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 23:14:12 +00:00
- Tree cleanups proposed on the mailing list. Move all non-Core OS modules to rosapps. Tests were already moved by Fireball to rostests.
svn path=/trunk/; revision=26033
This commit is contained in:
parent
ad07a1e58f
commit
1e3d5d70e9
420 changed files with 78215 additions and 0 deletions
131
rosapps/roshttpd/config.cpp
Normal file
131
rosapps/roshttpd/config.cpp
Normal file
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS HTTP Daemon
|
||||
* FILE: config.cpp
|
||||
* PURPOSE: Daemon configuration
|
||||
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
||||
* REVISIONS:
|
||||
* CSH 01/09/2000 Created
|
||||
*/
|
||||
#include <new>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <config.h>
|
||||
#include <tchar.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
LPCConfig pConfiguration;
|
||||
LPCHttpDaemonThread pDaemonThread;
|
||||
|
||||
// Default constructor
|
||||
CConfig::CConfig()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
// Default destructor
|
||||
CConfig::~CConfig()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
// Clear configuration
|
||||
void CConfig::Reset()
|
||||
{
|
||||
MainBase = NULL;
|
||||
HttpBase = NULL;
|
||||
DefaultResources.RemoveAll();
|
||||
}
|
||||
|
||||
// Create default configuration. Can throw bad_alloc
|
||||
void CConfig::Default()
|
||||
{
|
||||
Clear();
|
||||
MainBase = _wcsdup((LPWSTR)dcfgMainBase);
|
||||
HttpBase = _strdup(dcfgHttpBase);
|
||||
|
||||
LPSTR lpsStr;
|
||||
try {
|
||||
lpsStr = _strdup(dcfgDefaultResource);
|
||||
DefaultResources.Insert(lpsStr);
|
||||
} catch (bad_alloc e) {
|
||||
free((void *)lpsStr);
|
||||
Clear();
|
||||
throw;
|
||||
}
|
||||
|
||||
Port = dcfgDefaultPort;
|
||||
}
|
||||
|
||||
// Clear configuration
|
||||
void CConfig::Clear()
|
||||
{
|
||||
if (MainBase != NULL)
|
||||
free((void *)MainBase);
|
||||
if (HttpBase != NULL)
|
||||
free((void *)HttpBase);
|
||||
|
||||
// Free memory for all strings
|
||||
CIterator<LPSTR> *i = DefaultResources.CreateIterator();
|
||||
for (i->First(); !i->IsDone(); i->Next())
|
||||
free((void *)i->CurrentItem());
|
||||
delete i;
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
// Load configuration
|
||||
BOOL CConfig::Load()
|
||||
{
|
||||
Default();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Save configuration
|
||||
BOOL CConfig::Save()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Return MainBase
|
||||
LPWSTR CConfig::GetMainBase()
|
||||
{
|
||||
return MainBase;
|
||||
}
|
||||
|
||||
// Set MainBase
|
||||
void CConfig::SetMainBase(LPWSTR lpwsMainBase)
|
||||
{
|
||||
MainBase = lpwsMainBase;
|
||||
}
|
||||
|
||||
// Return HttpBase
|
||||
LPSTR CConfig::GetHttpBase()
|
||||
{
|
||||
return HttpBase;
|
||||
}
|
||||
|
||||
// Set HttpBase
|
||||
void CConfig::SetHttpBase(LPSTR lpsHttpBase)
|
||||
{
|
||||
HttpBase = lpsHttpBase;
|
||||
}
|
||||
|
||||
// Return DefaultResources
|
||||
CList<LPSTR>* CConfig::GetDefaultResources()
|
||||
{
|
||||
return &DefaultResources;
|
||||
}
|
||||
|
||||
// Return bound port
|
||||
USHORT CConfig::GetPort()
|
||||
{
|
||||
return Port;
|
||||
}
|
||||
|
||||
// Set port
|
||||
VOID CConfig::SetPort(USHORT wPort)
|
||||
{
|
||||
Port = wPort;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue