2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A * Error handling support for directory lookup. 2N/A * Actually, this is intended to be a very generic and extensible error 2N/A * reporting mechanism. 2N/A * This is the actual implementation of the opaque directory_error_t structure. 2N/A * True if this directory_error_t is statically allocated. Used to 2N/A * handle out of memory errors during error reporting. 2N/A * The error code. This is a locale-independent string that 2N/A * represents the precise error (to some level of granularity) 2N/A * that occurred. Internationalization processing could map it 2N/A * to an message. Errors may be subclassed by appending a dot 2N/A * and a name for the subclass. 2N/A * Note that this code plus the parameters allows for structured 2N/A * processing of error results. 2N/A * The default (in the absence of internationalization) format for 2N/A * the error message. %n interposes params[n - 1]. 2N/A * Parameters to the error message. Note that subclasses are 2N/A * required to have the same initial parameters as their superclasses, 2N/A * so that code that processes the superclass can work on the subclass. 2N/A * Cached printable form (that is, with params[] interpolated into 2N/A * fmt) of the error message. Created when requested. 2N/A * For debugging, reference count of directory_error instances still in 2N/A * existence. When the system is idle, this should be zero. 2N/A * Note that no attempt is made to make this MT safe, so it is not reliable 2N/A * in an MT environment. 2N/A * Free the specified directory_error_t. Note that this invalidates all strings 2N/A * returned based on it. 2N/A * Does nothing when de==NULL. 2N/A /* Don't free our internal static directory_error_ts! */ 2N/A /* Free parameters, if any */ 2N/A /* Free cached printable */ 2N/A * de = directory_error(code, fmt [, arg1 ... ]); 2N/A * Code, fmt, and arguments must be strings and will be copied. 2N/A /* Count our parameters */ 2N/A * Note that we do not copy the terminating NULL because we have 2N/A * Transform a directory_error returned by RPC into a directory_error_t. 2N/A * Convert a directory_error_t into a directory_error to send over RPC. 2N/A * Returns TRUE on successful conversion, FALSE on failure. 2N/A * Frees the directory_error_t. 2N/A * Note that most functions in this suite return boolean_t, as defined 2N/A * by types.h. This function is intended to be used directly as the 2N/A * return value from an RPC service function, and so it returns bool_t. 2N/A "Original error: %s\n" 2N/A "Conversion error: %s\n",
2N/A * Determines whether this directory_error_t is an instance of the 2N/A * particular error, or a subclass of that error. 2N/A * Expand the directory_error_t in de into buf, returning the size of the 2N/A * resulting string including terminating \0. If buf is NULL, just 2N/A * Return -1 if there are no substitutions, so that the caller can 2N/A * avoid memory allocation. 2N/A * Returns a printable version of this directory_error_t, suitable for 2N/A * human consumption. 2N/A * The value returned is valid as long as the directory_error_t is valid, 2N/A * and is freed when the directory_error_t is freed. 2N/A * Short circuit case to avoid memory allocation when there is 2N/A * no parameter substitution. 2N/A "Out of memory while expanding directory_error_t"));
2N/A * Stash the expansion away for later free, and to short-circuit 2N/A * repeated expansions. 2N/A * Returns the error code for the particular error, as a string. 2N/A * Note that this function should not normally be used to answer 2N/A * the question "did error X happen", since the value returned 2N/A * could be a subclass of X. directory_error_is_instance_of is intended 2N/A * to answer that question. 2N/A * The value returned is valid as long as the directory_error_t is valid, 2N/A * and is freed when the directory_error_t is freed. 2N/A * Returns one of the parameters of the directory_error_t, or NULL if 2N/A * the parameter does not exist. 2N/A * Note that it is required that error subclasses have initial parameters 2N/A * the same as their superclasses. 2N/A * The value returned is valid as long as the directory_error_t is valid, 2N/A * and is freed when the directory_error_t is freed. 2N/A * Here are some (almost) constant directory_error_t structures 2N/A * for use in reporting errors encountered while creating a 2N/A * directory_error_t structure. Unfortunately, the original error 2N/A#
define gettext(x) x
/* let xgettext see these messages */ 2N/A "ENOMEM.directory_error_t",
2N/A gettext(
"Out of memory while creating a directory_error_t"),
2N/A "EAGAIN.directory_error_t",
2N/A gettext(
"Out of resources while creating a directory_error_t"),
2N/A/* 40 is big enough for even 128 bits */ 2N/A "Unknown.directory_error_t",
2N/A gettext(
"Unknown error (%1) while creating a directory_error_t"),
2N/A /* Pray that we don't have a reentrancy problem ... */