5 /* Authors: Martin Quinson */
6 /* Copyright (C) 2003 the OURAGAN project. */
8 /* This program is free software; you can redistribute it and/or modify it
9 under the terms of the license (GNU LGPL) which comes with this package. */
11 #include "xbt/sysdep.h"
13 #include "xbt/error.h"
14 #include "xbt/dynar.h"
15 #include "xbt/config.h"
17 #include "gras/process.h" /* FIXME: bad loop */
19 #include "xbt/module.h" /* this module */
21 #include "xbt_modinter.h" /* prototype of other module's init/exit in XBT */
22 #include "gras_modinter.h" /* same in GRAS */
24 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module,xbt, "module handling");
26 static int xbt_running_process = 0;
32 xbt_module_new_fct_t new;
33 xbt_module_finalize_fct_t finalize;
37 xbt_init(int *argc, char **argv) {
38 static int first_run = 1;
40 xbt_init_defaultlog(argc, argv, NULL);
45 * xbt_init_defaultlog:
49 * Initialize the gras mecanisms.
52 xbt_init_defaultlog(int *argc,char **argv, const char *defaultlog) {
57 INFO0("Initialize GRAS");
59 /** Set logs and init log submodule */
60 for (i=1; i<*argc; i++) {
61 if (!strncmp(argv[i],"--gras-log=",strlen("--gras-log="))) {
63 opt=strchr(argv[i],'=');
65 xbt_log_control_set(opt);
66 DEBUG1("Did apply '%s' as log setting",opt);
67 /*remove this from argv*/
68 for (j=i+1; j<*argc; j++) {
73 i--; /* compensate effect of next loop incrementation */
76 if (!found && defaultlog) {
77 xbt_log_control_set(defaultlog);
80 gras_process_init(); /* calls procdata_init, which calls dynar_new */
81 /** init other submodules */
82 if (xbt_running_process++ == 0) {
92 * Finalize the gras mecanisms.
96 INFO0("Exiting GRAS");
98 if (--xbt_running_process == 0) {
101 gras_datadesc_exit();
104 DEBUG0("Exited GRAS");