~ubuntu-branches/debian/squeeze/alpine/squeeze

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * $Id: store.h 237 2006-11-16 04:08:15Z mikes@u.washington.edu $
 *
 * ========================================================================
 * Copyright 2006 University of Washington
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * ========================================================================
 */

#ifndef PITH_STORE_INCLUDED
#define PITH_STORE_INCLUDED


typedef enum {CharStarStar, CharStar, FileStar,
		TmpFileStar, PipeStar, ExternalText} SourceType;


/*
 * typedef used by storage object routines
 */

typedef struct store_object {
    unsigned char *dp;		/* current position in data		*/
    unsigned char *eod;		/* end of current data			*/
    void	  *txt;		/* container's data			*/
    unsigned char *eot;		/* end of space alloc'd for data	*/
    int  (*writec)(int, struct store_object *);
    int  (*readc)(unsigned char *, struct store_object *);
    int  (*puts)(struct store_object *, char *);
    fpos_t	   used;	/* amount of object in use		*/
    char          *name;	/* optional object name			*/
    SourceType     src;		/* what we're copying into		*/
    short          flags;	/* flags relating to object use		*/
    unsigned char  cbuf[6];	/* used for converting to or from	*/
    unsigned char *cbufp;	/*   locale-specific charset		*/
    unsigned char *cbufend;
    PARAMETER	   *attr;	/* attribute list			*/
} STORE_S;

#define	so_writec(c, so)	((*(so)->writec)((c), (so)))
#define	so_readc(c, so)		((*(so)->readc)((c), (so)))
#define	so_puts(so, s)		((*(so)->puts)((so), (s)))


/* exported protoypes */
STORE_S	*so_get(SourceType, char *, int);
int	 so_give(STORE_S **);
int	 so_nputs(STORE_S *, char *, long);
int	 so_seek(STORE_S *, long, int);
int	 so_truncate(STORE_S *, long);
long	 so_tell(STORE_S *);
char	*so_attr(STORE_S *, char *, char *);
int	 so_release(STORE_S *);
void	*so_text(STORE_S *);
char	*so_fgets(STORE_S *, char *, size_t);
void	 so_register_external_driver(STORE_S *(*)(void),
				     int      (*)(STORE_S **),
				     int      (*)(int, STORE_S *),
				     int      (*)(unsigned char *, STORE_S *),
				     int      (*)(STORE_S *, char *),
				     int      (*)(STORE_S *, long, int),
				     int      (*)(STORE_S *, off_t),
				     int      (*)(STORE_S *));


#endif /* PITH_STORE_INCLUDED */