result.c revision 40f53fa8d9c6a4fc38c0014495e7a42b08f52481
49dbdb0186eb23d87d685b96eaefa9ec3c71d9b8David Lawrence * Copyright (C) 1998-2000 Internet Software Consortium.
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * Permission to use, copy, modify, and distribute this software for any
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * purpose with or without fee is hereby granted, provided that the above
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * copyright notice and this permission notice appear in all copies.
15a44745412679c30a6d022733925af70a38b715David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
15a44745412679c30a6d022733925af70a38b715David Lawrence * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
15a44745412679c30a6d022733925af70a38b715David Lawrence * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
15a44745412679c30a6d022733925af70a38b715David Lawrence * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
15a44745412679c30a6d022733925af70a38b715David Lawrence * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15a44745412679c30a6d022733925af70a38b715David Lawrence * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence/* $Id: result.c,v 1.46 2000/08/01 01:29:43 tale Exp $ */
e4e071ae12aee942fefc2c0a3280e402938669deBob Halleytypedef struct resulttable {
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley unsigned int base;
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley unsigned int last;
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrence const char ** text;
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrenceregister_table(unsigned int base, unsigned int nresults, const char **text,
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley * We use malloc() here because we we want to be able to use
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley * isc_result_totext() even if there is no memory context.
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley RUNTIME_CHECK(isc_mutex_init(&lock) == ISC_R_SUCCESS);
d8dcd6ad4617cc8d7df979bd62101fa9c4bac1bcBob Halley result = register_table(ISC_RESULTCLASS_ISC, ISC_R_NRESULTS, text,
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
e4e071ae12aee942fefc2c0a3280e402938669deBob Halley if (result >= table->base && result <= table->last) {
d8dcd6ad4617cc8d7df979bd62101fa9c4bac1bcBob Halley * Note: we use 'index + 1' as the message number
d8dcd6ad4617cc8d7df979bd62101fa9c4bac1bcBob Halley * instead of index because isc_msgcat_get() requires
d8dcd6ad4617cc8d7df979bd62101fa9c4bac1bcBob Halley * the message number to be > 0.
5804af97ab0875fafd233f486aa1c1899ed5c00aBob Halley text = isc_msgcat_get(isc_msgcat, ISC_RESULT_UNAVAILABLESET,
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrenceisc_result_register(unsigned int base, unsigned int nresults,
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrence const char **text, isc_msgcat_t *msgcat, int set)