1 /* @(#)strar.h	1.7 19/10/13 Copyright 2001-2019 J. Schilling */
2 /*
3  *	Defitions for the stream archive interfaces.
4  *
5  *	A stream archive is based on the method used for
6  *	POSIX tar extended headers
7  *
8  *	Copyright (c) 2001-2019 J. Schilling
9  */
10 /*
11  * The contents of this file are subject to the terms of the
12  * Common Development and Distribution License, Version 1.0 only
13  * (the "License").  You may not use this file except in compliance
14  * with the License.
15  *
16  * See the file CDDL.Schily.txt in this distribution for details.
17  * A copy of the CDDL is also available via the Internet at
18  * http://www.opensource.org/licenses/cddl1.txt
19  *
20  * When distributing Covered Code, include this CDDL HEADER in each
21  * file and include the License file CDDL.Schily.txt from this distribution.
22  */
23 
24 #ifndef	_SCHILY_STRAR_H
25 #define	_SCHILY_STRAR_H
26 
27 #ifndef _SCHILY_MCONFIG_H
28 #include <schily/mconfig.h>
29 #endif
30 #ifndef _SCHILY_STAT_H
31 #include <schily/stat.h>
32 #endif
33 #ifndef _SCHILY_STDIO_H
34 #include <schily/stdio.h>
35 #endif
36 #ifndef _SCHILY_UTYPES_H
37 #include <schily/utypes.h>
38 #endif
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 typedef	struct	{
45 	FILE	*f_fp;		/* FILE * f. Archiv			  */
46 	const char *f_fpname;	/* Archive name				  */
47 	FILE	*f_list;	/* FILE * f. Listing Output		  */
48 	const char *f_listname;	/* List output name			  */
49 	Ulong	f_cmdflags;	/* Command specific flags		  */
50 
51 	char	*f_name;	/* Zeiger auf den langen Dateinamen	  */
52 	Ulong	f_namelen;	/* L�nge des Dateinamens		  */
53 	char	*f_lname;	/* Zeiger auf den langen Linknamen	  */
54 	Ulong	f_lnamelen;	/* L�nge des Linknamens			  */
55 
56 	char	*f_uname;	/* User name oder NULL Pointer		  */
57 	Ulong	f_umaxlen;	/* Maximale L�nge des Usernamens	  */
58 	char	*f_gname;	/* Group name oder NULL Pointer		  */
59 	Ulong	f_gmaxlen;	/* Maximale L�nge des Gruppennamens	  */
60 
61 	dev_t	f_dev;		/* Geraet auf dem sich d. Datei befindet  */
62 	dev_t	f_devmaj;	/* major(st_dev)			  */
63 	dev_t	f_devmin;	/* minor(st_dev)			  */
64 	ino_t	f_ino;		/* Dateinummer				  */
65 	nlink_t	f_nlink;	/* Anzahl der Links			  */
66 
67 	mode_t	f_mode;		/* Zugriffsrechte			  */
68 
69 	uid_t	f_uid;		/* Benutzernummer			  */
70 	gid_t	f_gid;		/* Benutzergruppe			  */
71 
72 	Ullong	f_llsize;	/* Dateigroesze wenn off_t zu kein	  */
73 	off_t	f_size;		/* Dateigroesze				  */
74 	off_t	f_rsize;	/* Dateigroesze auf Band		  */
75 
76 	Ulong	f_flags;	/* Bearbeitungshinweise			  */
77 	Ulong	f_xflags;	/* Flags f�r x-header			  */
78 	Ulong	f_xftype;	/* Header Dateityp (neu generell)	  */
79 	Ulong	f_rxftype;	/* Echter Dateityp (neu generell)	  */
80 
81 #ifdef	NEW_RDEV
82 	dev_t	f_rdev;		/* Major/Minor bei Geraeten		  */
83 	major_t	f_rdevmaj;	/* Major bei Geraeten			  */
84 	minor_t	f_rdevmin;	/* Minor bei Geraeten			  */
85 #else
86 	Ulong	f_rdev;		/* Major/Minor bei Geraeten		  */
87 	Ulong	f_rdevmaj;	/* Major bei Geraeten			  */
88 	Ulong	f_rdevmin;	/* Minor bei Geraeten			  */
89 #endif
90 
91 	time_t	f_atime;	/* Zeit d. letzten Zugriffs		  */
92 	long	f_ansec;	/* nsec Teil "				  */
93 	time_t	f_mtime;	/* Zeit d. letzten Aenderung		  */
94 	long	f_mnsec;	/* nsec Teil "				  */
95 	time_t	f_ctime;	/* Zeit d. letzten Statusaend.		  */
96 	long	f_cnsec;	/* nsec Teil "				  */
97 	long	f_status;	/* File send status			  */
98 } FINFO;
99 
100 typedef	FINFO	strar;
101 
102 /*
103  * Used with f_cmdflags
104  */
105 #define	CMD_VERBOSE	0xFF	/* Allow verbose levels from 0..255	  */
106 #define	CMD_CREATE	0x100
107 #define	CMD_XTRACT	0x200
108 #define	CMD_LIST	0x400
109 #define	CMD_CTIME	0x800
110 
111 /*
112  * Used with f_flags
113  */
114 #define	F_BAD_SIZE	0x1000	/* Bad size data detected		  */
115 #define	F_BAD_META	0x2000	/* Bad meta data detected		  */
116 #define	F_BAD_UID	0x4000	/* Bad uid value detected		  */
117 #define	F_BAD_GID	0x8000	/* Bad gid value detected		  */
118 
119 /*
120  * Used with f_xflags
121  */
122 #define	XF_ATIME	0x0001	/* Zeit d. letzten Zugriffs		  */
123 #define	XF_CTIME	0x0002	/* Zeit d. letzten Statusaend.		  */
124 #define	XF_MTIME	0x0004	/* Zeit d. letzten Aenderung		  */
125 #define	XF_COMMENT	0x0008	/* Beliebiger Kommentar			  */
126 #define	XF_UID		0x0010	/* Benutzernummer			  */
127 #define	XF_UNAME	0x0020	/* Langer Benutzername			  */
128 #define	XF_GID		0x0040	/* Benutzergruppe			  */
129 #define	XF_GNAME	0x0080	/* Langer Benutzergruppenname		  */
130 #define	XF_PATH		0x0100	/* Langer Name				  */
131 #define	XF_LINKPATH	0x0200	/* Langer Link Name			  */
132 				/* Dateigr��e auf Band (f_rsize)	  */
133 #define	XF_SIZE		0x0400	/* Dateigr��e wenn > 8 GB		  */
134 #define	XF_CHARSET	0x0800	/* Zeichensatz f�r Dateiinhalte		  */
135 
136 #define	XF_DEVMAJOR	0x1000	/* Major bei Ger�ten			  */
137 #define	XF_DEVMINOR	0x2000	/* Major bei Ger�ten			  */
138 #define	XF_FSDEVMAJOR	0x4000	/* Major Filesys			  */
139 #define	XF_FSDEVMINOR	0x8000	/* Major Filesys			  */
140 
141 #define	XF_FFLAGS	0x10000	/* File flags				  */
142 				/* Echte Dateigr��e (f_size)		  */
143 #define	XF_REALSIZE	0x20000	/* Dateigr��e wenn > 8 GB		  */
144 #define	XF_STATUS	0x40000	/* File send status			  */
145 #define	XF_EOF		0x80000	/* Logical EOF in archive		  */
146 #define	XF_DEV		0x100000 /* Device FS is on			  */
147 #define	XF_INO		0x200000 /* Inode number for file		  */
148 #define	XF_NLINK	0x400000 /* Link count				  */
149 #define	XF_MODE		0x800000 /* File mode				  */
150 #define	XF_FILETYPE	0x1000000 /* File type				  */
151 
152 #define	XF_BINARY    0x20000000	/* Binary path/usr/group in x-header	  */
153 
154 #define	XF_BASE_FILEMETA (XF_FILETYPE | XF_MODE)
155 #define	XF_ALL_FILEMETA	(XF_FILETYPE | XF_MODE | \
156 			XF_ATIME | XF_MTIME | XF_CTIME | \
157 			XF_UID | XF_GID | XF_UNAME | XF_GNAME | \
158 			XF_DEV | XF_FSDEVMAJOR | XF_FSDEVMINOR | \
159 			XF_INO | XF_NLINK | XF_DEVMAJOR | XF_DEVMINOR)
160 
161 /*
162  * All Extended header tags that are covered by POSIX.1-2001
163  */
164 #define	XF_POSIX	(XF_ATIME|XF_CTIME|XF_MTIME|XF_COMMENT|\
165 			XF_UID|XF_UNAME|XF_GID|XF_GNAME|\
166 			XF_PATH|XF_LINKPATH|XF_SIZE|XF_CHARSET)
167 
168 
169 /*
170  * Open modes
171  */
172 #define	OM_READ		1
173 #define	OM_WRITE	2
174 #define	OM_ARFD		4
175 
176 extern	int	strar_open	__PR((strar *s, const char *name, int arfd,
177 					int mode, const char *codeset));
178 extern	int	strar_close	__PR((strar *s));
179 extern	void	strar_init	__PR((strar *s));
180 extern	void	strar_reset	__PR((strar *s));
181 extern	void	strar_archtype	__PR((strar *s));
182 extern	void	strar_eof	__PR((strar *s));
183 extern	int	strar_send	__PR((strar *s, const char *name));
184 extern	int	strar_st_send	__PR((strar *s, struct stat *sp));
185 extern	void	strar_list_file	__PR((strar *s));
186 extern	void	strar_vprint	__PR((strar *s));
187 extern	int	strar_receive	__PR((strar *s, int (*func)(strar *)));
188 
189 extern	int	strar_hparse	__PR((strar *s));
190 extern	int	strar_get	__PR((strar *s));
191 extern	int	strar_skip	__PR((strar *s));
192 
193 extern	int	strar_setnowarn	__PR((int val));
194 extern	void	strar_xbreset	__PR((void));
195 
196 #ifdef	__cplusplus
197 }
198 #endif
199 
200 #endif	/* _SCHILY_STRAR_H */
201