Displaying 7 results from an estimated 7 matches for "getttywidth".
2002 Feb 06
2
SFTP Status Bar..
...+/* scp/sftp progression meter (from src/usr.bin/ftp/util.c) */
+static int
+foregroundproc(void)
+{
+ static pid_t pgrp = -1;
+ int ctty_pgrp;
+
+ if (pgrp == -1)
+ pgrp = getpgrp();
+
+ return ((ioctl(STDOUT_FILENO, TIOCGPGRP, &ctty_pgrp) != -1 &&
+ ctty_pgrp == pgrp));
+}
+
+int
+getttywidth(void)
+{
+ struct winsize winsize;
+
+ if (ioctl(fileno(stdout), TIOCGWINSZ, &winsize) != -1)
+ return (winsize.ws_col ? winsize.ws_col : 80);
+ else
+ return (80);
+}
+
+void
+progressmeter(off_t statbytes, off_t totalbytes, char *filename)
+{
+#define STALLTIME 5 /* number of seconds...
2002 Jan 30
1
Quick sftp status indicator.
...ay(&now, (struct timezone *) 0);
+ cursize = statbytes;
+ if (totalbytes != 0) {
+ ratio = 100.0 * cursize / totalbytes;
+ ratio = MAX(ratio, 0);
+ ratio = MIN(ratio, 100);
+ } else
+ ratio = 100;
+
+ snprintf(buf, sizeof(buf), "\r%-20.20s %3d%% ", curfile, ratio);
+
+ barlength = getttywidth() - 51;
+ if (barlength > progressbar_size) {
+ progressbar_size = barlength;
+ progressbar = xrealloc(progressbar, barlength);
+ memset(progressbar, '*', barlength);
+ }
+
+ if (barlength > 0) {
+ i = barlength * ratio / 100;
+ snprintf(buf + strlen(buf), sizeof(buf) - strlen(b...
2002 Feb 02
0
Version two of progressbar for scp/sftp
...zone *) 0);
+ cursize = statbytes;
+ if (totalbytes != 0) {
+ ratio = 100.0 * cursize / totalbytes;
+ ratio = MAX(ratio, 0);
+ ratio = MIN(ratio, 100);
+ } else
+ ratio = 100;
+
+ snprintf(buf, sizeof(buf), "\r%-20.20s %3d%% ", (filename?filename:""), ratio);
+
+ barlength = getttywidth() - 51;
+ if (barlength > progressbar_size) {
+ progressbar_size = barlength;
+ progressbar = xrealloc(progressbar, barlength);
+ memset(progressbar, '*', barlength);
+ }
+
+ if (barlength > 0) {
+ i = barlength * ratio / 100;
+ snprintf(buf + strlen(buf), sizeof(buf) - strlen(b...
2000 Jul 02
1
minor cosmetic bug
The progress metre in scp(1) breaks when the tty is too wide.
This patch is the effortless fix:
###########################################################################
:; diff -u openssh-2.1.1p2/scp.c openssh-2.1.1p2+jhc/scp.c
--- openssh-2.1.1p2+jhc/scp.c Thu Jun 22 07:32:32 2000
+++ openssh-2.1.1p2/scp.c Sat Jul 1 22:15:36 2000
@@ -1176,8 +1176,9 @@
i = barlength *
2002 Jul 13
0
[PATCH]: scp program improved
...ay(&now, (struct timezone *) 0);
- cursize = statbytes;
- if (totalbytes != 0) {
- ratio = 100.0 * cursize / totalbytes;
- ratio = MAX(ratio, 0);
- ratio = MIN(ratio, 100);
- } else
- ratio = 100;
-
- snprintf(buf, sizeof(buf), "\r%-20.20s %3d%% ", curfile, ratio);
-
- barlength = getttywidth() - 51;
- if (barlength > 0) {
- i = barlength * ratio / 100;
- snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
- "|%.*s%*s|", i,
- "*******************************************************"
- "******************************************************...
2000 Aug 24
0
patch for a few things
...+ double rate, abbrevrate;
+ int j;
+ char b;
int ratio, barlength, i, remaining;
char buf[256];
***************
*** 1148,1157 ****
ratio = MIN(ratio, 100);
} else
ratio = 100;
! snprintf(buf, sizeof(buf), "\r%-20.20s %3d%% ", curfile, ratio);
!
! barlength = getttywidth() - 51;
barlength = (barlength <= MAX_BARLENGTH)?barlength:MAX_BARLENGTH;
if (barlength > 0) {
i = barlength * ratio / 100;
--- 1176,1184 ----
ratio = MIN(ratio, 100);
} else
ratio = 100;
+ snprintf(buf, sizeof(buf), "\r%-18.18s %3d%% ", curfile, ratio);
!...
2001 May 12
4
Erase the source file open; specify a tempfile name option
...anged any documentation yet. I'd be glad to if this gets
accepted.
Enjoy,
..wayne..
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: scp.c
@@ -105,6 +105,7 @@
/* Returns width of the terminal (for progress meter calculations). */
int getttywidth(void);
+
int do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout, int argc);
/* Struct for addargs */
@@ -206,9 +207,11 @@
uid_t userid;
int errs, remin, remout;
int pflag, iamremote, iamrecursive, targetshouldbedirectory;
+int eraseflag;
+char *tmpfn = "";
-#define...