gethostname.c 810 B

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