hi .........i am sending this patch in unifom format.
diff -Nur gpxe-1.0.0/src/hci/readline.c gpxe-1.0.0.new/src/hci/readline.c
--- gpxe-1.0.0/src/hci/readline.c 2010-02-02 21:42:44.000000000 +0530
+++ gpxe-1.0.0.new/src/hci/readline.c 2010-04-07 00:15:35.000000000 +0530
@@ -25,6 +25,7 @@
#include <gpxe/keys.h>
#include <gpxe/editstring.h>
#include <readline/readline.h>
+#include <gpxe/command.h>
/** @file
*
@@ -86,8 +87,12 @@
char * readline ( const char *prompt ) {
char buf[READLINE_MAX];
struct edit_string string;
- int key;
+ int key,tempkey;
char *line;
+ int counter=0;
+ char *cmd=NULL;
+ struct command *command;
+ unsigned int hpos = 0,ref=0;
if ( prompt )
printf ( "%s", prompt );
@@ -98,7 +103,42 @@
buf[0] = '\0';
while ( 1 ) {
- key = edit_string ( &string, getkey() );
+ tempkey=getkey();
+ if(tempkey==TAB){
+ counter=0;
+ for_each_table_entry ( command, COMMANDS )
+ if(!strncmp(string.buf,command->name,strlen(string.buf))){
+ counter+=1;
+ if(cmd!=NULL)
+ free(cmd);
+ cmd=(char*)malloc(sizeof(command->name)+1);
+ strcpy(cmd,command->name);}
+
+ if(counter==1 && cmd!=NULL){
+ for(ref=strlen(string.buf);ref<strlen(cmd);ref++){
+ edit_string ( &string,cmd[ref]);
+ sync_console ( &string );}
+ }
+ else{
+ printf("\n");
+ for_each_table_entry ( command, COMMANDS ){
+ if(!strncmp(string.buf,command->name,strlen(string.buf)))
+ hpos += printf ( " %s", command->name );
+
+ if ( hpos > ( 16 * 4 ) ) {
+ printf ( "\n" );
+ hpos = 0;}
+ else {
+ while ( hpos % 16 ) {
+ printf ( " " );
+ hpos++; }
+ }
+ }
+ printf("\n");
+ printf ( "%s%s", prompt,string.buf);}
+ continue;}
+
+ key = edit_string ( &string, tempkey);
sync_console ( &string );
switch ( key ) {
case CR:
diff -Nur gpxe-1.0.0/src/hci/readline.c~ gpxe-1.0.0.new/src/hci/readline.c~
--- gpxe-1.0.0/src/hci/readline.c~ 1970-01-01 05:30:00.000000000 +0530
+++ gpxe-1.0.0.new/src/hci/readline.c~ 2010-04-06 19:55:23.000000000 +0530
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2006 Michael Brown <[email protected]>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <console.h>
+#include <gpxe/keys.h>
+#include <gpxe/editstring.h>
+#include <readline/readline.h>
+#include <gpxe/command.h>
+
+/** @file
+ *
+ * Minimal readline
+ *
+ */
+
+#define READLINE_MAX 256
+
+static void sync_console ( struct edit_string *string ) __nonnull;
+
+/**
+ * Synchronise console with edited string
+ *
+ * @v string Editable string
+ */
+static void sync_console ( struct edit_string *string ) {
+ unsigned int mod_start = string->mod_start;
+ unsigned int mod_end = string->mod_end;
+ unsigned int cursor = string->last_cursor;
+ size_t len = strlen ( string->buf );
+
+ /* Expand region back to old cursor position if applicable */
+ if ( mod_start > string->last_cursor )
+ mod_start = string->last_cursor;
+
+ /* Expand region forward to new cursor position if applicable */
+ if ( mod_end < string->cursor )
+ mod_end = string->cursor;
+
+ /* Backspace to start of region */
+ while ( cursor > mod_start ) {
+ putchar ( '\b' );
+ cursor--;
+ }
+
+ /* Print modified region */
+ while ( cursor < mod_end ) {
+ putchar ( ( cursor >= len ) ? ' ' : string->buf[cursor] );
+ cursor++;
+ }
+
+ /* Backspace to new cursor position */
+ while ( cursor > string->cursor ) {
+ putchar ( '\b' );
+ cursor--;
+ }
+}
+
+/**
+ * Read line from console
+ *
+ * @v prompt Prompt string
+ * @ret line Line read from console (excluding terminating newline)
+ *
+ * The returned line is allocated with malloc(); the caller must
+ * eventually call free() to release the storage.
+ */
+char * readline ( const char *prompt ) {
+ char buf[READLINE_MAX];
+ struct edit_string string;
+ int key,tempkey;
+ char *line;
+ int counter=0;
+ char *cmd=NULL;
+ struct command *command;
+ unsigned int hpos = 0,ref=0;
+
+ if ( prompt )
+ printf ( "%s", prompt );
+
+ memset ( &string, 0, sizeof ( string ) );
+ string.buf = buf;
+ string.len = sizeof ( buf );
+ buf[0] = '\0';
+
+ while ( 1 ) {
+ tempkey=getkey();
+ if(tempkey==TAB)
+ {
+
+ counter=0;
+ for_each_table_entry ( command, COMMANDS )
+ if(!strncmp(string.buf,command->name,strlen(string.buf))){
+ counter+=1;
+ if(cmd!=NULL)
+ free(cmd);
+ cmd=(char*)malloc(sizeof(command->name)+1);
+ strcpy(cmd,command->name);}
+
+ if(counter==1 && cmd!=NULL)
+ {
+ for(ref=strlen(string.buf);ref<strlen(cmd);ref++)
+ {
+ edit_string ( &string,cmd[ref]);
+ sync_console ( &string );
+ }
+ }
+ else{
+ printf("\n");
+ for_each_table_entry ( command, COMMANDS ) {
+ if(!strncmp(string.buf,command->name,strlen(string.buf)))
+ hpos += printf ( " %s", command->name );
+
+ if ( hpos > ( 16 * 4 ) ) {
+ printf ( "\n" );
+ hpos = 0;}
+ else {
+ while ( hpos % 16 ) {
+ printf ( " " );
+ hpos++;
+ }
+ }
+ }
+ printf("\n");
+ printf ( "%s%s", prompt,string.buf);
+
+ }
+ continue;
+ }
+
+ key = edit_string ( &string, tempkey);
+ sync_console ( &string );
+ switch ( key ) {
+ case CR:
+ case LF:
+ putchar ( '\n' );
+ line = strdup ( buf );
+ if ( ! line )
+ printf ( "Out of memory\n" );
+ return line;
+ case CTRL_C:
+ putchar ( '\n' );
+ return NULL;
+ default:
+ /* Do nothing */
+ break;
+ }
+ }
+}
_______________________________________________
gPXE mailing list
[email protected]
http://etherboot.org/mailman/listinfo/gpxe