mirror of
https://github.com/Thesola10/umd-livepatch.git
synced 2025-04-19 22:13:22 +00:00
Add load-mode to cli
This commit is contained in:
parent
cf70f04866
commit
0358242b2d
1
umdiff/.exrc
Normal file
1
umdiff/.exrc
Normal file
@ -0,0 +1 @@
|
||||
autocmd BufWritePost,FileWritePost USAGE !make usage.rl.h
|
16
umdiff/USAGE
16
umdiff/USAGE
@ -2,9 +2,21 @@ umdiff - Generate patch files for use with umd-livepatch
|
||||
|
||||
Usage:
|
||||
umdiff delta <source_file> <target_file> <output_file>
|
||||
umdiff patch <source_file> <umdiff_file> <output_file>
|
||||
umdiff patch [--load-mode MODE] <source_file> <umdiff_file> <output_file>
|
||||
umdiff from-rdiff <rdiff_file> <output_file>
|
||||
umdiff --help
|
||||
|
||||
Options:
|
||||
-h --help Prints a short usage summary.
|
||||
--load-mode=MODE How to load the UMDiff file into memory [default: 0]
|
||||
0: Load the file header into memory, read the rest ad-hoc
|
||||
1: Load all commands into memory, read patch data ad-hoc
|
||||
2: Load everything into memory
|
||||
-h --help Show this message and exit
|
||||
|
||||
Commands:
|
||||
delta Generate a UMDiff file from the delta between source_file
|
||||
and target_file, and write it to output_file.
|
||||
patch Patch source_file using umdiff_file, and write the result
|
||||
to output_file.
|
||||
from-rdiff Convert an existing rdiff delta in rdiff_file into a
|
||||
UMDiff file, and write it to output_file.
|
||||
|
@ -31,8 +31,9 @@ umdiff_delta(char *source, char *target, char *output)
|
||||
}
|
||||
|
||||
int
|
||||
umdiff_patch(char *source, char *umdiff, char *output)
|
||||
umdiff_patch(char *source, char *umdiff, char *output, char *load_mode)
|
||||
{
|
||||
umdiff_FileFlags lmode = atoi(load_mode);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -59,7 +60,8 @@ int main(int argc, char *argv[])
|
||||
if (opts.delta)
|
||||
return umdiff_delta(opts.source_file, opts.target_file, opts.output_file);
|
||||
else if (opts.patch)
|
||||
return umdiff_patch(opts.source_file, opts.umdiff_file, opts.output_file);
|
||||
return umdiff_patch(opts.source_file, opts.umdiff_file, opts.output_file,
|
||||
opts.loadmode);
|
||||
else if (opts.fromrdiff)
|
||||
return umdiff_fromRdiff(opts.rdiff_file, opts.output_file);
|
||||
|
||||
|
@ -90,9 +90,9 @@ typedef struct {
|
||||
* not load certain parts of a UMDiff file, instead resorting to in-situ reads.
|
||||
*/
|
||||
typedef enum {
|
||||
umdiff_FileFlags_HEADER_ONLY,
|
||||
umdiff_FileFlags_HEADER_AND_COMMANDS,
|
||||
umdiff_FileFlags_LOAD_FULL
|
||||
umdiff_FileFlags_HEADER_ONLY = 0,
|
||||
umdiff_FileFlags_HEADER_AND_COMMANDS = 1,
|
||||
umdiff_FileFlags_LOAD_FULL = 2
|
||||
} umdiff_FileFlags;
|
||||
|
||||
/**
|
||||
|
147
umdiff/usage.rl.h
generated
147
umdiff/usage.rl.h
generated
@ -17,7 +17,7 @@ typedef struct
|
||||
int help;
|
||||
|
||||
/* options */
|
||||
|
||||
char* loadmode;
|
||||
|
||||
/* arguments */
|
||||
char* output_file;
|
||||
@ -44,9 +44,10 @@ struct params
|
||||
#line 40 "usage.rl.h"
|
||||
static const char _params_actions[] = {
|
||||
0, 1, 0, 1, 3, 1, 4, 1,
|
||||
5, 1, 6, 2, 1, 7, 2, 1,
|
||||
8, 2, 1, 9, 2, 1, 10, 2,
|
||||
1, 11, 2, 2, 0
|
||||
5, 1, 6, 2, 1, 8, 2, 1,
|
||||
9, 2, 1, 10, 2, 1, 11, 2,
|
||||
1, 12, 2, 2, 0, 3, 1, 7,
|
||||
12, 3, 1, 10, 8
|
||||
};
|
||||
|
||||
static const char _params_key_offsets[] = {
|
||||
@ -54,7 +55,11 @@ static const char _params_key_offsets[] = {
|
||||
11, 12, 13, 14, 15, 16, 17, 18,
|
||||
19, 20, 21, 22, 23, 24, 25, 26,
|
||||
27, 28, 29, 30, 31, 32, 33, 34,
|
||||
35, 36, 37, 38, 39, 40, 41, 42
|
||||
35, 36, 37, 38, 40, 41, 42, 43,
|
||||
45, 47, 49, 51, 53, 55, 57, 59,
|
||||
61, 63, 64, 65, 66, 68, 69, 71,
|
||||
73, 75, 77, 79, 81, 83, 85, 87,
|
||||
89, 90, 90, 91
|
||||
};
|
||||
|
||||
static const char _params_trans_keys[] = {
|
||||
@ -62,8 +67,14 @@ static const char _params_trans_keys[] = {
|
||||
108, 112, 0, 101, 108, 116, 97, 0,
|
||||
0, 0, 0, 0, 0, 0, 114, 111,
|
||||
109, 114, 100, 105, 102, 102, 0, 0,
|
||||
0, 97, 116, 99, 104, 0, 0, 0,
|
||||
0, 0, 0
|
||||
0, 97, 116, 99, 104, 0, 0, 45,
|
||||
0, 0, 0, 0, 45, 0, 108, 0,
|
||||
111, 0, 97, 0, 100, 0, 45, 0,
|
||||
109, 0, 111, 0, 100, 0, 101, 0,
|
||||
0, 0, 0, 45, 0, 0, 45, 0,
|
||||
108, 0, 111, 0, 97, 0, 100, 0,
|
||||
45, 0, 109, 0, 111, 0, 100, 0,
|
||||
101, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const char _params_single_lengths[] = {
|
||||
@ -71,7 +82,11 @@ static const char _params_single_lengths[] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 0
|
||||
1, 1, 1, 2, 1, 1, 1, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 1, 1, 1, 2, 1, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2,
|
||||
1, 0, 1, 1
|
||||
};
|
||||
|
||||
static const char _params_range_lengths[] = {
|
||||
@ -79,47 +94,76 @@ static const char _params_range_lengths[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0
|
||||
};
|
||||
|
||||
static const char _params_index_offsets[] = {
|
||||
static const unsigned char _params_index_offsets[] = {
|
||||
0, 0, 5, 8, 10, 12, 14, 16,
|
||||
18, 20, 22, 24, 26, 28, 30, 32,
|
||||
34, 36, 38, 40, 42, 44, 46, 48,
|
||||
50, 52, 54, 56, 58, 60, 62, 64,
|
||||
66, 68, 70, 72, 74, 76, 78, 80
|
||||
66, 68, 70, 72, 75, 77, 79, 81,
|
||||
84, 87, 90, 93, 96, 99, 102, 105,
|
||||
108, 111, 113, 115, 117, 120, 122, 125,
|
||||
128, 131, 134, 137, 140, 143, 146, 149,
|
||||
152, 154, 155, 157
|
||||
};
|
||||
|
||||
static const char _params_indicies[] = {
|
||||
0, 2, 3, 4, 1, 5, 6, 1,
|
||||
7, 1, 8, 1, 9, 1, 6, 1,
|
||||
10, 1, 11, 1, 12, 1, 13, 1,
|
||||
14, 1, 15, 1, 1, 16, 18, 17,
|
||||
1, 19, 21, 20, 1, 22, 24, 23,
|
||||
25, 1, 26, 1, 27, 1, 28, 1,
|
||||
29, 1, 30, 1, 31, 1, 32, 1,
|
||||
33, 1, 1, 34, 36, 35, 37, 1,
|
||||
38, 1, 39, 1, 40, 1, 41, 1,
|
||||
1, 43, 42, 45, 44, 1, 46, 48,
|
||||
47, 45, 49, 44, 45, 50, 44, 45,
|
||||
51, 44, 45, 52, 44, 45, 53, 44,
|
||||
45, 54, 44, 45, 55, 44, 45, 56,
|
||||
44, 45, 57, 44, 45, 58, 44, 59,
|
||||
44, 1, 60, 62, 61, 1, 64, 63,
|
||||
66, 65, 66, 67, 65, 66, 68, 65,
|
||||
66, 69, 65, 66, 70, 65, 66, 71,
|
||||
65, 66, 72, 65, 66, 73, 65, 66,
|
||||
74, 65, 66, 75, 65, 66, 76, 65,
|
||||
77, 65, 1, 1, 46, 1, 60, 0
|
||||
};
|
||||
|
||||
static const char _params_trans_targs[] = {
|
||||
2, 8, 19, 30, 0, 3, 7, 0,
|
||||
4, 0, 5, 0, 6, 0, 7, 0,
|
||||
39, 0, 9, 0, 10, 0, 11, 0,
|
||||
12, 0, 13, 0, 0, 14, 15, 14,
|
||||
0, 16, 17, 16, 0, 18, 39, 18,
|
||||
20, 0, 21, 0, 22, 0, 23, 0,
|
||||
24, 0, 25, 0, 26, 0, 27, 0,
|
||||
28, 0, 0, 29, 17, 29, 31, 0,
|
||||
32, 0, 33, 0, 34, 0, 35, 0,
|
||||
0, 36, 37, 36, 0, 38, 17, 38,
|
||||
0, 0
|
||||
2, 0, 8, 19, 30, 3, 7, 4,
|
||||
5, 6, 65, 9, 10, 11, 12, 13,
|
||||
14, 14, 15, 16, 16, 17, 18, 18,
|
||||
65, 20, 21, 22, 23, 24, 25, 26,
|
||||
27, 28, 29, 29, 17, 31, 32, 33,
|
||||
34, 35, 36, 39, 36, 37, 38, 38,
|
||||
17, 40, 41, 42, 43, 44, 45, 46,
|
||||
47, 48, 49, 50, 51, 51, 52, 53,
|
||||
54, 53, 66, 55, 56, 57, 58, 59,
|
||||
60, 61, 62, 63, 64, 67
|
||||
};
|
||||
|
||||
static const char _params_trans_actions[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
9, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 3, 0, 0, 26, 17, 1,
|
||||
0, 26, 20, 1, 0, 26, 11, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
5, 0, 0, 26, 14, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 7, 0,
|
||||
0, 26, 17, 1, 0, 26, 23, 1,
|
||||
0, 0
|
||||
0, 0, 9, 0, 0, 0, 0, 3,
|
||||
26, 1, 17, 26, 1, 20, 26, 1,
|
||||
11, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 5, 26, 1, 14, 0, 0, 0,
|
||||
0, 7, 26, 26, 1, 17, 26, 1,
|
||||
23, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 17, 26, 1, 29, 26,
|
||||
26, 1, 33, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 33
|
||||
};
|
||||
|
||||
static const int params_start = 1;
|
||||
static const int params_first_final = 39;
|
||||
static const int params_first_final = 65;
|
||||
static const int params_error = 0;
|
||||
|
||||
static const int params_en_main = 1;
|
||||
@ -133,10 +177,10 @@ static void params_init(struct params *fsm, options_t* opt)
|
||||
|
||||
fsm->opt = opt;
|
||||
fsm->buflen = 0;
|
||||
fsm->opt->loadmode = strdup("0");
|
||||
|
||||
|
||||
|
||||
#line 131 "usage.rl.h"
|
||||
#line 175 "usage.rl.h"
|
||||
{
|
||||
fsm->cs = params_start;
|
||||
}
|
||||
@ -150,7 +194,7 @@ static void params_execute(struct params *fsm, const char *data, int len)
|
||||
const char *pe = data + len;
|
||||
|
||||
|
||||
#line 141 "usage.rl.h"
|
||||
#line 185 "usage.rl.h"
|
||||
{
|
||||
int _klen;
|
||||
unsigned int _trans;
|
||||
@ -212,6 +256,7 @@ _resume:
|
||||
}
|
||||
|
||||
_match:
|
||||
_trans = _params_indicies[_trans];
|
||||
fsm->cs = _params_trans_targs[_trans];
|
||||
|
||||
if ( _params_trans_actions[_trans] == 0 )
|
||||
@ -258,26 +303,30 @@ _match:
|
||||
{ fsm->opt->help = 1; }
|
||||
break;
|
||||
case 7:
|
||||
#line 57 "usage.rl"
|
||||
{ fsm->opt->loadmode = strdup(fsm->buffer); }
|
||||
break;
|
||||
case 8:
|
||||
#line 58 "usage.rl"
|
||||
{ fsm->opt->output_file = strdup(fsm->buffer); }
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
#line 59 "usage.rl"
|
||||
{ fsm->opt->rdiff_file = strdup(fsm->buffer); }
|
||||
break;
|
||||
case 9:
|
||||
case 10:
|
||||
#line 60 "usage.rl"
|
||||
{ fsm->opt->source_file = strdup(fsm->buffer); }
|
||||
break;
|
||||
case 10:
|
||||
case 11:
|
||||
#line 61 "usage.rl"
|
||||
{ fsm->opt->target_file = strdup(fsm->buffer); }
|
||||
break;
|
||||
case 11:
|
||||
case 12:
|
||||
#line 62 "usage.rl"
|
||||
{ fsm->opt->umdiff_file = strdup(fsm->buffer); }
|
||||
break;
|
||||
#line 255 "usage.rl.h"
|
||||
#line 303 "usage.rl.h"
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,12 +357,24 @@ static void show_usage()
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, "Usage:\n");
|
||||
fprintf(stdout, " umdiff delta <source_file> <target_file> <output_file>\n");
|
||||
fprintf(stdout, " umdiff patch <source_file> <umdiff_file> <output_file>\n");
|
||||
fprintf(stdout, " umdiff patch [--load-mode MODE] <source_file> <umdiff_file> <output_file>\n");
|
||||
fprintf(stdout, " umdiff from-rdiff <rdiff_file> <output_file>\n");
|
||||
fprintf(stdout, " umdiff --help\n");
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, "Options:\n");
|
||||
fprintf(stdout, " -h --help Prints a short usage summary.\n");
|
||||
fprintf(stdout, " --load-mode=MODE How to load the UMDiff file into memory [default: 0]\n");
|
||||
fprintf(stdout, " 0: Load the file header into memory, read the rest ad-hoc\n");
|
||||
fprintf(stdout, " 1: Load all commands into memory, read patch data ad-hoc\n");
|
||||
fprintf(stdout, " 2: Load everything into memory\n");
|
||||
fprintf(stdout, " -h --help Show this message and exit\n");
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, "Commands:\n");
|
||||
fprintf(stdout, " delta Generate a UMDiff file from the delta between source_file\n");
|
||||
fprintf(stdout, " and target_file, and write it to output_file.\n");
|
||||
fprintf(stdout, " patch Patch source_file using umdiff_file, and write the result\n");
|
||||
fprintf(stdout, " to output_file.\n");
|
||||
fprintf(stdout, " from-rdiff Convert an existing rdiff delta in rdiff_file into a\n");
|
||||
fprintf(stdout, " UMDiff file, and write it to output_file.\n");
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user