Example #1
0
int interactive_init()
{
    int status = CMD_RET_UNKNOWN;

    if (gl) {
        interactive_deinit();
    }

    gl = new_GetLine(CLI_MAX_LINE_LEN, CLI_MAX_HIST_LEN);

    if (gl) {

        /* Try to set up a clean exit on these signals. If it fails, we'll
        * trudge along with a warning */
        if (gl_trap_signal(gl, SIGINT, GLS_DONT_FORWARD, GLS_ABORT, EINTR)  ||
            gl_trap_signal(gl, SIGQUIT, GLS_DONT_FORWARD, GLS_ABORT, EINTR)) {

            fprintf(stderr, SIGHANLDER_FAILED);
        }

        status = 0;
    }

    return status;
}
Example #2
0
int input_init()
{
    int status = CLI_RET_UNKNOWN;

    if (gl) {
        input_deinit();
    }

    gl = new_GetLine(CLI_MAX_LINE_LEN, CLI_MAX_HIST_LEN);

    if (gl) {

        /* Try to set up a clean exit on these signals. If it fails, we'll
        * trudge along with a warning */
        if (gl_trap_signal(gl, SIGINT, GLS_DONT_FORWARD, GLS_ABORT, EINTR)  ||
            gl_trap_signal(gl, SIGQUIT, GLS_DONT_FORWARD, GLS_ABORT, EINTR)) {

            fprintf(stderr, SIGHANLDER_FAILED);
        }

        tab_complete = new_WordCompletion();
        if (tab_complete != NULL) {
            gl_customize_completion(gl, NULL, tab_completion);
        } else {
            /* Non-fatal - complain and carry on */
            fprintf(stderr, "Failed to initialize tab-completion.\n");
        }

        status = 0;
    }

    return status;
}