fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifndef _SPCS_S_U_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _SPCS_S_U_H
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * USER level status support utilities
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdio.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create and initialize local status. Call this prior to invoking
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * an ioctl
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return The status or NULL if malloc failed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortespcs_s_info_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortespcs_s_ucreate();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialize ioctl status storage to "remove" any status present
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ustatus The status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortespcs_s_uinit(spcs_s_info_t ustatus);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return a string with the module label and next status message text or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NULL if none left. Supplemental values are edited into the text and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the used status and values are removed so that subsequent calls will
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * access the next piece of information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note that status codes and supplemental values are processed in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the reverse order of their insertion by SPCS kernel code. That is,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * spcs_s_string returns the "youngest" status information first (i.e.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * LIFO).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note that spcs_s_string will not have any error information in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the special case where Solaris has aborted an ioctl and returned an
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * error code via errno or the ioctl service code had an "early" error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from copyin or could not allocate its status area. In this case
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * spcs_s_string will return NULL the first time it is called and a
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * positive integer error code will be present in errno and should get
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * handled by the spcs_s_string caller appropriately by using strerror.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ustatus The status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param msg A char array of at least SPCS_S_MAXTEXT length
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @return status message string or NULL if no more status present
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortechar *spcs_s_string(spcs_s_info_t ustatus, char *msg);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Write status info to the file specified
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Uses spsc_s_string to edit status into strings and output them
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to the file specifed in the same order that the status was inserted.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If there is no status present but errno contains a positive value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then it will be treated as a Solaris error code and its message text
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will be written. Note that this routine does NOT remove status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information so it can be called more than once.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ustatus The status
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param fd The file descriptor to use for output
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid spcs_s_report(spcs_s_info_t ustatus, FILE *fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Release (free) ioctl status storage.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note that this interface is an extension to SPARC 1998/038 10/22/98
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * commitment.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ustatus_a The address of the status (set to NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortespcs_s_ufree(spcs_s_info_t *ustatus_a);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Write message to log file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param product Product code for tagging in log file.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param ustatus The status - may be NULL.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * @param format printf style format.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortespcs_log(const char *product, spcs_s_info_t *ustatus, const char *format, ...);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef __cplusplus
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SPCS_S_U_H */