summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/curl_gethostname.c
diff options
context:
space:
mode:
authordartraiden <wowemuh@gmail.com>2022-12-22 16:31:20 +0300
committerdartraiden <wowemuh@gmail.com>2022-12-22 16:31:20 +0300
commit47b6881fe726c904f87aa4be059b730ef77954d0 (patch)
treeaa72b213043d3b514c883bc59a0fa0c434106156 /libs/libcurl/src/curl_gethostname.c
parent8fbc9220b7f3d3a04bbe45d32489ef882821558e (diff)
libcurl: update to 7.87.0
Diffstat (limited to 'libs/libcurl/src/curl_gethostname.c')
-rw-r--r--libs/libcurl/src/curl_gethostname.c204
1 files changed, 102 insertions, 102 deletions
diff --git a/libs/libcurl/src/curl_gethostname.c b/libs/libcurl/src/curl_gethostname.c
index 4747e938db..bc18698b62 100644
--- a/libs/libcurl/src/curl_gethostname.c
+++ b/libs/libcurl/src/curl_gethostname.c
@@ -1,102 +1,102 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- * SPDX-License-Identifier: curl
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-
-#include "curl_gethostname.h"
-
-/*
- * Curl_gethostname() is a wrapper around gethostname() which allows
- * overriding the host name that the function would normally return.
- * This capability is used by the test suite to verify exact matching
- * of NTLM authentication, which exercises libcurl's MD4 and DES code
- * as well as by the SMTP module when a hostname is not provided.
- *
- * For libcurl debug enabled builds host name overriding takes place
- * when environment variable CURL_GETHOSTNAME is set, using the value
- * held by the variable to override returned host name.
- *
- * Note: The function always returns the un-qualified hostname rather
- * than being provider dependent.
- *
- * For libcurl shared library release builds the test suite preloads
- * another shared library named libhostname using the LD_PRELOAD
- * mechanism which intercepts, and might override, the gethostname()
- * function call. In this case a given platform must support the
- * LD_PRELOAD mechanism and additionally have environment variable
- * CURL_GETHOSTNAME set in order to override the returned host name.
- *
- * For libcurl static library release builds no overriding takes place.
- */
-
-int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen)
-{
-#ifndef HAVE_GETHOSTNAME
-
- /* Allow compilation and return failure when unavailable */
- (void) name;
- (void) namelen;
- return -1;
-
-#else
- int err;
- char *dot;
-
-#ifdef DEBUGBUILD
-
- /* Override host name when environment variable CURL_GETHOSTNAME is set */
- const char *force_hostname = getenv("CURL_GETHOSTNAME");
- if(force_hostname) {
- strncpy(name, force_hostname, namelen);
- err = 0;
- }
- else {
- name[0] = '\0';
- err = gethostname(name, namelen);
- }
-
-#else /* DEBUGBUILD */
-
- /* The call to system's gethostname() might get intercepted by the
- libhostname library when libcurl is built as a non-debug shared
- library when running the test suite. */
- name[0] = '\0';
- err = gethostname(name, namelen);
-
-#endif
-
- name[namelen - 1] = '\0';
-
- if(err)
- return err;
-
- /* Truncate domain, leave only machine name */
- dot = strchr(name, '.');
- if(dot)
- *dot = '\0';
-
- return 0;
-#endif
-
-}
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#include "curl_gethostname.h"
+
+/*
+ * Curl_gethostname() is a wrapper around gethostname() which allows
+ * overriding the host name that the function would normally return.
+ * This capability is used by the test suite to verify exact matching
+ * of NTLM authentication, which exercises libcurl's MD4 and DES code
+ * as well as by the SMTP module when a hostname is not provided.
+ *
+ * For libcurl debug enabled builds host name overriding takes place
+ * when environment variable CURL_GETHOSTNAME is set, using the value
+ * held by the variable to override returned host name.
+ *
+ * Note: The function always returns the un-qualified hostname rather
+ * than being provider dependent.
+ *
+ * For libcurl shared library release builds the test suite preloads
+ * another shared library named libhostname using the LD_PRELOAD
+ * mechanism which intercepts, and might override, the gethostname()
+ * function call. In this case a given platform must support the
+ * LD_PRELOAD mechanism and additionally have environment variable
+ * CURL_GETHOSTNAME set in order to override the returned host name.
+ *
+ * For libcurl static library release builds no overriding takes place.
+ */
+
+int Curl_gethostname(char * const name, GETHOSTNAME_TYPE_ARG2 namelen)
+{
+#ifndef HAVE_GETHOSTNAME
+
+ /* Allow compilation and return failure when unavailable */
+ (void) name;
+ (void) namelen;
+ return -1;
+
+#else
+ int err;
+ char *dot;
+
+#ifdef DEBUGBUILD
+
+ /* Override host name when environment variable CURL_GETHOSTNAME is set */
+ const char *force_hostname = getenv("CURL_GETHOSTNAME");
+ if(force_hostname) {
+ strncpy(name, force_hostname, namelen);
+ err = 0;
+ }
+ else {
+ name[0] = '\0';
+ err = gethostname(name, namelen);
+ }
+
+#else /* DEBUGBUILD */
+
+ /* The call to system's gethostname() might get intercepted by the
+ libhostname library when libcurl is built as a non-debug shared
+ library when running the test suite. */
+ name[0] = '\0';
+ err = gethostname(name, namelen);
+
+#endif
+
+ name[namelen - 1] = '\0';
+
+ if(err)
+ return err;
+
+ /* Truncate domain, leave only machine name */
+ dot = strchr(name, '.');
+ if(dot)
+ *dot = '\0';
+
+ return 0;
+#endif
+
+}