Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / 3rd-party / zisofs_tools / mkzftree.h
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
4  * The behaviour and appearence of the program code below can differ to a major
5  * extent from the version distributed by the original author(s).
6  *
7  * For details, see Changelog file distributed with the cdrkit package. If you
8  * received this file from another source then ask the distributing person for
9  * a log of modifications.
10  *
11  */
12
13 #ident "$Id: mkzftree.h,v 1.7 2006/07/04 04:57:42 hpa Exp $"
14 /* ----------------------------------------------------------------------- *
15  *   
16  *   Copyright 2001-2006 H. Peter Anvin - All Rights Reserved
17  *
18  *   This program is free software; you can redistribute it and/or modify
19  *   it under the terms of the GNU General Public License as published by
20  *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
21  *   USA; either version 2 of the License, or (at your option) any later
22  *   version; incorporated herein by reference.
23  *
24  * ----------------------------------------------------------------------- */
25
26 #ifndef MKZFTREE_H
27 #define MKZFTREE_H
28
29 /* config.h should be included before any system headers!!!! */
30 #include "config.h"
31
32 #include <stddef.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <stdio.h>
36 #include <sys/types.h>
37 #include <sys/stat.h>
38 #ifdef HAVE_INTTYPES_H
39 #include <inttypes.h>
40 #endif
41 #ifdef HAVE_ENDIAN_H
42 #include <endian.h>
43 #endif
44
45 #ifdef HAVE_SYSEXITS_H
46 #include <sysexits.h>
47 #else
48 #define EX_USAGE        64      /* command line usage error */
49 #define EX_DATAERR      65      /* data format error */
50 #define EX_NOINPUT      66      /* cannot open input */
51 #define EX_NOUSER       67      /* addressee unknown */
52 #define EX_NOHOST       68      /* host name unknown */
53 #define EX_UNAVAILABLE  69      /* service unavailable */
54 #define EX_SOFTWARE     70      /* internal software error */
55 #define EX_OSERR        71      /* system error (e.g., can't fork) */
56 #define EX_OSFILE       72      /* critical OS file missing */
57 #define EX_CANTCREAT    73      /* can't create (user) output file */
58 #define EX_IOERR        74      /* input/output error */
59 #define EX_TEMPFAIL     75      /* temp failure; user is invited to retry */
60 #define EX_PROTOCOL     76      /* remote error in protocol */
61 #define EX_NOPERM       77      /* permission denied */
62 #define EX_CONFIG       78      /* configuration error */
63 #endif
64
65 /* File transformation functions */  
66 typedef int (*munger_func)(FILE *, FILE *, off_t);
67 int block_compress_file(FILE *, FILE *, off_t);
68 int block_uncompress_file(FILE *, FILE *, off_t);
69
70 /* mkzftree.c */
71 extern const char *program;     /* Program name */
72 enum verbosity {                /* Message verbosity */
73   vl_quiet,                     /* No messages */
74   vl_error,                     /* Error messages only */
75   vl_filename,                  /* Display filenames */
76   vl_crib,                      /* Cribbing files */
77 };
78 #define default_verbosity vl_error
79 struct cmdline_options {
80   int force;                    /* Always compress */
81   int level;                    /* Compression level */
82   int parallel;                 /* Parallelism (0 = strictly serial) */
83   int onefs;                    /* One filesystem only */
84   int onedir;                   /* One directory only */
85   int do_mkdir;                 /* Create stub directories */
86   int file_root;                /* The root may be a file */
87   int sloppy;                   /* Don't make sure metadata is set correctly */
88   enum verbosity verbosity;     /* Message verbosity */
89   munger_func munger;           /* Default action */
90 };
91 extern struct cmdline_options opt;
92
93 /* walk.c */
94 int munge_tree(const char *, const char *, const char *);
95 int munge_entry(const char *, const char *, const char *, const struct stat *);
96
97 /* workers.c */
98 void wait_for_all_workers(void);
99 int spawn_worker(void);
100 void end_worker(int);
101
102 /* util.c */
103 void *xmalloc(size_t);
104 void *xrealloc(void *, size_t);
105 char *xstrdup(const char *);
106 void message(enum verbosity, const char *, ...);
107
108 /* hash.c */
109 const char *hash_find_file(struct stat *);
110 void hash_insert_file(struct stat *, const char *);
111
112 /* copytime.h */
113 int copytime(const char *, const struct stat *);
114
115 #endif /* MKZFTREE_H */