1 /* Main program of GNU Thales. Copyright (C)
2 2012 Free Software Foundation, Inc. This file is part of GNU Thales.
4 GNU Thales is free software; you can redistribute it and/or modify it under the
5 terms of the GNU General Public License as published by the Free Software
6 Foundation; either version 3 of the License, or (at your option) any later
9 GNU Thales is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License along with
15 this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include "workers_registration.h"
25 static LIST_HEAD(workers
);
27 module_initialization_dispatcher(const char *type
,
28 const char *name
, const struct envz
*env
)
30 const struct worker_creator
*cr
= worker_creator_by_type(type
);
31 struct worker
*worker
;
34 fatal_error("No module of type `%s' registered", type
);
36 worker
= (*cr
->creator
)(env
);
38 fatal_error("Failed to initiailize modude of type %s with name %s",
41 list_add(&worker
->list
, &workers
);
44 main(int argc
, char **argv
)
46 struct cmd_options opts
= {
47 .conf_filename
= NULL
,
54 parse_cmdopts(&opts
, argc
, argv
);
55 config_file
= opts
.conf_filename
?
56 fopen(opts
.conf_filename
, "r")
57 : default_config_file();
59 fatal_error("failed to open config file");
60 init_worker_creators();
61 parse_config(config_file
, &module_initialization_dispatcher
);