VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/io/nsIInputStream.idl

Last change on this file was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Warren Harris <warren@netscape.com>
24 * Darin Fisher <darin@netscape.com>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40#include "nsISupports.idl"
41
42interface nsIInputStream;
43
44%{C++
45/**
46 * The signature of the writer function passed to ReadSegments. This
47 * is the "consumer" of data that gets read from the stream's buffer.
48 *
49 * @param aInStream stream being read
50 * @param aClosure opaque parameter passed to ReadSegments
51 * @param aFromSegment pointer to memory owned by the input stream
52 * @param aToOffset amount already read (since ReadSegments was called)
53 * @param aCount length of fromSegment
54 * @param aWriteCount number of bytes read
55 *
56 * Implementers should return the following:
57 *
58 * @return NS_OK and (*aWriteCount > 0) if consumed some data
59 * @return <any-error> if not interested in consuming any data
60 *
61 * Errors are never passed to the caller of ReadSegments.
62 *
63 * NOTE: returning NS_OK and (*aWriteCount = 0) has undefined behavior.
64 *
65 * @status FROZEN
66 */
67typedef NS_CALLBACK(nsWriteSegmentFun)(nsIInputStream *aInStream,
68 void *aClosure,
69 const char *aFromSegment,
70 PRUint32 aToOffset,
71 PRUint32 aCount,
72 PRUint32 *aWriteCount);
73%}
74
75native nsWriteSegmentFun(nsWriteSegmentFun);
76
77/**
78 * nsIInputStream
79 *
80 * @status FROZEN
81 */
82[scriptable, uuid(fa9c7f6c-61b3-11d4-9877-00c04fa0cf4a)]
83interface nsIInputStream : nsISupports
84{
85 /**
86 * Close the stream.
87 */
88 void close();
89
90 /**
91 * @return number of bytes currently available in the stream
92 */
93 unsigned long available();
94
95 /**
96 * Read data from the stream.
97 *
98 * @param aBuf the buffer into which the data is to be read
99 * @param aCount the maximum number of bytes to be read
100 *
101 * @return number of bytes read (may be less than aCount).
102 * @return 0 if reached end of file
103 *
104 * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream would
105 * block the calling thread (non-blocking mode only)
106 * @throws <other-error> on failure
107 */
108 [noscript] unsigned long read(in charPtr aBuf, in unsigned long aCount);
109
110 /**
111 * Low-level read method that has access to the stream's underlying buffer.
112 * The writer function may be called multiple times for segmented buffers.
113 * ReadSegments is expected to keep calling the writer until either there is
114 * nothing left to read or the writer returns an error. ReadSegments should
115 * not call the writer with zero bytes to consume.
116 *
117 * @param aWriter the "consumer" of the data to be read
118 * @param aClosure opaque parameter passed to writer
119 * @param aCount the maximum number of bytes to be read
120 *
121 * @return number of bytes read (may be less than aCount)
122 * @return 0 if reached end of file (or if aWriter refused to consume data)
123 *
124 * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream would
125 * block the calling thread (non-blocking mode only)
126 * @throws <other-error> on failure
127 *
128 * NOTE: this function may be unimplemented if a stream has no underlying
129 * buffer (e.g., socket input stream).
130 */
131 [noscript] unsigned long readSegments(in nsWriteSegmentFun aWriter,
132 in voidPtr aClosure,
133 in unsigned long aCount);
134
135 /**
136 * @return true if stream is non-blocking
137 */
138 boolean isNonBlocking();
139};
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette