-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzip.h
More file actions
45 lines (36 loc) · 1.01 KB
/
zip.h
File metadata and controls
45 lines (36 loc) · 1.01 KB
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
#ifndef SRC_ZIP_H_
#define SRC_ZIP_H_
#define _GNU_SOURCE
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <zlib.h>
#define USAGE \
"Usage: zip [options] filename [archive.zip]\n" \
" Run with -h for more info\n"
#define MB (1024U * 1024U)
#define MAX_CHUNK_SIZE (MB * 2U)
#define MIN_CHUNK_SIZE (1U)
#define DEFAULT_CHUNK_SIZE (2U << 12)
// config for read parameters
typedef struct {
int hFlag;
int fFlag; // force writing to output (error if not set)
int cFlag;
int chunksNumber;
} OptionsConfig;
// error types
typedef enum { ERROR = -1, OK = 0 } eErrorCode;
int zip(const char* filename, const char* archive_filename,
OptionsConfig config);
int scanOptions(int argc, char** argv, OptionsConfig* config);
eErrorCode readFromC(char* optarg, OptionsConfig* config);
#endif // SRC_ZIP_H_