ReactOS  0.4.13-dev-551-gf37fb1f
config.cpp
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS HTTP Daemon
4  * FILE: config.cpp
5  * PURPOSE: Daemon configuration
6  * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7  * REVISIONS:
8  * CSH 01/09/2000 Created
9  */
10 #include <new>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <config.h>
14 #include <tchar.h>
15 
16 using namespace std;
17 
20 
21 // Default constructor
23 {
24  Reset();
25 }
26 
27 // Default destructor
29 {
30  Clear();
31 }
32 
33 // Clear configuration
35 {
36  MainBase = NULL;
37  HttpBase = NULL;
38  DefaultResources.RemoveAll();
39 }
40 
41 // Create default configuration. Can throw bad_alloc
43 {
44  Clear();
45  MainBase = _wcsdup((LPWSTR)dcfgMainBase);
46  HttpBase = _strdup(dcfgHttpBase);
47 
48  LPSTR lpsStr;
49  try {
50  lpsStr = _strdup(dcfgDefaultResource);
51  DefaultResources.Insert(lpsStr);
52  } catch (bad_alloc e) {
53  free((void *)lpsStr);
54  Clear();
55  throw;
56  }
57 
59 }
60 
61 // Clear configuration
63 {
64  if (MainBase != NULL)
65  free((void *)MainBase);
66  if (HttpBase != NULL)
67  free((void *)HttpBase);
68 
69  // Free memory for all strings
70  CIterator<LPSTR> *i = DefaultResources.CreateIterator();
71  for (i->First(); !i->IsDone(); i->Next())
72  free((void *)i->CurrentItem());
73  delete i;
74 
75  Reset();
76 }
77 
78 // Load configuration
80 {
81  Default();
82  return TRUE;
83 }
84 
85 // Save configuration
87 {
88  return TRUE;
89 }
90 
91 // Return MainBase
93 {
94  return MainBase;
95 }
96 
97 // Set MainBase
98 void CConfig::SetMainBase(LPWSTR lpwsMainBase)
99 {
100  MainBase = lpwsMainBase;
101 }
102 
103 // Return HttpBase
105 {
106  return HttpBase;
107 }
108 
109 // Set HttpBase
110 void CConfig::SetHttpBase(LPSTR lpsHttpBase)
111 {
112  HttpBase = lpsHttpBase;
113 }
114 
115 // Return DefaultResources
117 {
118  return &DefaultResources;
119 }
120 
121 // Return bound port
123 {
124  return Port;
125 }
126 
127 // Set port
129 {
130  Port = wPort;
131 }
CList< LPSTR > * GetDefaultResources()
Definition: config.cpp:116
CPPORT Port[4]
Definition: headless.c:34
#define TRUE
Definition: types.h:120
#define free
Definition: debug_ros.c:5
#define dcfgDefaultPort
Definition: config.h:20
BOOL Load()
Definition: config.cpp:79
BOOL Save()
Definition: config.cpp:86
Definition: features.h:417
char * LPSTR
Definition: xmlstorage.h:182
#define _strdup
Definition: debug_ros.c:7
LPSTR GetHttpBase()
Definition: config.cpp:104
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
#define e
Definition: ke_i.h:82
VOID Default()
Definition: config.cpp:42
#define dcfgDefaultResource
Definition: config.h:19
smooth NULL
Definition: ftsmooth.c:416
VOID SetPort(USHORT wPort)
Definition: config.cpp:128
#define dcfgMainBase
Definition: config.h:17
USHORT GetPort()
Definition: config.cpp:122
CConfig()
Definition: config.cpp:22
VOID Reset()
Definition: config.cpp:34
VOID Clear()
Definition: config.cpp:62
unsigned short USHORT
Definition: pedump.c:61
~CConfig()
Definition: config.cpp:28
LPCHttpDaemonThread pDaemonThread
Definition: config.cpp:19
#define dcfgHttpBase
Definition: config.h:18
LPCConfig pConfiguration
Definition: config.cpp:18
VOID SetMainBase(LPWSTR lpwsMainBase)
Definition: config.cpp:98
VOID SetHttpBase(LPSTR lpsHttpBase)
Definition: config.cpp:110
LPWSTR GetMainBase()
Definition: config.cpp:92
void Clear(USHORT Window)
Definition: hardware.c:705
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
Definition: config.h:22