]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Sockets/SetHostName/SetHostName.c
4 Copyright (c) 2011-2012, Intel Corporation. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Library/DebugLib.h>
15 #include <Library/UefiLib.h>
17 #include <sys/socket.h>
25 @param [in] Argc The number of arguments
26 @param [in] Argv The argument value array
28 @retval 0 The application exited normally.
29 @retval Other An error occurred.
44 // Determine if the host name is specified
51 AppStatus
= sethostname ( Argv
[1], strlen ( Argv
[1]));
52 if ( -1 == AppStatus
) {
55 Print ( L
"ERROR - errno: %d\r\n", errno
);
59 Print ( L
"WARNING - Plarform does not support permanent storage!\r\n" );
63 Print ( L
"ERROR - Insufficient storage to save host name!\r\n" );
67 Print ( L
"ERROR - Platform does not support environment variable storage!\r\n" );
74 // Display the current host name
76 AppStatus
= gethostname ( &mBuffer
[0], sizeof ( mBuffer
));
77 if ( -1 == AppStatus
) {
78 Print ( L
"ERROR - Unable to get host name, errno: %d\r\n", errno
);
81 if ( 0 == mBuffer
[0]) {
82 Print ( L
"Host name is not set!\r\n" );
85 Print ( L
"Host name: %a", &mBuffer
[0]);