예제 #1
0
static void
send_status(u_int32_t id, u_int32_t status)
{
	struct sshbuf *msg;
	int r;

	debug3("request %u: sent status %u", id, status);
	if (log_level > SYSLOG_LEVEL_VERBOSE ||
	    (status != SSH2_FX_OK && status != SSH2_FX_EOF))
		logit("sent status %s", status_to_message(status));
	if ((msg = sshbuf_new()) == NULL)
		fatal("%s: sshbuf_new failed", __func__);
	if ((r = sshbuf_put_u8(msg, SSH2_FXP_STATUS)) != 0 ||
	    (r = sshbuf_put_u32(msg, id)) != 0 ||
	    (r = sshbuf_put_u32(msg, status)) != 0)
		fatal("%s: buffer error: %s", __func__, ssh_err(r));
	if (version >= 3) {
		if ((r = sshbuf_put_cstring(msg,
		    status_to_message(status))) != 0 ||
		    (r = sshbuf_put_cstring(msg, "")) != 0)
			fatal("%s: buffer error: %s", __func__, ssh_err(r));
	}
	send_msg(msg);
	sshbuf_free(msg);
}
예제 #2
0
static void
send_status(u_int32_t id, u_int32_t status)
{
	Buffer msg;

	debug3("request %u: sent status %u", id, status);
	if (log_level > SYSLOG_LEVEL_VERBOSE ||
	    (status != SSH2_FX_OK && status != SSH2_FX_EOF))
		logit("sent status %s", status_to_message(status));
	buffer_init(&msg);
	buffer_put_char(&msg, SSH2_FXP_STATUS);
	buffer_put_int(&msg, id);
	buffer_put_int(&msg, status);
	if (version >= 3) {
		buffer_put_cstring(&msg, status_to_message(status));
		buffer_put_cstring(&msg, "");
	}
	send_msg(&msg);
	buffer_free(&msg);
}
예제 #3
0
파일: ldap.c 프로젝트: LuaDist/lua-apr
static int push_ldap_error(lua_State *L, apr_status_t status, apr_ldap_err_t *error)
{
  if (error == NULL)
    return push_error_status(L, status);

  lua_pushnil(L);
  if (error->reason != NULL && error->msg != NULL) {
    /* "reason" is from APR and "msg" is from the LDAP SDK. */
    lua_pushfstring(L, "%s (%s)", error->reason, error->msg);
    lua_pushinteger(L, error->rc);
  } else if (error->reason != NULL) {
    /* Some APR functions fill in "reason" but not "msg". */
    lua_pushstring(L, error->reason);
    lua_pushinteger(L, error->rc);
  } else {
    /* Not sure this is needed. */
    status_to_message(L, status);
    status_to_name(L, status);
  }

  return 3;
}