summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3-main.h
diff options
context:
space:
mode:
authorjosh.macdonald <jmacd@users.noreply.github.com>2007-12-14 11:53:27 +0000
committerjosh.macdonald <jmacd@users.noreply.github.com>2007-12-14 11:53:27 +0000
commitd9111360bb5da1076924d1762fffb5dc90e4f10c (patch)
tree1bce69d89507f563506c2d401bed22f57b8938a7 /xdelta3/xdelta3-main.h
parent8f9de43ff27baf20547cbc25d3472b13fc49c24d (diff)
Add skeleton for "merge" command.
Diffstat (limited to 'xdelta3/xdelta3-main.h')
-rw-r--r--xdelta3/xdelta3-main.h67
1 files changed, 57 insertions, 10 deletions
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h
index 9ce7de1..cfff0fc 100644
--- a/xdelta3/xdelta3-main.h
+++ b/xdelta3/xdelta3-main.h
@@ -168,6 +168,7 @@ typedef enum
168 CMD_PRINTHDRS, 168 CMD_PRINTHDRS,
169 CMD_PRINTDELTA, 169 CMD_PRINTDELTA,
170 CMD_RECODE, 170 CMD_RECODE,
171 CMD_MERGE,
171#if XD3_ENCODER 172#if XD3_ENCODER
172 CMD_ENCODE, 173 CMD_ENCODE,
173#endif 174#endif
@@ -188,6 +189,8 @@ typedef struct _main_file main_file;
188typedef struct _main_extcomp main_extcomp; 189typedef struct _main_extcomp main_extcomp;
189typedef struct _main_blklru main_blklru; 190typedef struct _main_blklru main_blklru;
190typedef struct _main_blklru_list main_blklru_list; 191typedef struct _main_blklru_list main_blklru_list;
192typedef struct _main_merge main_merge;
193typedef struct _main_merge_list main_merge_list;
191 194
192/* The main_file object supports abstract system calls like open, 195/* The main_file object supports abstract system calls like open,
193 * close, read, write, seek, stat. The program uses these to 196 * close, read, write, seek, stat. The program uses these to
@@ -257,9 +260,24 @@ struct _main_blklru
257/* ... represented as a list (no cache index). */ 260/* ... represented as a list (no cache index). */
258XD3_MAKELIST(main_blklru_list,main_blklru,link); 261XD3_MAKELIST(main_blklru_list,main_blklru,link);
259 262
260// TODO: 263// Merge state:
261// struct _main_state 264
262// { 265struct _main_merge_list
266{
267 main_merge_list *next;
268 main_merge_list *prev;
269};
270
271struct _main_merge
272{
273 const char *filename;
274 main_merge_list link;
275};
276
277XD3_MAKELIST(main_merge_list,main_merge,link);
278
279// TODO: really need to put options in a struct so that internal
280// callers can easily reset state.
263 281
264/* Program options: various command line flags and options. */ 282/* Program options: various command line flags and options. */
265static int option_stdout = 0; 283static int option_stdout = 0;
@@ -2771,12 +2789,15 @@ main_input (xd3_cmd cmd,
2771 return EXIT_FAILURE; 2789 return EXIT_FAILURE;
2772 } 2790 }
2773 2791
2774 // TODO: main_set_appheader (recode_stream)
2775
2776 ifile->flags |= RD_NONEXTERNAL; 2792 ifile->flags |= RD_NONEXTERNAL;
2777 input_func = xd3_decode_input; 2793 input_func = xd3_decode_input;
2778 output_func = main_recode_func; 2794 output_func = main_recode_func;
2779 break; 2795 break;
2796
2797 case CMD_MERGE:
2798 XPR(NT "merge not implemented\n");
2799 return EXIT_FAILURE;
2800 //break;
2780#endif 2801#endif
2781#if XD3_ENCODER 2802#if XD3_ENCODER
2782 case CMD_ENCODE: 2803 case CMD_ENCODE:
@@ -3296,12 +3317,14 @@ xd3_main_cmdline (int argc, char **argv)
3296main (int argc, char **argv) 3317main (int argc, char **argv)
3297#endif 3318#endif
3298{ 3319{
3320 static const char *flags =
3321 "0123456789cdefhnqvDJNORTVs:m:B:C:E:F:I:L:O:M:P:W:A::S::";
3299 xd3_cmd cmd; 3322 xd3_cmd cmd;
3300 main_file ifile; 3323 main_file ifile;
3301 main_file ofile; 3324 main_file ofile;
3302 main_file sfile; 3325 main_file sfile;
3303 static const char *flags = 3326 main_merge_list merge_order;
3304 "0123456789cdefhnqvDJNORTVs:B:C:E:F:I:L:O:M:P:W:A::S::"; 3327 main_merge *merge;
3305 int my_optind; 3328 int my_optind;
3306 char *my_optarg; 3329 char *my_optarg;
3307 char *my_optstr; 3330 char *my_optstr;
@@ -3320,12 +3343,14 @@ main (int argc, char **argv)
3320 main_file_init (& ifile); 3343 main_file_init (& ifile);
3321 main_file_init (& ofile); 3344 main_file_init (& ofile);
3322 main_file_init (& sfile); 3345 main_file_init (& sfile);
3346 main_merge_list_init (& merge_order);
3323 3347
3324 reset_defaults(); 3348 reset_defaults();
3325 3349
3326 free_argv = NULL; 3350 free_argv = NULL;
3327 free_value = NULL; 3351 free_value = NULL;
3328 setup_environment(argc, argv, &env_argc, &env_argv, &free_argv, &free_value); 3352 setup_environment(argc, argv, &env_argc, &env_argv,
3353 &free_argv, &free_value);
3329 cmd = CMD_NONE; 3354 cmd = CMD_NONE;
3330 sfilename = NULL; 3355 sfilename = NULL;
3331 my_optind = 1; 3356 my_optind = 1;
@@ -3334,6 +3359,7 @@ main (int argc, char **argv)
3334 program_name = env_argv[0]; 3359 program_name = env_argv[0];
3335 extcomp_types[0].recomp_cmdname = program_name; 3360 extcomp_types[0].recomp_cmdname = program_name;
3336 extcomp_types[0].decomp_cmdname = program_name; 3361 extcomp_types[0].decomp_cmdname = program_name;
3362
3337 takearg: 3363 takearg:
3338 my_optarg = NULL; 3364 my_optarg = NULL;
3339 my_optstr = argv[my_optind]; 3365 my_optstr = argv[my_optind];
@@ -3444,6 +3470,7 @@ main (int argc, char **argv)
3444 else if (strcmp (my_optstr, "printdelta") == 0) 3470 else if (strcmp (my_optstr, "printdelta") == 0)
3445 { cmd = CMD_PRINTDELTA; } 3471 { cmd = CMD_PRINTDELTA; }
3446 else if (strcmp (my_optstr, "recode") == 0) { cmd = CMD_RECODE; } 3472 else if (strcmp (my_optstr, "recode") == 0) { cmd = CMD_RECODE; }
3473 else if (strcmp (my_optstr, "merge") == 0) { cmd = CMD_MERGE; }
3447#endif 3474#endif
3448 3475
3449 /* If no option was found and still no command, let the default 3476 /* If no option was found and still no command, let the default
@@ -3562,6 +3589,16 @@ main (int argc, char **argv)
3562 3589
3563 sfilename = my_optarg; 3590 sfilename = my_optarg;
3564 break; 3591 break;
3592 case 'm':
3593 if ((merge = (main_merge*)
3594 main_malloc (sizeof (main_merge))) == NULL)
3595 {
3596 goto cleanup;
3597 }
3598 main_merge_list_push_back (& merge_order, merge);
3599 merge->filename = my_optarg;
3600 // TODO: more cleanup
3601 break;
3565 3602
3566 case 'V': 3603 case 'V':
3567 ret = main_version (); goto exit; 3604 ret = main_version (); goto exit;
@@ -3582,7 +3619,6 @@ main (int argc, char **argv)
3582 if (argc > 2) 3619 if (argc > 2)
3583 { 3620 {
3584 XPR(NT "too many filenames: %s ...\n", argv[2]); 3621 XPR(NT "too many filenames: %s ...\n", argv[2]);
3585 ret = EXIT_FAILURE;
3586 goto cleanup; 3622 goto cleanup;
3587 } 3623 }
3588 3624
@@ -3629,6 +3665,7 @@ main (int argc, char **argv)
3629#if XD3_ENCODER 3665#if XD3_ENCODER
3630 case CMD_ENCODE: 3666 case CMD_ENCODE:
3631 case CMD_RECODE: 3667 case CMD_RECODE:
3668 case CMD_MERGE:
3632#endif 3669#endif
3633 case CMD_DECODE: 3670 case CMD_DECODE:
3634 ret = main_input (cmd, & ifile, & ofile, & sfile); 3671 ret = main_input (cmd, & ifile, & ofile, & sfile);
@@ -3669,6 +3706,12 @@ main (int argc, char **argv)
3669 main_file_cleanup (& ofile); 3706 main_file_cleanup (& ofile);
3670 main_file_cleanup (& sfile); 3707 main_file_cleanup (& sfile);
3671 3708
3709 while (! main_merge_list_empty (& merge_order))
3710 {
3711 merge = main_merge_list_pop_front (& merge_order);
3712 main_free (merge);
3713 }
3714
3672 main_free (free_argv); 3715 main_free (free_argv);
3673 main_free (free_value); 3716 main_free (free_value);
3674 3717
@@ -3700,6 +3743,7 @@ main_help (void)
3700 DP(RINT " printhdr print information about the first window\n"); 3743 DP(RINT " printhdr print information about the first window\n");
3701 DP(RINT " printhdrs print information about all windows\n"); 3744 DP(RINT " printhdrs print information about all windows\n");
3702 DP(RINT " recode encode with new application/secondary settings\n"); 3745 DP(RINT " recode encode with new application/secondary settings\n");
3746 DP(RINT " merge merge VCDIFF inputs (see below)\n");
3703#endif 3747#endif
3704 DP(RINT "standard options:\n"); 3748 DP(RINT "standard options:\n");
3705 DP(RINT " -0 .. -9 compression level\n"); 3749 DP(RINT " -0 .. -9 compression level\n");
@@ -3730,10 +3774,13 @@ main_help (void)
3730 DP(RINT " -A [apphead] disable/provide application header (encode)\n"); 3774 DP(RINT " -A [apphead] disable/provide application header (encode)\n");
3731 DP(RINT " -J disable output (check/compute only)\n"); 3775 DP(RINT " -J disable output (check/compute only)\n");
3732 DP(RINT " -T use alternate code table (test)\n"); 3776 DP(RINT " -T use alternate code table (test)\n");
3777 DP(RINT " -m arguments for \"merge\"\n");
3733 3778
3734 DP(RINT "the XDELTA environment variable may contain extra args:\n"); 3779 DP(RINT "the XDELTA environment variable may contain extra args:\n");
3735 DP(RINT " XDELTA=\"-s source-x.y.tar.gz\" \\\n"); 3780 DP(RINT " XDELTA=\"-s source-x.y.tar.gz\" \\\n");
3736 DP(RINT " tar --use-compress-program=xdelta3 \\\n"); 3781 DP(RINT " tar --use-compress-program=xdelta3 \\\n");
3737 DP(RINT " -cf target-x.z.tar.gz.vcdiff target-x.y/\n"); 3782 DP(RINT " -cf target-x.z.tar.gz.vcdiff target-x.y\n");
3783 DP(RINT "the \"merge\" command combines VCDIFF inputs as follows:\n");
3784 DP(RINT " xdelta3 merge -m 1.vcdiff -m 2.vcdiff 3.vcdiff merged.vcdiff\n");
3738 return EXIT_FAILURE; 3785 return EXIT_FAILURE;
3739} 3786}