Link to home
Start Free TrialLog in
Avatar of Ierokish
Ierokish

asked on

With ++. Using commands from a file, and pressing a key

Hello everyone, is there code to create your console, can you somehow link it to using commands from a file and pressing the enter key?
c ++

    #include <log.h>
    #include <cvar.h>
    #include <option.h>
    #include <stream.h>
    #include <xmpp.h>
    #include <xmpp_kb.h>
    #include <session.h>
    #include <threads.h>
    #include <lang.h>
    #include <tools.h>

    int main(int argc, char *argv[])
    {
        const char *exe_path = argv[0];

        cvar_init();

        cvar_parse_file("kb.cfg");

        if (cvar.g_language != NULL)
        {
            char *path;

            FORMAT(path, "kfg/dang/%s.kfg", cvar.g_language);
            cvar_parse_file(path);
            free(path);
        }

        char *token = NULL;
        char *online_id = NULL;
        char *cmdline = NULL;

        option_parse(argc, argv, &token, &online_id, &cmdline);

        /* Start */

        if (isatty(STDOUT_FILENO))
        {
        }

        /* End */

        idh_init();

        XMPP_REGISTER_QUERY_HDLR();
        XMPP_WF_REGISTER_QUERY_HDLR();

        int wfs = stream_connect(cvar.online_server,
                                 cvar.online_server_port);

        if (wfs > 0)
        {
            session_init(wfs, online_id);

            threads_init();

            xmpp_connect(token, online_id);

            threads_run(exe_path, cmdline);

            threads_quit();

            xmpp_close();

            session_free();
        }

        free(token);
        free(online_id);
        free(cmdline);

        xprintf("%s", LANG(kb_closing));

        cvar_free();

        return 0;
    }
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.