1
#include <drizzled/global.h>
3
#include <drizzled/serialize/binary_log.h>
8
#include <google/protobuf/io/coded_stream.h>
9
#include <google/protobuf/io/zero_copy_stream_impl.h>
16
using namespace google::protobuf;
17
using namespace google::protobuf::io;
19
void print_usage_and_exit(char *prog) {
21
const char *name= strrchr(prog, '/');
26
name= "binlog_reader";
27
cerr << "Usage: " << name << " <options>\n"
28
<< " --input name Read queries from file <name> (default: 'log.bin')\n"
35
print_event(BinaryLog::Event *)
41
main(int argc, char *argv[])
45
static struct option options[] = {
46
{ "input", 1 /* has_arg */, NULL, 0 },
50
const char *file_name= "log.bin";
53
while ((ch= getopt_long(argc, argv, "", options, &option_index)) != -1) {
55
print_usage_and_exit(argv[0]);
57
switch (option_index) {
66
print_usage_and_exit(argv[0]);
70
fb.open(file_name, std::ios::in);
73
ZeroCopyInputStream* raw_input = new IstreamInputStream(&is);
74
CodedInputStream *coded_input = new CodedInputStream(raw_input);
76
BinaryLog::Event event;
77
while (event.read(coded_input))
78
event.print(std::cout);