X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/0a49a7a4f1090b6f1ce1d0f9d969804c9226b53e..8d6d5106a6f1bcba010877d55932a8d8dcfa88bd:/src/src/os.c diff --git a/src/src/os.c b/src/src/os.c index b8d369307..ee754f9f2 100644 --- a/src/src/os.c +++ b/src/src/os.c @@ -1,10 +1,8 @@ -/* $Cambridge: exim/src/src/os.c,v 1.8 2009/11/16 19:50:37 nm4 Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2009 */ +/* Copyright (c) University of Cambridge 1995 - 2014 */ /* See the file NOTICE for conditions of use and distribution. */ #ifdef STAND_ALONE @@ -167,8 +165,8 @@ that have nothing. It provides a basic translation for the common standard signal numbers. I've been extra cautious with the ifdef's here. Probably more than is necessary... */ -char * -os_strsignal(int n) +const char * +os_strsignal(const int n) { switch (n) { @@ -284,8 +282,8 @@ switch (n) exit codes into text, but this function is implemented this way so that if any OS does have such a thing, it could be used instead of this build-in one. */ -char * -os_strexit(int n) +const char * +os_strexit(const int n) { switch (n) { @@ -797,6 +795,50 @@ return yield; +/* ----------------------------------------------------------------------- */ + +/*********************************************************** +* DNS Resolver Base Finder * +***********************************************************/ + +/* We need to be able to set options for the system resolver(5), historically +made available as _res. At least one OS (NetBSD) now no longer provides this +directly, instead making you call a function per thread to get a handle. +Other OSs handle thread-safe resolver differently, in ways which fail if the +programmer creates their own structs. */ + +#if !defined(OS_GET_DNS_RESOLVER_RES) && !defined(COMPILE_UTILITY) + +#include + +/* confirmed that res_state is typedef'd as a struct* on BSD and Linux, will +find out how unportable it is on other OSes, but most resolver implementations +should be descended from ISC's bind. + +Linux and BSD do: + define _res (*__res_state()) +identically. We just can't rely on __foo functions. It's surprising that use +of _res has been as portable as it has, for so long. + +So, since _res works everywhere, and everything can decode the struct, I'm +going to gamble that res_state is a typedef everywhere and use that as the +return type. +*/ + +res_state +os_get_dns_resolver_res(void) +{ + return &_res; +} + +#endif /* OS_GET_DNS_RESOLVER_RES */ + + +/* ----------------------------------------------------------------------- */ + + + + /************************************************* **************************************************