Commit 4e862be0 authored by sbc@chromium.org's avatar sbc@chromium.org

[NaCl SDK] nacl_io: fix TTY warning messages when using naclterm/hterm.

Passing strings rather than arraybuffers to the tty node is still
the only supported way to go, so don't warn about this method
being depreceated just yet :)

R=binji@chromium.org, binji

Review URL: https://codereview.chromium.org/318153004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275611 0039d316-1c4b-4281-b951-d872f2087c98
parent ea71697a
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
#define LOG_ERROR(format, ...) \ #define LOG_ERROR(format, ...) \
nacl_io_log(LOG_PREFIX "error: " format "\n", ##__VA_ARGS__) nacl_io_log(LOG_PREFIX "error: " format "\n", ##__VA_ARGS__)
#define LOG_WARN(format, ...) \
nacl_io_log(LOG_PREFIX "warning: " format "\n", ##__VA_ARGS__)
EXTERN_C_BEGIN EXTERN_C_BEGIN
/* /*
......
...@@ -409,12 +409,8 @@ void PSInstance::MessageHandlerInput(const pp::Var& key, ...@@ -409,12 +409,8 @@ void PSInstance::MessageHandlerInput(const pp::Var& key,
const pp::Var& message) { const pp::Var& message) {
std::string key_string = key.AsString(); std::string key_string = key.AsString();
// Legacy support for passing TTY data as a string, rather than a array
// buffer. TODO(sbc): remove this in a future release.
if (message.is_string() && key_string == tty_prefix_) { if (message.is_string() && key_string == tty_prefix_) {
std::string buffer = message.AsString(); std::string buffer = message.AsString();
Warn("Passing TTY input as a string is deprected. Please use a "
"JavaScript ArrayBuffer instead");
// Since our message may contain null characters, we can't send it as a // Since our message may contain null characters, we can't send it as a
// naked C string, so we package it up in this struct before sending it // naked C string, so we package it up in this struct before sending it
...@@ -422,11 +418,11 @@ void PSInstance::MessageHandlerInput(const pp::Var& key, ...@@ -422,11 +418,11 @@ void PSInstance::MessageHandlerInput(const pp::Var& key,
struct tioc_nacl_input_string ioctl_message; struct tioc_nacl_input_string ioctl_message;
ioctl_message.length = buffer.size(); ioctl_message.length = buffer.size();
ioctl_message.buffer = buffer.c_str(); ioctl_message.buffer = buffer.c_str();
int ret = int ret = ioctl(tty_fd_, TIOCNACLINPUT, &ioctl_message);
ioctl(tty_fd_, TIOCNACLINPUT, &ioctl_message);
if (ret != 0 && errno != ENOTTY) { if (ret != 0 && errno != ENOTTY) {
Error("ioctl returned unexpected error: %d.\n", ret); Error("ioctl returned unexpected error: %d.\n", ret);
} }
return;
} }
if (!message.is_array_buffer()) { if (!message.is_array_buffer()) {
...@@ -532,12 +528,12 @@ void PSInstance::PostEvent(PSEventType type, const PP_Var& var) { ...@@ -532,12 +528,12 @@ void PSInstance::PostEvent(PSEventType type, const PP_Var& var) {
// Legacy support for passing TTY input as a string <prefix>:<payload> // Legacy support for passing TTY input as a string <prefix>:<payload>
// TODO(sbc): remove this in a future release. // TODO(sbc): remove this in a future release.
if (tty_fd_ >= 0 && event.is_string()) { if (tty_fd_ >= 0 && event.is_string()) {
Warn("passing TTY data using a string prefix is deprected."
" Use a JavaScript dictionary instead.");
std::string message = event.AsString(); std::string message = event.AsString();
size_t prefix_len = strlen(tty_prefix_); size_t prefix_len = strlen(tty_prefix_);
if (message.size() > prefix_len) { if (message.size() > prefix_len) {
if (!strncmp(message.c_str(), tty_prefix_, prefix_len)) { if (!strncmp(message.c_str(), tty_prefix_, prefix_len)) {
LOG_WARN("Passing TTY data using a string prefix is deprecated. "
"Use a JavaScript dictionary instead.");
MessageHandlerInput(pp::Var(message.substr(0, prefix_len)), MessageHandlerInput(pp::Var(message.substr(0, prefix_len)),
pp::Var(message.substr(prefix_len))); pp::Var(message.substr(prefix_len)));
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment