libnwam_error.c revision 6ba597c56d749c61b4f783157f63196d7b2445f0
1N/A/*
1N/A * CDDL HEADER START
1N/A *
1N/A * The contents of this file are subject to the terms of the
1N/A * Common Development and Distribution License (the "License").
1N/A * You may not use this file except in compliance with the License.
1N/A *
1N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1N/A * or http://www.opensolaris.org/os/licensing.
1N/A * See the License for the specific language governing permissions
1N/A * and limitations under the License.
1N/A *
1N/A * When distributing Covered Code, include this CDDL HEADER in each
1N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1N/A * If applicable, add the following below this CDDL HEADER, with the
1N/A * fields enclosed by brackets "[]" replaced with your own identifying
1N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1N/A *
1N/A * CDDL HEADER END
1N/A */
1N/A
1N/A/*
1N/A * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
1N/A * Use is subject to license terms.
1N/A */
1N/A
1N/A#include <libnwam.h>
1N/A#include <libintl.h>
1N/A
1N/Astatic struct nwam_error_info {
1N/A nwam_error_t error_code;
1N/A const char *error_desc;
1N/A} nwam_errors[] = {
1N/A {NWAM_SUCCESS, "no error"},
1N/A {NWAM_LIST_END, "end of list reached"},
1N/A {NWAM_INVALID_HANDLE, "entity handle is invalid"},
1N/A {NWAM_HANDLE_UNBOUND, "handle not bound to entity"},
1N/A {NWAM_INVALID_ARG, "argument is invalid"},
1N/A {NWAM_PERMISSION_DENIED, "Insufficient permissions for action"},
1N/A {NWAM_NO_MEMORY, "out of memory"},
1N/A {NWAM_ENTITY_EXISTS, "entity exists"},
1N/A {NWAM_ENTITY_IN_USE, "entity in use"},
1N/A {NWAM_ENTITY_COMMITTED, "entity already committed"},
1N/A {NWAM_ENTITY_NOT_FOUND, "entity not found"},
1N/A {NWAM_ENTITY_TYPE_MISMATCH, "entity type mismatch"},
1N/A {NWAM_ENTITY_INVALID, "validation of entity failed"},
1N/A {NWAM_ENTITY_INVALID_MEMBER, "entity has invalid member"},
1N/A {NWAM_ENTITY_INVALID_STATE, "entity is in incorrect state"},
1N/A {NWAM_ENTITY_INVALID_VALUE, "validation of entity value failed"},
1N/A {NWAM_ENTITY_MISSING_MEMBER, "entity is missing required member"},
1N/A {NWAM_ENTITY_NO_VALUE, "no value associated with entity"},
1N/A {NWAM_ENTITY_MULTIPLE_VALUES, "multiple values for entity"},
1N/A {NWAM_ENTITY_READ_ONLY, "entity is read only"},
1N/A {NWAM_ENTITY_NOT_DESTROYABLE, "entity cannot be destroyed"},
1N/A {NWAM_ENTITY_NOT_MANUAL, "entity cannot be manually enabled/disabled"},
1N/A {NWAM_WALK_HALTED, "callback function returned nonzero"},
1N/A {NWAM_ERROR_BIND, "could not bind to backend server"},
1N/A {NWAM_ERROR_BACKEND_INIT, "could not initialize backend"},
1N/A {NWAM_ERROR_INTERNAL, "internal error"}
1N/A};
1N/A
1N/A#define NWAM_NUM_ERRORS (sizeof (nwam_errors) / sizeof (*nwam_errors))
1N/A
1N/Aconst char *
1N/Anwam_strerror(nwam_error_t code)
1N/A{
1N/A struct nwam_error_info *cur, *end;
1N/A
1N/A cur = nwam_errors;
1N/A end = cur + NWAM_NUM_ERRORS;
1N/A
1N/A for (; cur < end; cur++) {
1N/A if (code == cur->error_code)
1N/A return (dgettext(TEXT_DOMAIN, cur->error_desc));
1N/A }
1N/A
1N/A return (dgettext(TEXT_DOMAIN, "unknown error"));
1N/A}
1N/A