Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Burton2014-01-06 17:41:45 -0500
committerFelix Burton2014-01-06 17:41:45 -0500
commitec92dde6cc672902c0e36667e85c8a4b3c3eb91d (patch)
tree5875c189d594132c1161aaf72612f68513041196
parentf662fabf1f6dfd5928560f1cccf4a21ff3af4b45 (diff)
downloadorg.eclipse.tcf.agent-ec92dde6cc672902c0e36667e85c8a4b3c3eb91d.tar.gz
org.eclipse.tcf.agent-ec92dde6cc672902c0e36667e85c8a4b3c3eb91d.tar.xz
org.eclipse.tcf.agent-ec92dde6cc672902c0e36667e85c8a4b3c3eb91d.zip
Add more hooks
This change is a subset of contribution https://bugs.eclipse.org/bugs/show_bug.cgi?id=424841
-rw-r--r--agent/tcf/main/main.c10
-rw-r--r--agent/tcf/main/main_log.c22
-rw-r--r--server/tcf/main/server.c20
3 files changed, 48 insertions, 4 deletions
diff --git a/agent/tcf/main/main.c b/agent/tcf/main/main.c
index 4b6aceed..5d6f8948 100644
--- a/agent/tcf/main/main.c
+++ b/agent/tcf/main/main.c
@@ -87,6 +87,13 @@
#define POST_OPTION_HOOK do {} while(0)
#endif
+/* Hook for USAGE string */
+#ifndef USAGE_STRING_HOOK
+#define USAGE_STRING_HOOK \
+ "Usage: agent [OPTION]...", \
+ "Start Target Communication Framework agent."
+#endif
+
static const char * progname;
static unsigned int idle_timeout;
static unsigned int idle_count;
@@ -161,8 +168,7 @@ static BOOL CtrlHandler(DWORD ctrl) {
#if !defined(_WRS_KERNEL)
static const char * help_text[] = {
- "Usage: agent [OPTION]...",
- "Start Target Communication Framework agent.",
+ USAGE_STRING_HOOK,
" -d run in daemon mode (output is sent to system logger)",
#if ENABLE_Cmdline
" -i run in interactive mode",
diff --git a/agent/tcf/main/main_log.c b/agent/tcf/main/main_log.c
index 84a047b8..87c6bc14 100644
--- a/agent/tcf/main/main_log.c
+++ b/agent/tcf/main/main_log.c
@@ -16,7 +16,7 @@
/*
* TCF Logger main module.
*
- * TCF Logger is a simple TCF agent that des not provide any services itself,
+ * TCF Logger is a simple TCF agent that does not provide any services itself,
* instead it forward all TCF traffic to another agent.
* Logger prints all messages it forwards.
* It can be used as diagnostic and debugging tool.
@@ -37,10 +37,27 @@
#include <tcf/framework/proxy.h>
#include <tcf/framework/errors.h>
#include <tcf/services/discovery.h>
+#include <tcf/main/main_hooks.h>
static const char * progname;
static const char * dest_url = "TCP::1534";
+/* Hook to add help text. */
+#ifndef HELP_TEXT_HOOK
+#define HELP_TEXT_HOOK
+#endif
+
+/* Hook for illegal option case. This hook allows for handling off
+ * additional options. */
+#ifndef ILLEGAL_OPTION_HOOK
+#define ILLEGAL_OPTION_HOOK do {} while(0)
+#endif
+
+/* Hook for adding properties */
+#ifndef SERVER_ADDPROP_HOOK
+#define SERVER_ADDPROP_HOOK do {} while(0)
+#endif
+
typedef struct ConnectInfo {
PeerServer * ps;
Channel * c1;
@@ -278,6 +295,7 @@ static const char * help_text[] = {
" -fo,E,Locator,peerRemoved",
" -fo,E,Locator,peerChanged",
" -fo,C,Locator,getPeers",
+ HELP_TEXT_HOOK
NULL
};
@@ -392,6 +410,7 @@ int main(int argc, char ** argv) {
break;
default:
+ ILLEGAL_OPTION_HOOK;
fprintf(stderr, "%s: error: illegal option '%c'\n", progname, c);
show_help();
exit(1);
@@ -421,6 +440,7 @@ int main(int argc, char ** argv) {
}
peer_server_addprop(ps, loc_strdup("Name"), loc_strdup("TCF Protocol Logger"));
peer_server_addprop(ps, loc_strdup("Proxy"), loc_strdup(""));
+ SERVER_ADDPROP_HOOK;
serv = channel_server(ps);
if (serv == NULL) {
fprintf(stderr, "%s: cannot create TCF server: %s\n", progname, errno_to_str(errno));
diff --git a/server/tcf/main/server.c b/server/tcf/main/server.c
index 15d8b8bc..5e90c301 100644
--- a/server/tcf/main/server.c
+++ b/server/tcf/main/server.c
@@ -38,6 +38,15 @@
#define TARGET_SERVICE_CHECK_HOOK do {} while(0)
#endif
+/* Hook for adding properties */
+#ifndef SERVER_ADDPROP_HOOK
+#define SERVER_ADDPROP_HOOK do {} while(0)
+#endif
+
+#ifndef PROXY_NAME
+#define PROXY_NAME "TCF Proxy"
+#endif
+
static Protocol * proto;
static TCFBroadcastGroup * bcg;
@@ -66,7 +75,10 @@ static void channel_redirection_listener(Channel * host, Channel * target) {
#if defined(SERVICE_Disassembly) && SERVICE_Disassembly
int service_da = 0;
#endif
+#if defined(ENABLE_DebugContext) && ENABLE_DebugContext \
+ && defined(ENABLE_ContextProxy) && ENABLE_ContextProxy
int forward_pm = 0;
+#endif
for (i = 0; i < target->peer_service_cnt; i++) {
char * nm = target->peer_service_list[i];
if (strcmp(nm, "LineNumbers") == 0) service_ln = 1;
@@ -79,8 +91,13 @@ static void channel_redirection_listener(Channel * host, Channel * target) {
TARGET_SERVICE_CHECK_HOOK;
}
if (!service_pm || !service_ln || !service_sm) {
+#if SERVICE_PathMap
ini_path_map_service(host->protocol, bcg);
+#endif
+#if defined(ENABLE_DebugContext) && ENABLE_DebugContext \
+ && defined(ENABLE_ContextProxy) && ENABLE_ContextProxy
if (service_pm) forward_pm = 1;
+#endif
}
if (service_mm) {
#if defined(SERVICE_LineNumbers) && SERVICE_LineNumbers
@@ -117,8 +134,9 @@ int ini_server(const char * url, Protocol * p, TCFBroadcastGroup * 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("Name"), loc_strdup("TCF Proxy"));
+ peer_server_addprop(ps, loc_strdup("Name"), loc_strdup(PROXY_NAME));
peer_server_addprop(ps, loc_strdup("Proxy"), loc_strdup(""));
+ SERVER_ADDPROP_HOOK;
serv = channel_server(ps);
if (serv == NULL) exception(errno);
serv->new_conn = channel_new_connection;

Back to the top