Tor 0.4.9.0-alpha-dev
gethostname.c
Go to the documentation of this file.
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 */
26MOCK_IMPL(int,
27tor_gethostname,(char *name, size_t namelen))
28{
29 return gethostname(name,namelen);
30}
const char * name
Definition: config.c:2462
int tor_gethostname(char *name, size_t namelen)
Definition: gethostname.c:27
Header for gethostname.c.
#define MOCK_IMPL(rv, funcname, arglist)
Definition: testsupport.h:133