version 1.24, 2013/10/10 12:00:21 |
version 1.25, 2013/10/10 12:26:35 |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
|
|
#include <errno.h> |
#include <errno.h> |
|
#include <fcntl.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
struct client *c = cmdq->client; |
struct client *c = cmdq->client; |
struct session *s; |
struct session *s; |
FILE *f; |
FILE *f; |
const char *path, *newpath, *wd; |
const char *path; |
char *pdata, *new_pdata, *cause; |
char *pdata, *new_pdata, *cause; |
size_t psize; |
size_t psize; |
u_int limit; |
u_int limit; |
int ch, error, buffer, *buffer_ptr; |
int ch, error, buffer, *buffer_ptr, cwd, fd; |
|
|
if (!args_has(args, 'b')) |
if (!args_has(args, 'b')) |
buffer = -1; |
buffer = -1; |
|
|
return (CMD_RETURN_WAIT); |
return (CMD_RETURN_WAIT); |
} |
} |
|
|
if (c != NULL) |
if (c != NULL && c->session == NULL) |
wd = c->cwd; |
cwd = c->cwd; |
else if ((s = cmd_current_session(cmdq, 0)) != NULL) { |
else if ((s = cmd_current_session(cmdq, 0)) != NULL) |
wd = options_get_string(&s->options, "default-path"); |
cwd = s->cwd; |
if (*wd == '\0') |
else |
wd = s->cwd; |
cwd = AT_FDCWD; |
} else |
|
wd = NULL; |
if ((fd = openat(cwd, path, O_RDONLY)) == -1 || |
if (wd != NULL && *wd != '\0') { |
(f = fdopen(fd, "rb")) == NULL) { |
newpath = get_full_path(wd, path); |
if (fd != -1) |
if (newpath != NULL) |
close(fd); |
path = newpath; |
|
} |
|
if ((f = fopen(path, "rb")) == NULL) { |
|
cmdq_error(cmdq, "%s: %s", path, strerror(errno)); |
cmdq_error(cmdq, "%s: %s", path, strerror(errno)); |
return (CMD_RETURN_ERROR); |
return (CMD_RETURN_ERROR); |
} |
} |