Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2011-11-10 20:19:02 -0500
committerEugene Tarassov2011-11-10 20:19:02 -0500
commita107edc216f94c5ec059fdf74541908bc7e979bb (patch)
treea0d9a448043cf5b969c2ede059b7d19a3aa64b71 /agent/tcf/main/main_reg.c
parent07c7a005cded9e4b4ec842d756d0e4d79dade149 (diff)
downloadorg.eclipse.tcf.agent-a107edc216f94c5ec059fdf74541908bc7e979bb.tar.gz
org.eclipse.tcf.agent-a107edc216f94c5ec059fdf74541908bc7e979bb.tar.xz
org.eclipse.tcf.agent-a107edc216f94c5ec059fdf74541908bc7e979bb.zip
Agent code is moved into separate "agent" directory, all C code moved into "tcf" directory.
Diffstat (limited to 'agent/tcf/main/main_reg.c')
-rw-r--r--agent/tcf/main/main_reg.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/agent/tcf/main/main_reg.c b/agent/tcf/main/main_reg.c
new file mode 100644
index 00000000..78672977
--- /dev/null
+++ b/agent/tcf/main/main_reg.c
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * 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.
+ * You may elect to redistribute this code under either of these licenses.
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+/*
+ * TCF Registry main module.
+ * TCF Registry is dumbed down version of TCF Agent that provides no services.
+ * All it does is running TCF UDP auto-discovery protocol.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <assert.h>
+#include <framework/asyncreq.h>
+#include <framework/events.h>
+#include <framework/trace.h>
+#include <framework/channel.h>
+#include <framework/protocol.h>
+#include <framework/proxy.h>
+#include <services/discovery.h>
+
+static const char * progname;
+
+#if defined(_WRS_KERNEL)
+int tcf_registry(void) {
+#else
+int main(int argc, char **argv) {
+#endif
+ int c;
+ int ind;
+ const char * log_name = NULL;
+
+ ini_mdep();
+ ini_trace();
+ ini_events_queue();
+ ini_asyncreq();
+
+#if defined(_WRS_KERNEL)
+
+ progname = "tcf";
+ open_log_file("-");
+ log_mode = 0;
+
+#else
+
+ progname = argv[0];
+
+ /* Parse arguments */
+ for (ind = 1; ind < argc; ind++) {
+ const char * s = argv[ind];
+ if (*s != '-') {
+ break;
+ }
+ s++;
+ while ((c = *s++) != '\0') {
+ switch (c) {
+ case 'l':
+ case 'L':
+ if (*s == '\0') {
+ if (++ind >= argc) {
+ fprintf(stderr, "%s: error: no argument given to option '%c'\n", progname, c);
+ exit(1);
+ }
+ s = argv[ind];
+ }
+ switch (c) {
+ case 'l':
+ log_mode = strtol(s, 0, 0);
+ break;
+
+ case 'L':
+ log_name = s;
+ break;
+
+ default:
+ fprintf(stderr, "%s: error: illegal option '%c'\n", progname, c);
+ exit(1);
+ }
+ s = "";
+ break;
+
+ default:
+ fprintf(stderr, "%s: error: illegal option '%c'\n", progname, c);
+ exit(1);
+ }
+ }
+ }
+
+ open_log_file(log_name);
+
+#endif
+
+ discovery_start();
+
+ /* Process events - must run on the initial thread since ptrace()
+ * returns ECHILD otherwise, thinking we are not the owner. */
+ run_event_loop();
+ return 0;
+}

Back to the top