source: tags/arb-6.0.4/CORE/arb_cs.cxx

Last change on this file was 7246, checked in by westram, 13 years ago

merged from dev [7227] [7228]

  • extended SmartPtr
  • compile fix for coverage
File size: 1.4 KB
Line 
1// ============================================================= //
2//                                                               //
3//   File      : arb_cs.cxx                                      //
4//   Purpose   : Basics for client/server communication          //
5//                                                               //
6//   Coded by Ralf Westram (coder@reallysoft.de) in March 2011   //
7//   Institute of Microbiology (Technical University Munich)     //
8//   http://www.arb-home.de/                                     //
9//                                                               //
10// ============================================================= //
11
12#include "arb_cs.h"
13#include "arb_msg.h"
14#include <smartptr.h>
15#include <unistd.h>
16#include <netdb.h>
17
18void arb_gethostbyname(const char *name, struct hostent *& he, GB_ERROR& err) {
19    he = gethostbyname(name);
20    // Note: gethostbyname is marked obsolete.
21    // replacement getnameinfo seems less portable atm.
22
23    if (he) {
24        err = NULL;
25    }
26    else {
27        err = GBS_global_string("Cannot resolve hostname: '%s' (h_errno=%i='%s')",
28                                name, h_errno, hstrerror(h_errno));
29    }
30}
31
32const char *arb_gethostname() {
33    static SmartCharPtr hostname;
34    if (hostname.isNull()) {
35        char buffer[4096];
36        gethostname(buffer, 4095);
37        hostname = strdup(buffer);
38    }
39    return &*hostname;
40}
41
Note: See TracBrowser for help on using the repository browser.