Exemplo n.º 1
0
/** \brief Display the inlined help
 */
void	lib_apps_t::display_help(const clineopt_arr_t &clineopt_arr)	throw()
{
    // display a inlined help
    KLOG_STDERR(human_name() << " - " << summary() << "\n");
    KLOG_STDERR(canon_name() << " version " << version() << " - list of possible options:\n" );
    KLOG_STDERR(clineopt_helper_t::help_string(clineopt_arr) );
    KLOG_STDERR(longdesc() << "\n");
}
Exemplo n.º 2
0
static void about(WId h) {
	QMessageBox::about(QWidget::find(h), QString::fromStdWString(description), QString::fromStdWString(longdesc()));
}
Exemplo n.º 3
0
/** \brief start the apps
 */
libsess_err_t	lib_apps_t::start(int argc, char **argv, const clineopt_arr_t &apps_clineopt_arr
                                  , const std::string &m_canon_name, const std::string &m_human_name
                                  , const std::string &m_version, const std::string &m_summary
                                  , const std::string &m_longdesc, const apps_type_t &m_apps_type) throw()
{
    // copy the parameter
    this->m_canon_name	= m_canon_name;
    this->m_human_name	= m_human_name;
    this->m_version		= m_version;
    this->m_summary		= m_summary;
    this->m_longdesc	= m_longdesc;
    this->m_apps_type	= m_apps_type;

    // sanity check - all parameters MUST be set
    DBG_ASSERT( !canon_name().empty() );
    DBG_ASSERT( !human_name().empty() );
    DBG_ASSERT( !version().empty() );
    DBG_ASSERT( !summary().empty() );
    DBG_ASSERT( !longdesc().empty() );
    DBG_ASSERT( !apps_type().is_null() );

#if 0	// TODO fixup this issue... *apparently* setting this or not under window
    // didnt change the result. so i manually change the OS preference
    // - obviously this is crap :)
    // - as seens in neoip-nunit "all/base/string" which is failing with "1,0"
    //   on cout/cin

    // set 'locale' to the default C one
    // - without that the operating system may use display float(1.0) as "1,0"
    // - i didnt experience it under linux but did under _WIN32. likely because
    //   i run linux under english default
    // - as i do it only for float/double, maybe i should limit this to LC_NUMERIC ?
    setlocale(LC_ALL, "C" );
#endif

    // parse the command line
    clineopt_err_t	clineopt_err;
    clineopt_err	= parse_cmdline(argc, argv, apps_clineopt_arr);

    // display the short help if the clineopt is in the cmdline
    if( m_arg_option.contain_key("help") ) {
        // build the full clineopt_arr
        clineopt_arr_t	clineopt_arr	= apps_clineopt_arr;
        clineopt_arr	+= lib_session_t::clineopt_arr();
        clineopt_arr	+= neutral_clineopt_arr();
        // display the help
        display_help(clineopt_arr);
        // notify the caller not to launch the apps
        return libsess_err_t(libsess_err_t::OK, "DONTLAUNCHAPPS");
    }

    // display the version if the clineopt is in the cmdline
    if( m_arg_option.contain_key("version") ) {
        // display the version
        display_version();
        // notify the caller not to launch the apps
        return libsess_err_t(libsess_err_t::OK, "DONTLAUNCHAPPS");
    }

    // if the cmdline parsing failed, return an error
    if( clineopt_err.failed() )	return libsess_err_from_clineopt(clineopt_err);

    // initialize the lib_session
    if( lib_session_init() )	return libsess_err_t(libsess_err_t::ERROR, "lib_session_init() failed!!!");
    libsess_err_t	libsess_err;
    libsess_err	= lib_session_get()->set_profile(profile.lib_session()).start(this);
    if( libsess_err.failed() )	return libsess_err;

    // unbuffer the output just to debug
    setbuf(stderr, NULL);
    setbuf(stdout, NULL);
    /* init signal handler for stun shutdown */
    signal( SIGINT, signal_hd );
    signal( SIGTERM, signal_hd );

#ifndef _WIN32	// no sigpipe in mingw
    // NOTE: added to run only ELOOP_LEVT
    // - it was not needed for ELOOP_GLIB, likely glib use it for itself
    signal( SIGPIPE, SIG_IGN );
#endif

    // put a 'random' seed
    srand(time(NULL));
    // return no error
    return libsess_err_t::OK;
}