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_SOCKET_H |
| 6 #define PACKAGES_LIBRARIES_NACL_MOUNTS_BASE_SOCKET_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/types.h> |
| 14 #include <unistd.h> |
| 15 |
| 16 #include "../base/nacl_dirent.h" |
| 17 |
| 18 class Socket { |
| 19 public: |
| 20 virtual ~Socket() {} |
| 21 |
| 22 virtual void addref() = 0; |
| 23 virtual void release() = 0; |
| 24 |
| 25 virtual void close() = 0; |
| 26 virtual int read(char* buf, size_t count, size_t* nread) = 0; |
| 27 virtual int write(const char* buf, size_t count, size_t* nwrote) = 0; |
| 28 virtual int seek(nacl_abi_off_t offset, int whence, |
| 29 nacl_abi_off_t* new_offset) { |
| 30 return ESPIPE; |
| 31 } |
| 32 virtual int fstat(nacl_abi_stat* out) { |
| 33 memset(out, 0, sizeof(nacl_abi_stat)); |
| 34 return 0; |
| 35 } |
| 36 virtual int getdents(dirent* buf, size_t count, size_t* nread) { |
| 37 return ENOTDIR; |
| 38 } |
| 39 |
| 40 virtual int isatty() { |
| 41 errno = EINVAL; |
| 42 return 0; |
| 43 } |
| 44 |
| 45 virtual int fcntl(int cmd, va_list ap) { |
| 46 errno = EINVAL; |
| 47 return -1; |
| 48 } |
| 49 |
| 50 virtual int ioctl(int request, va_list ap) { |
| 51 errno = EINVAL; |
| 52 return -1; |
| 53 } |
| 54 |
| 55 virtual bool is_read_ready() { |
| 56 return true; |
| 57 } |
| 58 virtual bool is_write_ready() { |
| 59 return true; |
| 60 } |
| 61 virtual bool is_exception() { |
| 62 return false; |
| 63 } |
| 64 }; |
| 65 |
| 66 #endif // PACKAGES_LIBRARIES_NACL_MOUNTS_BASE_SOCKET_H |
| 67 |
OLD | NEW |