Bugzilla – Attachment 159 Details for
Bug 420
sftp client support of "ls [flags] [path [localfile]]"feature
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
diff file for sftp.1
sftp-diff1.txt (text/plain), 4.63 KB, created by
Calvin Cheng
on 2002-10-22 23:46:12 AEST
(
hide
)
Description:
diff file for sftp.1
Filename:
MIME Type:
Creator:
Calvin Cheng
Created:
2002-10-22 23:46:12 AEST
Size:
4.63 KB
patch
obsolete
>*** sftp-int.c.orig Wed Sep 11 20:34:15 2002 >--- sftp-int.c Fri Oct 18 16:01:20 2002 >*************** >*** 555,567 **** > > /* sftp ls.1 replacement for directories */ > static int >! do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag) > { > int n; > SFTP_DIRENT **d; > > if ((n = do_readdir(conn, path, &d)) != 0) > return (n); > > /* Count entries for sort */ > for (n = 0; d[n] != NULL; n++) >--- 555,587 ---- > > /* sftp ls.1 replacement for directories */ > static int >! do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag, >! char *localpath) > { > int n; > SFTP_DIRENT **d; >+ FILE *fp = NULL; >+ FILE *fp1 = NULL; >+ >+ if (localpath) { >+ fp = fopen(localpath, "w"); >+ if (!fp) >+ { >+ error("Can't write to file %s", localpath); >+ return -1; >+ } >+ } >+ >+ if (fp) >+ fp1 = fp; >+ else >+ fp1 = stdout; > > if ((n = do_readdir(conn, path, &d)) != 0) >+ { >+ if (fp) fclose(fp); > return (n); >+ } > > /* Count entries for sort */ > for (n = 0; d[n] != NULL; n++) >*************** >*** 583,598 **** > memset(&sb, 0, sizeof(sb)); > attrib_to_stat(&d[n]->a, &sb); > lname = ls_file(fname, &sb, 1); >! printf("%s\n", lname); > xfree(lname); > } else { > /* XXX - multicolumn display would be nice here */ >! printf("%s\n", fname); > } > > xfree(fname); > } > > free_sftp_dirents(d); > return (0); > } >--- 603,619 ---- > memset(&sb, 0, sizeof(sb)); > attrib_to_stat(&d[n]->a, &sb); > lname = ls_file(fname, &sb, 1); >! fprintf(fp1, "%s\n", lname); > xfree(lname); > } else { > /* XXX - multicolumn display would be nice here */ >! fprintf(fp1, "%s\n", fname); > } > > xfree(fname); > } > >+ if (fp) fclose(fp); > free_sftp_dirents(d); > return (0); > } >*************** >*** 600,611 **** > /* sftp ls.1 replacement which handles path globs */ > static int > do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path, >! int lflag) > { > glob_t g; > int i; > Attrib *a; > struct stat sb; > > memset(&g, 0, sizeof(g)); > >--- 621,634 ---- > /* sftp ls.1 replacement which handles path globs */ > static int > do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path, >! int lflag, char* localpath) > { > glob_t g; > int i; > Attrib *a; > struct stat sb; >+ FILE *fp = NULL; >+ FILE *fp1 = NULL; > > memset(&g, 0, sizeof(g)); > >*************** >*** 628,637 **** > if ((a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) && > S_ISDIR(a->perm)) { > globfree(&g); >! return (do_ls_dir(conn, path, strip_path, lflag)); > } > } > > for (i = 0; g.gl_pathv[i]; i++) { > char *fname, *lname; > >--- 651,675 ---- > if ((a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) && > S_ISDIR(a->perm)) { > globfree(&g); >! return (do_ls_dir(conn, path, strip_path, lflag, localpath)); > } > } > >+ if (localpath) >+ { >+ fp = fopen(localpath, "w"); >+ if (!fp) >+ { >+ error("Can't write to file %s", localpath); >+ return -1; >+ } >+ } >+ >+ if (fp) >+ fp1 = fp; >+ else >+ fp1 = stdout; >+ > for (i = 0; g.gl_pathv[i]; i++) { > char *fname, *lname; > >*************** >*** 650,666 **** > if (a != NULL) > attrib_to_stat(a, &sb); > lname = ls_file(fname, &sb, 1); >! printf("%s\n", lname); > xfree(lname); > } else { > /* XXX - multicolumn display would be nice here */ >! printf("%s\n", fname); > } > xfree(fname); > } > > if (g.gl_pathc) > globfree(&g); > > return (0); > } >--- 688,706 ---- > if (a != NULL) > attrib_to_stat(a, &sb); > lname = ls_file(fname, &sb, 1); >! fprintf(fp1, "%s\n", lname); > xfree(lname); > } else { > /* XXX - multicolumn display would be nice here */ >! fprintf(fp1, "%s\n", fname); > } > xfree(fname); > } > > if (g.gl_pathc) > globfree(&g); >+ if (fp) >+ fclose(fp); > > return (0); > } >*************** >*** 759,764 **** >--- 799,806 ---- > /* Path is optional */ > if (get_pathname(&cp, path1)) > return(-1); >+ if (get_pathname(&cp, path2)) >+ return(-1); > break; > case I_LLS: > case I_SHELL: >*************** >*** 897,903 **** > break; > case I_LS: > if (!path1) { >! do_globbed_ls(conn, *pwd, *pwd, lflag); > break; > } > >--- 939,945 ---- > break; > case I_LS: > if (!path1) { >! do_globbed_ls(conn, *pwd, *pwd, lflag, NULL); > break; > } > >*************** >*** 908,914 **** > > path1 = make_absolute(path1, *pwd); > >! do_globbed_ls(conn, path1, tmp, lflag); > break; > case I_LCHDIR: > if (chdir(path1) == -1) { >--- 950,956 ---- > > path1 = make_absolute(path1, *pwd); > >! do_globbed_ls(conn, path1, tmp, lflag, path2); > break; > case I_LCHDIR: > if (chdir(path1) == -1) {
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 420
:
158
| 159