| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Native Client Authors. All rights reserved. | 2 * Copyright 2008 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
| 4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 | 7 |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <signal.h> | 9 #include <signal.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 out[0] = 0xc0 | (c >> 6); | 95 out[0] = 0xc0 | (c >> 6); |
| 96 out[1] = 0x80 | (c & 0x3f); | 96 out[1] = 0x80 | (c & 0x3f); |
| 97 out += 2; | 97 out += 2; |
| 98 } | 98 } |
| 99 ++shm_addr; | 99 ++shm_addr; |
| 100 } | 100 } |
| 101 // Terminate the result string with 0. | 101 // Terminate the result string with 0. |
| 102 *out = 0; | 102 *out = 0; |
| 103 | 103 |
| 104 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_STRING; | 104 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_STRING; |
| 105 params->outs()[0]->u.sval.str = ret_string; | 105 params->outs()[0]->arrays.str = ret_string; |
| 106 | 106 |
| 107 return true; | 107 return true; |
| 108 } | 108 } |
| 109 | 109 |
| 110 bool RpcWrite(void* obj, plugin::SrpcParams* params) { | 110 bool RpcWrite(void* obj, plugin::SrpcParams* params) { |
| 111 plugin::SharedMemory* shared_memory = | 111 plugin::SharedMemory* shared_memory = |
| 112 reinterpret_cast<plugin::SharedMemory*>(obj); | 112 reinterpret_cast<plugin::SharedMemory*>(obj); |
| 113 uint32_t offset; | 113 uint32_t offset; |
| 114 uint32_t len; | 114 uint32_t len; |
| 115 | 115 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 140 if (offset + len > shared_memory->shm_size()) { | 140 if (offset + len > shared_memory->shm_size()) { |
| 141 params->set_exception_string( | 141 params->set_exception_string( |
| 142 "Offset + length overlaps end of shared memory"); | 142 "Offset + length overlaps end of shared memory"); |
| 143 return false; | 143 return false; |
| 144 } | 144 } |
| 145 | 145 |
| 146 // The input is a JavaScript string, which must consist of UFT-8 | 146 // The input is a JavaScript string, which must consist of UFT-8 |
| 147 // characters with character codes between 0 and 255 inclusive. | 147 // characters with character codes between 0 and 255 inclusive. |
| 148 NaClSrpcArg* str_param = params->ins()[2]; | 148 NaClSrpcArg* str_param = params->ins()[2]; |
| 149 const unsigned char* str = | 149 const unsigned char* str = |
| 150 reinterpret_cast<unsigned const char*>(str_param->u.sval.str); | 150 reinterpret_cast<unsigned const char*>(str_param->arrays.str); |
| 151 uint32_t utf_bytes = | 151 uint32_t utf_bytes = |
| 152 nacl::saturate_cast<uint32_t>(strlen(str_param->u.sval.str)); | 152 nacl::saturate_cast<uint32_t>(strlen(str_param->arrays.str)); |
| 153 unsigned char* shm_addr = | 153 unsigned char* shm_addr = |
| 154 reinterpret_cast<unsigned char*>(shared_memory->shm_addr()) + offset; | 154 reinterpret_cast<unsigned char*>(shared_memory->shm_addr()) + offset; |
| 155 | 155 |
| 156 // TODO(mseaborn): Change this function to use ByteStringFromUTF8(). | 156 // TODO(mseaborn): Change this function to use ByteStringFromUTF8(). |
| 157 for (unsigned int i = 0; i < len;) { | 157 for (unsigned int i = 0; i < len;) { |
| 158 unsigned char c1 = str[0]; | 158 unsigned char c1 = str[0]; |
| 159 unsigned char c2 = 0; | 159 unsigned char c2 = 0; |
| 160 | 160 |
| 161 // Check that we are still pointing into the JavaScript string we were | 161 // Check that we are still pointing into the JavaScript string we were |
| 162 // passed. | 162 // passed. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 // plugin_->effp_, | 291 // plugin_->effp_, |
| 292 // addr_, | 292 // addr_, |
| 293 // size_); | 293 // size_); |
| 294 // } | 294 // } |
| 295 // TODO(sehr): is there a missing delete desc() here? | 295 // TODO(sehr): is there a missing delete desc() here? |
| 296 // TODO(gregoryd): in addition, should we unref the descriptor if it was | 296 // TODO(gregoryd): in addition, should we unref the descriptor if it was |
| 297 // constructed during the initialization of this object? | 297 // constructed during the initialization of this object? |
| 298 } | 298 } |
| 299 | 299 |
| 300 } // namespace plugin | 300 } // namespace plugin |
| OLD | NEW |