aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adb/Android.mk1
-rw-r--r--adb/commandline.c122
-rwxr-xr-xadb/history.h13
-rwxr-xr-xadb/shlist.c185
-rwxr-xr-xadb/shlist.h34
5 files changed, 19 insertions, 336 deletions
diff --git a/adb/Android.mk b/adb/Android.mk
index f8f0596..740135e 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -57,7 +57,6 @@ LOCAL_SRC_FILES := \
file_sync_client.c \
$(EXTRA_SRCS) \
$(USB_SRCS) \
- shlist.c \
utils.c \
usb_vendors.c
diff --git a/adb/commandline.c b/adb/commandline.c
index 8003a64..d1eba5a 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,
@@ -232,23 +227,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;
@@ -257,9 +239,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);
@@ -268,97 +247,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;
}
diff --git a/adb/history.h b/adb/history.h
deleted file mode 100755
index ef86ad9..0000000
--- a/adb/history.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef _HISTORY_H_
-#define _HISTORY_H_
-
-#define SH_ARROW_ANY "\x1b\x5b"
-#define SH_ARROW_UP '\x41'
-#define SH_ARROW_DOWN '\x42'
-#define SH_ARROW_RIGHT '\x43'
-#define SH_ARROW_LEFT '\x44'
-#define SH_DEL_CHAR '\x7F'
-#define SH_BLANK_CHAR '\x20'
-
-#endif
-
diff --git a/adb/shlist.c b/adb/shlist.c
deleted file mode 100755
index 44919ef..0000000
--- a/adb/shlist.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*-------------------------------------------------------------------*/
-/* List Functionality */
-/*-------------------------------------------------------------------*/
-/* #define SH_LIST_DEBUG */
-/*-------------------------------------------------------------------*/
-#include <stdio.h>
-#include <stdlib.h>
-#include "shlist.h"
-/*-------------------------------------------------------------------*/
-void shListInitList( SHLIST *listPtr )
-{
- listPtr->data = (void *)0L;
- listPtr->next = listPtr;
- listPtr->prev = listPtr;
-}
-
-SHLIST *shListFindItem( SHLIST *head, void *val, shListEqual func )
-{
- SHLIST *item;
-
- for(item=head->next;( item != head );item=item->next)
- if( func ) {
- if( func( val, item->data ) ) {
- return( item );
- }
- }
- else {
- if( item->data == val ) {
- return( item );
- }
- }
- return( NULL );
-}
-
-SHLIST *shListGetLastItem( SHLIST *head )
-{
- if( head->prev != head )
- return( head->prev );
- return( NULL );
-}
-
-SHLIST *shListGetFirstItem( SHLIST *head )
-{
- if( head->next != head )
- return( head->next );
- return( NULL );
-}
-
-SHLIST *shListGetNItem( SHLIST *head, unsigned long num )
-{
- SHLIST *item;
- unsigned long i;
-
- for(i=0,item=head->next;( (i < num) && (item != head) );i++,item=item->next);
- if( item != head )
- return( item );
- return( NULL );
-}
-
-SHLIST *shListGetNextItem( SHLIST *head, SHLIST *item )
-{
- if( item == NULL )
- return( NULL );
- if( item->next != head )
- return( item->next );
- return( NULL );
-}
-
-SHLIST *shListGetPrevItem( SHLIST *head, SHLIST *item )
-{
- if( item == NULL )
- return( NULL );
- if( item->prev != head )
- return( item->prev );
- return( NULL );
-}
-
-void shListDelItem( SHLIST *head, SHLIST *item, shListFree func )
-{
- if( item == NULL )
- return;
-#ifdef SH_LIST_DEBUG
- fprintf(stderr, "Del %lx\n", (unsigned long)(item->data));
-#endif
- (item->prev)->next = item->next;
- (item->next)->prev = item->prev;
- if( func && item->data ) {
- func( (void *)(item->data) );
- }
- free( item );
- head->data = (void *)((unsigned long)(head->data) - 1);
-}
-
-void shListInsFirstItem( SHLIST *head, void *val )
-{ /* Insert to the beginning of the list */
- SHLIST *item;
-
- item = (SHLIST *)malloc( sizeof(SHLIST) );
- if( item == NULL )
- return;
- item->data = val;
- item->next = head->next;
- item->prev = head;
- (head->next)->prev = item;
- head->next = item;
-#ifdef SH_LIST_DEBUG
- fprintf(stderr, "Ins First %lx\n", (unsigned long)(item->data));
-#endif
- head->data = (void *)((unsigned long)(head->data) + 1);
-}
-
-void shListInsLastItem( SHLIST *head, void *val )
-{ /* Insert to the end of the list */
- SHLIST *item;
-
- item = (SHLIST *)malloc( sizeof(SHLIST) );
- if( item == NULL )
- return;
- item->data = val;
- item->next = head;
- item->prev = head->prev;
- (head->prev)->next = item;
- head->prev = item;
-#ifdef SH_LIST_DEBUG
- fprintf(stderr, "Ins Last %lx\n", (unsigned long)(item->data));
-#endif
- head->data = (void *)((unsigned long)(head->data) + 1);
-}
-
-void shListInsBeforeItem( SHLIST *head, void *val, void *etal,
- shListCmp func )
-{
- SHLIST *item, *iptr;
-
- if( func == NULL )
- shListInsFirstItem( head, val );
- else {
- item = (SHLIST *)malloc( sizeof(SHLIST) );
- if( item == NULL )
- return;
- item->data = val;
- for(iptr=head->next;( iptr != head );iptr=iptr->next)
- if( func( val, iptr->data, etal ) )
- break;
- item->next = iptr;
- item->prev = iptr->prev;
- (iptr->prev)->next = item;
- iptr->prev = item;
-#ifdef SH_LIST_DEBUG
- fprintf(stderr, "Ins Before %lx\n", (unsigned long)(item->data));
-#endif
- head->data = (void *)((unsigned long)(head->data) + 1);
- }
-}
-
-void shListDelAllItems( SHLIST *head, shListFree func )
-{
- SHLIST *item;
-
- for(item=head->next;( item != head );) {
- shListDelItem( head, item, func );
- item = head->next;
- }
- head->data = (void *)0L;
-}
-
-void shListPrintAllItems( SHLIST *head, shListPrint func )
-{
-#ifdef SH_LIST_DEBUG
- SHLIST *item;
-
- for(item=head->next;( item != head );item=item->next)
- if( func ) {
- func(item->data);
- }
- else {
- fprintf(stderr, "Item: %lx\n",(unsigned long)(item->data));
- }
-#endif
-}
-
-unsigned long shListGetCount( SHLIST *head )
-{
- return( (unsigned long)(head->data) );
-}
diff --git a/adb/shlist.h b/adb/shlist.h
deleted file mode 100755
index 0a9b07b..0000000
--- a/adb/shlist.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-------------------------------------------------------------------*/
-/* List Functionality */
-/*-------------------------------------------------------------------*/
-#ifndef _SHLIST_H_
-#define _SHLIST_H_
-
-typedef struct SHLIST_STRUC {
- void *data;
- struct SHLIST_STRUC *next;
- struct SHLIST_STRUC *prev;
-} SHLIST;
-
-typedef int (*shListCmp)( void *valo, void *valn, void *etalon );
-typedef int (*shListPrint)( void *val );
-typedef void (*shListFree)( void *val );
-typedef int (*shListEqual)( void *val, void *idata );
-
-void shListInitList( SHLIST *listPtr );
-SHLIST *shListFindItem( SHLIST *head, void *val, shListEqual func );
-SHLIST *shListGetFirstItem( SHLIST *head );
-SHLIST *shListGetNItem( SHLIST *head, unsigned long num );
-SHLIST *shListGetLastItem( SHLIST *head );
-SHLIST *shListGetNextItem( SHLIST *head, SHLIST *item );
-SHLIST *shListGetPrevItem( SHLIST *head, SHLIST *item );
-void shListDelItem( SHLIST *head, SHLIST *item, shListFree func );
-void shListInsFirstItem( SHLIST *head, void *val );
-void shListInsBeforeItem( SHLIST *head, void *val, void *etalon,
- shListCmp func );
-void shListInsLastItem( SHLIST *head, void *val );
-void shListDelAllItems( SHLIST *head, shListFree func );
-void shListPrintAllItems( SHLIST *head, shListPrint func );
-unsigned long shListGetCount( SHLIST *head );
-
-#endif