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