diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-05-15 16:47:25 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-05-15 16:47:25 +0300 |
commit | 168463b46dd58dd24009f2aacef604bab01300a5 (patch) | |
tree | 903b5dcd23037c04ad255b188f92a033a025f0c2 /cmdline.opt | |
download | grot-168463b46dd58dd24009f2aacef604bab01300a5.tar.gz grot-168463b46dd58dd24009f2aacef604bab01300a5.tar.bz2 |
Initial commit
Diffstat (limited to 'cmdline.opt')
-rw-r--r-- | cmdline.opt | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/cmdline.opt b/cmdline.opt new file mode 100644 index 0000000..16956d7 --- /dev/null +++ b/cmdline.opt @@ -0,0 +1,108 @@ +/* This file is part of Grot. -*- c -*- + Copyright (C) 2009 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 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) +} + |