Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
revert last change trying to inject the \0 after the name, since it was mainly cosmet...
[simgrid.git] / src / xbt / module.c
1 /* $Id$ */
2
3 /* module handling                                                          */
4
5 /* Authors: Martin Quinson                                                  */
6 /* Copyright (C) 2003 the OURAGAN project.                                  */
7
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. */
10
11 #include "gras_private.h"
12
13 GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(module,GRAS);
14
15 extern void gras_log_exit(void);
16
17 struct gras_module_ {
18   gras_dynar_t *deps;
19   gras_cfg_t *cfg;
20   int ref;
21   gras_module_new_fct_t new;
22   gras_module_finalize_fct_t finalize;
23 };
24
25 void 
26 gras_init(int *argc, char **argv) {
27    gras_init_defaultlog(argc, argv, NULL);
28 }
29
30 /**
31  * gras_init_defaultlog:
32  * @argc:
33  * @argv:
34  *
35  * Initialize the gras mecanisms.
36  */
37 void
38 gras_init_defaultlog(int *argc,char **argv, const char *defaultlog) {
39   int i,j;
40   char *opt;
41   gras_error_t errcode;
42   int found=0;
43
44   INFO0("Initialize GRAS");
45   
46   /** Set logs and init log submodule */
47   for (i=1; i<*argc; i++) {
48     if (!strncmp(argv[i],"--gras-log=",strlen("--gras-log="))) {
49       found = 1;
50       opt=strchr(argv[i],'=');
51       opt++;
52       TRYFAIL(gras_log_control_set(opt));
53       DEBUG1("Did apply '%s' as log setting",opt);
54       /*remove this from argv*/
55       for (j=i+1; j<*argc; j++) {
56         argv[j-1] = argv[j];
57       } 
58       argv[j-1] = NULL;
59       (*argc)--;
60       i--; /* compensate effect of next loop incrementation */
61       WARN1("argc %d",*argc);
62     }
63   }
64   if (!found && defaultlog) {
65      TRYFAIL(gras_log_control_set(defaultlog));
66   }
67    
68   /** init other submodules */
69   gras_msg_init();
70   gras_trp_init();
71   gras_datadesc_init();
72 }
73
74 /**
75  * gras_exit:
76  *
77  * Finalize the gras mecanisms.
78  */
79 void 
80 gras_exit(){
81   INFO0("Exiting GRAS");
82   gras_msg_exit();
83   gras_trp_exit();
84   gras_datadesc_exit();
85   gras_log_exit();
86   DEBUG0("Exited GRAS");
87 }