00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifdef HAVE_CONFIG_H
00036 #include <config.h>
00037 #endif
00038
00039 #include <biosphere.h>
00040 #include <xml.h>
00041 #include "module.h"
00042 #include "mutex.h"
00043 #include "node.h"
00044 #include "options.h"
00045 #include "service.h"
00046 #include "settings.h"
00047 #include "thread.h"
00048
00049 #include <stdio.h>
00050 #include <stdlib.h>
00051 #include <apr_pools.h>
00052
00053
00064 apr_pool_t *global_mp;
00065
00066
00070 static void cleanup(void)
00071 {
00072 apr_pool_destroy(global_mp);
00073 apr_terminate();
00074 printf("Bio-SPHERE shutting down\n");
00075 }
00076
00077
00081 static bs_status init_general(void)
00082 {
00083 printf("Bio-SPHERE starting up\n");
00084 apr_initialize();
00085 apr_pool_create(&global_mp, NULL);
00086
00087 atexit(cleanup);
00088 return BS_OK;
00089 }
00090
00091
00096 int main(int argc, const char *argv[])
00097 {
00098 if (init_general()) {
00099 fprintf(stderr, "Failed to initialize\n");
00100 return BS_ERROR;
00101 }
00102 if (init_mutexes(global_mp)) {
00103 fprintf(stderr, "Failed to initialize mutexes\n");
00104 return BS_ERROR;
00105 }
00106 if (init_options(argc, argv, global_mp)) {
00107 fprintf(stderr, "Failed to recognize command-line options\n");
00108 return BS_INIT_ERROR_OPTION;
00109 }
00110 if (init_service(global_mp)) {
00111 fprintf(stderr, "Failed to initialize services\n");
00112 return BS_INIT_ERROR_SERVICE;
00113 }
00114 if (init_module(global_mp)) {
00115 fprintf(stderr, "Failed to initialize modules\n");
00116 return BS_INIT_ERROR_MODULE;
00117 }
00118 if (init_node(global_mp)) {
00119 fprintf(stderr, "Failed to correctly add nodes\n");
00120 return BS_ERROR;
00121 }
00122 if (init_threadsystem(global_mp)) {
00123 fprintf(stderr, "Failed to initialize listening socket\n");
00124 return BS_INIT_ERROR_LISTENER;
00125 }
00126
00127
00128 lets_go_threaded();
00129
00130 return BS_OK;
00131 }
00132