+++ /dev/null
-/*\r
- * Copyright (c) 1999, 2000\r
- * Intel Corporation.\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without modification,\r
- * are permitted provided that the following conditions are met:\r
- *\r
- * 1. Redistributions of source code must retain the above copyright notice,\r
- * this list of conditions and the following disclaimer.\r
- *\r
- * 2. Redistributions in binary form must reproduce the above copyright notice,\r
- * this list of conditions and the following disclaimer in the documentation\r
- * and/or other materials provided with the distribution.\r
- *\r
- * 3. All advertising materials mentioning features or use of this software must\r
- * display the following acknowledgement:\r
- *\r
- * This product includes software developed by Intel Corporation and its\r
- * contributors.\r
- *\r
- * 4. Neither the name of Intel Corporation or its contributors may be used to\r
- * endorse or promote products derived from this software without specific\r
- * prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS'' AND\r
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
- * DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR CONTRIBUTORS BE LIABLE FOR\r
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- */\r
-\r
-#include <errno.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <Uefi.h>\r
-#include <unistd.h>\r
-#include <wchar.h>\r
-\r
-/*++\r
-\r
-Module Name:\r
-\r
- sethostname.c\r
-\r
-Abstract:\r
-\r
- Map FreeBSD sethostname call to EFI Interface\r
-\r
-\r
-Revision History\r
-\r
---*/\r
-\r
-int\r
-sethostname(\r
- const char * name,\r
- size_t namelen\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Set the hostname for this system.\r
-\r
-Arguments:\r
-\r
- name - Pointer to hostname.\r
- namelen - Length of name\r
-\r
-Returns:\r
-\r
- 0 on success, -1 if not set\r
-\r
---*/\r
-{\r
- int SetStatus;\r
- char * pName;\r
-\r
- //\r
- // Allocate a new buffer for name since the input value\r
- // does not need to be zero terminated\r
- //\r
- pName = malloc ( namelen + 1 );\r
- if ( NULL == pName ) {\r
- errno = ENOMEM;\r
- SetStatus = -1;\r
- }\r
- else {\r
- //\r
- // Create a zero terminated string for name\r
- //\r
- memcpy ( pName, name, namelen );\r
- pName[ namelen ] = 0;\r
- \r
- //\r
- // Set the environment variable\r
- //\r
- SetStatus = setenv ("HOSTNAME", pName, TRUE);\r
-\r
- //\r
- // Free the temporary buffer\r
- //\r
- free ( pName );\r
- }\r
-\r
- //\r
- // Return the results\r
- //\r
- return SetStatus;\r
-}\r