OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PACKAGES_LIBRARIES_NACL_MOUNTS_BASE_IO_INTERFACES_H |
| 6 #define PACKAGES_LIBRARIES_NACL_MOUNTS_BASE_IO_INTERFACES_H |
| 7 |
| 8 #include <errno.h> |
| 9 #include <fcntl.h> |
| 10 #include <stdarg.h> |
| 11 #include <string.h> |
| 12 #include <sys/dir.h> |
| 13 #include <sys/ioctl.h> |
| 14 #include <sys/types.h> |
| 15 #include <unistd.h> |
| 16 |
| 17 #include "../base/nacl_dirent.h" |
| 18 |
| 19 class Socket { |
| 20 public: |
| 21 virtual ~Socket() {} |
| 22 |
| 23 virtual void addref() = 0; |
| 24 virtual void release() = 0; |
| 25 |
| 26 virtual void close() = 0; |
| 27 virtual int read(char* buf, size_t count, size_t* nread) = 0; |
| 28 virtual int write(const char* buf, size_t count, size_t* nwrote) = 0; |
| 29 virtual int seek(nacl_abi_off_t offset, int whence, |
| 30 nacl_abi_off_t* new_offset) { |
| 31 return ESPIPE; |
| 32 } |
| 33 virtual int fstat(nacl_abi_stat* out) { |
| 34 memset(out, 0, sizeof(nacl_abi_stat)); |
| 35 return 0; |
| 36 } |
| 37 virtual int getdents(dirent* buf, size_t count, size_t* nread) { |
| 38 return ENOTDIR; |
| 39 } |
| 40 |
| 41 virtual int isatty() { |
| 42 errno = EINVAL; |
| 43 return 0; |
| 44 } |
| 45 virtual int fcntl(int cmd, va_list ap) { |
| 46 errno = EINVAL; |
| 47 return -1; |
| 48 } |
| 49 virtual int ioctl(int request, va_list ap) { |
| 50 errno = EINVAL; |
| 51 return -1; |
| 52 } |
| 53 |
| 54 virtual bool is_read_ready() { |
| 55 return true; |
| 56 } |
| 57 virtual bool is_write_ready() { |
| 58 return true; |
| 59 } |
| 60 virtual bool is_exception() { |
| 61 return false; |
| 62 } |
| 63 }; |
| 64 |
| 65 #endif // PACKAGES_LIBRARIES_NACL_MOUNTS_BASE_IO_INTERFACES_H |
| 66 |
OLD | NEW |