summaryrefslogtreecommitdiffabout
path: root/include
Unidiff
Diffstat (limited to 'include') (more/less context) (ignore whitespace changes)
-rw-r--r--include/sitecing/cgi_component.h11
-rw-r--r--include/sitecing/component_factory.h14
-rw-r--r--include/sitecing/component_so.h6
-rw-r--r--include/sitecing/configuration.h23
-rw-r--r--include/sitecing/file_factory.h4
-rw-r--r--include/sitecing/process_manager.h2
-rw-r--r--include/sitecing/scoreboard.h3
-rw-r--r--include/sitecing/sitecing_parser.h6
-rw-r--r--include/sitecing/sitecing_util.h24
-rw-r--r--include/sitecing/util.h4
10 files changed, 63 insertions, 34 deletions
diff --git a/include/sitecing/cgi_component.h b/include/sitecing/cgi_component.h
index 91df689..0cad438 100644
--- a/include/sitecing/cgi_component.h
+++ b/include/sitecing/cgi_component.h
@@ -1,54 +1,45 @@
1#ifndef __SITECING_CGI_COMPONENT_H 1#ifndef __SITECING_CGI_COMPONENT_H
2#define __SITECING_CGI_COMPONENT_H 2#define __SITECING_CGI_COMPONENT_H
3 3
4#include <map> 4#include <map>
5#include "kingate/cgi_gateway.h" 5#include "kingate/cgi_gateway.h"
6#include "sitecing/acomponent.h" 6#include "sitecing/acomponent.h"
7#include "sitecing/sitecing_interface_cgi.h" 7#include "sitecing/sitecing_interface_cgi.h"
8 8
9/** 9/**
10 * @file 10 * @file
11 * @brief The cgi_component class declaration. 11 * @brief The cgi_component class declaration.
12 */ 12 */
13 13
14namespace sitecing { 14namespace sitecing {
15 using namespace std; 15 using namespace std;
16 16
17 /** 17 /**
18 * The CGI-oriented component class. 18 * The CGI-oriented component class.
19 */ 19 */
20 class cgi_component : virtual public acomponent { 20 class cgi_component : virtual public acomponent {
21 public: 21 public:
22 /** 22 /**
23 * The interface to site-C-ing core. 23 * The interface to site-C-ing core.
24 */ 24 */
25 sitecing_interface_cgi* __SCIF; 25 sitecing_interface_cgi* __SCIF;
26 /** 26 /**
27 * The interface to the CGI gateway. 27 * The interface to the CGI gateway.
28 */ 28 */
29 kingate::cgi_gateway* __CGI; 29 kingate::cgi_gateway* __CGI;
30 30
31 cgi_component(); 31 cgi_component();
32 virtual ~cgi_component(); 32 virtual ~cgi_component();
33 33
34 /**
35 * @overload acomponent::__set_interface()
36 */
37 void __set_interface(sitecing_interface* scif); 34 void __set_interface(sitecing_interface* scif);
38 /** 35 void __on_change_interface(sitecing_interface *oscif);
39 * @overload acomponent::__on_change_interface()
40 */
41 void __on_change_interface(sitecing_interface *o);
42 /** 36 /**
43 * Invoked on the change of the interface to the CGI. 37 * Invoked on the change of the interface to the CGI.
44 */ 38 */
45 virtual void __on_change_CGI(kingate::cgi_gateway *o); 39 virtual void __on_change_CGI(kingate::cgi_gateway *o);
46 /**
47 * @overload acomponent::__on_imports()
48 */
49 virtual void __on_imports(); 40 virtual void __on_imports();
50 }; 41 };
51 42
52} 43}
53 44
54#endif /* __SITECING_CGI_COMPONENT_H */ 45#endif /* __SITECING_CGI_COMPONENT_H */
diff --git a/include/sitecing/component_factory.h b/include/sitecing/component_factory.h
index 9ddf70d..8f103e0 100644
--- a/include/sitecing/component_factory.h
+++ b/include/sitecing/component_factory.h
@@ -1,88 +1,76 @@
1#ifndef __SITECING_COMPONENT_FACTORY_H 1#ifndef __SITECING_COMPONENT_FACTORY_H
2#define __SITECING_COMPONENT_FACTORY_H 2#define __SITECING_COMPONENT_FACTORY_H
3 3
4#include <string> 4#include <string>
5#include <list> 5#include <list>
6#include <stdexcept> 6#include <stdexcept>
7#include "sitecing/file_factory.h" 7#include "sitecing/file_factory.h"
8#include "sitecing/configuration.h" 8#include "sitecing/configuration.h"
9 9
10/** 10/**
11 * @file 11 * @file
12 * @brief The component_factory class declaration. 12 * @brief The component_factory class declaration.
13 */ 13 */
14 14
15namespace sitecing { 15namespace sitecing {
16 using namespace std; 16 using namespace std;
17 17
18 /** 18 /**
19 * @brief The components builder. 19 * @brief The components builder.
20 */ 20 */
21 class component_factory : public file_factory { 21 class component_factory : public file_factory {
22 public: 22 public:
23 /** 23 /**
24 * Path to the source files root. 24 * Path to the source files root.
25 */ 25 */
26 string root_source; 26 string root_source;
27 /** 27 /**
28 * Path to the root of the intermediate files storage. 28 * Path to the root of the intermediate files storage.
29 */ 29 */
30 string root_intermediate; 30 string root_intermediate;
31 /** 31 /**
32 * Output path for .so components. 32 * Output path for .so components.
33 */ 33 */
34 string root_so; 34 string root_so;
35 /** 35 /**
36 * Reference to the configuration container. 36 * Reference to the configuration container.
37 */ 37 */
38 configuration& config; 38 configuration& config;
39 39
40 /** 40 /**
41 * @param c reference to the configuration container. 41 * @param c reference to the configuration container.
42 */ 42 */
43 component_factory(configuration& c); 43 component_factory(configuration& c);
44 44
45 /**
46 * @overload file_factory::get_dependencies()
47 */
48 virtual void get_dependencies(const string& dst,file_list_t& deps); 45 virtual void get_dependencies(const string& dst,file_list_t& deps);
49 /** 46 virtual bool is_uptodate(const string& dst,file_list_t *deps=0);
50 * @overload file_factory::is_uptodate()
51 */
52 virtual bool is_uptodate(const string& dst,file_list_t *deps=NULL);
53 /**
54 * @overload file_factory::build()
55 */
56 virtual void build(const string& dst); 47 virtual void build(const string& dst);
57 /**
58 * @overload file_factory::make()
59 */
60 virtual void make(const string& dst); 48 virtual void make(const string& dst);
61 49
62 /** 50 /**
63 * Helper function for executing external command. 51 * Helper function for executing external command.
64 * @param cmd the command to execute. 52 * @param cmd the command to execute.
65 * @param args the command line arguments. 53 * @param args the command line arguments.
66 * @param stdo stdout for the child process. 54 * @param stdo stdout for the child process.
67 * @param stde stderr for the child process. 55 * @param stde stderr for the child process.
68 * @return exit code. 56 * @return exit code.
69 */ 57 */
70 int execute(const string& cmd,const list<string>& args,int stdo,int stde); 58 int execute(const string& cmd,const list<string>& args,int stdo,int stde);
71 /** 59 /**
72 * Fetch the class name of the component. 60 * Fetch the class name of the component.
73 * @param component the component. 61 * @param component the component.
74 * @return the class name. 62 * @return the class name.
75 */ 63 */
76 string get_classname(const string& component); 64 string get_classname(const string& component);
77 /** 65 /**
78 * Get the components from which the target component has been 66 * Get the components from which the target component has been
79 * derived. 67 * derived.
80 * @param component the target component 68 * @param component the target component
81 * @param rv where to store the list of ancestors. 69 * @param rv where to store the list of ancestors.
82 */ 70 */
83 void get_ancestors(const string& component,file_list_t &rv); 71 void get_ancestors(const string& component,file_list_t &rv);
84 }; 72 };
85 73
86} 74}
87 75
88#endif /* __SITECING_COMPONENT_FACTORY_H */ 76#endif /* __SITECING_COMPONENT_FACTORY_H */
diff --git a/include/sitecing/component_so.h b/include/sitecing/component_so.h
index 3239d4a..3daceef 100644
--- a/include/sitecing/component_so.h
+++ b/include/sitecing/component_so.h
@@ -88,72 +88,78 @@ namespace sitecing {
88 */ 88 */
89 class so_component { 89 class so_component {
90 public: 90 public:
91 /** 91 /**
92 * Pointer to the component 'class'. 92 * Pointer to the component 'class'.
93 */ 93 */
94 component_so *hen; 94 component_so *hen;
95 /** 95 /**
96 * The instance in question. 96 * The instance in question.
97 */ 97 */
98 acomponent* ac; 98 acomponent* ac;
99 99
100 so_component() 100 so_component()
101 : hen(0), ac(0) { } 101 : hen(0), ac(0) { }
102 /** 102 /**
103 * @param h the 'class' object. 103 * @param h the 'class' object.
104 * @param scif pointer to the interface to the site-C-ing core. 104 * @param scif pointer to the interface to the site-C-ing core.
105 */ 105 */
106 so_component(component_so *h,sitecing_interface *scif); 106 so_component(component_so *h,sitecing_interface *scif);
107 /** 107 /**
108 * Copy constructor 108 * Copy constructor
109 * @param s source instance. 109 * @param s source instance.
110 */ 110 */
111 so_component(const so_component& s) 111 so_component(const so_component& s)
112 : hen(0), ac(0) { attach(s); } 112 : hen(0), ac(0) { attach(s); }
113 ~so_component() { detach(); } 113 ~so_component() { detach(); }
114 114
115 /** 115 /**
116 * Assignment operator. 116 * Assignment operator.
117 * @param s source instance. 117 * @param s source instance.
118 */ 118 */
119 so_component& operator=(const so_component& s) { 119 so_component& operator=(const so_component& s) {
120 attach(s); return *this; 120 attach(s); return *this;
121 } 121 }
122 122
123 /** 123 /**
124 * @todo TODO: wish I could remember the details -- document me. 124 * @todo TODO: wish I could remember the details -- document me.
125 * @param h the 'class' object. 125 * @param h the 'class' object.
126 * @param a the instance to be attached. 126 * @param a the instance to be attached.
127 */ 127 */
128 void attach(component_so *h,acomponent *a); 128 void attach(component_so *h,acomponent *a);
129 /** 129 /**
130 * @todo TODO: wish I could remember the details -- document me. 130 * @todo TODO: wish I could remember the details -- document me.
131 * @param s the source instance. 131 * @param s the source instance.
132 */ 132 */
133 void attach(const so_component& s) { attach(s.hen,s.ac); } 133 void attach(const so_component& s) { attach(s.hen,s.ac); }
134 /** 134 /**
135 * @todo TODO: wish I could remember the details -- document me. 135 * @todo TODO: wish I could remember the details -- document me.
136 */ 136 */
137 void detach(); 137 void detach();
138 }; 138 };
139 139
140 /** 140 /**
141 * The typed component instance container template. 141 * The typed component instance container template.
142 * @param CT the component class. 142 * @param CT the component class.
143 */ 143 */
144 template<typename CT> 144 template<typename CT>
145 class so_component_t : public sitecing::so_component { 145 class so_component_t : public sitecing::so_component {
146 public: 146 public:
147 /** 147 /**
148 * @param s The untyped instance container. 148 * @param s The untyped instance container.
149 */ 149 */
150 so_component_t(const so_component& s) 150 so_component_t(const so_component& s)
151 : so_component(s) { } 151 : so_component(s) { }
152
153 /**
154 * typed dereference operator
155 * @return the pointer to the most derived component instance
156 * @see acomponent::__the_most_derived_this()
157 */
152 CT* operator->() { 158 CT* operator->() {
153 return static_cast<CT*>(ac->__the_most_derived_this()); 159 return static_cast<CT*>(ac->__the_most_derived_this());
154 } 160 }
155 }; 161 };
156 162
157} 163}
158 164
159#endif /* __SITECING_COMPONENT_SO_H */ 165#endif /* __SITECING_COMPONENT_SO_H */
diff --git a/include/sitecing/configuration.h b/include/sitecing/configuration.h
index 330a5a6..a2bf612 100644
--- a/include/sitecing/configuration.h
+++ b/include/sitecing/configuration.h
@@ -83,377 +83,394 @@ namespace sitecing {
83 * The files to be built are specified in the context. 83 * The files to be built are specified in the context.
84 * @see auto_build_files 84 * @see auto_build_files
85 */ 85 */
86 flag_auto_build_files = 0x0400 86 flag_auto_build_files = 0x0400
87 }; 87 };
88 /** 88 /**
89 * The flags specifying what parts of configuration have been 89 * The flags specifying what parts of configuration have been
90 * specified for the context. 90 * specified for the context.
91 */ 91 */
92 int flags; 92 int flags;
93 93
94 /** 94 /**
95 * The skeleton for building components. 95 * The skeleton for building components.
96 */ 96 */
97 string skeleton; 97 string skeleton;
98 /** 98 /**
99 * The flags to pass to compiler. 99 * The flags to pass to compiler.
100 */ 100 */
101 list<string> cpp_flags; 101 list<string> cpp_flags;
102 /** 102 /**
103 * The flags to pass to linker. 103 * The flags to pass to linker.
104 */ 104 */
105 list<string> ld_flags; 105 list<string> ld_flags;
106 /** 106 /**
107 * Whether to build inexstent and outdated components. 107 * Whether to build inexstent and outdated components.
108 */ 108 */
109 bool build; 109 bool build;
110 /** 110 /**
111 * Whether to track cpp dependencies. 111 * Whether to track cpp dependencies.
112 */ 112 */
113 bool cpp_deps; 113 bool cpp_deps;
114 /** 114 /**
115 * The component handling caught exceptions. 115 * The component handling caught exceptions.
116 */ 116 */
117 string exception_handler; 117 string exception_handler;
118 /** 118 /**
119 * Enforced intermediate dependencies. 119 * Enforced intermediate dependencies.
120 */ 120 */
121 list<string> intermediate_deps; 121 list<string> intermediate_deps;
122 /** 122 /**
123 * Enforced depencies for .so objects. 123 * Enforced depencies for .so objects.
124 */ 124 */
125 list<string> so_deps; 125 list<string> so_deps;
126 /** 126 /**
127 * The action handler type. 127 * The action handler type.
128 */ 128 */
129 struct action_handler_t { 129 struct action_handler_t {
130 /** 130 /**
131 * The regexp to check request against. 131 * The regexp to check request against.
132 */ 132 */
133 string s_regex; 133 string s_regex;
134 /** 134 /**
135 * Precompiled regex. 135 * Precompiled regex.
136 */ 136 */
137 pcrepp::Pcre regex; 137 pcrepp::Pcre regex;
138 /** 138 /**
139 * The action handler component. 139 * The action handler component.
140 */ 140 */
141 string action; 141 string action;
142 /** 142 /**
143 * Arguments for the action hander coponent. 143 * Arguments for the action hander coponent.
144 */ 144 */
145 list<string> args; 145 list<string> args;
146 146
147 /**
148 * @param s regex pattern
149 * @param a action handler
150 */
147 action_handler_t(const string& s,const string& a) 151 action_handler_t(const string& s,const string& a)
148 : s_regex(s), regex(s), action(a) { } 152 : s_regex(s), regex(s), action(a) { }
153 /**
154 * Copy constructor
155 *
156 * @param s source object
157 */
149 action_handler_t(const action_handler_t& s) 158 action_handler_t(const action_handler_t& s)
150 : s_regex(s.s_regex), regex(s.regex), action (s.action), args(s.args) { } 159 : s_regex(s.s_regex), regex(s.regex), action (s.action), args(s.args) { }
151 }; 160 };
152 /** 161 /**
153 * Type for the list of action handlers. 162 * Type for the list of action handlers.
154 */ 163 */
155 typedef list<action_handler_t> action_handlers_t; 164 typedef list<action_handler_t> action_handlers_t;
156 /** 165 /**
157 * The list of action handlers. 166 * The list of action handlers.
158 */ 167 */
159 action_handlers_t action_handlers; 168 action_handlers_t action_handlers;
160 /** 169 /**
161 * Type for the map of HTTP status handler components. 170 * Type for the map of HTTP status handler components.
162 */ 171 */
163 typedef map<string,string> http_status_handlers_t; 172 typedef map<string,string> http_status_handlers_t;
164 /** 173 /**
165 * The map of HTTP status handler components. 174 * The map of HTTP status handler components.
166 */ 175 */
167 http_status_handlers_t http_status_handlers; 176 http_status_handlers_t http_status_handlers;
168 /** 177 /**
169 * Files to be built automatically. 178 * Files to be built automatically.
170 */ 179 */
171 list<string> auto_build_files; 180 list<string> auto_build_files;
172 181
173 config_options() 182 config_options()
174 : flags(0) { } 183 : flags(0) { }
175 184
176 /** 185 /**
177 * Look up if there is an action handler for the target defined. 186 * Look up if there is an action handler for the target defined.
178 * @param target the target component. 187 * @param target the target component.
179 * @return the pointer to handler or zero. 188 * @return the pointer to handler or zero.
180 */ 189 */
181 action_handler_t *lookup_action_handler(const string& target); 190 action_handler_t *lookup_action_handler(const string& target);
182 /** 191 /**
183 * Look up if there is a handler defined for the HTTP status. 192 * Look up if there is a handler defined for the HTTP status.
184 * @param status HTTP status 193 * @param status HTTP status
185 * @return the handler component. 194 * @return the handler component.
186 */ 195 */
187 string lookup_http_status_handler(const string& status); 196 string lookup_http_status_handler(const string& status);
188 /** 197 /**
189 * Check whether the file should be build automatically. 198 * Check whether the file should be build automatically.
190 * @param fn file name. 199 * @param fn file name.
191 * @param rv reference to the boolean where the answer should go. 200 * @param rv reference to the boolean where the answer should go.
192 * @return true if we know the answer. 201 * @return true if we know the answer.
193 */ 202 */
194 bool match_autobuild_files(const char *fn,bool &rv); 203 bool match_autobuild_files(const char *fn,bool &rv);
195 }; 204 };
196 205
197 /** 206 /**
198 * Configuration data container for the configuration loaded from disk file. 207 * Configuration data container for the configuration loaded from disk file.
199 */ 208 */
200 class loaded_options : public config_options { 209 class loaded_options : public config_options {
201 public: 210 public:
202 /** 211 /**
203 * The file where configuration originates from. 212 * The file where configuration originates from.
204 */ 213 */
205 string source_file; 214 string source_file;
206 /** 215 /**
207 * The stat structure for the source file as it was when we have 216 * The stat structure for the source file as it was when we have
208 * loaded it. 217 * loaded it.
209 */ 218 */
210 struct stat st; 219 struct stat st;
211 220
212 /** 221 /**
213 * See if the data is still valid. 222 * See if the data is still valid.
214 * @return true if yes. 223 * @return true if yes.
215 */ 224 */
216 bool is_valid(); 225 bool is_valid();
217 226
218 /** 227 /**
219 * Load the configuration file. 228 * Load the configuration file.
220 * @param config the main configuration container. 229 * @param config the main configuration container.
221 * @param the configuration file. 230 * @param cfile the configuration file.
222 */ 231 */
223 void parse(configuration *config,const string& cfile); 232 void parse(configuration *config,const string& cfile);
224 }; 233 };
225 234
226 /** 235 /**
227 * The main configuration container. 236 * The main configuration container.
228 */ 237 */
229 class configuration { 238 class configuration {
230 public: 239 public:
231 /** 240 /**
232 * @todo TODO:: document me. 241 * @todo TODO:: document me.
233 */ 242 */
234 bool autobuild; 243 bool autobuild;
235 /** 244 /**
236 * The flags enumeration. 245 * The flags enumeration.
237 */ 246 */
238 enum _flags { 247 enum _flags {
239 /** 248 /**
240 * Was the source root specified? 249 * Was the source root specified?
241 * @see root_source 250 * @see root_source
242 */ 251 */
243 flag_root_source = 0x00000001, 252 flag_root_source = 0x00000001,
244 /** 253 /**
245 * Was the root for intermediate files specified? 254 * Was the root for intermediate files specified?
246 * @see root_intermediate 255 * @see root_intermediate
247 */ 256 */
248 flag_root_intermediate = 0x00000002, 257 flag_root_intermediate = 0x00000002,
249 /** 258 /**
250 * Was the root for the resulting .so files specified? 259 * Was the root for the resulting .so files specified?
251 * @see root_so 260 * @see root_so
252 */ 261 */
253 flag_root_so = 0x00000004, 262 flag_root_so = 0x00000004,
254 /** 263 /**
255 * Was the socket to listen to specified? 264 * Was the socket to listen to specified?
256 * @see listen_socket 265 * @see listen_socket
257 */ 266 */
258 flag_listen_socket = 0x00000008, 267 flag_listen_socket = 0x00000008,
259 /** 268 /**
260 * Was the per-dir config file name specified. 269 * Was the per-dir config file name specified.
261 * @see rc_file_name 270 * @see rc_file_name
262 */ 271 */
263 flag_rc_file_name = 0x00000010, 272 flag_rc_file_name = 0x00000010,
264 /** 273 /**
265 * Was the minimum number of child processes specified? 274 * Was the minimum number of child processes specified?
266 * @see min_children 275 * @see min_children
267 */ 276 */
268 flag_min_children = 0x00000020, 277 flag_min_children = 0x00000020,
269 /** 278 /**
270 * Was the maximum number of child processes specified? 279 * Was the maximum number of child processes specified?
271 * @see max_children 280 * @see max_children
272 */ 281 */
273 flag_max_children = 0x00000040, 282 flag_max_children = 0x00000040,
274 /** 283 /**
275 * Was the minimum number of spare child processes specified? 284 * Was the minimum number of spare child processes specified?
276 * @see min_spare_children 285 * @see min_spare_children
277 */ 286 */
278 flag_min_spare_children = 0x00000080, 287 flag_min_spare_children = 0x00000080,
279 /** 288 /**
280 * Was he maximum number of spare child processes specified? 289 * Was he maximum number of spare child processes specified?
281 * @see max_spare_children 290 * @see max_spare_children
282 */ 291 */
283 flag_max_spare_children = 0x00000100, 292 flag_max_spare_children = 0x00000100,
284 /** 293 /**
285 * Was the number of requests to handle per child process 294 * Was the number of requests to handle per child process
286 * specified? 295 * specified?
287 * @see requests_per_child 296 * @see requests_per_child
288 */ 297 */
289 flag_requests_per_child = 0x00000200, 298 flag_requests_per_child = 0x00000200,
290 /** 299 /**
291 * Was the multiprocess node (or it's absences) specified? 300 * Was the multiprocess node (or it's absences) specified?
292 * @see multi_process 301 * @see multi_process
293 */ 302 */
294 flag_multi_process = 0x00000400, 303 flag_multi_process = 0x00000400,
295 /** 304 /**
296 * Was the user specified? 305 * Was the user specified?
297 * @see user 306 * @see user
298 */ 307 */
299 flag_user = 0x00000800, 308 flag_user = 0x00000800,
300 /** 309 /**
301 * @Was the group specified? 310 * Was the group specified?
302 * @see group 311 * @see group
303 */ 312 */
304 flag_group = 0x00001000, 313 flag_group = 0x00001000,
305 /** 314 /**
306 * Was the root to change to specified? 315 * Was the root to change to specified?
307 * @see chroot 316 * @see chroot
308 */ 317 */
309 flag_chroot = 0x00002000, 318 flag_chroot = 0x00002000,
310 /** 319 /**
311 * Was the file for storing PID specified? 320 * Was the file for storing PID specified?
312 * @see pidfile 321 * @see pidfile
313 */ 322 */
314 flag_pid_file = 0x00004000, 323 flag_pid_file = 0x00004000,
315 /** 324 /**
316 * Was it specified wether we should daemonize the process? 325 * Was it specified wether we should daemonize the process?
317 * @see daemonize 326 * @see daemonize
318 */ 327 */
319 flag_daemonize = 0x00008000 328 flag_daemonize = 0x00008000
320 }; 329 };
321 /** 330 /**
322 * The flags specifying what parts of the configuration has been 331 * The flags specifying what parts of the configuration has been
323 * loaded into the object. 332 * loaded into the object.
324 */ 333 */
325 long flags; 334 long flags;
326 335
327 /** 336 /**
328 * The root for the components source code. 337 * The root for the components source code.
329 */ 338 */
330 string root_source; 339 string root_source;
331 /** 340 /**
332 * The root for intermediate files. 341 * The root for intermediate files.
333 */ 342 */
334 string root_intermediate; 343 string root_intermediate;
335 /** 344 /**
336 * The root for .so files. 345 * The root for .so files.
337 */ 346 */
338 string root_so; 347 string root_so;
339 /** 348 /**
340 * Socket to bind to 349 * Socket to bind to
341 */ 350 */
342 string listen_socket; 351 string listen_socket;
343 /** 352 /**
344 * per-dir config file name. 353 * per-dir config file name.
345 */ 354 */
346 string rc_file_name; 355 string rc_file_name;
347 /** 356 /**
348 * The minimum number of child processes in multiprocess mode. 357 * The minimum number of child processes in multiprocess mode.
349 */ 358 */
350 int min_children; 359 int min_children;
351 /** 360 /**
352 * The maxium number of child processes in multiprocess mode. 361 * The maxium number of child processes in multiprocess mode.
353 */ 362 */
354 int max_children; 363 int max_children;
355 /** 364 /**
356 * The minimum number of spare chidren in multiprocess mode. 365 * The minimum number of spare chidren in multiprocess mode.
357 */ 366 */
358 int min_spare_children; 367 int min_spare_children;
359 /** 368 /**
360 * The maximum number of spare children in multiprocess mode. 369 * The maximum number of spare children in multiprocess mode.
361 */ 370 */
362 int max_spare_children; 371 int max_spare_children;
363 /** 372 /**
364 * The number of requests the child process should handle before 373 * The number of requests the child process should handle before
365 * exiting. 374 * exiting.
366 */ 375 */
367 int requests_per_child; 376 int requests_per_child;
368 /** 377 /**
369 * Whether we should run in multiprocess mode or not. 378 * Whether we should run in multiprocess mode or not.
370 */ 379 */
371 bool multi_process; 380 bool multi_process;
372 /** 381 /**
373 * User to change to. 382 * User to change to.
374 */ 383 */
375 string user; 384 string user;
376 /** 385 /**
377 * Group to set to. 386 * Group to set to.
378 */ 387 */
379 string group; 388 string group;
380 /** 389 /**
381 * Directory to change root to. 390 * Directory to change root to.
382 */ 391 */
383 string chroot; 392 string chroot;
384 /** 393 /**
385 * The file to store PID into. 394 * The file to store PID into.
386 */ 395 */
387 string pid_file; 396 string pid_file;
388 /** 397 /**
389 * Whether we should fork into background. 398 * Whether we should fork into background.
390 */ 399 */
391 bool daemonize; 400 bool daemonize;
392 401
402 /**
403 * Type for the config options map
404 * @see specs
405 */
393 typedef map<string,config_options> specs_t; 406 typedef map<string,config_options> specs_t;
394 /** 407 /**
395 * The local config options map. 408 * The local config options map.
396 */ 409 */
397 specs_t specs; 410 specs_t specs;
411 /**
412 * Type for the loaded per-dir config map
413 * @see loaded_specs
414 */
398 typedef map<string,loaded_options> loaded_specs_t; 415 typedef map<string,loaded_options> loaded_specs_t;
399 /** 416 /**
400 * The local config options as specified in per-dir config files 417 * The local config options as specified in per-dir config files
401 * map. 418 * map.
402 */ 419 */
403 loaded_specs_t loaded_specs; 420 loaded_specs_t loaded_specs;
404 421
405 configuration(); 422 configuration();
406 /** 423 /**
407 * @param cfile the configuration file. 424 * @param cfile the configuration file.
408 * @param ab @todo TODO:: document me 425 * @param ab document me @todo TODO:: document me
409 */ 426 */
410 configuration(const string& cfile,bool ab=false); 427 configuration(const string& cfile,bool ab=false);
411 428
412 /** 429 /**
413 * Parse the configuration file. 430 * Parse the configuration file.
414 * @param cfile the configuration file. 431 * @param cfile the configuration file.
415 */ 432 */
416 void parse(const string& cfile); 433 void parse(const string& cfile);
417 434
418 /** 435 /**
419 * Fetch the reference to options for the very root. 436 * Fetch the reference to options for the very root.
420 */ 437 */
421 config_options& root_options() { return specs[""]; } 438 config_options& root_options() { return specs[""]; }
422 /** 439 /**
423 * Lookup where the certain config option for the target lies in. 440 * Lookup where the certain config option for the target lies in.
424 * @param target the target component. 441 * @param target the target component.
425 * @param flag the flag specifying the option we're looking for. 442 * @param flag the flag specifying the option we're looking for.
426 * @return the destination options continer or zero. 443 * @return the destination options continer or zero.
427 */ 444 */
428 config_options* lookup_config(const string& target,int flag); 445 config_options* lookup_config(const string& target,int flag);
429 /** 446 /**
430 * Lookup the action handler for the target. 447 * Lookup the action handler for the target.
431 * @param target the target request. 448 * @param target the target request.
432 * @return the action handler or zero. 449 * @return the action handler or zero.
433 */ 450 */
434 config_options::action_handler_t *lookup_action_handler(const string& target); 451 config_options::action_handler_t *lookup_action_handler(const string& target);
435 /** 452 /**
436 * Lookup the HTPP status handler for the target. 453 * Lookup the HTPP status handler for the target.
437 * @param target the target. 454 * @param target the target.
438 * @param status the HTTP status. 455 * @param status the HTTP status.
439 * @return the handler component. 456 * @return the handler component.
440 */ 457 */
441 string lookup_http_status_handler(const string& target,const string& status); 458 string lookup_http_status_handler(const string& target,const string& status);
442 /** 459 /**
443 * Lookup the options loaded from per-dir config for the target 460 * Lookup the options loaded from per-dir config for the target
444 * @param target the target. 461 * @param target the target.
445 * @return options container or zero. 462 * @return options container or zero.
446 */ 463 */
447 loaded_options* lookup_loaded_options(const string& target); 464 loaded_options* lookup_loaded_options(const string& target);
448 /** 465 /**
449 * Check whether the components for the target should be prebuilt. 466 * Check whether the components for the target should be prebuilt.
450 * @param target the target. 467 * @param target the target.
451 * @param fn file name. 468 * @param fn file name.
452 * @return true if yes. 469 * @return true if yes.
453 */ 470 */
454 bool match_autobuild_files(const string& target,const char *fn); 471 bool match_autobuild_files(const string& target,const char *fn);
455 }; 472 };
456 473
457} 474}
458 475
459#endif /* __SITECING_CONFIGURATION_H */ 476#endif /* __SITECING_CONFIGURATION_H */
diff --git a/include/sitecing/file_factory.h b/include/sitecing/file_factory.h
index 7ec82da..43a27bb 100644
--- a/include/sitecing/file_factory.h
+++ b/include/sitecing/file_factory.h
@@ -1,64 +1,64 @@
1#ifndef __SITECING_FILE_FACTORY_H 1#ifndef __SITECING_FILE_FACTORY_H
2#define __SITECING_FILE_FACTORY_H 2#define __SITECING_FILE_FACTORY_H
3 3
4#include <string> 4#include <string>
5#include <list> 5#include <list>
6 6
7/** 7/**
8 * @file 8 * @file
9 * @brief the file_factory class declaration. 9 * @brief the file_factory class declaration.
10 */ 10 */
11 11
12namespace sitecing { 12namespace sitecing {
13 using namespace std; 13 using namespace std;
14 14
15 /** 15 /**
16 * The factory class. Does the job similar to that which is done by make 16 * The factory class. Does the job similar to that which is done by make
17 * utility. 17 * utility.
18 */ 18 */
19 class file_factory { 19 class file_factory {
20 public: 20 public:
21 /** 21 /**
22 * The recursion depth. 22 * The recursion depth.
23 */ 23 */
24 int depth; 24 int depth;
25 /** 25 /**
26 * The list of files type. The list of strings, in fact. 26 * The list of files type. The list of strings, in fact.
27 */ 27 */
28 typedef list<string> file_list_t; 28 typedef list<string> file_list_t;
29 29
30 file_factory() 30 file_factory()
31 : depth(0) { } 31 : depth(0) { }
32 32
33 /** 33 /**
34 * Fetch depndencies for the given file. 34 * Fetch depndencies for the given file.
35 * @param dst destination file. 35 * @param dst the destination file.
36 * @param deps where to put dependencies to. 36 * @param deps where to put dependencies to.
37 */ 37 */
38 virtual void get_dependencies(const string& dst,file_list_t& deps) = 0; 38 virtual void get_dependencies(const string& dst,file_list_t& deps) = 0;
39 /** 39 /**
40 * Check if the destination is up to day. 40 * Check if the destination is up to day.
41 * @param the destination file. 41 * @param dst the destination file.
42 * @param deps if the deps pointer is non there, the dependencies 42 * @param deps if the deps pointer is non there, the dependencies
43 * retrieved will be stored there. 43 * retrieved will be stored there.
44 * @return true if yes. 44 * @return true if yes.
45 * @see get_dependencies() 45 * @see get_dependencies()
46 */ 46 */
47 virtual bool is_uptodate(const string& dst,file_list_t* deps=0); 47 virtual bool is_uptodate(const string& dst,file_list_t* deps=0);
48 /** 48 /**
49 * Build the file requested. 49 * Build the file requested.
50 * @param dst the file requested. 50 * @param dst the file requested.
51 */ 51 */
52 virtual void build(const string& dst) = 0; 52 virtual void build(const string& dst) = 0;
53 /** 53 /**
54 * Make the file requested, which means: build it, unless it's 54 * Make the file requested, which means: build it, unless it's
55 * uptodate. 55 * uptodate.
56 * @see is_uptodate() 56 * @see is_uptodate()
57 * @see build() 57 * @see build()
58 */ 58 */
59 virtual void make(const string& dst); 59 virtual void make(const string& dst);
60 }; 60 };
61 61
62} 62}
63 63
64#endif /* __SITECING_FILE_FACTORY_H */ 64#endif /* __SITECING_FILE_FACTORY_H */
diff --git a/include/sitecing/process_manager.h b/include/sitecing/process_manager.h
index 73415d3..921f159 100644
--- a/include/sitecing/process_manager.h
+++ b/include/sitecing/process_manager.h
@@ -1,89 +1,89 @@
1#ifndef __SITECING_PROCESS_MANAGER_H 1#ifndef __SITECING_PROCESS_MANAGER_H
2#define __SITECING_PROCESS_MANAGER_H 2#define __SITECING_PROCESS_MANAGER_H
3 3
4#include <sitecing/scoreboard.h> 4#include <sitecing/scoreboard.h>
5 5
6/** 6/**
7 * @file 7 * @file
8 * @brief the process manager. 8 * @brief the process manager.
9 */ 9 */
10 10
11namespace sitecing { 11namespace sitecing {
12 12
13 /** 13 /**
14 * The process manager. 14 * The process manager.
15 */ 15 */
16 class process_manager { 16 class process_manager {
17 public: 17 public:
18 /** 18 /**
19 * Minimum number of child processes. 19 * Minimum number of child processes.
20 */ 20 */
21 int min_children; 21 int min_children;
22 /** 22 /**
23 * Maxinum number of child processes. 23 * Maxinum number of child processes.
24 */ 24 */
25 int max_children; 25 int max_children;
26 /** 26 /**
27 * Minimum number of spare child processes. 27 * Minimum number of spare child processes.
28 */ 28 */
29 int min_spare_children; 29 int min_spare_children;
30 /** 30 /**
31 * Maxiumum number of spare child processes. 31 * Maxiumum number of spare child processes.
32 */ 32 */
33 int max_spare_children; 33 int max_spare_children;
34 /** 34 /**
35 * The scoreboard. 35 * The scoreboard.
36 */ 36 */
37 scoreboard sboard; 37 scoreboard sboard;
38 /** 38 /**
39 * We're in the process of shutting down. 39 * We're in the process of shutting down.
40 */ 40 */
41 bool finishing; 41 bool finishing;
42 /** 42 /**
43 * @todo TODO: wish I could rememer -- document me. 43 * @todo TODO: wish I could rememer -- document me.
44 */ 44 */
45 bool die_humbly; 45 bool die_humbly;
46 46
47 process_manager(); 47 process_manager();
48 virtual ~process_manager(); 48 virtual ~process_manager();
49 49
50 /** 50 /**
51 * The main loop. 51 * The main loop.
52 */ 52 */
53 void manage(); 53 void manage();
54 54
55 /** 55 /**
56 * The worker function. 56 * The worker function.
57 * @param the slot allocated for the process. 57 * @param slot the slot allocated for the process.
58 */ 58 */
59 virtual void process(int slot) = 0; 59 virtual void process(int slot) = 0;
60 60
61 /** 61 /**
62 * @todo TODO: wish I could remember -- document me. 62 * @todo TODO: wish I could remember -- document me.
63 */ 63 */
64 void manage_children(); 64 void manage_children();
65 /** 65 /**
66 * @todo TODO: wish I could remember -- document me. 66 * @todo TODO: wish I could remember -- document me.
67 */ 67 */
68 bool spawn_children(); 68 bool spawn_children();
69 /** 69 /**
70 * @todo TODO: wish I could remember -- document me. 70 * @todo TODO: wish I could remember -- document me.
71 */ 71 */
72 bool kill_children(); 72 bool kill_children();
73 /** 73 /**
74 * @todo TODO: wish I could remember -- document me. 74 * @todo TODO: wish I could remember -- document me.
75 */ 75 */
76 void spawn_child(); 76 void spawn_child();
77 /** 77 /**
78 * @todo TODO: wish I could remember -- document me. 78 * @todo TODO: wish I could remember -- document me.
79 */ 79 */
80 void wait_for_children(bool hang=false); 80 void wait_for_children(bool hang=false);
81 /** 81 /**
82 * @todo TODO: wish I could remember -- document me. 82 * @todo TODO: wish I could remember -- document me.
83 */ 83 */
84 void collect_dead_souls(bool actively=false); 84 void collect_dead_souls(bool actively=false);
85 }; 85 };
86 86
87} 87}
88 88
89#endif /* __SITECING_PROCESS_MANAGER_H */ 89#endif /* __SITECING_PROCESS_MANAGER_H */
diff --git a/include/sitecing/scoreboard.h b/include/sitecing/scoreboard.h
index 788f881..1371ab1 100644
--- a/include/sitecing/scoreboard.h
+++ b/include/sitecing/scoreboard.h
@@ -1,102 +1,105 @@
1#ifndef __SITECING_SCOREBOARD_H 1#ifndef __SITECING_SCOREBOARD_H
2#define __SITECING_SCOREBOARD_H 2#define __SITECING_SCOREBOARD_H
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5 5
6/** 6/**
7 * @file 7 * @file
8 * @brief the scoreboard manager. 8 * @brief the scoreboard manager.
9 */ 9 */
10 10
11/** 11/**
12 * @def MAX_SITECING_SCOREBOARD_SLOTS 12 * @def MAX_SITECING_SCOREBOARD_SLOTS
13 * The maximum number of slots scoreboard can hold. 13 * The maximum number of slots scoreboard can hold.
14 */ 14 */
15 #define MAX_SITECING_SCOREBOARD_SLOTS512 15 #define MAX_SITECING_SCOREBOARD_SLOTS512
16 16
17namespace sitecing { 17namespace sitecing {
18 18
19 /** 19 /**
20 * The scoreboard slot. 20 * The scoreboard slot.
21 */ 21 */
22 struct scoreboard_slot { 22 struct scoreboard_slot {
23 /** 23 /**
24 * The state enumeration. 24 * The state enumeration.
25 */ 25 */
26 enum _state { 26 enum _state {
27 /** 27 /**
28 * The slot is free. 28 * The slot is free.
29 */ 29 */
30 state_free = 0, 30 state_free = 0,
31 /** 31 /**
32 * The slot is allocated. 32 * The slot is allocated.
33 */ 33 */
34 state_allocated, 34 state_allocated,
35 /** 35 /**
36 * The process is idle. 36 * The process is idle.
37 */ 37 */
38 state_idle, 38 state_idle,
39 /** 39 /**
40 * The process is accepting connection. 40 * The process is accepting connection.
41 */ 41 */
42 state_accept, 42 state_accept,
43 /** 43 /**
44 * The process is processing request. 44 * The process is processing request.
45 */ 45 */
46 state_processing 46 state_processing
47 } state; 47 } state;
48 /**
49 * Process ID
50 */
48 pid_t pid; 51 pid_t pid;
49 }; 52 };
50 53
51 /** 54 /**
52 * The scoreboard manager. 55 * The scoreboard manager.
53 */ 56 */
54 class scoreboard { 57 class scoreboard {
55 /** 58 /**
56 * shared memory id. 59 * shared memory id.
57 */ 60 */
58 int shmid; 61 int shmid;
59 public: 62 public:
60 /** 63 /**
61 * Pointer to the scoreboard slots. 64 * Pointer to the scoreboard slots.
62 */ 65 */
63 scoreboard_slot *slots; 66 scoreboard_slot *slots;
64 67
65 scoreboard(); 68 scoreboard();
66 ~scoreboard(); 69 ~scoreboard();
67 70
68 /** 71 /**
69 * Allocate a scoreboard slot. 72 * Allocate a scoreboard slot.
70 * @return the slot number. 73 * @return the slot number.
71 */ 74 */
72 int allocate_slot(); 75 int allocate_slot();
73 /** 76 /**
74 * Free the slot allocated. 77 * Free the slot allocated.
75 * @param slot the slot number. 78 * @param slot the slot number.
76 */ 79 */
77 void free_slot(int slot); 80 void free_slot(int slot);
78 81
79 /** 82 /**
80 * Get the pointer to the slot. 83 * Get the pointer to the slot.
81 * @param slot the slot number. 84 * @param slot the slot number.
82 * @return the pointer. 85 * @return the pointer.
83 */ 86 */
84 scoreboard_slot *get_slot(int slot); 87 scoreboard_slot *get_slot(int slot);
85 /** 88 /**
86 * Find the slot corresponding to the process ID. 89 * Find the slot corresponding to the process ID.
87 * @param pid the process id. 90 * @param pid the process id.
88 * @return the slot number. 91 * @return the slot number.
89 */ 92 */
90 int get_slot_by_pid(pid_t pid); 93 int get_slot_by_pid(pid_t pid);
91 94
92 /** 95 /**
93 * Count the slots in the particular state. 96 * Count the slots in the particular state.
94 * @param state the state. 97 * @param state the state.
95 * @return the number of slots found. 98 * @return the number of slots found.
96 */ 99 */
97 int count_slots(enum scoreboard_slot::_state state=scoreboard_slot::state_free); 100 int count_slots(enum scoreboard_slot::_state state=scoreboard_slot::state_free);
98 }; 101 };
99 102
100} 103}
101 104
102#endif /* __SITECING_SCOREBOARD_H */ 105#endif /* __SITECING_SCOREBOARD_H */
diff --git a/include/sitecing/sitecing_parser.h b/include/sitecing/sitecing_parser.h
index a8474f3..a53ef22 100644
--- a/include/sitecing/sitecing_parser.h
+++ b/include/sitecing/sitecing_parser.h
@@ -27,129 +27,130 @@ using namespace sitecing;
27 * The component source parser. 27 * The component source parser.
28 */ 28 */
29class sitecing_parser : public sitecing_parserFlexLexer { 29class sitecing_parser : public sitecing_parserFlexLexer {
30 public: 30 public:
31 /** 31 /**
32 * The ancestor class definition. 32 * The ancestor class definition.
33 */ 33 */
34 class ancestor_class { 34 class ancestor_class {
35 public: 35 public:
36 /** 36 /**
37 * The class name. 37 * The class name.
38 */ 38 */
39 string name; 39 string name;
40 /** 40 /**
41 * The source component path. 41 * The source component path.
42 */ 42 */
43 string path; 43 string path;
44 44
45 /** 45 /**
46 * @param n the class name. 46 * @param n the class name.
47 * @param p the component path. 47 * @param p the component path.
48 */ 48 */
49 ancestor_class(const string& n,const string& p) 49 ancestor_class(const string& n,const string& p)
50 : name(n), path(p) { } 50 : name(n), path(p) { }
51 }; 51 };
52 /** 52 /**
53 * The list of ancestor classes. 53 * The list of ancestor classes.
54 */ 54 */
55 typedef list<ancestor_class> ancestor_classes_t; 55 typedef list<ancestor_class> ancestor_classes_t;
56 /** 56 /**
57 * The ancestor classes. 57 * The ancestor classes.
58 */ 58 */
59 ancestor_classes_t ancestor_classes; 59 ancestor_classes_t ancestor_classes;
60 /** 60 /**
61 * The member variable definition. 61 * The member variable definition.
62 */ 62 */
63 class member_variable { 63 class member_variable {
64 public: 64 public:
65 /** 65 /**
66 * The member variable type. 66 * The member variable type.
67 */ 67 */
68 string type; 68 string type;
69 /** 69 /**
70 * The member variable name. 70 * The member variable name.
71 */ 71 */
72 string name; 72 string name;
73 /** 73 /**
74 * The member variable is a component. 74 * The member variable is a component.
75 */ 75 */
76 bool bComponent; 76 bool bComponent;
77 /** 77 /**
78 * The variable initializer. 78 * The variable initializer.
79 */ 79 */
80 string initializer; 80 string initializer;
81 /** 81 /**
82 * @todo TODO: wish I could remember -- document me. 82 * @todo TODO: wish I could remember -- document me.
83 */ 83 */
84 bool bTypeOnly; 84 bool bTypeOnly;
85 85
86 /** 86 /**
87 * @param t type. 87 * @param t type.
88 * @param n name. 88 * @param n name.
89 * @param i initializer. 89 * @param i initializer.
90 * @param bc whether it is a component. 90 * @param bc whether it is a component.
91 * @param bto @todo TODO: @see bTypeOnly. 91 * @param bto document me @todo TODO:
92 * @see bTypeOnly.
92 */ 93 */
93 member_variable(const string& t,const string& n,const string& i,bool bc = false,bool bto = false) 94 member_variable(const string& t,const string& n,const string& i,bool bc = false,bool bto = false)
94 : type(t), name(n), initializer(i), bComponent(bc), bTypeOnly(bto) { } 95 : type(t), name(n), initializer(i), bComponent(bc), bTypeOnly(bto) { }
95 }; 96 };
96 /** 97 /**
97 * The list of member variables. 98 * The list of member variables.
98 */ 99 */
99 typedef list<member_variable> member_variables_t; 100 typedef list<member_variable> member_variables_t;
100 /** 101 /**
101 * Member variables. 102 * Member variables.
102 */ 103 */
103 member_variables_t member_variables; 104 member_variables_t member_variables;
104 /** 105 /**
105 * @todo TODO: wish I could remember the details -- document me. 106 * @todo TODO: wish I could remember the details -- document me.
106 */ 107 */
107 bool have_initializers; 108 bool have_initializers;
108 /** 109 /**
109 * Whether the component has a constructor defined. 110 * Whether the component has a constructor defined.
110 */ 111 */
111 bool have_constructor; 112 bool have_constructor;
112 /** 113 /**
113 * Member function definition. 114 * Member function definition.
114 */ 115 */
115 class member_function { 116 class member_function {
116 public: 117 public:
117 /** 118 /**
118 * Return type. 119 * Return type.
119 */ 120 */
120 string type; 121 string type;
121 /** 122 /**
122 * Function name. 123 * Function name.
123 */ 124 */
124 string name; 125 string name;
125 /** 126 /**
126 * Arguments declaration. 127 * Arguments declaration.
127 */ 128 */
128 string args; 129 string args;
129 /** 130 /**
130 * Function body. 131 * Function body.
131 */ 132 */
132 string body; 133 string body;
133 134
134 /** 135 /**
135 * @param t type. 136 * @param t type.
136 * @param n name. 137 * @param n name.
137 * @param a arguments. 138 * @param a arguments.
138 * @param b body. 139 * @param b body.
139 */ 140 */
140 member_function(const string& t,const string& n,const string& a,const string& b) 141 member_function(const string& t,const string& n,const string& a,const string& b)
141 : type(t), name(n), args(a), body(b) { } 142 : type(t), name(n), args(a), body(b) { }
142 }; 143 };
143 /** 144 /**
144 * The list of member functions. 145 * The list of member functions.
145 */ 146 */
146 typedef list<member_function> member_functions_t; 147 typedef list<member_function> member_functions_t;
147 /** 148 /**
148 * Member functions. 149 * Member functions.
149 */ 150 */
150 member_functions_t member_functions; 151 member_functions_t member_functions;
151 /** 152 /**
152 * Current mode of operation. 153 * Current mode of operation.
153 */ 154 */
154 class modus_operandi { 155 class modus_operandi {
155 public: 156 public:
@@ -160,130 +161,129 @@ class sitecing_parser : public sitecing_parserFlexLexer {
160 /** 161 /**
161 * Building the code. 162 * Building the code.
162 */ 163 */
163 modus_code = 0, 164 modus_code = 0,
164 /** 165 /**
165 * Ready to do the '<<' thing. 166 * Ready to do the '<<' thing.
166 */ 167 */
167 modus_preop, 168 modus_preop,
168 /** 169 /**
169 * Just made a '<<'. 170 * Just made a '<<'.
170 */ 171 */
171 modus_postop, 172 modus_postop,
172 /** 173 /**
173 * Outputting raw output data. 174 * Outputting raw output data.
174 */ 175 */
175 modus_text, 176 modus_text,
176 /** 177 /**
177 * The number of modes. 178 * The number of modes.
178 */ 179 */
179 modi 180 modi
180 }; 181 };
181 /** 182 /**
182 * Processing flags enumeration. 183 * Processing flags enumeration.
183 */ 184 */
184 enum { 185 enum {
185 /** 186 /**
186 * Eat the comments. 187 * Eat the comments.
187 */ 188 */
188 flag_devour_comments = 0x0001, 189 flag_devour_comments = 0x0001,
189 /** 190 /**
190 * Eat whitespace. 191 * Eat whitespace.
191 */ 192 */
192 flag_devour_whitespace = 0x0002 193 flag_devour_whitespace = 0x0002
193 }; 194 };
194 /** 195 /**
195 * The processing mode. 196 * The processing mode.
196 */ 197 */
197 modus_t modus; 198 modus_t modus;
198 /** 199 /**
199 * The processing flags. 200 * The processing flags.
200 */ 201 */
201 int flags; 202 int flags;
202 /** 203 /**
203 * Output being built. 204 * Output being built.
204 */ 205 */
205 string output; 206 string output;
206 /** 207 /**
207 * The type for compound modes. 208 * The type for compound modes.
208 */ 209 */
209 string _type; 210 string _type;
210 /** 211 /**
211 * The last id encountered. 212 * The last id encountered.
212 */ 213 */
213 string _lastid; 214 string _lastid;
214 /** 215 /**
215 * The name for compound modes. 216 * The name for compound modes.
216 */ 217 */
217 string _name; 218 string _name;
218 /** 219 /**
219 * The argument declaration. Obviously for member functions. 220 * The argument declaration. Obviously for member functions.
220 */ 221 */
221 string _args; 222 string _args;
222 223
223 /** 224 /**
224 * @param flags. 225 * @param f processing flags @see flags
225 * @see flags
226 */ 226 */
227 modus_operandi(int f = 0) 227 modus_operandi(int f = 0)
228 : modus(modus_code), flags(f) { } 228 : modus(modus_code), flags(f) { }
229 229
230 /** 230 /**
231 * Change the processing mode. 231 * Change the processing mode.
232 */ 232 */
233 void modify(modus_t m); 233 void modify(modus_t m);
234 234
235 /** 235 /**
236 * See if we're eating up whitespaces. 236 * See if we're eating up whitespaces.
237 */ 237 */
238 bool devour_whitespace() { return flags&flag_devour_whitespace; } 238 bool devour_whitespace() { return flags&flag_devour_whitespace; }
239 /** 239 /**
240 * See if we're eating up the comments. 240 * See if we're eating up the comments.
241 */ 241 */
242 bool devour_comments() { return flags&flag_devour_comments; } 242 bool devour_comments() { return flags&flag_devour_comments; }
243 }; 243 };
244 /** 244 /**
245 * The modes stack type. 245 * The modes stack type.
246 */ 246 */
247 typedef list<modus_operandi> modi_operandi; 247 typedef list<modus_operandi> modi_operandi;
248 /** 248 /**
249 * The modes stack. 249 * The modes stack.
250 */ 250 */
251 modi_operandi modi; 251 modi_operandi modi;
252 /** 252 /**
253 * Input file name. 253 * Input file name.
254 */ 254 */
255 string input_file; 255 string input_file;
256 /** 256 /**
257 * Base class name. 257 * Base class name.
258 */ 258 */
259 string base_class; 259 string base_class;
260 /** 260 /**
261 * Base class header. 261 * Base class header.
262 */ 262 */
263 string base_header; 263 string base_header;
264 /** 264 /**
265 * Component's basename. 265 * Component's basename.
266 * @todo TODO: wish I could remember the details -- document me. 266 * @todo TODO: wish I could remember the details -- document me.
267 */ 267 */
268 string component_basename; 268 string component_basename;
269 /** 269 /**
270 * The skeleton file name. 270 * The skeleton file name.
271 */ 271 */
272 string skeleton; 272 string skeleton;
273 /** 273 /**
274 * The component class name. 274 * The component class name.
275 */ 275 */
276 string class_name; 276 string class_name;
277 /** 277 /**
278 * Output basename. 278 * Output basename.
279 * @todo TODO: wish I could remember the details -- document me. 279 * @todo TODO: wish I could remember the details -- document me.
280 */ 280 */
281 string output_basename; 281 string output_basename;
282 /** 282 /**
283 * Verbatim declaration part. 283 * Verbatim declaration part.
284 */ 284 */
285 string decl; 285 string decl;
286 /** 286 /**
287 * Verbatim implementation part. 287 * Verbatim implementation part.
288 */ 288 */
289 string impl; 289 string impl;
diff --git a/include/sitecing/sitecing_util.h b/include/sitecing/sitecing_util.h
index f642c74..233292c 100644
--- a/include/sitecing/sitecing_util.h
+++ b/include/sitecing/sitecing_util.h
@@ -1,110 +1,134 @@
1#ifndef __SITECING_SITECING_UTIL_H 1#ifndef __SITECING_SITECING_UTIL_H
2#define __SITECING_SITECING_UTIL_H 2#define __SITECING_SITECING_UTIL_H
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#include <string> 5#include <string>
6#include <konforka/exception.h> 6#include <konforka/exception.h>
7#include <konforka/util.h> 7#include <konforka/util.h>
8 8
9/** 9/**
10 * @file 10 * @file
11 * @brief utility classes and functions. 11 * @brief utility classes and functions.
12 */ 12 */
13 13
14namespace sitecing { 14namespace sitecing {
15 using namespace std; 15 using namespace std;
16 16
17 /** 17 /**
18 * Base class for utility exceptions. 18 * Base class for utility exceptions.
19 */ 19 */
20 class utility_error : public konforka::exception { 20 class utility_error : public konforka::exception {
21 public: 21 public:
22 /**
23 * @param fi file name
24 * @param fu function name
25 * @param l line number
26 * @param w what
27 */
22 utility_error(const string& fi,const string& fu,int l,const string& w) 28 utility_error(const string& fi,const string& fu,int l,const string& w)
23 : konforka::exception(fi,fu,l,w) { } 29 : konforka::exception(fi,fu,l,w) { }
24 }; 30 };
25 31
26 /** 32 /**
27 * No prefix or suffix found to strip out. 33 * No prefix or suffix found to strip out.
28 */ 34 */
29 class utility_no_affix : public utility_error { 35 class utility_no_affix : public utility_error {
30 public: 36 public:
37 /**
38 * @param fi file name
39 * @param fu function name
40 * @param l line number
41 * @param w what
42 */
31 utility_no_affix(const string& fi,const string& fu,int l,const string& w) 43 utility_no_affix(const string& fi,const string& fu,int l,const string& w)
32 : utility_error(fi,fu,l,w) { } 44 : utility_error(fi,fu,l,w) { }
33 }; 45 };
34 /** 46 /**
35 * No prefix to strip found. 47 * No prefix to strip found.
36 */ 48 */
37 class utility_no_prefix : public utility_no_affix { 49 class utility_no_prefix : public utility_no_affix {
38 public: 50 public:
51 /**
52 * @param fi file name
53 * @param fu function name
54 * @param l line number
55 * @param w what
56 */
39 utility_no_prefix(const string& fi,const string& fu,int l,const string& w) 57 utility_no_prefix(const string& fi,const string& fu,int l,const string& w)
40 : utility_no_affix(fi,fu,l,w) { } 58 : utility_no_affix(fi,fu,l,w) { }
41 }; 59 };
42 /** 60 /**
43 * No suffix to strip found. 61 * No suffix to strip found.
44 */ 62 */
45 class utility_no_suffix : public utility_no_affix { 63 class utility_no_suffix : public utility_no_affix {
46 public: 64 public:
65 /**
66 * @param fi file name
67 * @param fu function name
68 * @param l line number
69 * @param w what
70 */
47 utility_no_suffix(const string& fi,const string& fu,int l,const string& w) 71 utility_no_suffix(const string& fi,const string& fu,int l,const string& w)
48 : utility_no_affix(fi,fu,l,w) { } 72 : utility_no_affix(fi,fu,l,w) { }
49 }; 73 };
50 74
51 /** 75 /**
52 * The file lock object. Released at the object destruction. 76 * The file lock object. Released at the object destruction.
53 */ 77 */
54 class file_lock { 78 class file_lock {
55 public: 79 public:
56 /** 80 /**
57 * The file descriptor. 81 * The file descriptor.
58 */ 82 */
59 int fd; 83 int fd;
60 84
61 file_lock() 85 file_lock()
62 : fd(-1) { } 86 : fd(-1) { }
63 /** 87 /**
64 * @param f file name. 88 * @param f file name.
65 */ 89 */
66 file_lock(const string& f) 90 file_lock(const string& f)
67 : fd(-1) { lock(f); } 91 : fd(-1) { lock(f); }
68 ~file_lock() { unlock(); } 92 ~file_lock() { unlock(); }
69 93
70 /** 94 /**
71 * Do lock. 95 * Do lock.
72 * @param f file name. 96 * @param f file name.
73 */ 97 */
74 void lock(const string& f); 98 void lock(const string& f);
75 /** 99 /**
76 * @todo TODO: wish I could remember the details -- document me. 100 * @todo TODO: wish I could remember the details -- document me.
77 */ 101 */
78 void lock(); 102 void lock();
79 /** 103 /**
80 * Release the lock obtained. 104 * Release the lock obtained.
81 */ 105 */
82 void unlock(); 106 void unlock();
83 }; 107 };
84 108
85 /** 109 /**
86 * The pid file. Removed at object destruction. 110 * The pid file. Removed at object destruction.
87 */ 111 */
88 class pid_file { 112 class pid_file {
89 public: 113 public:
90 /** 114 /**
91 * The file name. 115 * The file name.
92 */ 116 */
93 string file_name; 117 string file_name;
94 /** 118 /**
95 * Do we unlink the file after we're done? 119 * Do we unlink the file after we're done?
96 */ 120 */
97 bool unlink_pid; 121 bool unlink_pid;
98 122
99 pid_file() 123 pid_file()
100 : unlink_pid(false) { } 124 : unlink_pid(false) { }
101 ~pid_file() { unlink(); } 125 ~pid_file() { unlink(); }
102 126
103 /** 127 /**
104 * @param f file name. 128 * @param f file name.
105 * @param u whether we want to unlink the file. 129 * @param u whether we want to unlink the file.
106 */ 130 */
107 void set(const string& f,bool u=true); 131 void set(const string& f,bool u=true);
108 /** 132 /**
109 * Unlink the file if we wanted to in the first place. 133 * Unlink the file if we wanted to in the first place.
110 */ 134 */
diff --git a/include/sitecing/util.h b/include/sitecing/util.h
index 5750ab6..a38ae90 100644
--- a/include/sitecing/util.h
+++ b/include/sitecing/util.h
@@ -1,97 +1,97 @@
1#ifndef __SITECING_UTIL_H 1#ifndef __SITECING_UTIL_H
2#define __SITECING_UTIL_H 2#define __SITECING_UTIL_H
3 3
4#include <ostream> 4#include <ostream>
5#include <string> 5#include <string>
6#include "sitecing/acomponent.h" 6#include "sitecing/acomponent.h"
7 7
8/** 8/**
9 * @file 9 * @file
10 * @brief more or less non-internal utility classes and functions. 10 * @brief more or less non-internal utility classes and functions.
11 */ 11 */
12 12
13namespace sitecing { 13namespace sitecing {
14 using namespace std; 14 using namespace std;
15 15
16 /** 16 /**
17 * the html_escape options enumeration. 17 * the html_escape options enumeration.
18 */ 18 */
19 enum html_escape_options { 19 enum html_escape_options {
20 /** 20 /**
21 * Turn spaces into &nbsp; 21 * Turn spaces into &nbsp;
22 */ 22 */
23 html_escape_nbsp = 0x0001, 23 html_escape_nbsp = 0x0001,
24 /** 24 /**
25 * Turn newlines into <br/> or <br>. 25 * Turn newlines into br/ or br.
26 */ 26 */
27 html_escape_br = 0x0002, 27 html_escape_br = 0x0002,
28 /** 28 /**
29 * Turn quotes to &quot; 29 * Turn quotes to &quot;
30 */ 30 */
31 html_escape_quot = 0x0004, 31 html_escape_quot = 0x0004,
32 /** 32 /**
33 * Do not put '/' into <br/> consruct. 33 * Do not put '/' into br consruct.
34 */ 34 */
35 html_escape_br_noslash = 0x0008 35 html_escape_br_noslash = 0x0008
36 }; 36 };
37 /** 37 /**
38 * Escape string suitable for html output. 38 * Escape string suitable for html output.
39 * @param str the string. 39 * @param str the string.
40 * @param flags options. 40 * @param flags options.
41 * @return the string escaped. 41 * @return the string escaped.
42 * @see html_escape_options 42 * @see html_escape_options
43 */ 43 */
44 string html_escape(const string& str,int flags=html_escape_br); 44 string html_escape(const string& str,int flags=html_escape_br);
45 45
46 /** 46 /**
47 * The output string checkpoint object, letting one to rollback output. 47 * The output string checkpoint object, letting one to rollback output.
48 */ 48 */
49 class checkpoint { 49 class checkpoint {
50 public: 50 public:
51 /** 51 /**
52 * The object's death will enumeration. 52 * The object's death will enumeration.
53 */ 53 */
54 enum will_t { 54 enum will_t {
55 /** 55 /**
56 * The stream is to be rolled back at object destruction. 56 * The stream is to be rolled back at object destruction.
57 */ 57 */
58 will_rollback, 58 will_rollback,
59 /** 59 /**
60 * The stream is not to be rolled back at object destruction. 60 * The stream is not to be rolled back at object destruction.
61 */ 61 */
62 will_commit, 62 will_commit,
63 /** 63 /**
64 * The object will die intestate. What's the point then? 64 * The object will die intestate. What's the point then?
65 */ 65 */
66 will_intestate 66 will_intestate
67 }; 67 };
68 /** 68 /**
69 * The output stream in question. 69 * The output stream in question.
70 */ 70 */
71 ostream* stream; 71 ostream* stream;
72 /** 72 /**
73 * The point at which objhect was created. 73 * The point at which objhect was created.
74 */ 74 */
75 ostream::pos_type point; 75 ostream::pos_type point;
76 /** 76 /**
77 * The last will. 77 * The last will.
78 */ 78 */
79 will_t last_will; 79 will_t last_will;
80 80
81 /** 81 /**
82 * @param s reference to the stream. 82 * @param s reference to the stream.
83 * @param lw the last will. 83 * @param lw the last will.
84 */ 84 */
85 checkpoint(ostream& s, will_t lw=will_rollback) 85 checkpoint(ostream& s, will_t lw=will_rollback)
86 : stream(&s), last_will(lw) { set(); } 86 : stream(&s), last_will(lw) { set(); }
87 /** 87 /**
88 * @param s pointer to the stream. 88 * @param s pointer to the stream.
89 * @param lw the last will. 89 * @param lw the last will.
90 */ 90 */
91 checkpoint(ostream* s, will_t lw=will_rollback) 91 checkpoint(ostream* s, will_t lw=will_rollback)
92 : stream(s), last_will(lw) { set(); } 92 : stream(s), last_will(lw) { set(); }
93 /** 93 /**
94 * @param s reference to the sitecing interface where to get output 94 * @param s reference to the sitecing interface where to get output
95 * stream from. 95 * stream from.
96 * @param lw the last will. 96 * @param lw the last will.
97 */ 97 */