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 "gras_private.h"
13 GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(module,gros, "module handling");
15 extern void gras_log_exit(void);
16 static int gras_running_process = 0;
22 gras_module_new_fct_t new;
23 gras_module_finalize_fct_t finalize;
27 gras_init(int *argc, char **argv) {
28 gras_init_defaultlog(argc, argv, NULL);
32 * gras_init_defaultlog:
36 * Initialize the gras mecanisms.
39 gras_init_defaultlog(int *argc,char **argv, const char *defaultlog) {
45 INFO0("Initialize GRAS");
47 /** Set logs and init log submodule */
48 for (i=1; i<*argc; i++) {
49 if (!strncmp(argv[i],"--gras-log=",strlen("--gras-log="))) {
51 opt=strchr(argv[i],'=');
53 TRYFAIL(gras_log_control_set(opt));
54 DEBUG1("Did apply '%s' as log setting",opt);
55 /*remove this from argv*/
56 for (j=i+1; j<*argc; j++) {
61 i--; /* compensate effect of next loop incrementation */
64 if (!found && defaultlog) {
65 TRYFAIL(gras_log_control_set(defaultlog));
68 gras_process_init(); /* calls procdata_init, which calls dynar_new */
69 /** init other submodules */
70 if (gras_running_process++ == 0) {
80 * Finalize the gras mecanisms.
84 INFO0("Exiting GRAS");
86 if (--gras_running_process == 0) {
92 DEBUG0("Exited GRAS");