iPXE
nslookup_cmd.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Patrick Plenefisch <phplenefisch@wpi.edu>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  */
19 
20 FILE_LICENCE ( GPL2_OR_LATER );
21 
22 #include <stdio.h>
23 #include <getopt.h>
24 #include <ipxe/command.h>
25 #include <ipxe/parseopt.h>
26 #include <usr/nslookup.h>
27 
28 /** @file
29  *
30  * nslookup command
31  *
32  */
33 
34 /** "nslookup" options */
35 struct nslookup_options {};
36 
37 /** "nslookup" option list */
38 static struct option_descriptor nslookup_opts[] = {};
39 
40 /** "nslookup" command descriptor */
43  "<setting> <name>" );
44 
45 /**
46  * The "nslookup" command
47  *
48  * @v argc Argument count
49  * @v argv Argument list
50  * @ret rc Return status code
51  */
52 static int nslookup_exec ( int argc, char **argv ) {
53  struct nslookup_options opts;
54  const char *name;
55  const char *setting_name;
56  int rc;
57 
58  /* Parse options */
59  if ( ( rc = parse_options ( argc, argv, &nslookup_cmd, &opts ) ) != 0 )
60  return rc;
61 
62  /* Parse setting name */
63  setting_name = argv[optind];
64 
65  /* Parse name to be resolved */
66  name = argv[ optind + 1 ];
67 
68  /* Look up name */
69  if ( ( rc = nslookup ( name, setting_name ) ) != 0 )
70  return rc;
71 
72  return 0;
73 }
74 
75 /** The "nslookup" command */
76 struct command nslookup_command __command = {
77  .name = "nslookup",
78  .exec = nslookup_exec,
79 };
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
int optind
Current option index.
Definition: getopt.c:51
static struct option_descriptor nslookup_opts[]
"nslookup" option list
Definition: nslookup_cmd.c:38
Standalone name resolution.
A command-line command.
Definition: command.h:9
int parse_options(int argc, char **argv, struct command_descriptor *cmd, void *opts)
Parse command-line options.
Definition: parseopt.c:484
A command descriptor.
Definition: parseopt.h:77
struct command nslookup_command __command
The "nslookup" command.
Definition: nslookup_cmd.c:76
Parse command-line options.
FILE_LICENCE(GPL2_OR_LATER)
Command line option parsing.
"nslookup" options
Definition: nslookup_cmd.c:35
static union @437 opts
"cert<xxx>" option list
const char * name
Name of the command.
Definition: command.h:11
static int nslookup_exec(int argc, char **argv)
The "nslookup" command.
Definition: nslookup_cmd.c:52
A command-line option descriptor.
Definition: parseopt.h:23
#define COMMAND_DESC(_struct, _options, _min_args, _max_args, _usage)
Construct command descriptor.
Definition: parseopt.h:108
int setting_name(struct settings *settings, const struct setting *setting, char *buf, size_t len)
Return full setting name.
Definition: settings.c:1606
static struct command_descriptor nslookup_cmd
"nslookup" command descriptor
Definition: nslookup_cmd.c:41
A name resolution request.
Definition: nslookup.c:39