Wed, 31 Aug 2016 16:21:28 +0200
Release of version 2.0
39
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
1 | /* |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
3 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
4 | * Copyright 2015 Olaf Wintermann. All rights reserved. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
5 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
8 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
11 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
15 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
27 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
28 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
29 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
30 | * @file buffer.h |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
31 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
32 | * Advanced buffer implementation. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
33 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
34 | * Instances of UcxBuffer can be used to read from or to write to like one |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
35 | * would do with a stream. This allows the use of ucx_stream_copy() to copy |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
36 | * contents from one buffer to another. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
37 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
38 | * Some features for convenient use of the buffer |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
39 | * can be enabled. See the documentation of the macro constants for more |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
40 | * information. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
41 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
42 | * @author Mike Becker |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
43 | * @author Olaf Wintermann |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
44 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
45 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
46 | #ifndef UCX_BUFFER_H |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
47 | #define UCX_BUFFER_H |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
48 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
49 | #include "ucx.h" |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
50 | #include <sys/types.h> |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
51 | #include <stdio.h> |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
52 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
53 | #ifdef __cplusplus |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
54 | extern "C" { |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
55 | #endif |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
56 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
57 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
58 | * No buffer features enabled (all flags cleared). |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
59 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
60 | #define UCX_BUFFER_DEFAULT 0x00 |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
61 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
62 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
63 | * If this flag is enabled, the buffer will automatically free its contents. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
64 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
65 | #define UCX_BUFFER_AUTOFREE 0x01 |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
66 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
67 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
68 | * If this flag is enabled, the buffer will automatically extends its capacity. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
69 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
70 | #define UCX_BUFFER_AUTOEXTEND 0x02 |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
71 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
72 | /** UCX Buffer. */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
73 | typedef struct { |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
74 | /** A pointer to the buffer contents. */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
75 | char *space; |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
76 | /** Current position of the buffer. */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
77 | size_t pos; |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
78 | /** Current capacity (i.e. maximum size) of the buffer. */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
79 | size_t capacity; |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
80 | /** Current size of the buffer content. */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
81 | size_t size; |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
82 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
83 | * Flag register for buffer features. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
84 | * @see #UCX_BUFFER_DEFAULT |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
85 | * @see #UCX_BUFFER_AUTOFREE |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
86 | * @see #UCX_BUFFER_AUTOEXTEND |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
87 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
88 | int flags; |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
89 | } UcxBuffer; |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
90 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
91 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
92 | * Creates a new buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
93 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
94 | * <b>Note:</b> you may provide <code>NULL</code> as argument for |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
95 | * <code>space</code>. Then this function will allocate the space and enforce |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
96 | * the #UCX_BUFFER_AUTOFREE flag. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
97 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
98 | * @param space pointer to the memory area, or <code>NULL</code> to allocate |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
99 | * new memory |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
100 | * @param capacity the capacity of the buffer |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
101 | * @param flags buffer features (see UcxBuffer.flags) |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
102 | * @return the new buffer |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
103 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
104 | UcxBuffer *ucx_buffer_new(void *space, size_t capacity, int flags); |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
105 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
106 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
107 | * Destroys a buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
108 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
109 | * If the #UCX_BUFFER_AUTOFREE feature is enabled, the contents of the buffer |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
110 | * are also freed. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
111 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
112 | * @param buffer the buffer to destroy |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
113 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
114 | void ucx_buffer_free(UcxBuffer* buffer); |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
115 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
116 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
117 | * Creates a new buffer and fills it with extracted content from another buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
118 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
119 | * <b>Note:</b> the #UCX_BUFFER_AUTOFREE feature is enforced for the new buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
120 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
121 | * @param src the source buffer |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
122 | * @param start the start position of extraction |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
123 | * @param length the count of bytes to extract (must not be zero) |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
124 | * @param flags feature mask for the new buffer |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
125 | * @return a new buffer containing the extraction |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
126 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
127 | UcxBuffer* ucx_buffer_extract(UcxBuffer *src, |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
128 | size_t start, size_t length, int flags); |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
129 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
130 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
131 | * A shorthand macro for the full extraction of the buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
132 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
133 | * @param src the source buffer |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
134 | * @param flags feature mask for the new buffer |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
135 | * @return a new buffer with the extracted content |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
136 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
137 | #define ucx_buffer_clone(src,flags) \ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
138 | ucx_buffer_extract(src, 0, (src)->capacity, flags) |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
139 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
140 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
141 | * Moves the position of the buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
142 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
143 | * The new position is relative to the <code>whence</code> argument. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
144 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
145 | * SEEK_SET marks the start of the buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
146 | * SEEK_CUR marks the current position. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
147 | * SEEK_END marks the end of the buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
148 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
149 | * With an offset of zero, this function sets the buffer position to zero |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
150 | * (SEEK_SET), the buffer size (SEEK_END) or leaves the buffer position |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
151 | * unchanged (SEEK_CUR). |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
152 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
153 | * @param buffer |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
154 | * @param offset position offset relative to <code>whence</code> |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
155 | * @param whence one of SEEK_SET, SEEK_CUR or SEEK_END |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
156 | * @return 0 on success, non-zero if the position is invalid |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
157 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
158 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
159 | int ucx_buffer_seek(UcxBuffer *buffer, off_t offset, int whence); |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
160 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
161 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
162 | * Clears the buffer by resetting the position and deleting the data. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
163 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
164 | * The data is deleted by a zeroing it with call to <code>memset()</code>. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
165 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
166 | * @param buffer the buffer to be cleared |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
167 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
168 | #define ucx_buffer_clear(buffer) memset(buffer->space, 0, buffer->size); \ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
169 | buffer->size = 0; buffer->pos = 0; |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
170 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
171 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
172 | * Tests, if the buffer position has exceeded the buffer capacity. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
173 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
174 | * @param buffer the buffer to test |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
175 | * @return non-zero, if the current buffer position has exceeded the last |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
176 | * available byte of the buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
177 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
178 | int ucx_buffer_eof(UcxBuffer *buffer); |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
179 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
180 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
181 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
182 | * Extends the capacity of the buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
183 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
184 | * <b>Note:</b> The buffer capacity increased by a power of two. I.e. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
185 | * the buffer capacity is doubled, as long as it would not hold the current |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
186 | * content plus the additional required bytes. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
187 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
188 | * <b>Attention:</b> the argument provided is the number of <i>additional</i> |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
189 | * bytes the buffer shall hold. It is <b>NOT</b> the total number of bytes the |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
190 | * buffer shall hold. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
191 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
192 | * @param buffer the buffer to extend |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
193 | * @param additional_bytes the number of additional bytes the buffer shall |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
194 | * <i>at least</i> hold |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
195 | * @return 0 on success or a non-zero value on failure |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
196 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
197 | int ucx_buffer_extend(UcxBuffer *buffer, size_t additional_bytes); |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
198 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
199 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
200 | * Writes data to an UcxBuffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
201 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
202 | * The position of the buffer is increased by the number of bytes written. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
203 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
204 | * @param ptr a pointer to the memory area containing the bytes to be written |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
205 | * @param size the length of one element |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
206 | * @param nitems the element count |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
207 | * @param buffer the UcxBuffer to write to |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
208 | * @return the total count of bytes written |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
209 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
210 | size_t ucx_buffer_write(const void *ptr, size_t size, size_t nitems, |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
211 | UcxBuffer *buffer); |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
212 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
213 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
214 | * Reads data from an UcxBuffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
215 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
216 | * The position of the buffer is increased by the number of bytes read. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
217 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
218 | * @param ptr a pointer to the memory area where to store the read data |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
219 | * @param size the length of one element |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
220 | * @param nitems the element count |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
221 | * @param buffer the UcxBuffer to read from |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
222 | * @return the total number of elements read |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
223 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
224 | size_t ucx_buffer_read(void *ptr, size_t size, size_t nitems, |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
225 | UcxBuffer *buffer); |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
226 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
227 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
228 | * Writes a character to a buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
229 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
230 | * The least significant byte of the argument is written to the buffer. If the |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
231 | * end of the buffer is reached and #UCX_BUFFER_AUTOEXTEND feature is enabled, |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
232 | * the buffer capacity is extended by ucx_buffer_extend(). If the feature is |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
233 | * disabled or buffer extension fails, <code>EOF</code> is returned. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
234 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
235 | * On successful write the position of the buffer is increased. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
236 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
237 | * @param buffer the buffer to write to |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
238 | * @param c the character to write as <code>int</code> value |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
239 | * @return the byte that has bean written as <code>int</code> value or |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
240 | * <code>EOF</code> when the end of the stream is reached and automatic |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
241 | * extension is not enabled or not possible |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
242 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
243 | int ucx_buffer_putc(UcxBuffer *buffer, int c); |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
244 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
245 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
246 | * Gets a character from a buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
247 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
248 | * The current position of the buffer is increased after a successful read. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
249 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
250 | * @param buffer the buffer to read from |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
251 | * @return the character as <code>int</code> value or <code>EOF</code>, if the |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
252 | * end of the buffer is reached |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
253 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
254 | int ucx_buffer_getc(UcxBuffer *buffer); |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
255 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
256 | /** |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
257 | * Writes a string to a buffer. |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
258 | * |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
259 | * @param buffer the buffer |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
260 | * @param str the string |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
261 | * @return the number of bytes written |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
262 | */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
263 | size_t ucx_buffer_puts(UcxBuffer *buffer, char *str); |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
264 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
265 | #ifdef __cplusplus |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
266 | } |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
267 | #endif |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
268 | |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
269 | #endif /* UCX_BUFFER_H */ |
ac35daceb24c
adds UCX + changes how the input file is read (uses an consecutive memory area now)
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
270 |