version 1.9, 2001/12/19 07:18:56 |
version 1.10, 2002/02/13 00:59:23 |
|
|
/* |
/* |
* 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 |
|
|
}; |
}; |
|
|
static struct { |
static struct { |
int fd_in; |
struct sftp_conn *conn; |
int fd_out; |
|
} cur; |
} cur; |
|
|
static void * |
static void * |
|
|
|
|
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)) |
return(NULL); |
return(NULL); |
|
|
r->offset = 0; |
r->offset = 0; |
|
|
{ |
{ |
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); |
|
|
{ |
{ |
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); |
|
|
} |
} |
|
|
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; |
|
|
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)); |
|
} |
} |