gethostname.c 732 B

12345678910111213141516171819202122232425
  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. #include "orconfig.h"
  6. #include "lib/net/gethostname.h"
  7. #ifdef HAVE_UNISTD_H
  8. #include <unistd.h>
  9. #endif
  10. #ifdef _WIN32
  11. #include <winsock2.h>
  12. #endif
  13. /** Get name of current host and write it to <b>name</b> array, whose
  14. * length is specified by <b>namelen</b> argument. Return 0 upon
  15. * successful completion; otherwise return return -1. (Currently,
  16. * this function is merely a mockable wrapper for POSIX gethostname().)
  17. */
  18. MOCK_IMPL(int,
  19. tor_gethostname,(char *name, size_t namelen))
  20. {
  21. return gethostname(name,namelen);
  22. }