int GlobalStateAccessor::init() { // These three fields used to be statically initialized. This made // it hard to use this code in a shared library. It is necessary, // now that we're doing dynamic initialization here, that we preserve // the old semantics: if an application modifies one of these three // fields of _res before res_init() is called, res_init() will not // alter them. Of course, if an application is setting them to // _zero_ before calling res_init(), hoping to override what used // to be the static default, we can't detect it and unexpected results // will follow. Zero for any of these fields would make no sense, // so one can safely assume that the applications were already getting // unexpected results. // g_nres.options is tricky since some apps were known to diddle the bits // before res_init() was first called. We can't replicate that semantic // with dynamic initialization (they may have turned bits off that are // set in RES_DEFAULT). Our solution is to declare such applications // "broken". They could fool us by setting RES_INIT but none do (yet). if (!state.retrans) state.retrans = RES_TIMEOUT; if (!state.retry) state.retry = 4; if (!(state.options & RES_INIT)) state.options = RES_DEFAULT;
// This one used to initialize implicitly to zero, so unless the app // has set it to something in particular, we can randomize it now. if (!state.id) state.id = res_randomid();
return __res_vinit(&state, 1);
}
int res_init(void) {
GlobalStateAccessor gsa; return gsa.init();
}
int res_send(const u_char* buf, int buflen, u_char* ans, int anssiz) {
GlobalStateAccessor gsa; return res_nsend(gsa.get(), buf, buflen, ans, anssiz);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.