gwenhywfar  4.3.3
buffer.h
Go to the documentation of this file.
1 /***************************************************************************
2  $RCSfile$
3  -------------------
4  cvs : $Id$
5  begin : Fri Sep 12 2003
6  copyright : (C) 2003 by Martin Preuss
7  email : martin@libchipcard.de
8 
9  ***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU Lesser General Public *
13  * License as published by the Free Software Foundation; either *
14  * version 2.1 of the License, or (at your option) any later version. *
15  * *
16  * This library is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
19  * Lesser General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU Lesser General Public *
22  * License along with this library; if not, write to the Free Software *
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
24  * MA 02111-1307 USA *
25  * *
26  ***************************************************************************/
27 
28 
29 #ifndef GWENHYWFAR_BUFFER_H
30 #define GWENHYWFAR_BUFFER_H
31 
32 #include <gwenhywfar/gwenhywfarapi.h>
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
41 typedef struct GWEN_BUFFER GWEN_BUFFER;
42 #ifdef __cplusplus
43 }
44 #endif
45 
46 #include <gwenhywfar/types.h>
47 #include <gwenhywfar/syncio.h>
48 
49 
50 #include <stdio.h>
51 /* This is needed for PalmOS, because it define some functions needed */
52 #include <string.h>
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
66 
67 #define GWEN_BUFFER_MAX_BOOKMARKS 64
68 
69 #define GWEN_BUFFER_MODE_DYNAMIC 0x0001
70 #define GWEN_BUFFER_MODE_ABORT_ON_MEMFULL 0x0002
71 #define GWEN_BUFFER_MODE_USE_SYNCIO 0x0010
72 #define GWEN_BUFFER_MODE_READONLY 0x0020
73 
74 #define GWEN_BUFFER_MODE_DEFAULT \
75  (\
76  GWEN_BUFFER_MODE_DYNAMIC | \
77  GWEN_BUFFER_MODE_ABORT_ON_MEMFULL\
78  )
79 
80 
105 GWEN_BUFFER *GWEN_Buffer_new(char *buffer,
106  uint32_t size,
107  uint32_t used,
108  int take_ownership);
109 
117 void GWEN_Buffer_free(GWEN_BUFFER *bf);
118 
119 
123 
124 
135 
141 uint32_t GWEN_Buffer_GetMode(GWEN_BUFFER *bf);
142 
148 void GWEN_Buffer_SetMode(GWEN_BUFFER *bf, uint32_t mode);
149 
155 void GWEN_Buffer_AddMode(GWEN_BUFFER *bf, uint32_t mode);
156 
162 void GWEN_Buffer_SubMode(GWEN_BUFFER *bf, uint32_t mode);
163 
170 
176 void GWEN_Buffer_SetHardLimit(GWEN_BUFFER *bf, uint32_t l);
177 
178 
185 uint32_t GWEN_Buffer_GetStep(GWEN_BUFFER *bf);
186 
195 void GWEN_Buffer_SetStep(GWEN_BUFFER *bf, uint32_t step);
196 
197 
207 int GWEN_Buffer_ReserveBytes(GWEN_BUFFER *bf, uint32_t res);
208 
209 
215 char *GWEN_Buffer_GetStart(const GWEN_BUFFER *bf);
216 
217 
222 uint32_t GWEN_Buffer_GetSize(const GWEN_BUFFER *bf);
223 
224 
230 uint32_t GWEN_Buffer_GetPos(const GWEN_BUFFER *bf);
231 
236 int GWEN_Buffer_SetPos(GWEN_BUFFER *bf, uint32_t i);
237 
241 uint32_t GWEN_Buffer_GetUsedBytes(const GWEN_BUFFER *bf);
242 
243 
248 uint32_t GWEN_Buffer_GetBookmark(const GWEN_BUFFER *bf, unsigned int idx);
249 
250 
256 void GWEN_Buffer_SetBookmark(GWEN_BUFFER *bf, unsigned int idx,
257  uint32_t v);
258 
259 
268  const char *buffer,
269  uint32_t size);
270 
273  unsigned char c,
274  uint32_t size);
275 
278  unsigned char c,
279  uint32_t size);
280 
281 
289  const char *buffer);
290 
291 
299 int GWEN_Buffer_AppendByte(GWEN_BUFFER *bf, char c);
300 
312  const char *buffer,
313  uint32_t size);
314 
327  uint32_t size);
328 
340 int GWEN_Buffer_RemoveRoom(GWEN_BUFFER *bf, uint32_t size);
341 
354  uint32_t rsize,
355  const char *buffer,
356  uint32_t size);
357 
358 
370  const char *buffer);
371 
385 int GWEN_Buffer_InsertByte(GWEN_BUFFER *bf, char c);
386 
394 
395 
403  char *buffer,
404  uint32_t *size);
405 
406 
415 
416 
419 int GWEN_Buffer_IncrementPos(GWEN_BUFFER *bf, uint32_t i);
420 
423 int GWEN_Buffer_DecrementPos(GWEN_BUFFER *bf, uint32_t i);
424 
449 
450 
458  GWEN_BUFFER *sf);
459 
466  GWEN_BUFFER *sf);
467 
468 
475 
476 
482 
483 
488 char *GWEN_Buffer_GetPosPointer(const GWEN_BUFFER *bf);
489 
490 
496 
502 
503 
508 int GWEN_Buffer_AllocRoom(GWEN_BUFFER *bf, uint32_t size);
509 
510 
511 /* crops the buffer to the specified bytes */
514  uint32_t pos,
515  uint32_t l);
516 
517 
527  GWEN_SYNCIO *sio,
528  int take);
529 
530 
533 void GWEN_Buffer_Dump(GWEN_BUFFER *bf, unsigned int insert);
534 
535 
538 #ifdef __cplusplus
539 }
540 #endif
541 
542 #endif
543 
544 
545 
546 
547 
548