wks_11.c revision 34416a7954da96c5a5f5803fe02f059cb94bf6fd
279c6ec074be17dce62dd1b2c6ed7c2cc56a7b78David Lawrence * Copyright (C) 2004, 2007, 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
281bfa2a98f1d1721538086e1b550185559f1d8bMark Andrews * Copyright (C) 1999-2002 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Permission to use, copy, modify, and/or distribute this software for any
279c6ec074be17dce62dd1b2c6ed7c2cc56a7b78David Lawrence * purpose with or without fee is hereby granted, provided that the above
279c6ec074be17dce62dd1b2c6ed7c2cc56a7b78David Lawrence * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
281bfa2a98f1d1721538086e1b550185559f1d8bMark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
281bfa2a98f1d1721538086e1b550185559f1d8bMark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
281bfa2a98f1d1721538086e1b550185559f1d8bMark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
281bfa2a98f1d1721538086e1b550185559f1d8bMark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
281bfa2a98f1d1721538086e1b550185559f1d8bMark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
281bfa2a98f1d1721538086e1b550185559f1d8bMark Andrews * PERFORMANCE OF THIS SOFTWARE.
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington/* Reviewed: Fri Mar 17 15:01:49 PST 2000 by explorer */
8d4257cff01b3821abcb9a21f46c6c6a43bb1e72Bob Halleystatic void init_lock(void) {
8d4257cff01b3821abcb9a21f46c6c6a43bb1e72Bob Halley RUNTIME_CHECK(isc_mutex_init(&wks_lock) == ISC_R_SUCCESS);
d8dcd6ad4617cc8d7df979bd62101fa9c4bac1bcBob Halleymygetservbyname(const char *name, const char *proto, long *port) {
703e1c0bb66f3cd3d300358ca0c1fdf3cb5fb1c5Brian Wellington unsigned int n;
3f123dcc2fe5d2cd08ca91b732741d86a4036906Brian Wellington RUNTIME_CHECK(isc_once_do(&once, init_lock) == ISC_R_SUCCESS);
64b92523f9333ba053f4b2860335583be455b0b3Brian Wellington * IPv4 dotted quad.
64b92523f9333ba053f4b2860335583be455b0b3Brian Wellington RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
876753d5ce1be48f3218fb4875fac501f8adfd6cDavid Lawrence if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1)
49a2cf8f211213712d452287ae8e121cf59e3178David Lawrence RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
49a2cf8f211213712d452287ae8e121cf59e3178David Lawrence else if (!mygetprotobyname(DNS_AS_STR(token), &proto))
489b76292622f5bc18bf1a18845f8166a73bd797Brian Wellington RETERR(isc_lex_getmastertoken(lexer, &token,
fd837244be31850a764863688bce11df9ce972f4Andreas Gustafsson * Lowercase the service string as some getservbyname() are
fd837244be31850a764863688bce11df9ce972f4Andreas Gustafsson * case sensitive and the database is usually in lowercase.
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews strncpy(service, DNS_AS_STR(token), sizeof(service));
43fe2897fc80bbec2115310ca79d432a252f3ea4Mark Andrews if (*e == 0)
f54d0c9c6e65de367d4ef08f51d22a2fb4c56208Mark Andrews else if (!mygetservbyname(service, ps, &port) &&
64b92523f9333ba053f4b2860335583be455b0b3Brian Wellington !mygetservbyname(DNS_AS_STR(token), ps, &port))
f54d0c9c6e65de367d4ef08f51d22a2fb4c56208Mark Andrews } while (1);
f54d0c9c6e65de367d4ef08f51d22a2fb4c56208Mark Andrews * Let upper layer handle eol/eof.
23ac30603a7639bea1d331537634b079b046b122Mark Andrews unsigned short proto;
f54d0c9c6e65de367d4ef08f51d22a2fb4c56208Mark Andrews unsigned int i, j;
f54d0c9c6e65de367d4ef08f51d22a2fb4c56208Mark Andrews for (j = 0; j < 8; j++)
f54d0c9c6e65de367d4ef08f51d22a2fb4c56208Mark Andrews return (mem_tobuffer(target, sr.base, sr.length));
f54d0c9c6e65de367d4ef08f51d22a2fb4c56208Mark Andrewsstatic inline int
static inline isc_result_t
isc_uint32_t a;
static inline isc_result_t
isc_uint32_t n;
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
static inline isc_result_t
return (ISC_R_SUCCESS);
static inline isc_result_t
isc_region_t r;
static inline isc_boolean_t
static inline isc_boolean_t
return (ISC_TRUE);