summaryrefslogtreecommitdiffstats
path: root/readline.c
Commit message (Collapse)AuthorAgeFilesLines
* monitor: avoid use of global *cur_mon in readline_completion()Wenchao Xia2013-08-301-2/+1Star
| | | | | | | | | | | | | Now all completion functions do not use *cur_mon any more, instead they use rs->mon. In short, structure ReadLineState decide where the complete action would be taken now. Tested with the case that qemu have two telnet monitors, auto completion function works normal. Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* monitor: avoid use of global *cur_mon in monitor_find_completion()Wenchao Xia2013-08-301-1/+1
| | | | | | | | | | Parameter *mon is added, and local variable *mon added in previous patch is removed. The caller readline_completion(), pass rs->mon as value, which should be initialized in readline_init() called by monitor_init(). Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* readline: Handle xterm escape sequences for Home/End keysKevin Wolf2013-05-141-0/+15
| | | | | | | | This fixes the Home/End keys in the monitor using the GTK frontend. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-id: 1368526554-15866-1-git-send-email-kwolf@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* readline: Fix unchecked strdup() by converting to g_strdup()Markus Armbruster2013-01-301-2/+2
| | | | | | Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* readline: avoid memcpy() of overlapping regionsNickolai Zeldovich2013-01-081-2/+2
| | | | | | | | | | | memcpy() for overlapping regions is undefined behavior; use memmove() instead in readline_hist_add(). [Keep tab characters since surrounding code still uses them -- Stefan] Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* monitor: move include files to include/monitor/Paolo Bonzini2012-12-191-2/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* monitor: Fix memory leak with readline completionStefan Weil2012-06-111-0/+3
| | | | | | | | | | Each string which is shown during readline completion in the QEMU monitor is allocated dynamically but currently never deallocated. Add the missing loop which calls g_free for the allocated strings. Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* readline: Fix buffer overrun on re-add to historyMarkus Armbruster2011-11-071-1/+1
| | | | | | | | | | | | | | | | readline_hist_add() moves the history entry to the end of history. It uses memmove() to move rs->history[idx + 1..] to rs->history[idx..]. However, its size argument is off by two array elements, so it writes one element beyond rs->history[], and reads two. On my system, this clobbers rs->hist_entry and the hole right after it. Since the function assigns to rs->hist_entry in time, the bug has no ill effects for me. Spotted by Coverity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* Use glib memory allocation and free functionsAnthony Liguori2011-08-211-4/+4
| | | | | | qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* cope with printf macro definition in readline.cPaolo Bonzini2010-02-081-0/+1
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: malc <av1474@comtv.ru>
* Revert "On some systems printf is a macro"malc2010-02-081-4/+0Star
| | | | This reverts commit bc5b6004588ad17370e0416e40b4aa9cf977023b.
* On some systems printf is a macromalc2010-02-071-0/+4
| | | | Signed-off-by: malc <av1474@comtv.ru>
* readline: Remove unneeded qemu_mallocz() checkLuiz Capitulino2009-06-161-3/+0Star
| | | | | | | | qemu_mallocz() already checks for NULL returns, readline_init() doesn't have to do it again. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* monitor: Provide empty command as final history entry (Jan Kiszka)aliguori2009-03-131-3/+5
| | | | | | | | | | | Provide an empty line as last entry in command line history, just like bash e.g. does. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6842 c046a42c-6fe2-441c-8c8c-71466251a162
* monitor: Improve mux'ed console experience (Jan Kiszka)aliguori2009-03-061-0/+5
| | | | | | | | | | | | | | | Up to now, you never really knew if you already switched the console after pressing CTRL-A C or if you mistyped it again. This patch clarifies the situation by providing a prompt in a new line and injecting a linebreak when switching away again. For this purpose, the two events CHR_EVENT_MUX_IN and CHR_EVENT_MUX_OUT are introduced and distributed on focus switches. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6716 c046a42c-6fe2-441c-8c8c-71466251a162
* monitor: Introduce ReadLineState (Jan Kiszka)aliguori2009-03-061-207/+189Star
| | | | | | | | | | | | | As another step towards decoupled monitor terminals encapsulate the state of the readline processor in a separate data structure called ReadLineState and adapt all interfaces appropriately. For now the monitor continues to instantiate just a single readline state. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6714 c046a42c-6fe2-441c-8c8c-71466251a162
* monitor: Rework API (Jan Kiszka)aliguori2009-03-061-18/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor the monitor API and prepare it for decoupled terminals: term_print functions are renamed to monitor_* and all monitor services gain a new parameter (mon) that will once refer to the monitor instance the output is supposed to appear on. However, the argument remains unused for now. All monitor command callbacks are also extended by a mon parameter so that command handlers are able to pass an appropriate reference to monitor output services. For the case that monitor outputs so far happen without clearly identifiable context, the global variable cur_mon is introduced that shall once provide a pointer either to the current active monitor (while processing commands) or to the default one. On the mid or long term, those use case will be obsoleted so that this variable can be removed again. Due to the broad usage of the monitor interface, this patch mostly deals with converting users of the monitor API. A few of them are already extended to pass 'mon' from the command handler further down to internal functions that invoke monitor_printf. At this chance, monitor-related prototypes are moved from console.h to a new monitor.h. The same is done for the readline API. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6711 c046a42c-6fe2-441c-8c8c-71466251a162
* monitor: Break out readline_show_prompt (Jan Kiszka)aliguori2009-03-061-10/+4Star
| | | | | | | | | | | Break readline_show_prompt out of readline_start so that (re-)printing the prompt can be controlled in a more fine-grained way. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6709 c046a42c-6fe2-441c-8c8c-71466251a162
* toplevel: remove error handling from qemu_malloc() callers (Avi Kivity)aliguori2009-02-051-2/+0Star
| | | | | | | | Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6531 c046a42c-6fe2-441c-8c8c-71466251a162
* Remove unnecessary trailing newlinesblueswir12008-12-131-2/+0Star
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6000 c046a42c-6fe2-441c-8c8c-71466251a162
* Attached patch fixes a series of this warningblueswir12008-11-161-2/+2
| | | | | | | | | | | when compiling on NetBSD: warning: array subscript has type 'char' Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5727 c046a42c-6fe2-441c-8c8c-71466251a162
* Handle history additions properly, by Andreas Schwab.ths2007-12-171-2/+2
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3835 c046a42c-6fe2-441c-8c8c-71466251a162
* Break up vl.h.pbrook2007-11-171-1/+2
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3674 c046a42c-6fe2-441c-8c8c-71466251a162
* Improve completion in monitor, by Pascal Terjan.ths2007-09-251-1/+16
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3233 c046a42c-6fe2-441c-8c8c-71466251a162
* find -type f | xargs sed -i 's/[\t ]*$//g' # Yes, again. Note the star in ↵ths2007-09-171-1/+1
| | | | | | the regex. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3177 c046a42c-6fe2-441c-8c8c-71466251a162
* find -type f | xargs sed -i 's/[\t ]$//g' # on most filesths2007-09-161-4/+4
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3173 c046a42c-6fe2-441c-8c8c-71466251a162
* Reset buffer pointers after CR/LF, by Jim Paris.ths2007-08-261-0/+4
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3145 c046a42c-6fe2-441c-8c8c-71466251a162
* Implement ^W in readline.c, by Michal Hanselmann.ths2007-06-251-0/+43
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3016 c046a42c-6fe2-441c-8c8c-71466251a162
* separated readline from monitor code - added password input support - added ↵bellard2004-08-011-0/+425
output buffer git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1034 c046a42c-6fe2-441c-8c8c-71466251a162