/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* The SPCS status support user utilities
* See spcs_s_u.h and the docs subdirectory for functional spec
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <locale.h>
#include <libintl.h>
/*
* Initialize ioctl status storage to "remove" any old status present
*/
void
{
p->major = SPCS_S_MAJOR_REV;
p->minor = SPCS_S_MINOR_REV;
p->icount = 0;
p->scount = 0;
p->tcount = 0;
}
/*
* Create and initialize local status. Call this prior to invoking
* an ioctl.
*/
{
if (need_to_bind) {
need_to_bind = 0;
};
return ((spcs_s_info_t)ustatus);
}
/*
* Return the idata index of the last status code in the array (i.e.
* the "youngest" code present). The assumption is that the caller has
* checked to see that pcount is nonzero.
*/
ISSTATIC int
{
int last = 0;
int idx = 0;
}
return (last);
}
/*
* Return a string with the module label and error message text or NULL
* if none left
*/
char *
{
int idx;
int sup;
int s;
char *format;
if (p->icount > 0) {
idx = last_code_idx(p);
/*
* The gettext formal parameter is a const char*
* I guess the gettext creator couldn't imagine
* needing a variable string. If there is an underlying
* routine that can be called it should be used.
* otherwise there will be a compiler warning about this
* line FOREVER (TS).
*/
else
/*
* step across the status code to the first supplemental data
* descriptor.
*/
idx += 1;
/*
* Initialize the array with empty string pointers so we don't
* seg fault if there are actually fewer values than "%s"
* format descriptors.
*/
for (s = 0; s < SPCS_S_MAXSUPP; s++)
sp[s] = "";
/*
* Walk through the supplemental value descriptors and build
* an array of string pointers.
*/
for (s = 0; s < sup; s++) {
}
/*
* Now format the message. The unused string pointers will be
* ignored.
* NOTE: Any change to SPCS_S_MAXSUPP requires a change to
* this sprintf.
*/
/* remove the code and its supplemental info */
} else
return (NULL);
}
/*
* Write status info
*/
void
{
char *sp;
char *se;
do {
else if (first_time && (errno > 0)) {
/*
* This covers the case where Solaris aborted the
* operation or the ioctl service code got an EFAULT
* or something from copyin or couldn't allocate the
* kernel status structure. If errno > 0 but not a
* valid Solaris error code the extended error is
* decoded and printed.
*/
if (se)
else {
spcs_errno.i = errno;
dgettext("unistat",
[spcs_errno.f.code]));
}
}
first_time = 0;
} while (sp);
p->icount = saved_count;
}
/*ARGSUSED*/
void
{
}
/*
* Release (free) ioctl status storage.
*/
void
{
}