Exemplo n.º 1
0
static void		pipex_right(char *cmd, int fd_out, int *pipefd)
{
	close(pipefd[1]);
	dup2(pipefd[2], 1);
	command_proc(cmd, pipefd[0], fd_out);
	exit(EXIT_SUCCESS);
}
Exemplo n.º 2
0
static void		pipex_left(char *cmd, int fd_in, int *pipefd)
{
	close(pipefd[0]);
	dup2(pipefd[1], 0);
	command_proc(cmd, fd_in, pipefd[1]);
	exit(EXIT_SUCCESS);
}
Exemplo n.º 3
0
static void register_code(uint8_t code)
{
    if IS_KEY(code) {
        if (!command_proc(code)) {
            host_add_key(code);
            host_send_keyboard_report();
        }
    }
    else if IS_MOD(code) {
Exemplo n.º 4
0
/** \brief Utilities for actions. (FIXME: Needs better description)
 *
 * FIXME: Needs documentation.
 */
void register_code(uint8_t code)
{
    if (code == KC_NO) {
        return;
    }

#ifdef LOCKING_SUPPORT_ENABLE
    else if (KC_LOCKING_CAPS == code) {
#ifdef LOCKING_RESYNC_ENABLE
        // Resync: ignore if caps lock already is on
        if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) return;
#endif
        add_key(KC_CAPSLOCK);
        send_keyboard_report();
        wait_ms(100);
        del_key(KC_CAPSLOCK);
        send_keyboard_report();
    }

    else if (KC_LOCKING_NUM == code) {
#ifdef LOCKING_RESYNC_ENABLE
        if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) return;
#endif
        add_key(KC_NUMLOCK);
        send_keyboard_report();
        wait_ms(100);
        del_key(KC_NUMLOCK);
        send_keyboard_report();
    }

    else if (KC_LOCKING_SCROLL == code) {
#ifdef LOCKING_RESYNC_ENABLE
        if (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) return;
#endif
        add_key(KC_SCROLLLOCK);
        send_keyboard_report();
        wait_ms(100);
        del_key(KC_SCROLLLOCK);
        send_keyboard_report();
    }
#endif

    else if IS_KEY(code) {
        // TODO: should push command_proc out of this block?
        if (command_proc(code)) return;

#ifndef NO_ACTION_ONESHOT
/* TODO: remove
        if (oneshot_state.mods && !oneshot_state.disabled) {
            uint8_t tmp_mods = get_mods();
            add_mods(oneshot_state.mods);

            add_key(code);
            send_keyboard_report();

            set_mods(tmp_mods);
            send_keyboard_report();
            oneshot_cancel();
        } else
*/
#endif
        {
            add_key(code);
            send_keyboard_report();
        }
    }
    else if IS_MOD(code) {
Exemplo n.º 5
0
void client_event_read(struct bufferevent *bev, void *arg)
{
    log_debug("client_event_read");
    client_t *c = (client_t*) arg;
    server_t *s = c->server;
    log_debug("Received read event from client socket %d", c->socket);

    if(c->msg == NULL)
    {
        c->msg = msg_init(c->worker->msg_buf);
    }

    int res = evbuffer_add_buffer(c->evbuf, bufferevent_get_input(bev));
    char *line;

    while((line = evbuffer_readln(c->evbuf, NULL, EVBUFFER_EOL_CRLF)) != NULL)
    {
        log_debug("Read data : %s", line);
        decode_result res = decoder_run(c->msg, line);
        msg_print(c->msg);

        switch(res)
        {
            case DR_ERR_FORMAT:
                client_increase_req_err(c);
                worker_increase_req_err(c->worker);
                msg_clean(c->msg);
                log_debug("Wrong message format : %s", line);
                resp_error_wrong_msg_format(c->worker->msg_buf, c->socket);
                break;

            case DR_ERR_PARAM_FORMAT:
                client_increase_req_err(c);
                worker_increase_req_err(c->worker);
                msg_clean(c->msg);
                log_debug("Wrong parameter format : %s", line);
                resp_error_param_format(c->worker->msg_buf, c->socket);
                break;

            case DR_OK:
                log_debug("Data OK.");
                break;

            default:
                break;
        }

        enum cmd_func_ret cmd_ret;

        switch(msg_get_stat(c->msg))
        {
            case MSG_STAT_DONE:
                log_debug("Message Done.");
                client_increase_req_ok(c);
                worker_increase_req_ok(c->worker);
                cmd_ret = command_proc(c, c->msg);
                if(cmd_ret != CMD_FUNC_DONE)
                {
                    c->req_ok++;
                    s->req_ok++;
                }
                msg_clean(c->msg);
                break;
        }


//        ic_trans_stat trans_stat = decoder_read_line(c, line);
//        log_debug("Trans stat : %d", trans_stat);
//        if(trans_stat == IC_TRANS_ALL_DONE)
//        {
//            log_debug("Trasfer done, ");
//        }
    }

}