/src/tor/src/lib/net/gethostname.c
Line | Count | Source |
1 | | /* Copyright (c) 2003-2004, Roger Dingledine |
2 | | * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. |
3 | | * Copyright (c) 2007-2021, The Tor Project, Inc. */ |
4 | | /* See LICENSE for licensing information */ |
5 | | |
6 | | /** |
7 | | * \file gethostname.c |
8 | | * \brief Mockable wrapper for gethostname(). |
9 | | */ |
10 | | |
11 | | #include "orconfig.h" |
12 | | #include "lib/net/gethostname.h" |
13 | | |
14 | | #ifdef HAVE_UNISTD_H |
15 | | #include <unistd.h> |
16 | | #endif |
17 | | #ifdef _WIN32 |
18 | | #include <winsock2.h> |
19 | | #endif |
20 | | |
21 | | /** Get name of current host and write it to <b>name</b> array, whose |
22 | | * length is specified by <b>namelen</b> argument. Return 0 upon |
23 | | * successful completion; otherwise return return -1. (Currently, |
24 | | * this function is merely a mockable wrapper for POSIX gethostname().) |
25 | | */ |
26 | | MOCK_IMPL(int, |
27 | | tor_gethostname,(char *name, size_t namelen)) |
28 | 0 | { |
29 | 0 | return gethostname(name,namelen); |
30 | 0 | } |