2
* $Id: store.h 237 2006-11-16 04:08:15Z mikes@u.washington.edu $
4
* ========================================================================
5
* Copyright 2006 University of Washington
7
* Licensed under the Apache License, Version 2.0 (the "License");
8
* you may not use this file except in compliance with the License.
9
* You may obtain a copy of the License at
11
* http://www.apache.org/licenses/LICENSE-2.0
13
* ========================================================================
16
#ifndef PITH_STORE_INCLUDED
17
#define PITH_STORE_INCLUDED
20
typedef enum {CharStarStar, CharStar, FileStar,
21
TmpFileStar, PipeStar, ExternalText} SourceType;
25
* typedef used by storage object routines
28
typedef struct store_object {
29
unsigned char *dp; /* current position in data */
30
unsigned char *eod; /* end of current data */
31
void *txt; /* container's data */
32
unsigned char *eot; /* end of space alloc'd for data */
33
int (*writec)(int, struct store_object *);
34
int (*readc)(unsigned char *, struct store_object *);
35
int (*puts)(struct store_object *, char *);
36
fpos_t used; /* amount of object in use */
37
char *name; /* optional object name */
38
SourceType src; /* what we're copying into */
39
short flags; /* flags relating to object use */
40
unsigned char cbuf[6]; /* used for converting to or from */
41
unsigned char *cbufp; /* locale-specific charset */
42
unsigned char *cbufend;
43
PARAMETER *attr; /* attribute list */
46
#define so_writec(c, so) ((*(so)->writec)((c), (so)))
47
#define so_readc(c, so) ((*(so)->readc)((c), (so)))
48
#define so_puts(so, s) ((*(so)->puts)((so), (s)))
51
/* exported protoypes */
52
STORE_S *so_get(SourceType, char *, int);
53
int so_give(STORE_S **);
54
int so_nputs(STORE_S *, char *, long);
55
int so_seek(STORE_S *, long, int);
56
int so_truncate(STORE_S *, long);
57
long so_tell(STORE_S *);
58
char *so_attr(STORE_S *, char *, char *);
59
int so_release(STORE_S *);
60
void *so_text(STORE_S *);
61
char *so_fgets(STORE_S *, char *, size_t);
62
void so_register_external_driver(STORE_S *(*)(void),
64
int (*)(int, STORE_S *),
65
int (*)(unsigned char *, STORE_S *),
66
int (*)(STORE_S *, char *),
67
int (*)(STORE_S *, long, int),
68
int (*)(STORE_S *, off_t),
72
#endif /* PITH_STORE_INCLUDED */