5 /* Copyright (c) 2004 Martin Quinson. All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #include "xbt/sysdep.h"
12 #include "xbt/error.h"
13 #include "xbt/dynar.h"
14 #include "xbt/config.h"
16 #include "gras/process.h" /* FIXME: bad loop */
18 #include "xbt/module.h" /* this module */
20 #include "xbt_modinter.h" /* prototype of other module's init/exit in XBT */
21 #include "gras_modinter.h" /* same in GRAS */
23 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module,xbt, "module handling");
25 static int xbt_running_process = 0;
31 xbt_module_new_fct_t new;
32 xbt_module_finalize_fct_t finalize;
36 xbt_init(int *argc, char **argv) {
37 static short int first_run = 1;
39 xbt_init_defaultlog(argc, argv, NULL);
44 * xbt_init_defaultlog:
48 * Initialize the gras mecanisms.
51 xbt_init_defaultlog(int *argc,char **argv, const char *defaultlog) {
56 INFO0("Initialize GRAS");
58 /** Set logs and init log submodule */
59 for (i=1; i<*argc; i++) {
60 if (!strncmp(argv[i],"--gras-log=",strlen("--gras-log="))) {
62 opt=strchr(argv[i],'=');
64 xbt_log_control_set(opt);
65 DEBUG1("Did apply '%s' as log setting",opt);
66 /*remove this from argv*/
67 for (j=i+1; j<*argc; j++) {
72 i--; /* compensate effect of next loop incrementation */
75 if (!found && defaultlog) {
76 xbt_log_control_set(defaultlog);
79 gras_process_init(); /* calls procdata_init, which calls dynar_new */
80 /** init other submodules */
81 if (xbt_running_process++ == 0) {
91 * Finalize the gras mecanisms.
95 INFO0("Exiting GRAS");
97 if (--xbt_running_process == 0) {
100 gras_datadesc_exit();
103 DEBUG0("Exited GRAS");