예제 #1
0
/*
 * Shows the prompt
 */
void ReadLinePrompt ()
{
    int gpos = rl_colpos;

    if (rl_prompt_stat == 1)
        return;
#if DEBUG_RL
    fprintf (stderr, "killoper: %s\n", s_qquote (rl_operate.txt));
#endif
    s_init (&rl_operate, "", 0);
    if (rl_prompt_stat == 2)
        rl_goto (0);
    if (rl_prompt_stat == 2)
    {
        s_catc (&rl_operate, '\r');
#ifdef ANSI_TERM
        s_cat (&rl_operate, ANSI_CLEAR);
#endif
        rl_prompt_stat = 0;
    }
#if DEBUG_RL
    fprintf (stderr, "oper(rm): %s\n", s_qquote (rl_operate.txt));
#endif
    printf ("%s", rl_operate.txt);
    if (rl_prompt_stat == 0)
    {
        rl_print ("\r");
        rl_print (rl_prompt.txt);
        rl_prompt_len = rl_pos ();
        rl_prompt_stat = 1;
        rl_colpos = 0;
    }
    s_init (&rl_operate, "", 0);
    rl_recheck (TRUE);
    rl_goto (gpos);
    printf ("%s", rl_operate.txt);
}
예제 #2
0
파일: util_io.c 프로젝트: tadu/climm
io_err_t UtilIOShowError (Connection *conn, io_err_t rc)
{
    int e = errno;
    const char *t = NULL;

    switch (rc) {
    
        case IO_CONNECTED: 
            rl_print ("");
            if (prG->verbose || (conn->serv && conn == conn->serv->conn))
                if (rl_pos () > 0)
                     rl_print (i18n (1634, "ok.\n"));
            return IO_CONNECTED;

        case IO_OK:
            return IO_OK;

        case IO_NO_MEM:
        case IO_NO_PARAM:
            assert (0);

        case IO_NO_SOCKET:
            if (1) t = i18n (1638, "Couldn't create socket"); else
        case IO_NO_NONBLOCK:
            if (1) t = i18n (1950, "Couldn't set socket nonblocking"); else
        case IO_NO_HOSTNAME:
            if (1) t = i18n (2743, "Can't find hostname"); else
        case IO_CONN_TO:
            if (1) t = i18n (2744, "Connection timed out"); else
        case IO_NO_CONN:
                   t = i18n (1952, "Couldn't open connection");
            if (prG->verbose || (conn->serv && conn == conn->serv->conn))
            {
                Contact *cont = conn->cont;
                char *semi = strchr (conn->server, ';');
                if (semi)
                    *semi = 0;
                rl_log_for (cont->nick, COLCONTACT);
                rl_printf (i18n (2745, "Opening connection to %s:%s%ld%s "),
                          s_wordquote (conn->server), COLQUOTE, UD2UL (conn->port), COLNONE);
                if (semi)
                    *semi = ';';
                rl_print (i18n (1949, "failed:\n"));
                rl_printf ("%s [%d]\n",
                    s_sprintf  ("%s: %s (%d).", t, conn->dispatcher->funcs->f_err (conn, conn->dispatcher), e),
                    __LINE__);
            }
            UtilIOClose (conn);
            return IO_RW;
        case IO_CLOSED:
#ifdef ECONNRESET
            if (!errno)
                errno = ECONNRESET;
#endif
        case IO_RW:
            if (prG->verbose || (conn->serv && conn == conn->serv->conn))
            {
                Contact *cont;
                if ((cont = conn->cont))
                {
                    rl_log_for (cont->nick, COLCONTACT);
                    rl_printf (i18n (1878, "Error while reading from socket: %s (%d, %d)\n"), conn->dispatcher->funcs->f_err (conn, conn->dispatcher), rc, errno);
                }
            }
            UtilIOClose (conn);
            return IO_RW;
        default:
            assert (0);
    }
}