Merge lp:~linuxjedi/libdrizzle/5.1-remove-tools into lp:libdrizzle

Proposed by Andrew Hutchings
Status: Merged
Approved by: Andrew Hutchings
Approved revision: 96
Merged at revision: 96
Proposed branch: lp:~linuxjedi/libdrizzle/5.1-remove-tools
Merge into: lp:libdrizzle
Diff against target: 504 lines (+0/-436)
9 files modified
Makefile.am (+0/-1)
cli/drizzle_binlogs.c (+0/-350)
cli/drizzle_binlogs_check.sh.in (+0/-4)
cli/include.am (+0/-12)
configure.ac (+0/-1)
docs/cli/drizzle_binlog.rst (+0/-59)
docs/cli/index.rst (+0/-7)
docs/index.rst (+0/-1)
rpm/spec.in (+0/-1)
To merge this branch: bzr merge lp:~linuxjedi/libdrizzle/5.1-remove-tools
Reviewer Review Type Date Requested Status
Drizzle Trunk Pending
Review via email: mp+143879@code.launchpad.net

Description of the change

Remove drizzle_binlogs tool

It is now in the drizzle-tools project:
https://launchpad.net/drizzle-tools/

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2013-01-08 12:12:01 +0000
3+++ Makefile.am 2013-01-18 13:36:23 +0000
4@@ -37,7 +37,6 @@
5 include yatl/include.am
6 include tests/include.am
7 include m4/include.am
8-include cli/include.am
9 include libdrizzle/include.am
10 include libdrizzle-5.1/include.am
11 include rpm/include.am
12
13=== removed directory 'cli'
14=== removed file 'cli/drizzle_binlogs.c'
15--- cli/drizzle_binlogs.c 2013-01-17 20:37:10 +0000
16+++ cli/drizzle_binlogs.c 1970-01-01 00:00:00 +0000
17@@ -1,350 +0,0 @@
18-/*
19- * Drizzle Client & Protocol Library
20- *
21- * Copyright (C) 2012 Drizzle Developer Group
22- * All rights reserved.
23- *
24- * Redistribution and use in source and binary forms, with or without
25- * modification, are permitted provided that the following conditions are
26- * met:
27- *
28- * * Redistributions of source code must retain the above copyright
29- * notice, this list of conditions and the following disclaimer.
30- *
31- * * Redistributions in binary form must reproduce the above
32- * copyright notice, this list of conditions and the following disclaimer
33- * in the documentation and/or other materials provided with the
34- * distribution.
35- *
36- * * The names of its contributors may not be used to endorse or
37- * promote products derived from this software without specific prior
38- * written permission.
39- *
40- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
51- *
52- */
53-
54-#include "config.h"
55-
56-#include <libdrizzle-5.1/libdrizzle.h>
57-#include <stdlib.h>
58-#include <sys/types.h>
59-
60-#ifdef HAVE_PWD_H
61-# include <pwd.h>
62-#endif
63-
64-#include <unistd.h>
65-#include <errno.h>
66-#include <time.h>
67-
68-#ifdef HAVE_ARGP_H
69-# include <argp.h>
70-#else
71-# error "drizzle_binlogs requires <argp.h>"
72-#endif
73-
74-#define STR_HELPER(x) #x
75-#define STR(x) STR_HELPER(x)
76-
77-char *host= NULL;
78-uint16_t port= DRIZZLE_DEFAULT_TCP_PORT;
79-char *user= NULL;
80-bool user_alloced= false;
81-char *pass= NULL;
82-char *outdir= NULL;
83-char *start_file= NULL;
84-uint32_t start_pos= 0;
85-bool continuous= false;
86-bool verify_checksums= false;
87-uint8_t opt_count= 0;
88-
89-typedef enum
90-{
91- OPT_NONE,
92- OPT_HOST,
93- OPT_PORT,
94- OPT_USER,
95- OPT_PASS,
96- OPT_OUTDIR,
97- OPT_FILE,
98- OPT_START_POS,
99- OPT_CONTINUOUS,
100- OPT_VERIFY_CHECKSUMS
101-} option_consts_t;
102-
103-static struct argp_option options[]= {
104- { "host", OPT_HOST, "HOST", 0, "Hostname of server, default "DRIZZLE_DEFAULT_TCP_HOST, 0 },
105- { "port", OPT_PORT, "PORT", 0, "Port number of server, default "STR(DRIZZLE_DEFAULT_TCP_PORT), 0 },
106- { "user", OPT_USER, "USER", 0, "Username for the server, default is current system user", 0 },
107- { "pass", OPT_PASS, "PASS", 0, "Password for the server", 0 },
108- { "outdir", OPT_OUTDIR, "OUTDIR", 0, "Output directory", 0 },
109- { 0, 0, 0, 0, "Binlog Options", 1 },
110- { "start-file", OPT_FILE, "FILENAME", 0, "Binlog file to start with", 1 },
111- { "start-pos", OPT_START_POS, "POS", 0, "Position to start with", 1 },
112- { "continuous", OPT_CONTINUOUS, 0, 0, "Continous download mode", 1 },
113- { "verify-checksums", OPT_VERIFY_CHECKSUMS, 0, 0, "Verify binlog checkums", 1 },
114- { 0 }
115-};
116-
117-static char doc[]= "Drizzle binlog retriever";
118-static char args_doc[]= "";
119-static error_t parse_opt(int key, char *arg, struct argp_state *state)
120-{
121- (void)(state);
122- switch(key)
123- {
124- case OPT_HOST:
125- host= arg;
126- opt_count++;
127- break;
128- case OPT_PORT:
129- port= atoi(arg);
130- opt_count++;
131- break;
132- case OPT_USER:
133- user= arg;
134- opt_count++;
135- break;
136- case OPT_PASS:
137- pass= arg;
138- opt_count++;
139- break;
140- case OPT_OUTDIR:
141- outdir= arg;
142- opt_count++;
143- break;
144- case OPT_FILE:
145- start_file= arg;
146- opt_count++;
147- break;
148- case OPT_START_POS:
149- start_pos= atoi(arg);
150- opt_count++;
151- break;
152- case OPT_CONTINUOUS:
153- continuous= true;
154- opt_count++;
155- break;
156- case OPT_VERIFY_CHECKSUMS:
157- verify_checksums= true;
158- opt_count++;
159- break;
160- case ARGP_KEY_NO_ARGS:
161- break;
162- default:
163- return ARGP_ERR_UNKNOWN;
164- break;
165- }
166- return 0;
167-}
168-
169-static struct argp argp = { options, parse_opt, args_doc, doc, NULL, NULL, NULL };
170-
171-bool get_system_user(char *dest, uint8_t len);
172-drizzle_st *_connect(void);
173-FILE *create_binlog_file(char *binlog_file);
174-void get_binlogs(drizzle_st *con);
175-void write_binlog(FILE* file, const unsigned char* data, uint32_t len);
176-
177-bool get_system_user(char *dest, uint8_t len)
178-{
179- long pw_len= sysconf(_SC_GETPW_R_SIZE_MAX);
180- struct passwd pw_struct;
181- struct passwd *pw_tmp_struct;
182- if (pw_len == -1)
183- {
184- pw_len= 1024;
185- }
186- char *pw_buffer= malloc(pw_len);
187-
188- if (getpwuid_r(geteuid(), &pw_struct, pw_buffer, pw_len, &pw_tmp_struct) == 0)
189- {
190- strncpy(dest, pw_struct.pw_name, len);
191- free(pw_buffer);
192- return true;
193- }
194- free(pw_buffer);
195- return false;
196-}
197-
198-drizzle_st *_connect(void)
199-{
200- drizzle_st *con;
201- drizzle_return_t ret;
202-
203- con= drizzle_create_tcp(host, port, user, pass, "", 0);
204- if (!con)
205- {
206- printf("Drizzle connection object creation error\n");
207- return NULL;
208- }
209- ret= drizzle_connect(con);
210- if (ret != DRIZZLE_RETURN_OK)
211- {
212- printf("Error connecting to server: %s\n", drizzle_error(con));
213- return NULL;
214- }
215- return con;
216-}
217-
218-FILE *create_binlog_file(char *binlog_file)
219-{
220- FILE *outfile;
221- char filename[PATH_MAX];
222- if (outdir)
223- {
224- snprintf(filename, PATH_MAX, "%s/%s", outdir, binlog_file);
225- outfile= fopen(filename, "w");
226- }
227- else
228- {
229- outfile= fopen(binlog_file, "w");
230- }
231-
232- return outfile;
233-}
234-
235-void get_binlogs(drizzle_st *con)
236-{
237- drizzle_result_st *result;
238- drizzle_return_t ret;
239- uint16_t server_id;
240- FILE *outfile;
241- char binlog_file[PATH_MAX];
242- uint32_t event_len;
243- bool read_end= false;
244-
245- if (continuous)
246- {
247- srand(time(NULL));
248- // Random server ID from range 32767 - 65535
249- server_id= rand() % 32768 + 32767;
250- }
251- else
252- {
253- server_id= 0;
254- }
255-
256- result= drizzle_start_binlog(con, server_id, start_file, start_pos, verify_checksums, &ret);
257- if (ret != DRIZZLE_RETURN_OK)
258- {
259- printf("Drizzle binlog start failure: %s\n", drizzle_error(con));
260- exit(EXIT_FAILURE);
261- }
262-
263- snprintf(binlog_file, PATH_MAX, "%s", start_file);
264- outfile= create_binlog_file(binlog_file);
265- if (!outfile)
266- {
267- printf("Could not create binlog file '%s', errno %d\n", binlog_file, errno);
268- exit(EXIT_FAILURE);
269- }
270-
271- while(1)
272- {
273- write_binlog(outfile, (unsigned char *)DRIZZLE_BINLOG_MAGIC, 4);
274- while(1)
275- {
276- ret= drizzle_binlog_get_next_event(result);
277- event_len= drizzle_binlog_event_raw_length(result);
278- if (ret != DRIZZLE_RETURN_OK)
279- {
280- // EOF
281- if (ret != DRIZZLE_RETURN_EOF)
282- {
283- printf("Read error: %d - %s\n", ret, drizzle_error(con));
284- }
285- read_end= true;
286- break;
287- }
288- if (drizzle_binlog_event_type(result) == DRIZZLE_EVENT_TYPE_ROTATE)
289- {
290- fclose(outfile);
291- snprintf(binlog_file, PATH_MAX, "%.*s", drizzle_binlog_event_length(result), drizzle_binlog_event_data(result));
292- outfile= create_binlog_file(binlog_file);
293- if (!outfile)
294- {
295- printf("Could not create binlog file '%s', errno %d\n", binlog_file, errno);
296- exit(EXIT_FAILURE);
297- }
298- break;
299- }
300- write_binlog(outfile, drizzle_binlog_event_raw_data(result), event_len);
301- }
302- if (read_end)
303- {
304- break;
305- }
306- }
307-
308- drizzle_result_free(result);
309-}
310-
311-void write_binlog(FILE* file, const unsigned char* data, uint32_t len)
312-{
313- if (len)
314- {
315- if (fwrite(data, 1, len, file) != len)
316- {
317- printf("Error: binlog: Error writing binary log: %s", strerror(errno));
318- exit(EXIT_FAILURE);
319- }
320- }
321-
322-}
323-
324-int main(int argc, char *argv[])
325-{
326- drizzle_st *con;
327- char sysuser[DRIZZLE_MAX_USER_SIZE];
328- // Use the define here because we want it fixed at compile time
329- argp_program_version= LIBDRIZZLE_VERSION_STRING;
330- argp_program_bug_address= drizzle_bugreport();
331- argp_parse(&argp, argc, argv, 0, 0, NULL);
332- if (opt_count == 0)
333- {
334- argp_help(&argp, stdout, ARGP_HELP_STD_USAGE, program_invocation_short_name);
335- return EXIT_FAILURE;
336- }
337- if (!user)
338- {
339- user= sysuser;
340- if (!get_system_user(user, DRIZZLE_MAX_USER_SIZE))
341- {
342- printf("No user specified and could not determine current user\n");
343- return EXIT_FAILURE;
344- }
345- }
346- if (!host)
347- {
348- host= (char*)DRIZZLE_DEFAULT_TCP_HOST;
349- }
350- if (!port)
351- {
352- port= DRIZZLE_DEFAULT_TCP_PORT;
353- }
354- if (!start_file)
355- {
356- printf("Binlog start file required\n");
357- return EXIT_FAILURE;
358- }
359- con = _connect();
360- if (!con)
361- {
362- return EXIT_FAILURE;
363- }
364- get_binlogs(con);
365- drizzle_quit(con);
366- return EXIT_SUCCESS;
367-}
368
369=== removed file 'cli/drizzle_binlogs_check.sh.in'
370--- cli/drizzle_binlogs_check.sh.in 2013-01-08 12:12:01 +0000
371+++ cli/drizzle_binlogs_check.sh.in 1970-01-01 00:00:00 +0000
372@@ -1,4 +0,0 @@
373-#!/bin/sh
374-# Simple test for drizzle_binlog
375-
376-cli/drizzle_binlogs --help &> /dev/null
377
378=== removed file 'cli/include.am'
379--- cli/include.am 2013-01-08 12:12:01 +0000
380+++ cli/include.am 1970-01-01 00:00:00 +0000
381@@ -1,12 +0,0 @@
382-# vim:ft=automake
383-# included from Top Level Makefile.am
384-# All paths should be given relative to the root
385-
386-if BUILD_WIN32
387-else
388-bin_PROGRAMS+= cli/drizzle_binlogs
389-cli_drizzle_binlogs_SOURCES= cli/drizzle_binlogs.c
390-cli_drizzle_binlogs_LDADD= libdrizzle/libdrizzle.la
391-
392-check_SCRIPTS+= cli/drizzle_binlogs_check.sh
393-endif
394
395=== modified file 'configure.ac'
396--- configure.ac 2013-01-13 20:48:01 +0000
397+++ configure.ac 2013-01-18 13:36:23 +0000
398@@ -98,7 +98,6 @@
399 AX_CREATE_GENERIC_CONFIG
400 AX_AM_JOBSERVER([yes])
401
402-AC_CONFIG_FILES([cli/drizzle_binlogs_check.sh],[chmod +x cli/drizzle_binlogs_check.sh])
403 AC_CONFIG_FILES([Makefile
404 docs/conf.py
405 rpm/spec
406
407=== removed directory 'docs/cli'
408=== removed file 'docs/cli/drizzle_binlog.rst'
409--- docs/cli/drizzle_binlog.rst 2012-12-19 13:05:44 +0000
410+++ docs/cli/drizzle_binlog.rst 1970-01-01 00:00:00 +0000
411@@ -1,59 +0,0 @@
412-.. program:: drizzle_binlog
413-
414-Drizzle Binlog
415-==============
416-
417-Introduction
418-------------
419-
420-Drizzle binlog is an example tool which will connect to a MySQL server as a
421-slave, retrieve the binary log data and store it as local copies of the binary
422-log files. It has a continuous mode which will continue to download new events
423-as they are applied.
424-
425-Usage
426------
427-
428-:program:`drizzle_binlog` :option:`--start-file=binlog_file <--start-file>` OPTIONS
429-
430-Options
431--------
432-
433-Main Options
434-^^^^^^^^^^^^
435-
436-.. option:: --host <hostname>
437-
438- The hostname for the MySQL server (default 'localhost')
439-
440-.. option:: --port <port>
441-
442- The port number for the MySQL server (default 3306)
443-
444-.. option:: --user <user>
445-
446- The MySQL user to connect as (default is the system user drizzle_binlog is executed as)
447-
448-.. option:: --pass <pass>
449-
450- The MySQL password to connect using
451-
452-.. option:: --outdir <outdir>
453-
454- The output directory to store the binlogs
455-
456-Binlog Options
457-^^^^^^^^^^^^^^
458-
459-.. option:: --start-file <file>
460-
461- Which binlog file should be requested first
462-
463-.. option:: --start-pos <pos>
464-
465- Position in the binlog file to start at
466-
467-.. option:: --continuous
468-
469- Connect as a random slave ID of 32768-65535 so drizzle_binlogs isn't
470- disconnected at the end of the last log
471
472=== removed file 'docs/cli/index.rst'
473--- docs/cli/index.rst 2012-12-19 13:05:44 +0000
474+++ docs/cli/index.rst 1970-01-01 00:00:00 +0000
475@@ -1,7 +0,0 @@
476-Example Command Line Clients
477-============================
478-
479-.. toctree::
480- :maxdepth: 2
481-
482- drizzle_binlog
483
484=== modified file 'docs/index.rst'
485--- docs/index.rst 2012-12-19 13:05:44 +0000
486+++ docs/index.rst 2013-01-18 13:36:23 +0000
487@@ -8,5 +8,4 @@
488 license
489 compiling
490 api/index
491- cli/index
492 examples/index
493
494=== modified file 'rpm/spec.in'
495--- rpm/spec.in 2013-01-17 20:37:10 +0000
496+++ rpm/spec.in 2013-01-18 13:36:23 +0000
497@@ -54,7 +54,6 @@
498 %{_libdir}/libdrizzle.la
499 %{_libdir}/libdrizzle.so
500 %{_libdir}/libdrizzle.so.*
501-%{_bindir}/drizzle_binlogs
502 %{_bindir}/libdrizzle-config
503
504 %files devel

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: