| 1 | diff -u -r ../apt-1.1.3/apt-pkg/contrib/srvrec.cc ./apt-pkg/contrib/srvrec.cc |
| 2 | --- ../apt-1.1.3/apt-pkg/contrib/srvrec.cc 2015-11-30 03:08:24.000000000 -0500 |
| 3 | +++ ./apt-pkg/contrib/srvrec.cc 2015-12-03 16:21:54.397715576 -0500 |
| 4 | @@ -40,14 +40,27 @@ |
| 5 | struct servent *s_ent = nullptr; |
| 6 | std::vector<char> buf(1024); |
| 7 | |
| 8 | +#ifdef __ANDROID__ |
| 9 | + s_ent = getservbyport(htons(port), "tcp"); |
| 10 | + if (s_ent == nullptr) return false; |
| 11 | +#else |
| 12 | res = getservbyport_r(htons(port), "tcp", &s_ent_buf, buf.data(), buf.size(), &s_ent); |
| 13 | if (res != 0 || s_ent == nullptr) |
| 14 | return false; |
| 15 | +#endif |
| 16 | |
| 17 | strprintf(target, "_%s._tcp.%s", s_ent->s_name, host.c_str()); |
| 18 | return GetSrvRecords(target, Result); |
| 19 | } |
| 20 | |
| 21 | +/* Bionic has res_init() but it's not in any header */ |
| 22 | +#ifdef __ANDROID__ |
| 23 | +extern "C" int res_init(); |
| 24 | +extern "C" int res_query(const char* dname, int class_, int type_, unsigned char* answer, int anslen); |
| 25 | +extern "C" int __dn_skipname(const unsigned char* comp_dn, const unsigned char* eom); |
| 26 | +static inline int dn_skipname(const unsigned char* a, const unsigned char* b) { return __dn_skipname(a,b); } |
| 27 | +#endif |
| 28 | + |
| 29 | bool GetSrvRecords(std::string name, std::vector<SrvRec> &Result) |
| 30 | { |
| 31 | unsigned char answer[PACKETSZ]; |