Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / hci / commands / login_cmd.c
1 /*
2  * Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
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 #include <string.h>
21 #include <stdio.h>
22 #include <ipxe/command.h>
23 #include <ipxe/parseopt.h>
24 #include <ipxe/login_ui.h>
25
26 FILE_LICENCE ( GPL2_OR_LATER );
27
28 /** @file
29  *
30  * Login commands
31  *
32  */
33
34 /** "login" options */
35 struct login_options {};
36
37 /** "login" option list */
38 static struct option_descriptor login_opts[] = {};
39
40 /** "login" command descriptor */
41 static struct command_descriptor login_cmd =
42         COMMAND_DESC ( struct login_options, login_opts, 0, 0, NULL );
43
44 /**
45  * "login" command
46  *
47  * @v argc              Argument count
48  * @v argv              Argument list
49  * @ret rc              Return status code
50  */
51 static int login_exec ( int argc, char **argv ) {
52         struct login_options opts;
53         int rc;
54
55         /* Parse options */
56         if ( ( rc = parse_options ( argc, argv, &login_cmd, &opts ) ) != 0 )
57                 return rc;
58
59         /* Show login UI */
60         if ( ( rc = login_ui() ) != 0 ) {
61                 printf ( "Could not set credentials: %s\n",
62                          strerror ( rc ) );
63                 return rc;
64         }
65
66         return 0;
67 }
68
69 /** Login commands */
70 struct command login_command __command = {
71         .name = "login",
72         .exec = login_exec,
73 };