Show
Ignore:
Timestamp:
02/08/08 05:31:31 (7 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1202448691 +0000
git-parent:

[46304a4547d3e7cd3b7e98eaa2b8653034cd1c6b]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1202448691 +0000
Message:

libedit actually works now?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit_console.c

    r3070001 r3f67984  
    9494noit_console_closure_free(noit_console_closure_t ncct) { 
    9595  if(ncct->el) el_end(ncct->el); 
     96  if(ncct->hist) history_end(ncct->hist); 
    9697  if(ncct->pty_master >= 0) close(ncct->pty_master); 
    9798  if(ncct->pty_slave >= 0) close(ncct->pty_slave); 
     
    147148  char *cmds[32]; 
    148149  int i, cnt = 32; 
    149   nc_printf(ncct, "You said: %s", buffer); 
     150  nc_printf(ncct, "You said: %s\r\n", buffer); 
    150151  i = noit_tokenize(buffer, cmds, &cnt); 
    151152  if(i>cnt) nc_printf(ncct, "Command length too long.\n"); 
    152153  if(i<0) nc_printf(ncct, "Error at offset: %d\n", 0-i); 
    153154  for(i=0;i<cnt;i++) { 
    154     nc_printf(ncct, "[%d] '%s'\n", i, cmds[i]); 
     155    nc_printf(ncct, "[%d] '%s'\r\n", i, cmds[i]); 
    155156    free(cmds[i]); 
    156157  } 
     
    183184    } 
    184185    else { 
     186      HistEvent ev; 
     187      ncct->hist = history_init(); 
     188      history(ncct->hist, &ev, H_SETSIZE, 500); 
    185189      ncct->el = el_init("noitd", ncct->pty_master, e->fd, e->fd); 
    186190      el_set(ncct->el, EL_EDITOR, "emacs"); 
     191      el_set(ncct->el, EL_HIST, history, ncct->hist); 
    187192      ncct->telnet = noit_console_telnet_alloc(ncct); 
    188193    } 
     
    208213 
    209214    len = e->opset->read(e->fd, sbuf, sizeof(sbuf)-1, &newmask, e); 
     215noitL(noit_stderr, "opset->read => %d bytes\n", len); 
    210216    if(len == 0 || (len < 0 && errno != EAGAIN)) { 
    211217      eventer_remove_fd(e->fd); 
     
    225231    } 
    226232    if(buffer) { 
    227       printf("IN: %s", buffer); 
    228       noit_console_dispatch(e, buffer, ncct); 
     233      char *cmd_buffer; 
     234      HistEvent ev; 
     235      cmd_buffer = malloc(plen+1); 
     236      memcpy(cmd_buffer, buffer, plen); 
     237      /* chomp */ 
     238      cmd_buffer[plen] = '\0'; 
     239      if(cmd_buffer[plen-1] == '\n') cmd_buffer[plen-1] = '\0'; 
     240      noitL(noit_debug, "IN: '%s'\n", cmd_buffer); 
     241      history(ncct->hist, &ev, H_ENTER, cmd_buffer); 
     242      noit_console_dispatch(e, cmd_buffer, ncct); 
     243      free(cmd_buffer); 
    229244      if(noit_console_continue_sending(ncct, &newmask) == -1) { 
    230245        if(errno != EAGAIN) goto socket_error;