Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2010-05-05 15:00:28 -0400
committereutarass2010-05-05 15:00:28 -0400
commit5ed8f82e33bd1753b9bc8aec925242e895707521 (patch)
treedf010a1822a5004be4cfd22128e0909ed926686a /main/server.c
parente65167f5a7e234b5eac8145ec233895f8bcf8b72 (diff)
downloadorg.eclipse.tcf.agent-5ed8f82e33bd1753b9bc8aec925242e895707521.tar.gz
org.eclipse.tcf.agent-5ed8f82e33bd1753b9bc8aec925242e895707521.tar.xz
org.eclipse.tcf.agent-5ed8f82e33bd1753b9bc8aec925242e895707521.zip
Bug 311420: Move CONFIG_MAIN into main.c:
1. Service initialization code moved from config.h into separate file: main/services.c 2. Server initialization code moved from main.c into separate file: main/server.c 3. Created file main/services-ext.h to allow user extensions of services initialization code.
Diffstat (limited to 'main/server.c')
-rw-r--r--main/server.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/main/server.c b/main/server.c
new file mode 100644
index 00000000..97a5c9b2
--- /dev/null
+++ b/main/server.c
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 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.
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+/*
+ * Server initialization code.
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include "errors.h"
+#include "server.h"
+
+static Protocol * proto;
+static TCFBroadcastGroup * bcg;
+
+static void channel_new_connection(ChannelServer * serv, Channel * c) {
+ protocol_reference(proto);
+ c->protocol = proto;
+ channel_set_broadcast_group(c, bcg);
+ channel_start(c);
+}
+
+void 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);
+ }
+ proto = p;
+ bcg = b;
+ serv = channel_server(ps);
+ if (serv == NULL) {
+ fprintf(stderr, "Cannot create TCF server: %s\n", errno_to_str(errno));
+ exit(1);
+ }
+ serv->new_conn = channel_new_connection;
+}

Back to the top