diff --git a/etk/etk.cpp b/etk/etk.cpp index 2b41854..a3d7d44 100644 --- a/etk/etk.cpp +++ b/etk/etk.cpp @@ -11,24 +11,60 @@ #include #include +static int32_t nbTimeInit = 0; + +void etk::unInit() { + if (nbTimeInit > 1) { + nbTimeInit--; + // not the time to uninit + return; + } + nbTimeInit--; + if (nbTimeInit < 0) { + TK_ERROR("E-TK system un-init More un-init than init ..."); + nbTimeInit = 0; + return; + } + TK_INFO("E-TK system un-init (BEGIN)"); + TK_INFO("E-TK system un-init (END)"); +} + void etk::init(int _argc, const char** _argv) { - TK_INFO("E-TK system init (BEGIN) " << _argv[0]); + if (nbTimeInit > 0) { + nbTimeInit++; + // already init + return; + } + nbTimeInit++; + if (_argc >= 1) { + TK_INFO("E-TK system init (BEGIN) " << _argv[0]); + } else { + TK_INFO("E-TK system init (BEGIN) "); + } elog::init(_argc, _argv); - etk::setArgZero(_argv[0]); + TK_PRINT("plooooooooooooooooooooppppppppppppppppppppppppp"); + #if !defined(__TARGET_OS__Android) and !defined(__TARGET_OS__IOs) + // This action is done by the main wrapper... + if (_argc >= 1) { + TK_PRINT("ploppppppppppppppppppppppppp"); + etk::setArgZero(_argv[0]); + } + #endif + for (int32_t iii=0; iii<_argc ; ++iii) { std::string data = _argv[iii]; if ( data == "-h" || data == "--help") { TK_PRINT("etk - help : "); - TK_PRINT(" " << _argv[0] << " [options]"); + if (_argc >= 1) { + TK_PRINT(" " << _argv[0] << " [options]"); + } /* TK_PRINT(" --etk-log-lib=name:X Set a library specific level:"); TK_PRINT(" name Name of the library"); TK_PRINT(" X Log level to set [0..6]"); */ TK_PRINT(" -h/--help: this help"); - TK_PRINT(" example:"); - TK_PRINT(" " << _argv[0] << " ..."); } else if (etk::start_with(data, "--etk")) { TK_ERROR("Can not parse the argument : '" << data << "'"); } diff --git a/etk/etk.hpp b/etk/etk.hpp index 9a1f1fa..4b78500 100644 --- a/etk/etk.hpp +++ b/etk/etk.hpp @@ -16,6 +16,10 @@ namespace etk { * @param[in] _argv List of arguments */ void init(int _argc, const char** _argv); + /** + * @brief Un-Initialize etk + */ + void unInit(); /** * @brief Get application name.