diff options
author | josh.macdonald <jmacd@users.noreply.github.com> | 2012-06-16 14:31:55 +0000 |
---|---|---|
committer | josh.macdonald <jmacd@users.noreply.github.com> | 2012-06-16 14:31:55 +0000 |
commit | c53d22c90235600c9518eccc63d2dd1416320044 (patch) | |
tree | 7de631d70b5669d9441241d9dc9089b08f3072b1 /xdelta3/xdelta3-internal.h | |
parent | 54ac3c4c0c03d7dd52db661a94ec3ecccff826b4 (diff) |
Updates for iOS build, Automake setup
Diffstat (limited to 'xdelta3/xdelta3-internal.h')
-rw-r--r-- | xdelta3/xdelta3-internal.h | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/xdelta3/xdelta3-internal.h b/xdelta3/xdelta3-internal.h new file mode 100644 index 0000000..47cfe59 --- /dev/null +++ b/xdelta3/xdelta3-internal.h | |||
@@ -0,0 +1,125 @@ | |||
1 | /* xdelta3 - delta compression tools and library | ||
2 | * Copyright (C) 2011, 2012 Joshua P. MacDonald | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | */ | ||
18 | |||
19 | #include <stdio.h> | ||
20 | #include <stdarg.h> | ||
21 | |||
22 | #ifndef _XDELTA3_INTERNAL_H_ | ||
23 | #define _XDELTA3_INTERNAL_H_ | ||
24 | |||
25 | typedef struct _main_file main_file; | ||
26 | typedef struct _main_extcomp main_extcomp; | ||
27 | |||
28 | void main_file_init (main_file *xfile); | ||
29 | int main_file_close (main_file *xfile); | ||
30 | void main_file_cleanup (main_file *xfile); | ||
31 | int main_file_isopen (main_file *xfile); | ||
32 | int main_file_open (main_file *xfile, const char* name, int mode); | ||
33 | int main_file_exists (main_file *xfile); | ||
34 | int xd3_whole_append_window (xd3_stream *stream); | ||
35 | int xd3_main_cmdline (int argc, char **argv); | ||
36 | int main_file_read (main_file *ifile, | ||
37 | uint8_t *buf, | ||
38 | usize_t size, | ||
39 | usize_t *nread, | ||
40 | const char *msg); | ||
41 | int main_file_write (main_file *ofile, uint8_t *buf, | ||
42 | usize_t size, const char *msg); | ||
43 | usize_t xd3_bytes_on_srcblk (xd3_source *src, xoff_t blkno); | ||
44 | xoff_t xd3_source_eof(const xd3_source *src); | ||
45 | uint32_t xd3_large_cksum_update (uint32_t cksum, | ||
46 | const uint8_t *base, | ||
47 | usize_t look); | ||
48 | int xd3_encode_init_full (xd3_stream *stream); | ||
49 | #if PYTHON_MODULE || SWIG_MODULE || NOT_MAIN | ||
50 | int xd3_main_cmdline (int argc, char **argv); | ||
51 | #endif | ||
52 | |||
53 | /* main_file->mode values */ | ||
54 | typedef enum | ||
55 | { | ||
56 | XO_READ = 0, | ||
57 | XO_WRITE = 1, | ||
58 | } main_file_modes; | ||
59 | |||
60 | struct _main_file | ||
61 | { | ||
62 | #if XD3_STDIO | ||
63 | FILE *file; | ||
64 | #elif XD3_POSIX | ||
65 | int file; | ||
66 | #elif XD3_WIN32 | ||
67 | HANDLE file; | ||
68 | #endif | ||
69 | |||
70 | int mode; /* XO_READ and XO_WRITE */ | ||
71 | const char *filename; /* File name or /dev/stdin, | ||
72 | * /dev/stdout, /dev/stderr. */ | ||
73 | char *filename_copy; /* File name or /dev/stdin, | ||
74 | * /dev/stdout, /dev/stderr. */ | ||
75 | const char *realname; /* File name or /dev/stdin, | ||
76 | * /dev/stdout, /dev/stderr. */ | ||
77 | const main_extcomp *compressor; /* External compression struct. */ | ||
78 | int flags; /* RD_FIRST, RD_NONEXTERNAL, ... */ | ||
79 | xoff_t nread; /* for input position */ | ||
80 | xoff_t nwrite; /* for output position */ | ||
81 | uint8_t *snprintf_buf; /* internal snprintf() use */ | ||
82 | int size_known; /* Set by main_set_souze */ | ||
83 | xoff_t source_position; /* for avoiding seek in getblk_func */ | ||
84 | int seek_failed; /* after seek fails once, try FIFO */ | ||
85 | }; | ||
86 | |||
87 | /* According to the internet, Windows vsnprintf() differs from most | ||
88 | * Unix implementations regarding the terminating 0 when the boundary | ||
89 | * condition is met. It doesn't matter here, we don't rely on the | ||
90 | * trailing 0. Besides, both Windows and DJGPP vsnprintf return -1 | ||
91 | * upon truncation, which isn't C99 compliant. To overcome this, | ||
92 | * recent MinGW runtimes provided their own vsnprintf (notice the | ||
93 | * absence of the '_' prefix) but they were initially buggy. So, | ||
94 | * always use the native '_'-prefixed version with Win32. */ | ||
95 | #ifdef _WIN32 | ||
96 | #define vsnprintf_func _vsnprintf | ||
97 | #else | ||
98 | #define vsnprintf_func vsnprintf | ||
99 | #endif | ||
100 | |||
101 | /* Prior to SVN 303 this function was only defined in DJGPP and WIN32 | ||
102 | * environments and other platforms would use the builtin snprintf() | ||
103 | * with an arrangement of macros below. In OS X 10.6, Apply made | ||
104 | * snprintf() a macro, which defeated those macros (since snprintf | ||
105 | * would be evaluated before its argument macros were expanded, | ||
106 | * therefore always define xsnprintf_func. */ | ||
107 | #undef PRINTF_ATTRIBUTE | ||
108 | #ifdef __GNUC__ | ||
109 | /* Let's just assume no one uses gcc 2.x! */ | ||
110 | #define PRINTF_ATTRIBUTE(x,y) __attribute__ ((__format__ (__printf__, x, y))) | ||
111 | #else | ||
112 | #define PRINTF_ATTRIBUTE(x,y) | ||
113 | #endif | ||
114 | |||
115 | /* Underlying xprintf() */ | ||
116 | int xsnprintf_func (char *str, int n, const char *fmt, ...) | ||
117 | PRINTF_ATTRIBUTE(3,4); | ||
118 | |||
119 | /* XPR(NT "", ...) (used by main) prefixes an "xdelta3: " to the output. */ | ||
120 | void xprintf(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); | ||
121 | #define XPR xprintf | ||
122 | #define NT "xdelta3: " | ||
123 | #define NTR "" | ||
124 | |||
125 | #endif | ||