2 * $Id: store.h 1074 2008-06-04 00:08:43Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2013-2018 Eduardo Chappa
6 * Copyright 2006-2008 University of Washington
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * ========================================================================
17 #ifndef PITH_STORE_INCLUDED
18 #define PITH_STORE_INCLUDED
21 #include "../pith/filttype.h"
23 #include <openssl/bio.h>
27 typedef enum {CharStarStar
, CharStar
, FileStar
,
31 TmpFileStar
, PipeStar
, ExternalText
} SourceType
;
35 * typedef used by storage object routines
38 typedef struct store_object
{
39 unsigned char *dp
; /* current position in data */
40 unsigned char *eod
; /* end of current data */
41 void *txt
; /* container's data */
42 unsigned char *eot
; /* end of space alloc'd for data */
43 int (*writec
)(int, struct store_object
*);
44 int (*readc
)(unsigned char *, struct store_object
*);
45 int (*puts
)(struct store_object
*, char *);
46 fpos_t used
; /* amount of object in use */
47 char *name
; /* optional object name */
48 SourceType src
; /* what we're copying into */
49 short flags
; /* flags relating to object use */
51 PARAMETER
*attr
; /* attribute list */
54 #define so_writec(c, so) ((*(so)->writec)((c), (so)))
55 #define so_readc(c, so) ((*(so)->readc)((c), (so)))
56 #define so_puts(so, s) ((*(so)->puts)((so), (s)))
59 /* exported protoypes */
60 STORE_S
*so_get(SourceType
, char *, int);
61 int so_give(STORE_S
**);
62 int so_nputs(STORE_S
*, char *, long);
63 int so_seek(STORE_S
*, long, int);
64 int so_truncate(STORE_S
*, long);
65 long so_tell(STORE_S
*);
66 char *so_attr(STORE_S
*, char *, char *);
67 int so_release(STORE_S
*);
68 void *so_text(STORE_S
*);
69 char *so_fgets(STORE_S
*, char *, size_t);
70 void so_register_external_driver(STORE_S
*(*)(void),
72 int (*)(int, STORE_S
*),
73 int (*)(unsigned char *, STORE_S
*),
74 int (*)(STORE_S
*, char *),
75 int (*)(STORE_S
*, long, int),
76 int (*)(STORE_S
*, off_t
),
80 #endif /* PITH_STORE_INCLUDED */