Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'main/server.c')
-rw-r--r--main/server.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/main/server.c b/main/server.c
index 91eed512..247d4e5f 100644
--- a/main/server.c
+++ b/main/server.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -18,9 +18,8 @@
#include <config.h>
-#include <stdio.h>
-#include <framework/errors.h>
#include <framework/myalloc.h>
+#include <framework/exceptions.h>
#include <main/server.h>
static Protocol * proto;
@@ -33,23 +32,28 @@ static void channel_new_connection(ChannelServer * serv, Channel * c) {
channel_start(c);
}
-void ini_server(const char * url, Protocol * p, TCFBroadcastGroup * b) {
+int ini_server(const char * url, Protocol * p, TCFBroadcastGroup * b) {
ChannelServer * serv = NULL;
- PeerServer * ps = channel_peer_from_url(url);
-
- if (ps == NULL) {
- fprintf(stderr, "Invalid server URL (-s option value): %s\n", url);
- exit(1);
+ PeerServer * ps = NULL;
+ Trap trap;
+
+ if (!set_trap(&trap)) {
+ bcg = NULL;
+ proto = NULL;
+ if (ps != NULL) peer_server_free(ps);
+ errno = trap.error;
+ return -1;
}
- peer_server_addprop(ps, loc_strdup("ServerManagerID"), loc_strdup(get_service_manager_id(p)));
-
- proto = p;
bcg = b;
+ proto = p;
+ ps = channel_peer_from_url(url);
+ if (ps == NULL) str_exception(ERR_OTHER, "Invalid server URL");
+ peer_server_addprop(ps, loc_strdup("ServerManagerID"), loc_strdup(get_service_manager_id(p)));
serv = channel_server(ps);
- if (serv == NULL) {
- fprintf(stderr, "Cannot create TCF server: %s\n", errno_to_str(errno));
- exit(1);
- }
+ if (serv == NULL) exception(errno);
serv->new_conn = channel_new_connection;
+
+ clear_trap(&trap);
+ return 0;
}

Back to the top