summaryrefslogtreecommitdiff
path: root/extra/resolveip.c
diff options
context:
space:
mode:
authormonty@hundin.mysql.fi <>2002-06-03 12:59:31 +0300
committermonty@hundin.mysql.fi <>2002-06-03 12:59:31 +0300
commitf0b28da6f91cf87804015b5dde4820be040c2de7 (patch)
treebe04186411dc657ef6bbcbe01267d30f2675c914 /extra/resolveip.c
parent3ede8f6289b53345f44aecffd70c7e291f88186b (diff)
parent544f95c45112993df1d31d3eda859dd5e4efff89 (diff)
downloadmariadb-git-f0b28da6f91cf87804015b5dde4820be040c2de7.tar.gz
merge with 4.0
Diffstat (limited to 'extra/resolveip.c')
-rw-r--r--extra/resolveip.c78
1 files changed, 36 insertions, 42 deletions
diff --git a/extra/resolveip.c b/extra/resolveip.c
index 20630d8414d..17bf087bd19 100644
--- a/extra/resolveip.c
+++ b/extra/resolveip.c
@@ -16,11 +16,10 @@
/* Resolves IP's to hostname and hostnames to IP's */
-#define RESOLVE_VERSION "2.0"
+#define RESOLVE_VERSION "2.2"
#include <my_global.h>
#include <m_ctype.h>
-#include <my_net.h>
#include <my_sys.h>
#include <m_string.h>
#include <sys/types.h>
@@ -30,27 +29,27 @@
#endif
#include <arpa/inet.h>
#include <netdb.h>
-#include <getopt.h>
-
-#ifdef SCO
-#undef h_errno
-#define h_errno errno
-#endif
+#include <my_net.h>
+#include <my_getopt.h>
#if !defined(_AIX) && !defined(HAVE_UNIXWARE7_THREADS) && !defined(HAVE_UNIXWARE7_POSIX) && !defined(h_errno)
extern int h_errno;
#endif
-static int silent=0;
+static my_bool silent;
-static struct option long_options[] =
+static struct my_option my_long_options[] =
{
- {"help", no_argument, 0, '?'},
- {"info", no_argument, 0, 'I'},
- {"silent", no_argument, 0, 's'},
- {"version", no_argument, 0, 'V'},
- {0, 0, 0, 0}
+ {"help", '?', "Displays this help and exits.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"info", 'I', "Synonym for --help",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"silent", 's', "Be more silent.", (gptr*) &silent, (gptr*) &silent,
+ 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+ {"version", 'V', "Displays version information and exits.",
+ 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+ { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
};
@@ -67,41 +66,36 @@ static void usage(void)
puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n");
puts("Get hostname based on IP-address or IP-address based on hostname.\n");
printf("Usage: %s [OPTIONS] hostname or IP-address\n",my_progname);
- printf("\n\
- -?, --help Displays this help and exits.\n\
- -I, --info Synonym for the above.\n\
- -s, --silent Be more silent.\n\
- -V, --version Displays version information and exits.\n");
+ my_print_help(my_long_options);
+ my_print_variables(my_long_options);
+}
+
+
+static my_bool
+get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
+ char *argument __attribute__((unused)))
+{
+ switch (optid) {
+ case 'V': print_version(); exit(0);
+ case 'I':
+ case '?':
+ usage();
+ exit(0);
+ }
+ return 0;
}
/*static my_string load_default_groups[]= { "resolveip","client",0 }; */
static int get_options(int *argc,char ***argv)
{
- int c,option_index;
+ int ho_error;
/* load_defaults("my",load_default_groups,argc,argv); */
- while ((c=getopt_long(*argc,*argv,"?IsV",
- long_options, &option_index)) != EOF)
- {
- switch (c) {
- case 's':
- silent=1;
- break;
- case 'V': print_version(); exit(0);
- case 'I':
- case '?':
- usage();
- exit(0);
- default:
- fprintf(stderr,"%s: Illegal option character '%c'\n",
- my_progname,opterr);
- return(1);
- break;
- }
- }
- (*argc)-=optind;
- (*argv)+=optind;
+
+ if ((ho_error=handle_options(argc, argv, my_long_options, get_one_option)))
+ exit(ho_error);
+
if (*argc == 0)
{
usage();