summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ConfigParser.m12
-rw-r--r--ObjWebServer.m10
-rw-r--r--StaticModule.m8
3 files changed, 18 insertions, 12 deletions
diff --git a/ConfigParser.m b/ConfigParser.m
index 93595fc..ebd3143 100644
--- a/ConfigParser.m
+++ b/ConfigParser.m
@@ -53,13 +53,19 @@
self = [super init];
@try {
+ void *pool = objc_autoreleasePoolPush();
+ OFFile *configFile = [OFFile fileWithPath: configPath
+ mode: @"r"];
+
OFXMLElement *config = [[OFXMLElement alloc]
- initWithFile: configPath];
+ initWithStream: configFile];
@try {
[self _parseConfig: config];
} @finally {
[config release];
}
+
+ objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
@@ -112,7 +118,7 @@
listenConfig.host = host;
@try {
- intmax_t port = portString.decimalValue;
+ long long port = portString.longLongValue;
if (port < 0 || port > 65535)
@throw [OFInvalidFormatException exception];
@@ -169,7 +175,7 @@
- (void)_invalidConfig: (OFString *)message
{
- [of_stderr writeFormat: @"Error parsing config: %@", message];
+ [OFStdErr writeFormat: @"Error parsing config: %@", message];
[OFApplication terminateWithStatus: 1];
}
@end
diff --git a/ObjWebServer.m b/ObjWebServer.m
index 4492054..db3fbd5 100644
--- a/ObjWebServer.m
+++ b/ObjWebServer.m
@@ -70,9 +70,9 @@ OF_APPLICATION_DELEGATE(ObjWebServer)
{
OFPlugin <Module> *module;
- of_log(@"Loading module at %@", path);
+ OFLog(@"Loading module at %@", path);
- module = [OFPlugin pluginFromFile: path];
+ module = [OFPlugin pluginWithPath: path];
[module parseConfig: config];
return module;
@@ -94,7 +94,7 @@ OF_APPLICATION_DELEGATE(ObjWebServer)
server.numberOfThreads = [OFSystemInfo numberOfCPUs] + 1;
server.delegate = self;
- of_log(@"Starting server on host %@ port %" PRIu16,
+ OFLog(@"Starting server on host %@ port %" PRIu16,
listenConfig.host, listenConfig.port);
[server start];
@@ -107,7 +107,7 @@ OF_APPLICATION_DELEGATE(ObjWebServer)
{
OFString *path = request.URL.path;
- of_log(@"Request: %@", request);
+ OFLog(@"Request: %@", request);
for (OFPair OF_GENERIC(OFString *, id <Module>) *module in _modules)
if ([path hasPrefix: module.firstObject])
@@ -120,7 +120,7 @@ OF_APPLICATION_DELEGATE(ObjWebServer)
- (bool)server: (OFHTTPServer *)server
didReceiveExceptionOnListeningSocket: (id)exception
{
- of_log(@"Exception on listening socket: %@", exception);
+ OFLog(@"Exception on listening socket: %@", exception);
return true;
}
diff --git a/StaticModule.m b/StaticModule.m
index 067781f..4bed351 100644
--- a/StaticModule.m
+++ b/StaticModule.m
@@ -97,7 +97,7 @@ readData(OFStream *stream)
_root = [[config elementForName: @"root"].stringValue copy];
if (_root == nil) {
- [of_stderr writeString:
+ [OFStdErr writeString:
@"Error parsing config: No <root/> element!"];
[OFApplication terminateWithStatus: 1];
}
@@ -110,13 +110,13 @@ readData(OFStream *stream)
[MIMEType attributeForName: @"type"].stringValue;
if (extension == nil) {
- [of_stderr writeString:
+ [OFStdErr writeString:
@"Error parsing config: "
@"<mime-type/> has no extension attribute!"];
[OFApplication terminateWithStatus: 1];
}
if (type == nil) {
- [of_stderr writeString:
+ [OFStdErr writeString:
@"Error parsing config: "
@"<mime-type/> has no type attribute!"];
[OFApplication terminateWithStatus: 1];
@@ -189,7 +189,7 @@ readData(OFStream *stream)
@end
StaticModule *
-init_plugin(void)
+OFPluginInit(void)
{
return [[[StaticModule alloc] init] autorelease];
}