Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 272965 Details for
Bug 367015
app-misc/dtach: scrollback buffer patch
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Scrollback buffer patch for dtach-0.8
scrollback-buffer-0.8.patch (text/plain), 3.10 KB, created by
yannick
on 2011-05-12 18:09:26 UTC
(
hide
)
Description:
Scrollback buffer patch for dtach-0.8
Filename:
MIME Type:
Creator:
yannick
Created:
2011-05-12 18:09:26 UTC
Size:
3.10 KB
patch
obsolete
>From 21ede5c752f1cadcb51d6809964e04387d012133 Mon Sep 17 00:00:00 2001 >From: Justin Bogner <mail@justinbogner.com> >Date: Wed, 30 Jul 2008 16:01:50 -0600 >Subject: [PATCH 2/2] Store a scrollback buffer > >Every time we do I/O, store it in a buffer. >When a new client connects, send them that buffer. >--- > dtach.h | 2 + > master.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 70 insertions(+), 0 deletions(-) > >diff --git a/dtach.h b/dtach.h >index f2f4951..ef47d99 100644 >--- a/dtach.h >+++ b/dtach.h >@@ -124,6 +124,8 @@ struct packet > */ > #define BUFSIZE 4096 > >+#define SCROLLSIZE 8192 >+ > /* This hopefully moves to the bottom of the screen */ > #define EOS "\033[999H" > >diff --git a/master.c b/master.c >index 34cd0fa..4ddc255 100644 >--- a/master.c >+++ b/master.c >@@ -54,6 +54,10 @@ static struct client *clients; > /* The pseudo-terminal created for the child process. */ > static struct pty the_pty; > >+/* The scrollback buffer */ >+static unsigned char scrollback[SCROLLSIZE]; >+static int scroll_end, scroll_full; >+ > #ifndef HAVE_FORKPTY > pid_t forkpty(int *amaster, char *name, struct termios *termp, > struct winsize *winp); >@@ -214,6 +218,66 @@ create_socket(char *name) > return s; > } > >+/* Write the data in *buf into the scrollback buffer */ >+static void >+write_scrollback(unsigned char *buf, int len) >+{ >+ int n; >+ if (len > SCROLLSIZE) >+ { >+ buf = buf + (len - SCROLLSIZE); >+ len = SCROLLSIZE; >+ } >+ >+ n = SCROLLSIZE - scroll_end; >+ if (n >= len) >+ { >+ memcpy(scrollback + scroll_end, buf, >+ len * sizeof(unsigned char)); >+ scroll_end += len * sizeof(unsigned char); >+ scroll_full = 1; >+ } >+ else >+ { >+ memcpy(scrollback + scroll_end, buf, >+ n * sizeof(unsigned char)); >+ scroll_end = len - n; >+ memcpy(scrollback, buf, >+ scroll_end * sizeof(unsigned char)); >+ } >+} >+ >+/* Send the data in the scrollback buffer to client */ >+static void >+send_scrollback(struct client *p) >+{ >+ int written, len; >+ if (scroll_full) >+ { >+ len = SCROLLSIZE - scroll_end; >+ written = 0; >+ while (written < len) >+ { >+ int n = write(p->fd, scrollback + scroll_end + written, >+ len - written); >+ if (n > 0) >+ written += n; >+ else if (n == 0 || errno != EINTR) >+ break; >+ } >+ } >+ len = scroll_end; >+ written = 0; >+ while (written < len) >+ { >+ int n = write(p->fd, scrollback + written, len - written); >+ if (n > 0) >+ written += n; >+ else if (n == 0 || errno != EINTR) >+ break; >+ } >+} >+ > /* Process activity on the pty - Input and terminal changes are sent out to > ** the attached clients. If the pty goes away, we die. */ > static void >@@ -296,6 +360,8 @@ top: > /* Try again if nothing happened. */ > if (!FD_ISSET(s, &readfds) && nclients == 0) > goto top; >+ >+ write_scrollback( buf, len ); > } > > /* Process activity on the control socket */ >@@ -324,6 +390,8 @@ control_activity(int s) > if (p->next) > p->next->pprev = &p->next; > *(p->pprev) = p; >+ >+ send_scrollback( p ); > } > > /* Process activity from a client. */ >-- >1.7.3.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 367015
: 272965 |
272967