Return Type | Function name | Arguments |
---|---|---|
hzEcode | InitIpInfo | (const hzString&,) |
Declared in file: hzIpaddr.h
Defined in file : hzIpServer.cpp
Function Logic:
Function body:
hzEcode InitIpInfo (const hzString& dataDir) { _hzfunc(__func__) ; ifstream is ; hzIpinfo ipi ; hzIpaddr ipa ; uint32_t nLine ; char buf [24]; hzEcode rc = E_OK ; if (!dataDir) return E_ARGUMENT ; rc = AssertDir(dataDir, 0666); if (rc != E_OK) return rc ; s_status_ip_fname = dataDir + "/status_ip.ips" ; rc = TestFile(s_status_ip_fname) ; if (rc == E_OK) { is.open(*s_status_ip_fname) ; if (is.fail()) return hzerr(E_OPENFAIL, "Cannot open file %s\n", *s_status_ip_fname) ; for (nLine = 1;; nLine++) { is.getline(buf, 23); if (!is.gcount()) break ; ipa = buf ; if (!ipa) return hzerr(E_FORMAT, "Line %d of file %s, is not a valid IP address", nLine, *s_status_ip_fname) ; _hzGlobal_StatusIP.Insert(ipa, ipi) ; } is.close() ; is.clear() ; threadLog("Loaded %d IP address in WHITELIST\n", _hzGlobal_StatusIP.Count()) ; } else { if (rc != E_NOTFOUND && rc != E_NODATA) return hzerr(rc, "File error %s\n", *s_status_ip_fname) ; } rc = E_OK ; s_status_ip_os.open(*s_status_ip_fname, ios::app) ; if (s_status_ip_os.fail()) return hzerr(E_OPENFAIL, "Cannot open %s for writing", *s_status_ip_fname) ; return rc ; }