optional Configuration::GetEnv()

in src/hbase/client/configuration.cc [92:131]


optional<std::string> Configuration::GetEnv(const std::string &key) const {
  char buf[2048];

  if ("user.name" == key) {
#ifdef HAVE_GETLOGIN
    return getlogin();
#else
    DLOG(WARNING) << "Client user.name not implemented";
    return none;
#endif
  }

  if ("user.dir" == key) {
#ifdef HAVE_GETCWD
    if (getcwd(buf, sizeof(buf))) {
      return buf;
    } else {
      return none;
    }
#else
    DLOG(WARNING) << "Client user.dir not implemented";
    return none;
#endif
  }

  if ("user.home" == key) {
#if defined(HAVE_GETUID) && defined(HAVE_GETPWUID_R)
    uid = getuid();
    if (!getpwuid_r(uid, &pw, buf, sizeof(buf), &pwp)) {
      return buf;
    } else {
      return none;
    }
#else
    DLOG(WARNING) << "Client user.home not implemented";
    return none;
#endif
  }
  return none;
}