diff options
Diffstat (limited to 'xdelta3/xdelta3-main.h')
-rwxr-xr-x | xdelta3/xdelta3-main.h | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index 6225cb3..e222eb4 100755 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -31,10 +31,13 @@ | |||
31 | */ | 31 | */ |
32 | 32 | ||
33 | /* TODO list: | 33 | /* TODO list: |
34 | * 1. do exact gzip-like filename, stdout handling. make a .xz extension, refuse | 34 | * 1. do exact gzip-like filename, stdout handling. make a .vcdiff extension, refuse |
35 | * to encode to stdout without -cf, etc. | 35 | * to encode to stdout without -cf, etc. |
36 | * 2. Allow the user to add a comment string to the app header without disturbing the default | 36 | * 2. Allow the user to add a comment string to the app header without disturbing the default |
37 | * behavior. | 37 | * behavior. |
38 | * 3. "Source file must be seekable" is not actually true for encoding, given current | ||
39 | * behavior. Allow non-seekable sources? It would in theory let you use a fifo for | ||
40 | * the source. | ||
38 | */ | 41 | */ |
39 | 42 | ||
40 | /* On error handling and printing: | 43 | /* On error handling and printing: |
@@ -116,6 +119,9 @@ const char* xd3_mainerror(int err_num); | |||
116 | # define S_ISREG(m) 1 | 119 | # define S_ISREG(m) 1 |
117 | //# endif | 120 | //# endif |
118 | #endif /* !S_ISREG */ | 121 | #endif /* !S_ISREG */ |
122 | |||
123 | // For standard input/output handles | ||
124 | static STARTUPINFO winStartupInfo; | ||
119 | #endif | 125 | #endif |
120 | 126 | ||
121 | /****************************************************************************************** | 127 | /****************************************************************************************** |
@@ -252,7 +258,7 @@ static int option_use_checksum = 1; | |||
252 | static int option_use_altcodetable = 0; | 258 | static int option_use_altcodetable = 0; |
253 | static char* option_smatch_config = NULL; | 259 | static char* option_smatch_config = NULL; |
254 | static int option_no_compress = 0; | 260 | static int option_no_compress = 0; |
255 | static int option_no_output = 0; /* go through the motions, but do not open or write output */ | 261 | static int option_no_output = 0; /* do not open or write output */ |
256 | static const char *option_source_filename = NULL; | 262 | static const char *option_source_filename = NULL; |
257 | 263 | ||
258 | static usize_t option_iopt_size = XD3_DEFAULT_IOPT_SIZE; | 264 | static usize_t option_iopt_size = XD3_DEFAULT_IOPT_SIZE; |
@@ -638,20 +644,17 @@ main_atou (const char* arg, usize_t *xo, usize_t low, usize_t high, char which) | |||
638 | #if XD3_STDIO | 644 | #if XD3_STDIO |
639 | #define XFNO(f) fileno(f->file) | 645 | #define XFNO(f) fileno(f->file) |
640 | #define XSTDOUT_XF(f) { (f)->file = stdout; (f)->filename = "/dev/stdout"; } | 646 | #define XSTDOUT_XF(f) { (f)->file = stdout; (f)->filename = "/dev/stdout"; } |
641 | #define XSTDERR_XF(f) { (f)->file = stderr; (f)->filename = "/dev/stderr"; } | ||
642 | #define XSTDIN_XF(f) { (f)->file = stdin; (f)->filename = "/dev/stdin"; } | 647 | #define XSTDIN_XF(f) { (f)->file = stdin; (f)->filename = "/dev/stdin"; } |
643 | 648 | ||
644 | #elif XD3_POSIX | 649 | #elif XD3_POSIX |
645 | #define XFNO(f) f->file | 650 | #define XFNO(f) f->file |
646 | #define XSTDOUT_XF(f) { (f)->file = STDOUT_FILENO; (f)->filename = "/dev/stdout"; } | 651 | #define XSTDOUT_XF(f) { (f)->file = STDOUT_FILENO; (f)->filename = "/dev/stdout"; } |
647 | #define XSTDERR_XF(f) { (f)->file = STDERR_FILENO; (f)->filename = "/dev/stderr"; } | ||
648 | #define XSTDIN_XF(f) { (f)->file = STDIN_FILENO; (f)->filename = "/dev/stdin"; } | 652 | #define XSTDIN_XF(f) { (f)->file = STDIN_FILENO; (f)->filename = "/dev/stdin"; } |
649 | 653 | ||
650 | #elif XD3_WIN32 | 654 | #elif XD3_WIN32 |
651 | #define XFNO(f) -1 | 655 | #define XFNO(f) -1 |
652 | #define XSTDOUT_XF(f) { (f)->file = INVALID_HANDLE_VALUE; (f)->filename = "/dev/stdout"; } | 656 | #define XSTDOUT_XF(f) { (f)->file = winStartupInfo.hStdOutput; (f)->filename = "(stdout)"; } |
653 | #define XSTDERR_XF(f) { (f)->file = INVALID_HANDLE_VALUE; (f)->filename = "/dev/stderr"; } | 657 | #define XSTDIN_XF(f) { (f)->file = winStartupInfo.hStdInput; (f)->filename = "(stdin)"; } |
654 | #define XSTDIN_XF(f) { (f)->file = INVALID_HANDLE_VALUE; (f)->filename = "/dev/stdin"; } | ||
655 | #endif | 658 | #endif |
656 | 659 | ||
657 | static void | 660 | static void |
@@ -967,6 +970,23 @@ main_file_seek (main_file *xfile, xoff_t pos) | |||
967 | ******************************************************************************************/ | 970 | ******************************************************************************************/ |
968 | 971 | ||
969 | #if VCDIFF_TOOLS | 972 | #if VCDIFF_TOOLS |
973 | #ifdef WIN32 | ||
974 | /* According to the internet, Windows vsnprintf() differs from most Unix | ||
975 | * implementations regarding the terminating 0 when the boundary condition | ||
976 | * is met. It doesn't matter here, we don't rely on the trailing 0. */ | ||
977 | #include <stdarg.h> | ||
978 | int | ||
979 | snprintf (char *str, int n, char *fmt, ...) | ||
980 | { | ||
981 | va_list a; | ||
982 | int ret; | ||
983 | va_start (a, fmt); | ||
984 | ret = vsnprintf (str, n, fmt, a); | ||
985 | va_end (a); | ||
986 | return ret; | ||
987 | } | ||
988 | #endif | ||
989 | |||
970 | #define SNPRINTF_BUFSIZE XD3_ALLOCSIZE | 990 | #define SNPRINTF_BUFSIZE XD3_ALLOCSIZE |
971 | #define VC do { if (((ret = snprintf | 991 | #define VC do { if (((ret = snprintf |
972 | #define UT xfile->snprintf_buf, SNPRINTF_BUFSIZE, | 992 | #define UT xfile->snprintf_buf, SNPRINTF_BUFSIZE, |
@@ -2791,6 +2811,10 @@ main (int argc, char **argv) | |||
2791 | char **orig_argv = argv; | 2811 | char **orig_argv = argv; |
2792 | int ret; | 2812 | int ret; |
2793 | 2813 | ||
2814 | #ifdef _WIN32 | ||
2815 | GetStartupInfo(&winStartupInfo); | ||
2816 | #endif | ||
2817 | |||
2794 | main_file_init (& ifile); | 2818 | main_file_init (& ifile); |
2795 | main_file_init (& ofile); | 2819 | main_file_init (& ofile); |
2796 | main_file_init (& sfile); | 2820 | main_file_init (& sfile); |
@@ -3053,24 +3077,6 @@ main (int argc, char **argv) | |||
3053 | goto cleanup; | 3077 | goto cleanup; |
3054 | } | 3078 | } |
3055 | 3079 | ||
3056 | if (option_verbose > 1) | ||
3057 | { | ||
3058 | int l = 1; | ||
3059 | int i; | ||
3060 | char buf[1024]; | ||
3061 | for (i = 0; i < orig_argc; i += 1) | ||
3062 | { | ||
3063 | l += strlen (orig_argv[i]) + 1; | ||
3064 | } | ||
3065 | buf[0] = 0; | ||
3066 | for (i = 0; i < orig_argc; i += 1) | ||
3067 | { | ||
3068 | strcat (buf, orig_argv[i]); | ||
3069 | strcat (buf, " "); | ||
3070 | } | ||
3071 | XPR(NT "command line: %s\n", buf); | ||
3072 | } | ||
3073 | |||
3074 | ifile.flags = RD_FIRST; | 3080 | ifile.flags = RD_FIRST; |
3075 | sfile.flags = RD_FIRST; | 3081 | sfile.flags = RD_FIRST; |
3076 | sfile.filename = option_source_filename; | 3082 | sfile.filename = option_source_filename; |