612.2.4
by Monty Taylor
Moved some defines to config.h. Stopped including config.h directly anywhere. |
1 |
#include <drizzled/global.h> |
481.1.9
by Monty Taylor
Added autoconf tests for location of cstdint and cinttypes. Use those in C++ programs now, so that we don't have to define _STDC_LIMIT_MACROS, etc by hand. Stop, in fact, defining those by hand. |
2 |
|
988.1.1
by Jay Pipes
Changes libserialize to libdrizzledmessage per ML discussion. All GPB messages are now in the drizzled::message namespace. |
3 |
#include <drizzled/message/binary_log.h> |
324.1.1
by Mats Kindahl
Adding specification of a simple protobuf-based binary log format, |
4 |
|
5 |
#include <iostream> |
|
520.9.1
by mordred
More solaris fixes. |
6 |
#include <fstream> |
324.1.1
by Mats Kindahl
Adding specification of a simple protobuf-based binary log format, |
7 |
|
8 |
#include <google/protobuf/io/coded_stream.h> |
|
9 |
#include <google/protobuf/io/zero_copy_stream_impl.h> |
|
10 |
||
11 |
#include <getopt.h> |
|
12 |
#include <fcntl.h> |
|
13 |
||
14 |
#include <sys/stat.h> |
|
15 |
||
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
16 |
using namespace std; |
17 |
using namespace google; |
|
324.1.1
by Mats Kindahl
Adding specification of a simple protobuf-based binary log format, |
18 |
|
1085.1.2
by Monty Taylor
Fixed -Wmissing-declarations |
19 |
static void print_usage_and_exit(char *prog) { |
324.1.1
by Mats Kindahl
Adding specification of a simple protobuf-based binary log format, |
20 |
const char *name= strrchr(prog, '/'); |
21 |
||
22 |
if (name) |
|
23 |
++name; |
|
24 |
else
|
|
25 |
name= "binlog_reader"; |
|
26 |
cerr << "Usage: " << name << " <options>\n" |
|
27 |
<< " --input name Read queries from file <name> (default: 'log.bin')\n" |
|
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
28 |
<< flush; |
324.1.1
by Mats Kindahl
Adding specification of a simple protobuf-based binary log format, |
29 |
exit(1); |
30 |
}
|
|
31 |
||
32 |
||
33 |
int
|
|
34 |
main(int argc, char *argv[]) |
|
35 |
{
|
|
36 |
||
37 |
static struct option options[] = { |
|
38 |
{ "input", 1 /* has_arg */, NULL, 0 }, |
|
39 |
{ 0, 0, 0, 0 } |
|
40 |
};
|
|
41 |
||
42 |
const char *file_name= "log.bin"; |
|
43 |
||
44 |
int ch, option_index; |
|
45 |
while ((ch= getopt_long(argc, argv, "", options, &option_index)) != -1) { |
|
46 |
if (ch == '?') |
|
47 |
print_usage_and_exit(argv[0]); |
|
48 |
||
49 |
switch (option_index) { |
|
50 |
case 0: // --input |
|
51 |
file_name= optarg; |
|
52 |
break; |
|
53 |
||
54 |
}
|
|
55 |
}
|
|
56 |
||
57 |
if (optind > argc) |
|
58 |
print_usage_and_exit(argv[0]); |
|
59 |
||
520.9.1
by mordred
More solaris fixes. |
60 |
filebuf fb; |
61 |
||
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
62 |
fb.open(file_name, ios::in); |
520.9.1
by mordred
More solaris fixes. |
63 |
istream is(&fb); |
64 |
||
1101.2.1
by Monty Taylor
Fixed the first set of using namespace |
65 |
protobuf::io::ZeroCopyInputStream* raw_input= |
66 |
new protobuf::io::IstreamInputStream(&is); |
|
67 |
protobuf::io::CodedInputStream *coded_input= |
|
68 |
new protobuf::io::CodedInputStream(raw_input); |
|
324.1.1
by Mats Kindahl
Adding specification of a simple protobuf-based binary log format, |
69 |
|
70 |
BinaryLog::Event event; |
|
71 |
while (event.read(coded_input)) |
|
72 |
event.print(std::cout); |
|
73 |
||
74 |
delete coded_input; |
|
75 |
delete raw_input; |
|
520.9.1
by mordred
More solaris fixes. |
76 |
fb.close(); |
324.1.1
by Mats Kindahl
Adding specification of a simple protobuf-based binary log format, |
77 |
}
|