Example #1
0
void displaymap(unsigned char c, char *buf)
{
    buf[0] = '^';
    if (IS_CTRL(c))
        buf[1] = c + 64;
    else
        buf[1] = uppercase(c);
}
Example #2
0
void *connection_worker(void *arg) {
  msg_node *mn;
  message *msg;
  conn_node *c;
  
  c=(conn_node *) arg;
  
#ifndef NDEBUG
  print( DEBUG, "started (fd=%d, tid=%lu)", c->fd, pthread_self() );
#endif
  
  pthread_mutex_lock(&(c->incoming.control.mutex));
  
  while(c->incoming.control.active || c->incoming.list.head) {
    
    while(!(c->incoming.list.head) && c->incoming.control.active) {
      pthread_cond_wait(&(c->incoming.control.cond), &(c->incoming.control.mutex));
    }
    
    mn = (msg_node *) queue_get(&(c->incoming.list));
    
    if(!mn)
      continue;
    
    pthread_mutex_unlock(&(c->incoming.control.mutex));
    
    msg = mn->msg;
    
    if(IS_CTRL(msg)) {
      if(on_control_request(c, msg)) {
        print( ERROR, "cannot handle the following control message" );
        dump_message(msg);
      }
    } else {
      if(on_child_message(c, msg)) {
        print( ERROR, "cannot handle the following message" );
        dump_message(msg);
      }
    }
    
    free_message(msg);
    free(mn);
    
    pthread_mutex_lock(&(c->incoming.control.mutex));
  }
  
  pthread_mutex_unlock(&(c->incoming.control.mutex));
  
  pthread_mutex_lock(&(c->control.mutex));
  c->worker_done=1;
  pthread_mutex_unlock(&(c->control.mutex));
  
  pthread_cond_broadcast(&(c->control.cond));
  
  send_me_to_graveyard();
  
  return 0;
}
Example #3
0
void vt100_echo(termstate_t *term, char c, l4_int8_t old)
{
    char buf[2];

    switch(c)
    {
    case '\b':
        if (IS_CTRL(old))
        {
            vt100_write( term,"\b \b", 3);
        }
        vt100_write(term, "\b \b", 3);
        break;
    case 13:  // RETURN is a ctrl-character but should not print as ^M
        vt100_write(term, "\n", 1);
        break;
    case 10:  // ^R is a ctrl-character but should print a LF additionally
        displaymap(c, buf);
        vt100_write(term, buf, 2);
        vt100_write(term, "\n", 1);
        break;
    default:
        if (IS_CTRL(c))
        {
            displaymap(c, buf);
            vt100_write(term, buf, 2);
        }
        else if (term->__ctrl)   // fixme: what is this used for???
        {
            displaymap(c, buf);
            vt100_write( term, buf, 2 );
        }
        else
        {
            vt100_write( term, &c, 1 );
        }
        break;
    }
}