tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

gethostname.c (810B)


      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 {
     29   return gethostname(name,namelen);
     30 }