]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/sethostname.c
Fix send to properly wait while long transmits are in progress
[mirror_edk2.git] / StdLib / BsdSocketLib / sethostname.c
CommitLineData
d7ce7006 1/*\r
2 * Copyright (c) 1999, 2000\r
3 * Intel Corporation.\r
4 * All rights reserved.\r
5 *\r
6 * Redistribution and use in source and binary forms, with or without modification,\r
7 * are permitted provided that the following conditions are met:\r
8 *\r
9 * 1. Redistributions of source code must retain the above copyright notice,\r
10 * this list of conditions and the following disclaimer.\r
11 *\r
12 * 2. Redistributions in binary form must reproduce the above copyright notice,\r
13 * this list of conditions and the following disclaimer in the documentation\r
14 * and/or other materials provided with the distribution.\r
15 *\r
16 * 3. All advertising materials mentioning features or use of this software must\r
17 * display the following acknowledgement:\r
18 *\r
19 * This product includes software developed by Intel Corporation and its\r
20 * contributors.\r
21 *\r
22 * 4. Neither the name of Intel Corporation or its contributors may be used to\r
23 * endorse or promote products derived from this software without specific\r
24 * prior written permission.\r
25 *\r
26 * THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS'' AND\r
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
29 * DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR CONTRIBUTORS BE LIABLE FOR\r
30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r
33 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
36 *\r
37 */\r
38\r
39#include <errno.h>\r
40#include <stdlib.h>\r
41#include <string.h>\r
42#include <Uefi.h>\r
43#include <unistd.h>\r
44#include <wchar.h>\r
45\r
46/*++\r
47\r
48Module Name:\r
49\r
50 sethostname.c\r
51\r
52Abstract:\r
53\r
54 Map FreeBSD sethostname call to EFI Interface\r
55\r
56\r
57Revision History\r
58\r
59--*/\r
60\r
61int\r
62sethostname(\r
63 const char * name,\r
64 size_t namelen\r
65 )\r
66/*++\r
67\r
68Routine Description:\r
69\r
70 Set the hostname for this system.\r
71\r
72Arguments:\r
73\r
74 name - Pointer to hostname.\r
75 namelen - Length of name\r
76\r
77Returns:\r
78\r
79 0 on success, -1 if not set\r
80\r
81--*/\r
82{\r
83 int SetStatus;\r
84 char * pName;\r
85\r
86 //\r
87 // Allocate a new buffer for name since the input value\r
88 // does not need to be zero terminated\r
89 //\r
90 pName = malloc ( namelen + 1 );\r
91 if ( NULL == pName ) {\r
92 errno = ENOMEM;\r
93 SetStatus = -1;\r
94 }\r
95 else {\r
96 //\r
97 // Create a zero terminated string for name\r
98 //\r
99 memcpy ( pName, name, namelen );\r
100 pName [ namelen ] = 0;\r
101 \r
102 //\r
103 // Set the environment variable\r
104 //\r
105 SetStatus = setenv ("HOSTNAME", pName, TRUE);\r
106\r
107 //\r
108 // Free the temporary buffer\r
109 //\r
110 free ( pName );\r
111 }\r
112\r
113 //\r
114 // Return the results\r
115 //\r
116 return SetStatus;\r
117}\r