OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // Written in NSPR style to also be suitable for adding to the NSS demo suite | 4 // Written in NSPR style to also be suitable for adding to the NSS demo suite |
5 | 5 |
6 #ifndef __MEMIO_H | 6 #ifndef __MEMIO_H |
7 #define __MEMIO_H | 7 #define __MEMIO_H |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 * memio did not result in PR_WOULD_BLOCK_ERROR, returns 0. | 56 * memio did not result in PR_WOULD_BLOCK_ERROR, returns 0. |
57 */ | 57 */ |
58 int memio_GetReadRequest(memio_Private *secret); | 58 int memio_GetReadRequest(memio_Private *secret); |
59 | 59 |
60 /* Ask memio where to put bytes from the network, and how many it can handle. | 60 /* Ask memio where to put bytes from the network, and how many it can handle. |
61 * Returns bytes available to write, or 0 if none available. | 61 * Returns bytes available to write, or 0 if none available. |
62 * Puts current buffer position into *buf. | 62 * Puts current buffer position into *buf. |
63 */ | 63 */ |
64 int memio_GetReadParams(memio_Private *secret, char **buf); | 64 int memio_GetReadParams(memio_Private *secret, char **buf); |
65 | 65 |
| 66 /* Ask memio how many bytes are contained in the internal buffer. |
| 67 * Returns bytes available to read, or 0 if none available. |
| 68 */ |
| 69 int memio_GetReadableBufferSize(memio_Private *secret); |
| 70 |
66 /* Tell memio how many bytes were read from the network. | 71 /* Tell memio how many bytes were read from the network. |
67 * If bytes_read is 0, causes EOF to be reported to | 72 * If bytes_read is 0, causes EOF to be reported to |
68 * NSS after it reads the last byte from the circular buffer. | 73 * NSS after it reads the last byte from the circular buffer. |
69 * If bytes_read is < 0, it is treated as an NSPR error code. | 74 * If bytes_read is < 0, it is treated as an NSPR error code. |
70 * See nspr/pr/src/md/unix/unix_errors.c for how to | 75 * See nspr/pr/src/md/unix/unix_errors.c for how to |
71 * map from Unix errors to NSPR error codes. | 76 * map from Unix errors to NSPR error codes. |
72 * On EWOULDBLOCK or the equivalent, don't call this function. | 77 * On EWOULDBLOCK or the equivalent, don't call this function. |
73 */ | 78 */ |
74 void memio_PutReadResult(memio_Private *secret, int bytes_read); | 79 void memio_PutReadResult(memio_Private *secret, int bytes_read); |
75 | 80 |
(...skipping 11 matching lines...) Expand all Loading... |
87 * map from Unix errors to NSPR error codes. | 92 * map from Unix errors to NSPR error codes. |
88 * On EWOULDBLOCK or the equivalent, don't call this function. | 93 * On EWOULDBLOCK or the equivalent, don't call this function. |
89 */ | 94 */ |
90 void memio_PutWriteResult(memio_Private *secret, int bytes_written); | 95 void memio_PutWriteResult(memio_Private *secret, int bytes_written); |
91 | 96 |
92 #ifdef __cplusplus | 97 #ifdef __cplusplus |
93 } | 98 } |
94 #endif | 99 #endif |
95 | 100 |
96 #endif | 101 #endif |
OLD | NEW |