本文整理汇总了C++中send_status函数的典型用法代码示例。如果您正苦于以下问题:C++ send_status函数的具体用法?C++ send_status怎么用?C++ send_status使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_status函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process_extended_fsync
static void
process_extended_fsync(u_int32_t id)
{
int handle, fd, r, status = SSH2_FX_OP_UNSUPPORTED;
if ((r = get_handle(iqueue, &handle)) != 0)
fatal("%s: buffer error: %s", __func__, ssh_err(r));
debug3("request %u: fsync (handle %u)", id, handle);
verbose("fsync \"%s\"", handle_to_name(handle));
if ((fd = handle_to_fd(handle)) < 0)
status = SSH2_FX_NO_SUCH_FILE;
else if (handle_is_ok(handle, HANDLE_FILE)) {
r = fsync(fd);
status = (r == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
}
send_status(id, status);
}
示例2: process_setstat
static void
process_setstat(u_int32_t id)
{
Attrib a;
char *name;
int r, status = SSH2_FX_OK;
if ((r = sshbuf_get_cstring(iqueue, &name, NULL)) != 0 ||
(r = decode_attrib(iqueue, &a)) != 0)
fatal("%s: buffer error: %s", __func__, ssh_err(r));
debug("request %u: setstat name \"%s\"", id, name);
if (a.flags & SSH2_FILEXFER_ATTR_SIZE) {
logit("set \"%s\" size %llu",
name, (unsigned long long)a.size);
r = truncate(name, a.size);
if (r == -1)
status = errno_to_portable(errno);
}
if (a.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) {
logit("set \"%s\" mode %04o", name, a.perm);
r = chmod(name, a.perm & 07777);
if (r == -1)
status = errno_to_portable(errno);
}
if (a.flags & SSH2_FILEXFER_ATTR_ACMODTIME) {
char buf[64];
time_t t = a.mtime;
strftime(buf, sizeof(buf), "%Y%m%d-%H:%M:%S",
localtime(&t));
logit("set \"%s\" modtime %s", name, buf);
r = utimes(name, attrib_to_tv(&a));
if (r == -1)
status = errno_to_portable(errno);
}
if (a.flags & SSH2_FILEXFER_ATTR_UIDGID) {
logit("set \"%s\" owner %lu group %lu", name,
(u_long)a.uid, (u_long)a.gid);
r = chown(name, a.uid, a.gid);
if (r == -1)
status = errno_to_portable(errno);
}
send_status(id, status);
free(name);
}
示例3: switch
bool RNGDevice::run(SerialCommand *cmd)
{
// comment out for the optimization
//if (cmd == NULL) return false;
SerialCommandType type = cmd->get_type();
if (type == CMD_RNG_SEND) { // cmd from read()
switch ((RNGSendCommand)cmd->get_id()) {
case RNG_SEND_PAYLOAD: {
// in case it's forced
if (payload_len <= 0) return false;
#ifdef DEBUG
printf_P(PSTR("Payload [RNG]"));
for (uint16_t i = 0; i < payload_len; i++) printf_P(PSTR(" %02X"), payload[i]);
printf_P(PSTR("\r\n"));
#endif
if (!send(cmd, (const unsigned char *)&payload, payload_len)) {
payload_len = 0;
return false;
}
payload_len = 0;
break;
}
default:
return false;
}
} else if (type == CMD_RNG) {
switch ((RNGCommand)cmd->get_id()) {
case RNG_FLOOD_ON: // R0
flood = true;
break;
case RNG_FLOOD_OFF: // R1
payload_len = 0;
flood = false;
break; // calibration will be started on-the-fly
case RNG_STATUS: // R2
if (!send_status(cmd)) return false;
break;
default:
return false;
}
}
return true;
}
示例4: process_extended
static void
process_extended(void)
{
u_int32_t id;
char *request;
id = get_int();
request = get_string(NULL);
if (strcmp(request, "[email protected]") == 0)
process_extended_posix_rename(id);
else if (strcmp(request, "[email protected]") == 0)
process_extended_statvfs(id);
else if (strcmp(request, "[email protected]") == 0)
process_extended_fstatvfs(id);
else
send_status(id, SSH2_FX_OP_UNSUPPORTED); /* MUST */
xfree(request);
}
示例5: process_mkdir
static void
process_mkdir(u_int32_t id)
{
Attrib *a;
char *name;
int ret, mode, status = SSH2_FX_FAILURE;
name = get_string(NULL);
a = get_attrib();
mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ?
a->perm & 07777 : 0777;
debug3("request %u: mkdir", id);
logit("mkdir name \"%s\" mode 0%o", name, mode);
ret = mkdir(name, mode);
status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
send_status(id, status);
free(name);
}
示例6: process_extended_statvfs
static void
process_extended_statvfs(u_int32_t id)
{
char *path;
struct statvfs st;
int r;
if ((r = sshbuf_get_cstring(iqueue, &path, NULL)) != 0)
fatal("%s: buffer error: %s", __func__, ssh_err(r));
debug3("request %u: statvfs", id);
logit("statvfs \"%s\"", path);
if (statvfs(path, &st) != 0)
send_status(id, errno_to_portable(errno));
else
send_statvfs(id, &st);
free(path);
}
示例7: process_extended_hardlink
static void
process_extended_hardlink(u_int32_t id)
{
char *oldpath, *newpath;
int r, status;
if ((r = sshbuf_get_cstring(iqueue, &oldpath, NULL)) != 0 ||
(r = sshbuf_get_cstring(iqueue, &newpath, NULL)) != 0)
fatal("%s: buffer error: %s", __func__, ssh_err(r));
debug3("request %u: hardlink", id);
logit("hardlink old \"%s\" new \"%s\"", oldpath, newpath);
r = link(oldpath, newpath);
status = (r == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
send_status(id, status);
free(oldpath);
free(newpath);
}
示例8: process_setstat
static void
process_setstat(u_int32_t id)
{
Attrib *a;
char *name;
int status = SSH2_FX_OK, ret;
name = get_string(NULL);
a = get_attrib();
debug("request %u: setstat name \"%s\"", id, name);
if (a->flags & SSH2_FILEXFER_ATTR_SIZE) {
logit("set \"%s\" size %llu",
name, (unsigned long long)a->size);
ret = truncate(name, a->size);
if (ret == -1)
status = errno_to_portable(errno);
}
if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) {
logit("set \"%s\" mode %04o", name, a->perm);
ret = chmod(name, a->perm & 07777);
if (ret == -1)
status = errno_to_portable(errno);
}
if (a->flags & SSH2_FILEXFER_ATTR_ACMODTIME) {
char buf[64];
time_t t = a->mtime;
strftime(buf, sizeof(buf), "%Y%m%d-%H:%M:%S",
localtime(&t));
logit("set \"%s\" modtime %s", name, buf);
ret = utimes(name, attrib_to_tv(a));
if (ret == -1)
status = errno_to_portable(errno);
}
if (a->flags & SSH2_FILEXFER_ATTR_UIDGID) {
logit("set \"%s\" owner %lu group %lu", name,
(u_long)a->uid, (u_long)a->gid);
ret = chown(name, a->uid, a->gid);
if (ret == -1)
status = errno_to_portable(errno);
}
send_status(id, status);
free(name);
}
示例9: process_write
static void
process_write(void)
{
u_int32_t id;
u_int64_t off;
u_int len;
int handle, fd, ret, status;
char *data;
id = get_int();
handle = get_handle();
off = get_int64();
data = get_string(&len);
debug("request %u: write \"%s\" (handle %d) off %llu len %d",
id, handle_to_name(handle), handle, (unsigned long long)off, len);
fd = handle_to_fd(handle);
if (fd < 0)
status = SSH2_FX_FAILURE;
else if (readonly)
status = SSH2_FX_PERMISSION_DENIED;
else {
if (lseek(fd, off, SEEK_SET) < 0) {
status = errno_to_portable(errno);
error("process_write: seek failed");
} else {
/* XXX ATOMICIO ? */
ret = write(fd, data, len);
if (ret < 0) {
error("process_write: write failed");
status = errno_to_portable(errno);
} else if ((size_t)ret == len) {
status = SSH2_FX_OK;
handle_update_write(handle, ret);
} else {
debug2("nothing at all written");
status = SSH2_FX_FAILURE;
}
}
}
send_status(id, status);
xfree(data);
}
示例10: process_mkdir
static void
process_mkdir(void)
{
Attrib *a;
u_int32_t id;
char *name;
int ret, mode, status = SSH2_FX_FAILURE;
id = get_int();
name = get_string(NULL);
a = get_attrib();
mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ?
a->perm & 0777 : 0777;
TRACE("mkdir id %u name %s mode 0%o", id, name, mode);
ret = mkdir(name, mode);
status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
send_status(id, status);
xfree(name);
}
示例11: get_int
void SFTP::process_remove(void)
{
char *utf8_name;
u_int32_t id;
int status = SSH2_FX_FAILURE;
id = get_int();
utf8_name = (char*) get_string(NULL);
debug3("request %u: remove", (unsigned) id);
logit("remove name \"%s\"", utf8_name);
const SFTPFilePath path = pathFact.create_path (utf8_name);
BOOL res = ::DeleteFileW (path.get_for_call ().c_str ());
status = (!res)
? errno_to_portable(::GetLastError ())
: SSH2_FX_OK;
send_status(id, status);
xfree(utf8_name);
}
示例12: process_reply
static int process_reply(int sock, int type,
struct iovec *out_iovec, int retval)
{
switch (type) {
case T_OPEN:
case T_CREATE:
if (send_fd(sock, retval) < 0) {
return -1;
}
break;
case T_MKNOD:
case T_MKDIR:
case T_SYMLINK:
case T_LINK:
case T_CHMOD:
case T_CHOWN:
case T_TRUNCATE:
case T_UTIME:
case T_RENAME:
case T_REMOVE:
case T_LSETXATTR:
case T_LREMOVEXATTR:
if (send_status(sock, out_iovec, retval) < 0) {
return -1;
}
break;
case T_LSTAT:
case T_STATFS:
case T_READLINK:
case T_LGETXATTR:
case T_LLISTXATTR:
case T_GETVERSION:
if (send_response(sock, out_iovec, retval) < 0) {
return -1;
}
break;
default:
return -1;
break;
}
return 0;
}
示例13: process_write
static void
process_write(u_int32_t id)
{
u_int64_t off;
size_t len;
int r, handle, fd, ret, status;
u_char *data;
if ((r = get_handle(iqueue, &handle)) != 0 ||
(r = sshbuf_get_u64(iqueue, &off)) != 0 ||
(r = sshbuf_get_string(iqueue, &data, &len)) != 0)
fatal("%s: buffer error: %s", __func__, ssh_err(r));
debug("request %u: write \"%s\" (handle %d) off %llu len %zu",
id, handle_to_name(handle), handle, (unsigned long long)off, len);
fd = handle_to_fd(handle);
if (fd < 0)
status = SSH2_FX_FAILURE;
else {
if (!(handle_to_flags(handle) & O_APPEND) &&
lseek(fd, off, SEEK_SET) < 0) {
status = errno_to_portable(errno);
error("process_write: seek failed");
} else {
/* XXX ATOMICIO ? */
ret = write(fd, data, len);
if (ret < 0) {
error("process_write: write failed");
status = errno_to_portable(errno);
} else if ((size_t)ret == len) {
status = SSH2_FX_OK;
handle_update_write(handle, ret);
} else {
debug2("nothing at all written");
status = SSH2_FX_FAILURE;
}
}
}
send_status(id, status);
free(data);
}
示例14: process_rmdir
static void
process_rmdir(void)
{
u_int32_t id;
char *name;
int ret, status;
id = get_int();
name = get_string(NULL);
debug3("request %u: rmdir", id);
logit("rmdir name \"%s\"", name);
if (readonly)
status = SSH2_FX_PERMISSION_DENIED;
else {
ret = rmdir(name);
status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
}
send_status(id, status);
xfree(name);
}
示例15: process_mkdir
static void
process_mkdir(u_int32_t id)
{
Attrib a;
char *name;
int r, mode, status = SSH2_FX_FAILURE;
if ((r = sshbuf_get_cstring(iqueue, &name, NULL)) != 0 ||
(r = decode_attrib(iqueue, &a)) != 0)
fatal("%s: buffer error: %s", __func__, ssh_err(r));
mode = (a.flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ?
a.perm & 07777 : 0777;
debug3("request %u: mkdir", id);
logit("mkdir name \"%s\" mode 0%o", name, mode);
r = mkdir(name, mode);
status = (r == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
send_status(id, status);
free(name);
}