Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 105 lines (93 sloc) 3.295 kb
1511c27 Con Kolivas header-mangling-part-2-move-all-function-prototypes
authored
1 /*
2 Copyright (C) 2006-2011 Con Kolivas
3 Copyright (C) 2011 Peter Hyman
4 Copyright (C) 1998 Andrew Tridgell
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef LRZIP_UTIL_H
20 #define LRZIP_UTIL_H
21
22 #include "lrzip_private.h"
6dd20d7 giant clusterfuck commit: *add and use alloca/strdupa in some spots *imp...
discomfitor authored
23 #include <stdarg.h>
1511c27 Con Kolivas header-mangling-part-2-move-all-function-prototypes
authored
24
cbff8fa move liblrzip.h contents to lrzip_private.h global variables-----
discomfitor authored
25 void register_infile(rzip_control *control, const char *name, char delete);
26 void register_outfile(rzip_control *control, const char *name, char delete);
27 void unlink_files(rzip_control *control);
28 void register_outputfile(rzip_control *control, FILE *f);
6dd20d7 giant clusterfuck commit: *add and use alloca/strdupa in some spots *imp...
discomfitor authored
29 void fatal_exit(rzip_control *control);
30 /* Failure when there is likely to be a meaningful error in perror */
31 static inline void fatal(const rzip_control *control, unsigned int line, const char *file, const char *format, ...)
32 {
33 va_list ap;
34
35 va_start(ap, format);
36 if (!control->log_cb) {
37 vfprintf(stderr, format, ap);
38 perror(NULL);
39 } else
40 control->log_cb(control->log_data, line, file, format, ap);
41 va_end(ap);
42 if (!control->library_mode)
43 fatal_exit((rzip_control*)control);
44 }
45 #ifdef fatal
46 # undef fatal
47 #endif
48 #define fatal(stuff...) fatal(control, __LINE__, __FILE__, stuff)
49 #define fatal_return(stuff, ...) do { \
50 fatal stuff; \
51 return __VA_ARGS__; \
52 } while (0)
53 #define fatal_goto(stuff, label) do { \
54 fatal stuff; \
55 goto label; \
56 } while (0)
57 static inline void failure(const rzip_control *control, unsigned int line, const char *file, const char *format, ...)
58 {
59 va_list ap;
60
61 va_start(ap, format);
62 if (!control->log_cb)
63 vfprintf(stderr, format, ap);
64 else
65 control->log_cb(control->log_data, line, file, format, ap);
66 va_end(ap);
67 if (!control->library_mode)
68 fatal_exit((rzip_control*)control);
69 }
70 #ifdef failure
71 # undef failure
72 #endif
73 #define failure(stuff...) failure(control, __LINE__, __FILE__, stuff)
74 #define failure_return(stuff, ...) do { \
75 failure stuff; \
76 return __VA_ARGS__; \
77 } while (0)
78 #define failure_goto(stuff, label) do { \
79 failure stuff; \
80 goto label; \
81 } while (0)
e85e4df move compression overhead calcs out of main()
discomfitor authored
82 void setup_overhead(rzip_control *control);
1c64dcf more initialization stuff out of main(), remove weird coincidentally suc...
discomfitor authored
83 void setup_ram(rzip_control *control);
1511c27 Con Kolivas header-mangling-part-2-move-all-function-prototypes
authored
84 void round_to_page(i64 *size);
6dd20d7 giant clusterfuck commit: *add and use alloca/strdupa in some spots *imp...
discomfitor authored
85 bool get_rand(rzip_control *control, uchar *buf, int len);
86 bool read_config(rzip_control *control);
8c8f5bd Con Kolivas lrz_crypt tweaks courtesy of Serge Belyshev.
authored
87 void lrz_stretch(rzip_control *control);
88 void lrz_stretch2(rzip_control *control);
6dd20d7 giant clusterfuck commit: *add and use alloca/strdupa in some spots *imp...
discomfitor authored
89 bool lrz_crypt(const rzip_control *control, uchar *buf, i64 len, const uchar *salt, int encrypt);
8c8f5bd Con Kolivas lrz_crypt tweaks courtesy of Serge Belyshev.
authored
90
91 #define LRZ_DECRYPT (0)
92 #define LRZ_ENCRYPT (1)
93
6dd20d7 giant clusterfuck commit: *add and use alloca/strdupa in some spots *imp...
discomfitor authored
94 static inline bool lrz_encrypt(const rzip_control *control, uchar *buf, i64 len, const uchar *salt)
8c8f5bd Con Kolivas lrz_crypt tweaks courtesy of Serge Belyshev.
authored
95 {
6dd20d7 giant clusterfuck commit: *add and use alloca/strdupa in some spots *imp...
discomfitor authored
96 return lrz_crypt(control, buf, len, salt, LRZ_ENCRYPT);
8c8f5bd Con Kolivas lrz_crypt tweaks courtesy of Serge Belyshev.
authored
97 }
98
6dd20d7 giant clusterfuck commit: *add and use alloca/strdupa in some spots *imp...
discomfitor authored
99 static inline bool lrz_decrypt(const rzip_control *control, uchar *buf, i64 len, const uchar *salt)
8c8f5bd Con Kolivas lrz_crypt tweaks courtesy of Serge Belyshev.
authored
100 {
6dd20d7 giant clusterfuck commit: *add and use alloca/strdupa in some spots *imp...
discomfitor authored
101 return lrz_crypt(control, buf, len, salt, LRZ_DECRYPT);
8c8f5bd Con Kolivas lrz_crypt tweaks courtesy of Serge Belyshev.
authored
102 }
1511c27 Con Kolivas header-mangling-part-2-move-all-function-prototypes
authored
103
104 #endif
Something went wrong with that request. Please try again.