File: buf.decls

package info (click to toggle)
memchan 2.3%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,356 kB
  • sloc: ansic: 3,320; sh: 990; tcl: 687; makefile: 48
file content (216 lines) | stat: -rw-r--r-- 5,495 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# buf.decls -- -*- tcl -*-
#
#	This file contains the declarations for all supported public
#	functions that are exported by the Buf library inside of
#	memchan via its stub table.
#
#	This file is used to generate the bufDecls.h file.
#	

library buf

# Define the buf interface with several sub interfaces:
#     bufPlat	 - platform specific public
#     bufInt	 - generic private
#     bufPlatInt - platform specific private

interface buf
hooks {bufInt memchan}

# Declare each of the functions in the public Buf interface.  Note that
# every index should never be reused for a different function in order
# to preserve backwards compatibility.

# --------------------------------------------------
# Initialization of buf ... Already done ?, Do it.

declare 0 generic {
    int Buf_IsInitialized (Tcl_Interp *interp)
}

declare 1 generic {
    int Buf_Init (Tcl_Interp *interp)
}

# --------------------------------------------------
# Management of buffer types.

declare 10 generic {
    void Buf_RegisterType (Buf_BufferType* bufType)
}

# --------------------------------------------------
# Refcount management, general accessors

declare 20 generic {
    void Buf_IncrRefcount (Buf_Buffer buf)
}

declare 21 generic {
    void Buf_DecrRefcount (Buf_Buffer buf)
}

declare 22 generic {
    int Buf_IsShared (Buf_Buffer buf)
}

declare 23 generic {
    Buf_BufferType* Buf_GetType (Buf_Buffer buf)
}

declare 24 generic {
    CONST char* Buf_GetTypeName (Buf_Buffer buf)
}

declare 25 generic {
    int Buf_Size (Buf_Buffer buf)
}

declare 26 generic {
    ClientData Buf_GetClientData (Buf_Buffer buf)
}



# --------------------------------------------------
# Creation of buffers (generic, for the predefined types).

# Generic creation of a new buffer from clientdata for a
# specific type and the type reference itself.

declare 30 generic {
    Buf_Buffer Buf_Create (Buf_BufferType* bufType, ClientData clientData)
}

# Create an independent duplicate of the incoming buffer.
# (May defer the actual duplication of the content until
# the first write access to any of the copies!)

declare 31 generic {
    Buf_Buffer Buf_Dup (Buf_Buffer buf)
}

# --------------------------------------------------
# Create a buffer of fixed size, containing at most
# size bytes.

declare 32 generic {
    Buf_Buffer Buf_CreateFixedBuffer (int size)
}

# Create an extendable buffer with an initial size of
# size bytes.

declare 33 generic {
    Buf_Buffer Buf_CreateExtendableBuffer (int size)
}

# Create a buffer which is a fixed range in another
# buffer. It contains 'size' bytes and starts at the
# current read position of the underlying buffer.
# The range references the underlying buffer and
# consequently increments its refcount.
#
# Creating a range from a range is possible, but is
# also automatically reduced to a range over a non-
# range.
#
# The range is not allowed to exceed the current size
# of the underlying buffer.

declare 34 generic {
    Buf_Buffer Buf_CreateRange (Buf_Buffer buf, int size)
}

# --------------------------------------------------
# Reading and writing data from/to a buffer, positions

# Read at most size bytes from the buffer into the array outbuf.
# Returns the number of read bytes.

declare 40 generic {
    int Buf_Read (Buf_Buffer buf, void* outbuf, int size)
}

# Take at most size bytes from the array inbuf and append it to the
# buffer. Returns the number of written bytes. Behaviour when writing
# to a range depends on the way the range was created.  A duplicate of
# a range or a range with duplicates lying aroung will now enforce
# actual separation of content. A normal range (without duplicates)
# will simply write into the underlying buffer. Creating separate
# ranges over the same area of a buffer creates dependent
# copies. Writing into one will affect all others.

declare 41 generic {
    int Buf_Write (Buf_Buffer buf, CONST void* inbuf, int size)
}

# --------------------------------------------------
# Buffer locations.

# Convert a location in the buffer into a pointer to the data at that
# location.

declare 50 generic {
    char* Buf_PositionPtr (Buf_BufferPosition loc)
}

# Ask a buffer for the current location to read from.

declare 51 generic {
    Buf_BufferPosition Buf_Tell (Buf_Buffer buf)
}

declare 52 generic {
    void Buf_FreePosition (Buf_BufferPosition loc)
}

declare 53 generic {
    void Buf_MovePosition (Buf_BufferPosition loc, int offset)
}

declare 54 generic {
    Buf_BufferPosition Buf_DupPosition (Buf_BufferPosition loc)
}

declare 55 generic {
    int Buf_PositionOffset (Buf_BufferPosition loc)
}

declare 56 generic {
    Buf_BufferPosition Buf_PositionFromOffset (Buf_Buffer buf, int offset)
}

# --------------------------------------------------
# Queues made out of buffers (Used fixed size buffers naturally).
# Read / Write are like on buffers, but extended.

declare 60 generic {
    Buf_BufferQueue Buf_NewQueue (void)
}

declare 61 generic {
    void Buf_FreeQueue (Buf_BufferQueue queue)
}

declare 62 generic {
    int Buf_QueueRead (Buf_BufferQueue queue, char* outbuf, int size)
}

declare 63 generic {
    int Buf_QueueWrite (Buf_BufferQueue queue, CONST char* inbuf, int size)
}

declare 64 generic {
    void Buf_QueueAppend (Buf_BufferQueue queue, Buf_Buffer buf)
}

declare 65 generic {
    int Buf_QueueSize (Buf_BufferQueue queue)
}


# --------------------------------------------------
# Place for more

# --------------------------------------------------