Git init
[external/curl.git] / tests / libtest / sethostname.c
1 /*****************************************************************************
2  *                                  _   _ ____  _
3  *  Project                     ___| | | |  _ \| |
4  *                             / __| | | | |_) | |
5  *                            | (__| |_| |  _ <| |___
6  *                             \___|\___/|_| \_\_____|
7  *
8  */
9
10 #include "setup.h"
11
12 #include "sethostname.h"
13
14 /*
15  * we force our own host name, in order to make some tests machine independent
16  */
17
18 int gethostname(char *name, GETHOSTNAME_TYPE_ARG2 namelen)
19 {
20   const char *force_hostname = getenv("CURL_GETHOSTNAME");
21   if(force_hostname) {
22     strncpy(name, force_hostname, namelen);
23     name[namelen-1] = '\0';
24     return 0;
25   }
26
27   /* LD_PRELOAD used, but no hostname set, we'll just return a failure */
28   return -1;
29 }