16ba597cAnurag S. Maskey/*
26ba597cAnurag S. Maskey * CDDL HEADER START
36ba597cAnurag S. Maskey *
46ba597cAnurag S. Maskey * The contents of this file are subject to the terms of the
56ba597cAnurag S. Maskey * Common Development and Distribution License (the "License").
66ba597cAnurag S. Maskey * You may not use this file except in compliance with the License.
76ba597cAnurag S. Maskey *
86ba597cAnurag S. Maskey * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96ba597cAnurag S. Maskey * or http://www.opensolaris.org/os/licensing.
106ba597cAnurag S. Maskey * See the License for the specific language governing permissions
116ba597cAnurag S. Maskey * and limitations under the License.
126ba597cAnurag S. Maskey *
136ba597cAnurag S. Maskey * When distributing Covered Code, include this CDDL HEADER in each
146ba597cAnurag S. Maskey * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156ba597cAnurag S. Maskey * If applicable, add the following below this CDDL HEADER, with the
166ba597cAnurag S. Maskey * fields enclosed by brackets "[]" replaced with your own identifying
176ba597cAnurag S. Maskey * information: Portions Copyright [yyyy] [name of copyright owner]
186ba597cAnurag S. Maskey *
196ba597cAnurag S. Maskey * CDDL HEADER END
206ba597cAnurag S. Maskey */
216ba597cAnurag S. Maskey
226ba597cAnurag S. Maskey/*
236ba597cAnurag S. Maskey * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
246ba597cAnurag S. Maskey * Use is subject to license terms.
256ba597cAnurag S. Maskey */
266ba597cAnurag S. Maskey
276ba597cAnurag S. Maskey#include <libnwam.h>
286ba597cAnurag S. Maskey#include <libintl.h>
296ba597cAnurag S. Maskey
306ba597cAnurag S. Maskeystatic struct nwam_error_info {
316ba597cAnurag S. Maskey	nwam_error_t error_code;
326ba597cAnurag S. Maskey	const char *error_desc;
336ba597cAnurag S. Maskey} nwam_errors[] = {
346ba597cAnurag S. Maskey	{NWAM_SUCCESS,			"no error"},
356ba597cAnurag S. Maskey	{NWAM_LIST_END,			"end of list reached"},
366ba597cAnurag S. Maskey	{NWAM_INVALID_HANDLE,		"entity handle is invalid"},
376ba597cAnurag S. Maskey	{NWAM_HANDLE_UNBOUND,		"handle not bound to entity"},
386ba597cAnurag S. Maskey	{NWAM_INVALID_ARG,		"argument is invalid"},
396ba597cAnurag S. Maskey	{NWAM_PERMISSION_DENIED,	"Insufficient permissions for action"},
406ba597cAnurag S. Maskey	{NWAM_NO_MEMORY,		"out of memory"},
416ba597cAnurag S. Maskey	{NWAM_ENTITY_EXISTS,		"entity exists"},
426ba597cAnurag S. Maskey	{NWAM_ENTITY_IN_USE,		"entity in use"},
436ba597cAnurag S. Maskey	{NWAM_ENTITY_COMMITTED,		"entity already committed"},
446ba597cAnurag S. Maskey	{NWAM_ENTITY_NOT_FOUND,		"entity not found"},
456ba597cAnurag S. Maskey	{NWAM_ENTITY_TYPE_MISMATCH,	"entity type mismatch"},
466ba597cAnurag S. Maskey	{NWAM_ENTITY_INVALID,		"validation of entity failed"},
476ba597cAnurag S. Maskey	{NWAM_ENTITY_INVALID_MEMBER,	"entity has invalid member"},
486ba597cAnurag S. Maskey	{NWAM_ENTITY_INVALID_STATE,	"entity is in incorrect state"},
496ba597cAnurag S. Maskey	{NWAM_ENTITY_INVALID_VALUE,	"validation of entity value failed"},
506ba597cAnurag S. Maskey	{NWAM_ENTITY_MISSING_MEMBER,	"entity is missing required member"},
516ba597cAnurag S. Maskey	{NWAM_ENTITY_NO_VALUE,		"no value associated with entity"},
526ba597cAnurag S. Maskey	{NWAM_ENTITY_MULTIPLE_VALUES,	"multiple values for entity"},
536ba597cAnurag S. Maskey	{NWAM_ENTITY_READ_ONLY,		"entity is read only"},
546ba597cAnurag S. Maskey	{NWAM_ENTITY_NOT_DESTROYABLE,	"entity cannot be destroyed"},
556ba597cAnurag S. Maskey	{NWAM_ENTITY_NOT_MANUAL, "entity cannot be manually enabled/disabled"},
566ba597cAnurag S. Maskey	{NWAM_WALK_HALTED,		"callback function returned nonzero"},
576ba597cAnurag S. Maskey	{NWAM_ERROR_BIND,		"could not bind to backend server"},
586ba597cAnurag S. Maskey	{NWAM_ERROR_BACKEND_INIT,	"could not initialize backend"},
596ba597cAnurag S. Maskey	{NWAM_ERROR_INTERNAL,		"internal error"}
606ba597cAnurag S. Maskey};
616ba597cAnurag S. Maskey
626ba597cAnurag S. Maskey#define	NWAM_NUM_ERRORS	(sizeof (nwam_errors) / sizeof (*nwam_errors))
636ba597cAnurag S. Maskey
646ba597cAnurag S. Maskeyconst char *
656ba597cAnurag S. Maskeynwam_strerror(nwam_error_t code)
666ba597cAnurag S. Maskey{
676ba597cAnurag S. Maskey	struct nwam_error_info *cur, *end;
686ba597cAnurag S. Maskey
696ba597cAnurag S. Maskey	cur = nwam_errors;
706ba597cAnurag S. Maskey	end = cur + NWAM_NUM_ERRORS;
716ba597cAnurag S. Maskey
726ba597cAnurag S. Maskey	for (; cur < end; cur++) {
736ba597cAnurag S. Maskey		if (code == cur->error_code)
746ba597cAnurag S. Maskey			return (dgettext(TEXT_DOMAIN, cur->error_desc));
756ba597cAnurag S. Maskey	}
766ba597cAnurag S. Maskey
776ba597cAnurag S. Maskey	return (dgettext(TEXT_DOMAIN, "unknown error"));
786ba597cAnurag S. Maskey}