X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d21c9d9527afd7a99ee30e1ace72749025464b95..a23cdba841776d9ef2396c8a8f7dc01bcc274094:/src/xbt/module.c diff --git a/src/xbt/module.c b/src/xbt/module.c index 1398642f10..cbad5ef2f5 100644 --- a/src/xbt/module.c +++ b/src/xbt/module.c @@ -2,86 +2,53 @@ /* module handling */ -/* Authors: Martin Quinson */ -/* Copyright (C) 2003 the OURAGAN project. */ +/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it - under the terms of the license (GNU LGPL) which comes with this package. */ + * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "gras_private.h" +#include "xbt/sysdep.h" +#include "xbt/log.h" +#include "xbt/error.h" +#include "xbt/dynar.h" +#include "xbt/config.h" -GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(module,GRAS); +#include "xbt/module.h" /* this module */ -extern void gras_log_exit(void); +#include "xbt_modinter.h" /* prototype of other module's init/exit in XBT */ -struct gras_module_ { - gras_dynar_t *deps; - gras_cfg_t *cfg; +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module,xbt, "module handling"); + +struct xbt_module_ { + xbt_dynar_t *deps; + xbt_cfg_t *cfg; int ref; - gras_module_new_fct_t new; - gras_module_finalize_fct_t finalize; + xbt_module_new_fct_t new; + xbt_module_finalize_fct_t finalize; }; +/** @brief Initialize the xbt mechanisms. */ void -gras_init(int *argc, char **argv) { - gras_init_defaultlog(argc, argv, NULL); +xbt_init(int *argc, char **argv) { + xbt_init_defaultlog(argc, argv, NULL); } -/** - * gras_init_defaultlog: - * @argc: - * @argv: - * - * Initialize the gras mecanisms. - */ +/** @brief Initialize the xbt mechanisms. */ void -gras_init_defaultlog(int *argc,char **argv, const char *defaultlog) { - int i,j; - char *opt; - gras_error_t errcode; - int found=0; - - INFO0("Initialize GRAS"); +xbt_init_defaultlog(int *argc,char **argv, const char *defaultlog) { + static short int first_run = 1; + if (!first_run) + return; - /** Set logs and init log submodule */ - for (i=1; i<*argc; i++) { - if (!strncmp(argv[i],"--gras-log=",strlen("--gras-log="))) { - found = 1; - opt=strchr(argv[i],'='); - opt++; - TRYFAIL(gras_log_control_set(opt)); - DEBUG1("Did apply '%s' as log setting",opt); - /*remove this from argv*/ - for (j=i+1; j<*argc; j++) { - argv[j-1] = argv[j]; - } - argv[j-1] = NULL; - (*argc)--; - i--; /* compensate effect of next loop incrementation */ - WARN1("argc %d",*argc); - } - } - if (!found && defaultlog) { - TRYFAIL(gras_log_control_set(defaultlog)); - } - - /** init other submodules */ - gras_msg_init(); - gras_trp_init(); - gras_datadesc_init(); + first_run = 0; + VERB0("Initialize XBT"); + + xbt_log_init(argc,argv,defaultlog); } -/** - * gras_exit: - * - * Finalize the gras mecanisms. - */ +/** @brief Finalize the xbt mechanisms. */ void -gras_exit(){ - INFO0("Exiting GRAS"); - gras_msg_exit(); - gras_trp_exit(); - gras_datadesc_exit(); - gras_log_exit(); - DEBUG0("Exited GRAS"); +xbt_exit(){ + xbt_log_exit(); } +