4 #include "iprop-commands.h"
7 dump_wrap(int argc
, char **argv
)
9 struct dump_options opt
;
12 struct getargs args
[] = {
13 { "config-file", 'c', arg_string
, NULL
, "configuration file", "file" },
14 { "realm", 'r', arg_string
, NULL
, "realm", NULL
},
15 { "help", 'h', arg_flag
, NULL
, NULL
, NULL
}
18 opt
.config_file_string
= NULL
;
19 opt
.realm_string
= NULL
;
20 args
[0].value
= &opt
.config_file_string
;
21 args
[1].value
= &opt
.realm_string
;
22 args
[2].value
= &help_flag
;
23 if(getarg(args
, 3, argc
, argv
, &optidx
))
25 if(argc
- optidx
> 0) {
26 fprintf(stderr
, "Arguments given (%u) are more than expected (0).\n\n", argc
- optidx
);
31 ret
= iprop_dump(&opt
, argc
- optidx
, argv
+ optidx
);
34 arg_printusage (args
, 3, "dump", "");
39 truncate_wrap(int argc
, char **argv
)
41 struct truncate_options opt
;
44 struct getargs args
[] = {
45 { "config-file", 'c', arg_string
, NULL
, "configuration file", "file" },
46 { "realm", 'r', arg_string
, NULL
, "realm", NULL
},
47 { "help", 'h', arg_flag
, NULL
, NULL
, NULL
}
50 opt
.config_file_string
= NULL
;
51 opt
.realm_string
= NULL
;
52 args
[0].value
= &opt
.config_file_string
;
53 args
[1].value
= &opt
.realm_string
;
54 args
[2].value
= &help_flag
;
55 if(getarg(args
, 3, argc
, argv
, &optidx
))
57 if(argc
- optidx
> 0) {
58 fprintf(stderr
, "Arguments given (%u) are more than expected (0).\n\n", argc
- optidx
);
63 ret
= iprop_truncate(&opt
, argc
- optidx
, argv
+ optidx
);
66 arg_printusage (args
, 3, "truncate", "");
71 replay_wrap(int argc
, char **argv
)
73 struct replay_options opt
;
76 struct getargs args
[] = {
77 { "start-version", 0, arg_integer
, NULL
, "start replay with this version", "version-number" },
78 { "end-version", 0, arg_integer
, NULL
, "end replay with this version", "version-number" },
79 { "config-file", 'c', arg_string
, NULL
, "configuration file", "file" },
80 { "realm", 'r', arg_string
, NULL
, "realm", NULL
},
81 { "help", 'h', arg_flag
, NULL
, NULL
, NULL
}
84 opt
.start_version_integer
= -1;
85 opt
.end_version_integer
= -1;
86 opt
.config_file_string
= NULL
;
87 opt
.realm_string
= NULL
;
88 args
[0].value
= &opt
.start_version_integer
;
89 args
[1].value
= &opt
.end_version_integer
;
90 args
[2].value
= &opt
.config_file_string
;
91 args
[3].value
= &opt
.realm_string
;
92 args
[4].value
= &help_flag
;
93 if(getarg(args
, 5, argc
, argv
, &optidx
))
95 if(argc
- optidx
> 0) {
96 fprintf(stderr
, "Arguments given (%u) are more than expected (0).\n\n", argc
- optidx
);
101 ret
= iprop_replay(&opt
, argc
- optidx
, argv
+ optidx
);
104 arg_printusage (args
, 5, "replay", "");
109 last_version_wrap(int argc
, char **argv
)
111 struct last_version_options opt
;
114 struct getargs args
[] = {
115 { "config-file", 'c', arg_string
, NULL
, "configuration file", "file" },
116 { "realm", 'r', arg_string
, NULL
, "realm", NULL
},
117 { "help", 'h', arg_flag
, NULL
, NULL
, NULL
}
120 opt
.config_file_string
= NULL
;
121 opt
.realm_string
= NULL
;
122 args
[0].value
= &opt
.config_file_string
;
123 args
[1].value
= &opt
.realm_string
;
124 args
[2].value
= &help_flag
;
125 if(getarg(args
, 3, argc
, argv
, &optidx
))
127 if(argc
- optidx
> 0) {
128 fprintf(stderr
, "Arguments given (%u) are more than expected (0).\n\n", argc
- optidx
);
133 ret
= last_version(&opt
, argc
- optidx
, argv
+ optidx
);
136 arg_printusage (args
, 3, "last-version", "");
141 help_wrap(int argc
, char **argv
)
145 struct getargs args
[] = {
146 { "help", 'h', arg_flag
, NULL
, NULL
, NULL
}
149 args
[0].value
= &help_flag
;
150 if(getarg(args
, 1, argc
, argv
, &optidx
))
152 if(argc
- optidx
> 1) {
153 fprintf(stderr
, "Arguments given (%u) are more than expected (1).\n\n", argc
- optidx
);
158 ret
= help(NULL
, argc
- optidx
, argv
+ optidx
);
161 arg_printusage (args
, 1, "help", "command");
165 SL_cmd commands
[] = {
166 { "dump", dump_wrap
, "dump", "Prints the iprop transaction log in text." },
168 { "truncate", truncate_wrap
, "truncate", "Truncate the log, preserve the version number." },
170 { "replay", replay_wrap
, "replay", "Replay the log on the database." },
172 { "last-version", last_version_wrap
, "last-version", "Print the last version of the log-file." },
174 { "help", help_wrap
, "help command", NULL
},