source: branches/blt4/src/core/RpBufferCInterface.h @ 2305

Last change on this file since 2305 was 1366, checked in by gah, 15 years ago

Begin reorganizing Rappture C++ API, starting with the use of
Rappture::Outcome.

Instead of returning an Outcome and expecting every routine to
save it, pass it as a reference. Let's strip it down to what's
needed right now and add back functionality as required.

Right now too many return values are ignored in the rappture library.
We need to check all results and return the error messages via
the Outcome. At the topmost level where is touches the developer
API we can drop the error checking or turn it on via an environment
variable.

Example. Not enough checks are made for memory allocation failure.
If the application is running on an over-committed server memory
allocation errors will be silently passed on. It's okay to be
fault tolerant where possible, but if we fail to check in the internal
library functions, it's too late.

--gah

File size: 2.0 KB
Line 
1
2/*
3 * ----------------------------------------------------------------------
4 *  INTERFACE: C Rappture Buffer Header
5 *
6 * ======================================================================
7 *  AUTHOR:  Derrick Kearney, Purdue University
8 *  Copyright (c) 2004-2007  Purdue Research Foundation
9 *
10 *  See the file "license.terms" for information on usage and
11 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12 * ======================================================================
13 */
14
15
16#ifndef _RAPPTURE_BUFFER_C_H
17#define _RAPPTURE_BUFFER_C_H
18
19#include "RpOutcomeCInterface.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif // ifdef __cplusplus
24
25typedef struct {
26    void* _buf;
27    /*
28    const char* (*bytes)();
29    unsigned int (*size)();
30    // void (*clear)();
31    int (*append)(const char*, int);
32    int (*read)(const char*, int);
33    int (*seek)(int, int);
34    int (*tell)();
35    // void (*rewind);
36    bool (*load)(Outcome &result, const char*);
37    bool (*dump)(Outcome &result, const char*);
38    bool (*encode)(Outcome &result, bool, bool);
39    bool (*decode)(Outcome &result, bool, bool);
40    */
41}RapptureBuffer;
42
43int RapptureBufferInit(RapptureBuffer* buf);
44int RapptureBufferNew(RapptureBuffer* buf);
45int RapptureBufferFree(RapptureBuffer* buf);
46const char* RapptureBufferBytes(RapptureBuffer* buf);
47unsigned int RapptureBufferSize(RapptureBuffer* buf);
48int RapptureBufferAppend(RapptureBuffer* buf, const char* bytes, int size);
49int RapptureBufferRead(RapptureBuffer* buf, const char* bytes, int size);
50int RapptureBufferSeek(RapptureBuffer* buf, int offset, int whence);
51int RapptureBufferTell(RapptureBuffer* buf);
52RapptureOutcome RapptureBufferLoad(RapptureBuffer* buf, const char* filename);
53RapptureOutcome RapptureBufferDump(RapptureBuffer* buf, const char* filename);
54RapptureOutcome RapptureBufferEncode(RapptureBuffer* buf, int compress,
55        int base64 );
56RapptureOutcome RapptureBufferDecode(RapptureBuffer* buf,
57        int decompress, int base64 );
58
59#ifdef __cplusplus
60}
61#endif // ifdef __cplusplus
62
63#endif // ifndef _RAPPTURE_BUFFER_C_H
Note: See TracBrowser for help on using the repository browser.