]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/gethostname.c
UefiCpuPkg/MicrocodeUpdateDxe: Fix coding style issues in INF file
[mirror_edk2.git] / StdLib / BsdSocketLib / gethostname.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 <stdlib.h>\r
40#include <string.h>\r
41#include <unistd.h>\r
42\r
43/*++\r
44\r
45Module Name:\r
46\r
47 gethostname.c\r
48 \r
49Abstract:\r
50\r
51 Map FreeBSD gethostname call to EFI Interface\r
52\r
53\r
54Revision History\r
55\r
56--*/\r
57\r
58int\r
59gethostname(\r
60 char *name,\r
61 size_t namelen\r
62 )\r
63/*++\r
64\r
65Routine Description:\r
66\r
67 Get the hostname for this system.\r
68\r
69Arguments:\r
70 \r
71 name - Pointer to storage for hostname.\r
72 namelen - Length of name\r
73\r
74Returns:\r
75\r
76 0 on success, -1 if not set\r
77\r
78--*/\r
79{\r
80 char *pHost;\r
81\r
82 pHost = getenv ("HOSTNAME");\r
83\r
84 if ( pHost == NULL ) {\r
85 *name = 0;\r
86 } else {\r
87 strncpy (name, pHost, namelen);\r
88 name[namelen-1] = 0;\r
89 }\r
90\r
91 return (0);\r
92}\r