diff options
author | Felix Burton | 2013-05-10 18:41:59 +0000 |
---|---|---|
committer | Felix Burton | 2013-05-10 18:41:59 +0000 |
commit | 28d99a19fc1866ce0c04263f74cd02605b48e5ad (patch) | |
tree | 78dfae98376d37e7ccae14466f887d0872987a39 | |
parent | 765555a4d999dadd8b8dcc9188623ba723c06a2e (diff) | |
download | org.eclipse.tcf.agent-28d99a19fc1866ce0c04263f74cd02605b48e5ad.tar.gz org.eclipse.tcf.agent-28d99a19fc1866ce0c04263f74cd02605b48e5ad.tar.xz org.eclipse.tcf.agent-28d99a19fc1866ce0c04263f74cd02605b48e5ad.zip |
Add hooks to main.c to allow extensions without coping/merging
-rw-r--r-- | agent/tcf/main/main.c | 35 | ||||
-rw-r--r-- | agent/tcf/main/main_hooks.h | 19 |
2 files changed, 54 insertions, 0 deletions
diff --git a/agent/tcf/main/main.c b/agent/tcf/main/main.c index 45b3680b..d17cc579 100644 --- a/agent/tcf/main/main.c +++ b/agent/tcf/main/main.c @@ -37,6 +37,7 @@ #include <tcf/main/cmdline.h> #include <tcf/main/services.h> #include <tcf/main/server.h> +#include <tcf/main/main_hooks.h> #ifndef ENABLE_SignalHandlers # define ENABLE_SignalHandlers 1 @@ -46,6 +47,35 @@ # define DEFAULT_SERVER_URL "TCP:" #endif +/* Hook before all TCF initialization. This hook can add local variables. */ +#ifndef PRE_INIT_HOOK +#define PRE_INIT_HOOK do {} while(0) +#endif + +/* Hook before any TCF threads are created. This hook can do + * initialization that will affect all threads and call most basic TCF + * functions, like post_event. */ +#ifndef PRE_THREADING_HOOK +#define PRE_THREADING_HOOK do {} while(0) +#endif + +/* Hook before becoming a daemon process. This hook can output + * banners and other information. */ +#ifndef PRE_DAEMON_HOOK +#define PRE_DAEMON_HOOK do {} while(0) +#endif + +/* 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 + static const char * progname; static unsigned int idle_timeout; static unsigned int idle_count; @@ -140,6 +170,7 @@ static const char * help_text[] = { #if ENABLE_SSL " -c generate SSL certificate and exit", #endif + HELP_TEXT_HOOK NULL }; @@ -178,10 +209,12 @@ int main(int argc, char ** argv) { Protocol * proto; TCFBroadcastGroup * bcg; + PRE_INIT_HOOK; ini_mdep(); ini_trace(); ini_events_queue(); ini_asyncreq(); + PRE_THREADING_HOOK; #if defined(_WRS_KERNEL) @@ -280,6 +313,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); @@ -337,6 +371,7 @@ int main(int argc, char ** argv) { loc_free(server_properties); } + PRE_DAEMON_HOOK; if (daemon) close_out_and_err(); diff --git a/agent/tcf/main/main_hooks.h b/agent/tcf/main/main_hooks.h new file mode 100644 index 00000000..2df597dd --- /dev/null +++ b/agent/tcf/main/main_hooks.h @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2013 Xilinx, 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: + * Xilinx - initial API and implementation + *******************************************************************************/ + +/* + * Hook definitions for main.c. This file is intended to be empty. + * Default hook definitions are intended to be defined in main.c + */ |