# buffer.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  $RCSfile: buffer.h,v $
    00003                              -------------------
    00004     cvs         : $Id: buffer.h,v 1.30 2005/03/25 17:35:26 aquamaniac Exp $
    00005     begin       : Fri Sep 12 2003
    00006     copyright   : (C) 2003 by Martin Preuss
    00007     email       : martin@libchipcard.de
    00008
    00009  ***************************************************************************
    00010  *                                                                         *
    00011  *   This library is free software; you can redistribute it and/or         *
    00012  *   modify it under the terms of the GNU Lesser General Public            *
    00013  *   License as published by the Free Software Foundation; either          *
    00014  *   version 2.1 of the License, or (at your option) any later version.    *
    00015  *                                                                         *
    00016  *   This library is distributed in the hope that it will be useful,       *
    00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
    00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
    00019  *   Lesser General Public License for more details.                       *
    00020  *                                                                         *
    00021  *   You should have received a copy of the GNU Lesser General Public      *
    00022  *   License along with this library; if not, write to the Free Software   *
    00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
    00024  *   MA  02111-1307  USA                                                   *
    00025  *                                                                         *
    00026  ***************************************************************************/
    00027
    00028
    00029 #ifndef GWENHYWFAR_BUFFER_H
    00030 #define GWENHYWFAR_BUFFER_H
    00031
    00032 #include <gwenhywfar/gwenhywfarapi.h>
    00033 #ifdef __cplusplus
    00034 extern "C" {
    00035 #endif
    00036 typedef struct GWEN_BUFFER GWEN_BUFFER;
    00037 #ifdef __cplusplus
    00038 }
    00039 #endif
    00040
    00041 #include <gwenhywfar/types.h>
    00042 #include <gwenhywfar/bufferedio.h>
    00043
    00044
    00045 #include <stdio.h>
    00046 /* This is needed for PalmOS, because it define some functions needed */
    00047 #include <string.h>
    00048
    00049 #ifdef __cplusplus
    00050 extern "C" {
    00051 #endif
    00052
    00060
    00061 #define GWEN_BUFFER_MAX_BOOKMARKS 4
    00062
    00063 #define GWEN_BUFFER_MODE_DYNAMIC          0x0001
    00064 #define GWEN_BUFFER_MODE_ABORT_ON_MEMFULL 0x0002
    00065 #define GWEN_BUFFER_MODE_USE_BIO    0x0004
    00066
    00067 #define GWEN_BUFFER_MODE_DEFAULT \
    00068   (\
    00069   GWEN_BUFFER_MODE_DYNAMIC | \
    00070   GWEN_BUFFER_MODE_ABORT_ON_MEMFULL\
    00071   )
    00072
    00073
    00084 GWENHYWFAR_API
    00085 GWEN_BUFFER *GWEN_Buffer_new(char *buffer,
    00086                              GWEN_TYPE_UINT32 size,
    00087                              GWEN_TYPE_UINT32 used,
    00088                              int take);
    00089
    00090 GWENHYWFAR_API
    00091 void GWEN_Buffer_free(GWEN_BUFFER *bf);
    00092
    00093
    00094 GWENHYWFAR_API
    00095 GWEN_BUFFER *GWEN_Buffer_dup(GWEN_BUFFER *bf);
    00096
    00097
    00102 GWENHYWFAR_API
    00103 GWEN_TYPE_UINT32 GWEN_Buffer_GetMode(GWEN_BUFFER *bf);
    00104
    00109 GWENHYWFAR_API
    00110 void GWEN_Buffer_SetMode(GWEN_BUFFER *bf, GWEN_TYPE_UINT32 mode);
    00111
    00116 GWENHYWFAR_API
    00117 void GWEN_Buffer_AddMode(GWEN_BUFFER *bf, GWEN_TYPE_UINT32 mode);
    00118
    00123 GWENHYWFAR_API
    00124 void GWEN_Buffer_SubMode(GWEN_BUFFER *bf, GWEN_TYPE_UINT32 mode);
    00125
    00130 GWENHYWFAR_API
    00131 GWEN_TYPE_UINT32 GWEN_Buffer_GetHardLimit(GWEN_BUFFER *bf);
    00132
    00137 GWENHYWFAR_API
    00138 void GWEN_Buffer_SetHardLimit(GWEN_BUFFER *bf, GWEN_TYPE_UINT32 l);
    00139
    00140
    00146 GWENHYWFAR_API
    00147 GWEN_TYPE_UINT32 GWEN_Buffer_GetStep(GWEN_BUFFER *bf);
    00148
    00156 GWENHYWFAR_API
    00157 void GWEN_Buffer_SetStep(GWEN_BUFFER *bf, GWEN_TYPE_UINT32 step);
    00158
    00159
    00168 GWENHYWFAR_API
    00169 int GWEN_Buffer_ReserveBytes(GWEN_BUFFER *bf, GWEN_TYPE_UINT32 res);
    00170
    00171
    00176 GWENHYWFAR_API
    00177 char *GWEN_Buffer_GetStart(GWEN_BUFFER *bf);
    00178
    00179
    00183 GWENHYWFAR_API
    00184 GWEN_TYPE_UINT32 GWEN_Buffer_GetSize(GWEN_BUFFER *bf);
    00185
    00186
    00191 GWENHYWFAR_API
    00192 GWEN_TYPE_UINT32 GWEN_Buffer_GetPos(GWEN_BUFFER *bf);
    00193
    00197 GWENHYWFAR_API
    00198 int GWEN_Buffer_SetPos(GWEN_BUFFER *bf, GWEN_TYPE_UINT32 i);
    00199
    00202 GWENHYWFAR_API
    00203 GWEN_TYPE_UINT32 GWEN_Buffer_GetUsedBytes(GWEN_BUFFER *bf);
    00204
    00205
    00209 GWENHYWFAR_API
    00210 GWEN_TYPE_UINT32 GWEN_Buffer_GetBookmark(GWEN_BUFFER *bf, unsigned int idx);
    00211
    00212
    00217 GWENHYWFAR_API
    00218 void GWEN_Buffer_SetBookmark(GWEN_BUFFER *bf, unsigned int idx,
    00219                              GWEN_TYPE_UINT32 v);
    00220
    00221
    00225 GWENHYWFAR_API
    00226 int GWEN_Buffer_SetUsedBytes(GWEN_BUFFER *bf, GWEN_TYPE_UINT32 i);
    00227
    00234 GWENHYWFAR_API
    00235 int GWEN_Buffer_AppendBytes(GWEN_BUFFER *bf,
    00236                             const char *buffer,
    00237                             GWEN_TYPE_UINT32 size);
    00238
    00239 GWENHYWFAR_API
    00240 int GWEN_Buffer_FillWithBytes(GWEN_BUFFER *bf,
    00241                               unsigned char c,
    00242                               GWEN_TYPE_UINT32 size);
    00243
    00244 GWENHYWFAR_API
    00245 int GWEN_Buffer_FillLeftWithBytes(GWEN_BUFFER *bf,
    00246                                   unsigned char c,
    00247                                   GWEN_TYPE_UINT32 size);
    00248
    00249
    00255 GWENHYWFAR_API
    00256   int GWEN_Buffer_AppendString(GWEN_BUFFER *bf,
    00257                                const char *buffer);
    00258
    00259
    00266 GWENHYWFAR_API
    00267 int GWEN_Buffer_AppendByte(GWEN_BUFFER *bf, char c);
    00268
    00278 GWENHYWFAR_API
    00279 int GWEN_Buffer_InsertBytes(GWEN_BUFFER *bf,
    00280                             const char *buffer,
    00281                             GWEN_TYPE_UINT32 size);
    00282
    00292 GWENHYWFAR_API
    00293 int GWEN_Buffer_InsertRoom(GWEN_BUFFER *bf,
    00294                            GWEN_TYPE_UINT32 size);
    00295
    00296
    00305 GWENHYWFAR_API
    00306 int GWEN_Buffer_InsertString(GWEN_BUFFER *bf,
    00307                              const char *buffer);
    00308
    00320 GWENHYWFAR_API
    00321 int GWEN_Buffer_InsertByte(GWEN_BUFFER *bf, char c);
    00322
    00328 GWENHYWFAR_API
    00329 int GWEN_Buffer_ReadByte(GWEN_BUFFER *bf);
    00330
    00331
    00337 GWENHYWFAR_API
    00338 int GWEN_Buffer_ReadBytes(GWEN_BUFFER *bf,
    00339                           char *buffer,
    00340                           GWEN_TYPE_UINT32 *size);
    00341
    00342
    00349 GWENHYWFAR_API
    00350 int GWEN_Buffer_PeekByte(GWEN_BUFFER *bf);
    00351
    00352
    00353 GWENHYWFAR_API
    00354 int GWEN_Buffer_IncrementPos(GWEN_BUFFER *bf, GWEN_TYPE_UINT32 i);
    00355
    00356 GWENHYWFAR_API
    00357 int GWEN_Buffer_DecrementPos(GWEN_BUFFER *bf, GWEN_TYPE_UINT32 i);
    00358
    00359 GWENHYWFAR_API
    00360 int GWEN_Buffer_AdjustUsedBytes(GWEN_BUFFER *bf);
    00361
    00362
    00363 GWENHYWFAR_API
    00364 int GWEN_Buffer_InsertBuffer(GWEN_BUFFER *bf,
    00365                              GWEN_BUFFER *sf);
    00366
    00367 GWENHYWFAR_API
    00368 int GWEN_Buffer_AppendBuffer(GWEN_BUFFER *bf,
    00369                              GWEN_BUFFER *sf);
    00370
    00374 GWENHYWFAR_API
    00375 GWEN_TYPE_UINT32 GWEN_Buffer_RoomLeft(GWEN_BUFFER *bf);
    00376
    00377
    00382 GWENHYWFAR_API
    00383 GWEN_TYPE_UINT32 GWEN_Buffer_GetMaxUnsegmentedWrite(GWEN_BUFFER *bf);
    00384
    00385
    00390 GWENHYWFAR_API
    00391 GWEN_TYPE_UINT32 GWEN_Buffer_BytesLeft(GWEN_BUFFER *bf);
    00392
    00396 GWENHYWFAR_API
    00397 GWEN_TYPE_UINT32 GWEN_Buffer_GetBytesLeft(GWEN_BUFFER *bf);
    00398
    00399
    00403 GWENHYWFAR_API
    00404 char *GWEN_Buffer_GetPosPointer(GWEN_BUFFER *bf);
    00405
    00406
    00410 GWENHYWFAR_API
    00411 void GWEN_Buffer_Reset(GWEN_BUFFER *bf);
    00412
    00416 GWENHYWFAR_API
    00417 void GWEN_Buffer_Rewind(GWEN_BUFFER *bf);
    00418
    00419
    00423 GWENHYWFAR_API
    00424 int GWEN_Buffer_AllocRoom(GWEN_BUFFER *bf, GWEN_TYPE_UINT32 size);
    00425
    00426
    00427 /* crops the buffer to the specified bytes */
    00428 GWENHYWFAR_API
    00429 int GWEN_Buffer_Crop(GWEN_BUFFER *bf,
    00430                      GWEN_TYPE_UINT32 pos,
    00431                      GWEN_TYPE_UINT32 l);
    00432
    00433
    00441 GWENHYWFAR_API
    00442 void GWEN_Buffer_SetSourceBIO(GWEN_BUFFER *bf,
    00443                               GWEN_BUFFEREDIO *bio,
    00444                               int take);
    00445
    00446
    00447 GWENHYWFAR_API
    00448 void GWEN_Buffer_Dump(GWEN_BUFFER *bf, FILE *f, unsigned int insert);
    00449
    00450
    00453 #ifdef __cplusplus
    00454 }
    00455 #endif
    00456
    00457 #endif
    00458
    00459
    00460
    00461
    00462
    00463