[BACK]Return to sftp-glob.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/sftp-glob.c between version 1.8 and 1.8.2.2

version 1.8, 2001/07/14 15:10:17 version 1.8.2.2, 2002/10/11 14:53:07
Line 1 
Line 1 
 /*  /*
  * Copyright (c) 2001 Damien Miller.  All rights reserved.   * Copyright (c) 2001,2002 Damien Miller.  All rights reserved.
  *   *
  * Redistribution and use in source and binary forms, with or without   * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions   * modification, are permitted provided that the following conditions
Line 43 
Line 43 
 };  };
   
 static struct {  static struct {
         int fd_in;          struct sftp_conn *conn;
         int fd_out;  
 } cur;  } cur;
   
 static void *  static void *
 fudge_opendir(const char *path)  fudge_opendir(const char *path)
 {  {
         struct SFTP_OPENDIR *r;          struct SFTP_OPENDIR *r;
   
         r = xmalloc(sizeof(*r));          r = xmalloc(sizeof(*r));
   
         if (do_readdir(cur.fd_in, cur.fd_out, (char*)path, &r->dir))          if (do_readdir(cur.conn, (char *)path, &r->dir)) {
                   xfree(r);
                 return(NULL);                  return(NULL);
           }
   
         r->offset = 0;          r->offset = 0;
   
         return((void*)r);          return((void *)r);
 }  }
   
 static struct dirent *  static struct dirent *
 fudge_readdir(struct SFTP_OPENDIR *od)  fudge_readdir(struct SFTP_OPENDIR *od)
 {  {
         static struct dirent ret;          static struct dirent ret;
   
         if (od->dir[od->offset] == NULL)          if (od->dir[od->offset] == NULL)
                 return(NULL);                  return(NULL);
   
Line 84 
Line 85 
         xfree(od);          xfree(od);
 }  }
   
 static void  
 attrib_to_stat(Attrib *a, struct stat *st)  
 {  
         memset(st, 0, sizeof(*st));  
   
         if (a->flags & SSH2_FILEXFER_ATTR_SIZE)  
                 st->st_size = a->size;  
         if (a->flags & SSH2_FILEXFER_ATTR_UIDGID) {  
                 st->st_uid = a->uid;  
                 st->st_gid = a->gid;  
         }  
         if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS)  
                 st->st_mode = a->perm;  
         if (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME) {  
                 st->st_atime = a->atime;  
                 st->st_mtime = a->mtime;  
         }  
 }  
   
 static int  static int
 fudge_lstat(const char *path, struct stat *st)  fudge_lstat(const char *path, struct stat *st)
 {  {
         Attrib *a;          Attrib *a;
   
         if (!(a = do_lstat(cur.fd_in, cur.fd_out, (char*)path, 0)))          if (!(a = do_lstat(cur.conn, (char *)path, 0)))
                 return(-1);                  return(-1);
   
         attrib_to_stat(a, st);          attrib_to_stat(a, st);
   
         return(0);          return(0);
 }  }
   
Line 120 
Line 102 
 fudge_stat(const char *path, struct stat *st)  fudge_stat(const char *path, struct stat *st)
 {  {
         Attrib *a;          Attrib *a;
   
         if (!(a = do_stat(cur.fd_in, cur.fd_out, (char*)path, 0)))          if (!(a = do_stat(cur.conn, (char *)path, 0)))
                 return(-1);                  return(-1);
   
         attrib_to_stat(a, st);          attrib_to_stat(a, st);
   
         return(0);          return(0);
 }  }
   
 int  int
 remote_glob(int fd_in, int fd_out, const char *pattern, int flags,  remote_glob(struct sftp_conn *conn, const char *pattern, int flags,
     int (*errfunc)(const char *, int), glob_t *pglob)      int (*errfunc)(const char *, int), glob_t *pglob)
 {  {
         pglob->gl_opendir = fudge_opendir;          pglob->gl_opendir = fudge_opendir;
Line 138 
Line 120 
         pglob->gl_closedir = (void (*)(void *))fudge_closedir;          pglob->gl_closedir = (void (*)(void *))fudge_closedir;
         pglob->gl_lstat = fudge_lstat;          pglob->gl_lstat = fudge_lstat;
         pglob->gl_stat = fudge_stat;          pglob->gl_stat = fudge_stat;
   
         memset(&cur, 0, sizeof(cur));          memset(&cur, 0, sizeof(cur));
         cur.fd_in = fd_in;          cur.conn = conn;
         cur.fd_out = fd_out;  
   
         return(glob(pattern, flags | GLOB_ALTDIRFUNC, errfunc,          return(glob(pattern, flags | GLOB_ALTDIRFUNC, errfunc, pglob));
             pglob));  
 }  }

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.8.2.2