1 /*
2  * $Id: store.h 1074 2008-06-04 00:08:43Z hubert@u.washington.edu $
3  *
4  * ========================================================================
5  * Copyright 2013-2021 Eduardo Chappa
6  * Copyright 2006-2008 University of Washington
7  *
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
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * ========================================================================
15  */
16 
17 #ifndef PITH_STORE_INCLUDED
18 #define PITH_STORE_INCLUDED
19 
20 
21 #include "../pith/filttype.h"
22 #ifdef SMIME
23 #include <openssl/bio.h>
24 #endif /* SMIME */
25 
26 
27 typedef enum {CharStarStar, CharStar, FileStar,
28 #ifdef SMIME
29 		BioType,
30 #endif /* SMIME */
31 		TmpFileStar, PipeStar, ExternalText} SourceType;
32 
33 
34 /*
35  * typedef used by storage object routines
36  */
37 
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		*/
50     CBUF_S         cb;
51     PARAMETER	   *attr;	/* attribute list			*/
52 } STORE_S;
53 
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)))
57 
58 
59 /* exported prototypes */
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),
71 				     int      (*)(STORE_S **),
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),
77 				     int      (*)(STORE_S *));
78 
79 
80 #endif /* PITH_STORE_INCLUDED */
81