aboutsummaryrefslogtreecommitdiff
path: root/cmdline.opt
blob: 51ec8f9550354a1f945e4a211ed59e6b9cf97df8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* This file is part of Grot.  -*- c -*-
   Copyright (C) 2009, 2010 Sergey Poznyakoff

   Grot is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   Grot is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with grot.  If not, see <http://www.gnu.org/licenses/>. */

#include "grot.h"
#include <getopt.h>

#define gettext(s) s
#define _(s) gettext(s)
#define N_(s) s

char *grot_host;
char *grot_password;
int password_option;
unsigned grot_port;
char *grot_socket;
char *grot_user;
int verbose;
int dry_run_option;
int flush_logs_option = 1;
size_t keep_count;

OPTIONS_BEGIN(gnu, "grot",
              [<Gray's Rotation Tool for MySQL binary logs>])

OPTION(host,H,[NAME],
       [<server host>])
BEGIN
	grot_host = optarg;
END

OPTION(password,p,[PASS],
       [<MySQL user password>])
BEGIN
	grot_password = optarg;
	password_option = 1;
END

OPTION(port,P,NUMBER,
       [<port number>])
BEGIN
	char *p;
	grot_port = strtoul(optarg, &p, 10);
	if (!grot_port || *p)
	    terror(1, NULL, "invalid port number: %s", optarg);
END

OPTION(socket,S,STRING,
       [<socket file name>])
BEGIN
	grot_socket = optarg;
END


OPTION(user,u,NAME,
       [<user name>])
BEGIN
	grot_user = optarg;
END

OPTION(verbose,v,,
       [<increase verbosity level>])
BEGIN
	verbose++;
END	

OPTION(dry-run,n,,
       [<do not actually rotate the logs>])
BEGIN
	dry_run_option = 1;
	verbose++;
END

OPTION(no-flush,,,
       [<do not flush logs after rotating>])
BEGIN
	flush_logs_option = 0;
END	

OPTION(keep,k,NUMBER,
       [<keep NUMBER of files before the oldest>])
BEGIN
	char *p;	
	keep_count = strtoul(optarg, &p, 0);
	if (*p)
		terror(1, NULL, "invalid number: %s", optarg);
END		

OPTIONS_END

void
read_options(int argc, char *argv[])
{
    GETOPT(argc, argv)
}

Return to:

Send suggestions and report system problems to the System administrator.