/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <macros.h>
#include <errno.h>
#include <locale.h>
#include <libdevinfo.h>
#include <librcm.h>
#define CFGA_PLUGIN_LIB
#include <config_admin.h>
#include "ap.h"
#ifdef SBD_DEBUG
int
debugging(void)
{
char *ep;
static int inited;
if (inited)
inited = 1;
return (0);
if (*ep == '\0')
else {
return (0);
}
return (1);
}
/*PRINTFLIKE1*/
void
{
if (!debugging())
return;
}
#endif
static char *
ap_err_fmts[] = {
"command invalid: %s",
"%s %s: %s%s%s", /* command failed */
"%s %s", /* command nacked */
"command not supported: %s %s",
"command aborted: %s %s",
"option invalid: %s",
"option requires value: %s",
"option requires no value: %s",
"option value invalid: %s %s",
"attachment point invalid: %s",
"component invalid: %s",
"sequence invalid: %s (%s %s) %s",
"change signal disposition failed",
"cannot get RCM handle",
"RCM %s failed for %s",
"\n%-30s %-10s %s",
"cannot open %s%s%s",
"cannot find symbol %s in %s",
"cannot stat %s: %s",
"not enough memory",
"%s plugin: %s",
"unknown error",
};
static char *
ap_msg_fmts[] = {
"%s %s\n",
"%s %s skipped\n",
"System may be temporarily suspended, proceed",
"%s %s aborted\n",
"%s %s done\n",
"%s %s failed\n",
"RCM library not found, feature will be disabled\n",
"Unknown message\n",
};
{ \
if (((c) = ap_cmd_name((v))) == NULL) \
(c) = STR_CMD_UNKNOWN; \
}
if (!str_valid((t))) \
(t) = STR_TGT_UNKNOWN; \
}
(t) = (tgt); \
else \
(t) = STR_TGT_UNKNOWN; \
}
{ \
if ((v) == NULL) \
(v) = (d); \
}
static char *
ap_stnames[] = {
"unknown state",
"empty",
"disconnected",
"connected",
"unconfigured",
"configured"
};
/*
* ap_err() accepts a variable number of message IDs and constructs
* a corresponding error string. ap_err() calls dgettext() to
* internationalize the proper portions of a message. If a system
* error was encountered (errno set), ap_err() looks for the error
* string corresponding to the returned error code if one is available.
* If not, the standard libc error string is fetched.
*/
void
{
int v;
int err;
int len;
char *p;
char *sep;
char *rsep;
const char *fmt;
char *cmd;
char *value;
char *target;
char *serr;
char *syserr;
char *rstate;
char *ostate;
char *srsrc;
char *sysrsrc;
char *option;
char *path;
char *sym;
char *msg;
const char *error;
char **errstring;
DBG("ap_err(%p)\n", (void *)a);
/*
* If there is no descriptor or string pointer or if
* there is an outstanding error, just return.
*/
return;
sep = "";
/*
* Get the proper arguments for the error.
*/
switch (err) {
case ERR_CMD_ABORT:
case ERR_CMD_FAIL:
case ERR_CMD_NACK:
break;
case ERR_CMD_NOTSUPP:
else
break;
case ERR_AP_INVAL:
break;
case ERR_CMD_INVAL:
case ERR_CM_INVAL:
case ERR_OPT_INVAL:
case ERR_OPT_NOVAL:
case ERR_OPT_VAL:
case ERR_OPT_BADVAL:
if (err != ERR_OPT_BADVAL)
break;
break;
case ERR_TRANS_INVAL: {
break;
}
case ERR_RCM_CMD: {
}
break;
}
case ERR_LIB_OPEN:
break;
case ERR_LIB_SYM:
break;
case ERR_STAT:
break;
case ERR_PLUGIN:
break;
default:
DBG("<NOARGS>");
break;
}
/*
* In case of a system error, get the reason for
* the failure as well as the resource if availbale.
* If we already got some error info (e.g. from RCM)
* don't bother looking.
*/
else
sysrsrc = "";
else
} else
rsep = "";
} else
DBG("\n");
*errstring = p;
/*
* Print the string with appropriate arguments.
*/
switch (err) {
case ERR_CMD_FAIL:
break;
case ERR_CMD_ABORT:
case ERR_CMD_NACK:
case ERR_CMD_NOTSUPP:
break;
case ERR_AP_INVAL:
break;
case ERR_CMD_INVAL:
case ERR_CM_INVAL:
case ERR_OPT_INVAL:
case ERR_OPT_NOVAL:
case ERR_OPT_VAL:
break;
case ERR_OPT_BADVAL:
break;
case ERR_TRANS_INVAL:
break;
case ERR_SIG_CHANGE:
case ERR_RCM_HANDLE:
break;
case ERR_RCM_CMD:
/*
* If the rinfostr has a string, then the librcm has returned
* us a text field of its reasons why the command failed.
*
* If the rinfostr is not returning data, we will use
* the standard ap_err_fmts[] for the rcm error.
*/
else
break;
case ERR_LIB_OPEN:
break;
case ERR_LIB_SYM:
break;
case ERR_STAT:
break;
case ERR_NOMEM:
break;
case ERR_PLUGIN:
break;
default:
break;
}
if (serr)
if (srsrc)
}
/*
* ap_msg() accepts a variable number of message IDs and constructs
* a corresponding message string which is printed via the message print
* routine argument. ap_msg() internationalizes the appropriate portion
* of the message.
*/
void
{
int v;
int len;
char *p;
const char *fmt;
char *cmd;
char *target;
DBG("ap_msg(%p)\n", (void *)a);
return;
return;
DBG("<%d>", v);
switch (v) {
case MSG_ISSUE:
case MSG_SKIP:
case MSG_ABORT:
case MSG_FAIL:
case MSG_DONE:
break;
default:
break;
}
return;
free(p);
}
int
{
int rc;
char *msg;
if (a == NULL)
return (0);
return (0);
return (rc);
}