3
* Guido Draheim <guidod@gmx.de>
5
* Copyright (c) 2000,2001,2002 Guido Draheim
7
* use under the restrictions of the
8
* Lesser GNU General Public License
9
* note the additional license information
10
* that can be found in COPYING.ZZIP
14
#include "clamav-config.h"
17
#include <zzip.h> /* exported... */
18
#include <zzip-file.h>
19
#include <zzipformat.h>
21
#ifdef ZZIP_HAVE_SYS_STAT_H
29
* just returns dir->errcode of the ZZIP_DIR handle
30
* see: => zzip_dir_open, => zzip_diropen, => zzip_readdir, => zzip_dir_read
33
zzip_error(ZZIP_DIR * dir)
39
* This function just does dir->errcode = errcode
42
zzip_seterror(ZZIP_DIR * dir, int errcode)
43
{ dir->errcode = errcode; }
46
* This function will just return fp->dir
48
* If a ZZIP_FILE is contained within a zip-file that one will be a valid
49
* pointer, otherwise a NULL is returned and the ZZIP_FILE wraps a real file.
52
zzip_dirhandle(ZZIP_FILE * fp)
58
* This function will just return dir->fd
60
* If a ZZIP_DIR does point to a zipfile then the file-descriptor of that
61
* zipfile is returned, otherwise a NULL is returned and the ZZIP_DIR wraps
62
* a real directory DIR (if you have dirent on your system).
65
zzip_dirfd(ZZIP_DIR* dir)
71
* return static const string of the known compression methods,
72
* otherwise just "zipped" is returned
75
zzip_compr_str(int compr)
79
case ZZIP_IS_STORED: return "stored";
80
case ZZIP_IS_SHRUNK: return "shrunk";
81
case ZZIP_IS_REDUCEDx1:
82
case ZZIP_IS_REDUCEDx2:
83
case ZZIP_IS_REDUCEDx3:
84
case ZZIP_IS_REDUCEDx4: return "reduced";
85
case ZZIP_IS_IMPLODED: return "imploded";
86
case ZZIP_IS_TOKENIZED: return "tokenized";
87
case ZZIP_IS_DEFLATED: return "deflated";
88
case ZZIP_IS_DEFLATED_BETTER: return "deflatedX";
89
case ZZIP_IS_IMPLODED_BETTER: return "implodedX";
91
if (0 < compr && compr < 256) return "zipped";
95
if (S_ISDIR(compr)) return "directory";
98
if (S_ISCHR(compr)) return "is/chr";
101
if (S_ISBLK(compr)) return "is/blk";
104
if (S_ISFIFO(compr)) return "is/fifo";
107
if (S_ISSOCK(compr)) return "is/sock";
110
if (S_ISLNK(compr)) return "is/lnk";
117
/** => zzip_file_real
118
* This function checks if the ZZIP_DIR-handle is wrapping
119
* a real directory or a zip-archive.
120
* Returns 1 for a stat'able directory, and 0 for a handle to zip-archive.
123
zzip_dir_real(ZZIP_DIR* dir)
125
return dir->realdir != 0;
129
* This function checks if the ZZIP_FILE-handle is wrapping
130
* a real file or a zip-contained file.
131
* Returns 1 for a stat'able file, and 0 for a file inside a zip-archive.
134
zzip_file_real(ZZIP_FILE* fp)
136
return fp->dir == 0; /* ie. not dependent on a zip-arch-dir */
139
/** => zzip_file_real
140
* This function returns the posix DIR* handle (if one exists).
141
* Check before with => zzip_dir_real if the
142
* the ZZIP_DIR points to a real directory.
145
zzip_realdir(ZZIP_DIR* dir)
150
/** => zzip_file_real
151
* This function returns the posix file descriptor (if one exists).
152
* Check before with => zzip_file_real if the
153
* the ZZIP_FILE points to a real file.
156
zzip_realfd(ZZIP_FILE* fp)
163
* c-file-style: "stroustrup"