Changeset 2451 for neercs


Ignore:
Timestamp:
Jun 18, 2008, 11:08:44 PM (13 years ago)
Author:
Pascal Terjan
Message:
  • Remove termios stuff, does not do anything currently
Location:
neercs/trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/grab.c

    r2450 r2451  
    55#include <stdlib.h>
    66#include <string.h>
    7 #include <termios.h>
    87#include <unistd.h>
    98
     
    180179}
    181180
    182 static int do_get_termios(pid_t pid, int fd, struct termios *t) {
    183     struct user_regs_struct regs;
    184     void *backup_page;
    185     void *target_page = (void*)(0x08048000);
    186     size_t size = (1<<12)*2; /* 8K */
    187     int ret;
    188 
    189     /* Backup the pages that we will use */
    190     backup_page = malloc(size);
    191     if (memcpy_from_target(pid, backup_page, target_page, size) < 0)
    192         return -1;
    193 
    194     if(ptrace(PTRACE_GETREGS, pid, NULL, &regs) < 0)
    195     {
    196         fprintf(stderr, "PTRACE_GETREGS failed\n");
    197         return errno;
    198     }
    199 
    200     regs.eax = SYS_ioctl;
    201     regs.ebx = fd;
    202     regs.ecx = TCGETS;
    203     regs.edx = ((long)target_page);
    204 
    205     if((ret = do_syscall(pid, &regs)) != 0)
    206     {
    207         return ret;
    208     }
    209 
    210     if (regs.eax < 0) {
    211         fprintf(stderr, "ioctl failed\n");
    212         return (-regs.eax);
    213     }
    214 
    215     memcpy_from_target(pid, t, (void*)(target_page), sizeof(struct termios));
    216 
    217     /* Restore the pages */
    218     memcpy_into_target(pid, target_page, backup_page, size);
    219 
    220     return 0;
    221 }
    222 
    223181static int do_setsid(pid_t pid) {
    224182    struct user_regs_struct regs;
     
    266224int grab_process(pid_t pid, char *ptyname, int ptyfd)
    267225{
    268     struct termios t;
    269226    int i, fd = 0, mode, ret;
    270227    char fdstr[1024];
     
    302259
    303260        debug("fd %d is a pty", i);
    304         if((ret = do_get_termios(pid, i, &t)))
    305         {
    306             fprintf(stderr, "do_get_termios %s\n", strerror(ret));
    307         }
    308261        if((ret = do_close(pid, i)))
    309262        {
  • neercs/trunk/src/main.c

    r2448 r2451  
    211211        if(ret && (caca_get_event_type(&ev) & CACA_EVENT_KEY_PRESS))
    212212        {
    213             unsigned int c = caca_get_event_key_ch(&ev);
     213            unsigned int c = caca_get_event_key_utf32(&ev);
    214214
    215215            if(command)
  • neercs/trunk/src/neercs.h

    r2448 r2451  
    170170
    171171
    172 #if 0
     172#if 1
    173173#   define debug(f, z...) fprintf(stderr, f "\n", z)
    174174#else
  • neercs/trunk/src/term.c

    r2445 r2451  
    344344        {
    345345            unsigned int bytes;
     346            char tmp[7];
    346347
    347348            if(i + 6 < size)
     
    350351            {
    351352                /* Add a trailing zero to what we're going to read */
    352                 char tmp[7];
    353353                memcpy(tmp, buffer + i, size - i);
    354354                tmp[size - i] = '\0';
    355355                ch = cucul_utf8_to_utf32(tmp, &bytes);
    356356            }
    357 
     357            /* FIXME awful for perfs
     358               should get a better way to know if utf8 was valid */
     359            memset(tmp, 0, 7);
     360            cucul_utf32_to_utf8(tmp, ch);
     361            if(strncmp(tmp, (char const *)(buffer + i), strlen(tmp)))
     362                bytes = 0;
    358363            if(!bytes)
    359364            {
    360365                /* If the Unicode is invalid, assume it was latin1. */
    361366                ch = buffer[i];
     367                debug("Invalid UTF-8 : %c", ch);
    362368                bytes = 1;
    363369            }
Note: See TracChangeset for help on using the changeset viewer.