diff options
| author | The Android Open Source Project <initial-contribution@android.com> | 2010-06-02 08:14:33 -0700 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2010-06-02 08:14:33 -0700 |
| commit | 456688bfb4fa7817031a1d704e8353e1dd5efb3c (patch) | |
| tree | e7cd04042f2d684b1afd7b02030527ac2d057834 /adb/commandline.c | |
| parent | 5dc0f5db7152a604377af30f7d2139a84fd7b30c (diff) | |
| parent | 67d5358e2a870f9e9447517bfa49bf5c6b410a50 (diff) | |
| download | system_core-456688bfb4fa7817031a1d704e8353e1dd5efb3c.tar.gz system_core-456688bfb4fa7817031a1d704e8353e1dd5efb3c.tar.bz2 system_core-456688bfb4fa7817031a1d704e8353e1dd5efb3c.zip | |
merge from open-source master
Change-Id: I99ae03ba51ee185b9cfecf4f26e94a757f3815c2
Diffstat (limited to 'adb/commandline.c')
| -rw-r--r-- | adb/commandline.c | 122 |
1 files changed, 19 insertions, 103 deletions
diff --git a/adb/commandline.c b/adb/commandline.c index d97e97d0..4d7d357f 100644 --- a/adb/commandline.c +++ b/adb/commandline.c @@ -37,11 +37,6 @@ #include "adb_client.h" #include "file_sync_service.h" -#ifdef SH_HISTORY -#include "shlist.h" -#include "history.h" -#endif - enum { IGNORE_DATA, WIPE_DATA, @@ -233,23 +228,10 @@ static void read_and_dump(int fd) } } -#ifdef SH_HISTORY -int shItemCmp( void *val, void *idata ) -{ - return( (strcmp( val, idata ) == 0) ); -} -#endif - static void *stdin_read_thread(void *x) { int fd, fdi; unsigned char buf[1024]; -#ifdef SH_HISTORY - unsigned char realbuf[1024], *buf_ptr; - SHLIST history; - SHLIST *item = &history; - int cmdlen = 0, ins_flag = 0; -#endif int r, n; int state = 0; @@ -258,9 +240,6 @@ static void *stdin_read_thread(void *x) fdi = fds[1]; free(fds); -#ifdef SH_HISTORY - shListInitList( &history ); -#endif for(;;) { /* fdi is really the client's stdin, so use read, not adb_read here */ r = unix_read(fdi, buf, 1024); @@ -269,97 +248,34 @@ static void *stdin_read_thread(void *x) if(errno == EINTR) continue; break; } -#ifdef SH_HISTORY - if( (r == 3) && /* Arrow processing */ - (memcmp( (void *)buf, SH_ARROW_ANY, 2 ) == 0) ) { - switch( buf[2] ) { - case SH_ARROW_UP: - item = shListGetNextItem( &history, item ); - break; - case SH_ARROW_DOWN: - item = shListGetPrevItem( &history, item ); - break; - default: - item = NULL; - break; - } - memset( buf, SH_DEL_CHAR, cmdlen ); - if( item != NULL ) { - n = snprintf( (char *)(&buf[cmdlen]), sizeof buf - cmdlen, "%s", (char *)(item->data) ); - memcpy( realbuf, item->data, n ); - } - else { /* Clean buffer */ - item = &history; - n = 0; - } - r = n + cmdlen; - cmdlen = n; - ins_flag = 0; - if( r == 0 ) - continue; - } - else { -#endif - for(n = 0; n < r; n++){ - switch(buf[n]) { - case '\n': -#ifdef SH_HISTORY - if( ins_flag && (SH_BLANK_CHAR <= realbuf[0]) ) { - buf_ptr = malloc(cmdlen + 1); - if( buf_ptr != NULL ) { - memcpy( buf_ptr, realbuf, cmdlen ); - buf_ptr[cmdlen] = '\0'; - if( (item = shListFindItem( &history, (void *)buf_ptr, shItemCmp )) == NULL ) { - shListInsFirstItem( &history, (void *)buf_ptr ); - item = &history; - } - } - } - cmdlen = 0; - ins_flag = 0; -#endif - state = 1; - break; - case '\r': - state = 1; - break; - case '~': - if(state == 1) state++; - break; - case '.': - if(state == 2) { - fprintf(stderr,"\n* disconnect *\n"); - #ifdef HAVE_TERMIO_H - stdin_raw_restore(fdi); - #endif - exit(0); - } - default: -#ifdef SH_HISTORY - if( buf[n] == SH_DEL_CHAR ) { - if( cmdlen > 0 ) - cmdlen--; - } - else { - realbuf[cmdlen] = buf[n]; - cmdlen++; - } - ins_flag = 1; + for(n = 0; n < r; n++){ + switch(buf[n]) { + case '\n': + state = 1; + break; + case '\r': + state = 1; + break; + case '~': + if(state == 1) state++; + break; + case '.': + if(state == 2) { + fprintf(stderr,"\n* disconnect *\n"); +#ifdef HAVE_TERMIO_H + stdin_raw_restore(fdi); #endif - state = 0; + exit(0); } + default: + state = 0; } -#ifdef SH_HISTORY } -#endif r = adb_write(fd, buf, r); if(r <= 0) { break; } } -#ifdef SH_HISTORY - shListDelAllItems( &history, (shListFree)free ); -#endif return 0; } |
