~drizzle-trunk/drizzle/development

487 by Brian Aker
First pieces to new master.info file.
1
#include <iostream>
2
#include <fstream>
3
#include <string>
988.1.1 by Jay Pipes
Changes libserialize to libdrizzledmessage per ML discussion. All GPB messages are now in the drizzled::message namespace.
4
#include <drizzled/message/master_list.pb.h>
487 by Brian Aker
First pieces to new master.info file.
5
using namespace std;
6
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
7
/*
487 by Brian Aker
First pieces to new master.info file.
8
  Example script for reader a Drizzle master replication list.
9
*/
10
1085.1.2 by Monty Taylor
Fixed -Wmissing-declarations
11
static void fill_master_record(drizzle::MasterList_Record *record, const char *hostname)
487 by Brian Aker
First pieces to new master.info file.
12
{
13
  using namespace drizzle;
14
  record->set_hostname(hostname);
15
  record->set_username("root");
16
  record->set_password("mine");
17
  record->set_port(3306);
18
  record->set_connect_retry(5);
19
  record->set_log_name("/tmp/foo");
20
  record->set_log_position(0);
21
}
22
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
23
int main(int argc, char* argv[])
487 by Brian Aker
First pieces to new master.info file.
24
{
25
  GOOGLE_PROTOBUF_VERIFY_VERSION;
26
27
  if (argc != 2) {
28
    cerr << "Usage:  " << argv[0] << " MASTER_LIST" << endl;
29
    return -1;
30
  }
31
32
  drizzle::MasterList list;
33
34
  fill_master_record(list.add_record(), "master.example.com");
35
  fill_master_record(list.add_record(), "foo.example.com");
36
37
  fstream output(argv[1], ios::out | ios::trunc | ios::binary);
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
38
  if (!list.SerializeToOstream(&output))
487 by Brian Aker
First pieces to new master.info file.
39
  {
40
    cerr << "Failed to write master_list." << endl;
41
    return -1;
42
  }
43
44
  return 0;
45
}