1*7836SJohn.Forte@Sun.COM /* 2*7836SJohn.Forte@Sun.COM * CDDL HEADER START 3*7836SJohn.Forte@Sun.COM * 4*7836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the 5*7836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License"). 6*7836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License. 7*7836SJohn.Forte@Sun.COM * 8*7836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*7836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*7836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions 11*7836SJohn.Forte@Sun.COM * and limitations under the License. 12*7836SJohn.Forte@Sun.COM * 13*7836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*7836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*7836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*7836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*7836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*7836SJohn.Forte@Sun.COM * 19*7836SJohn.Forte@Sun.COM * CDDL HEADER END 20*7836SJohn.Forte@Sun.COM */ 21*7836SJohn.Forte@Sun.COM /* 22*7836SJohn.Forte@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23*7836SJohn.Forte@Sun.COM * Use is subject to license terms. 24*7836SJohn.Forte@Sun.COM */ 25*7836SJohn.Forte@Sun.COM 26*7836SJohn.Forte@Sun.COM #ifndef _SPCS_S_U_H 27*7836SJohn.Forte@Sun.COM #define _SPCS_S_U_H 28*7836SJohn.Forte@Sun.COM 29*7836SJohn.Forte@Sun.COM #ifdef __cplusplus 30*7836SJohn.Forte@Sun.COM extern "C" { 31*7836SJohn.Forte@Sun.COM #endif 32*7836SJohn.Forte@Sun.COM 33*7836SJohn.Forte@Sun.COM /* 34*7836SJohn.Forte@Sun.COM * USER level status support utilities 35*7836SJohn.Forte@Sun.COM */ 36*7836SJohn.Forte@Sun.COM 37*7836SJohn.Forte@Sun.COM #include <stdio.h> 38*7836SJohn.Forte@Sun.COM 39*7836SJohn.Forte@Sun.COM /* 40*7836SJohn.Forte@Sun.COM * Create and initialize local status. Call this prior to invoking 41*7836SJohn.Forte@Sun.COM * an ioctl 42*7836SJohn.Forte@Sun.COM * @return The status or NULL if malloc failed 43*7836SJohn.Forte@Sun.COM */ 44*7836SJohn.Forte@Sun.COM 45*7836SJohn.Forte@Sun.COM spcs_s_info_t 46*7836SJohn.Forte@Sun.COM spcs_s_ucreate(); 47*7836SJohn.Forte@Sun.COM 48*7836SJohn.Forte@Sun.COM /* 49*7836SJohn.Forte@Sun.COM * Initialize ioctl status storage to "remove" any status present 50*7836SJohn.Forte@Sun.COM * @param ustatus The status 51*7836SJohn.Forte@Sun.COM */ 52*7836SJohn.Forte@Sun.COM 53*7836SJohn.Forte@Sun.COM void 54*7836SJohn.Forte@Sun.COM spcs_s_uinit(spcs_s_info_t ustatus); 55*7836SJohn.Forte@Sun.COM 56*7836SJohn.Forte@Sun.COM /* 57*7836SJohn.Forte@Sun.COM * Return a string with the module label and next status message text or 58*7836SJohn.Forte@Sun.COM * NULL if none left. Supplemental values are edited into the text and 59*7836SJohn.Forte@Sun.COM * the used status and values are removed so that subsequent calls will 60*7836SJohn.Forte@Sun.COM * access the next piece of information. 61*7836SJohn.Forte@Sun.COM * Note that status codes and supplemental values are processed in 62*7836SJohn.Forte@Sun.COM * the reverse order of their insertion by SPCS kernel code. That is, 63*7836SJohn.Forte@Sun.COM * spcs_s_string returns the "youngest" status information first (i.e. 64*7836SJohn.Forte@Sun.COM * LIFO). 65*7836SJohn.Forte@Sun.COM * Note that spcs_s_string will not have any error information in 66*7836SJohn.Forte@Sun.COM * the special case where Solaris has aborted an ioctl and returned an 67*7836SJohn.Forte@Sun.COM * error code via errno or the ioctl service code had an "early" error 68*7836SJohn.Forte@Sun.COM * from copyin or could not allocate its status area. In this case 69*7836SJohn.Forte@Sun.COM * spcs_s_string will return NULL the first time it is called and a 70*7836SJohn.Forte@Sun.COM * positive integer error code will be present in errno and should get 71*7836SJohn.Forte@Sun.COM * handled by the spcs_s_string caller appropriately by using strerror. 72*7836SJohn.Forte@Sun.COM * @param ustatus The status 73*7836SJohn.Forte@Sun.COM * @param msg A char array of at least SPCS_S_MAXTEXT length 74*7836SJohn.Forte@Sun.COM * @return status message string or NULL if no more status present 75*7836SJohn.Forte@Sun.COM */ 76*7836SJohn.Forte@Sun.COM 77*7836SJohn.Forte@Sun.COM char *spcs_s_string(spcs_s_info_t ustatus, char *msg); 78*7836SJohn.Forte@Sun.COM 79*7836SJohn.Forte@Sun.COM /* 80*7836SJohn.Forte@Sun.COM * Write status info to the file specified 81*7836SJohn.Forte@Sun.COM * Uses spsc_s_string to edit status into strings and output them 82*7836SJohn.Forte@Sun.COM * to the file specifed in the same order that the status was inserted. 83*7836SJohn.Forte@Sun.COM * If there is no status present but errno contains a positive value 84*7836SJohn.Forte@Sun.COM * then it will be treated as a Solaris error code and its message text 85*7836SJohn.Forte@Sun.COM * will be written. Note that this routine does NOT remove status 86*7836SJohn.Forte@Sun.COM * information so it can be called more than once. 87*7836SJohn.Forte@Sun.COM * @param ustatus The status 88*7836SJohn.Forte@Sun.COM * @param fd The file descriptor to use for output 89*7836SJohn.Forte@Sun.COM */ 90*7836SJohn.Forte@Sun.COM 91*7836SJohn.Forte@Sun.COM void spcs_s_report(spcs_s_info_t ustatus, FILE *fd); 92*7836SJohn.Forte@Sun.COM 93*7836SJohn.Forte@Sun.COM /* 94*7836SJohn.Forte@Sun.COM * Release (free) ioctl status storage. 95*7836SJohn.Forte@Sun.COM * Note that this interface is an extension to SPARC 1998/038 10/22/98 96*7836SJohn.Forte@Sun.COM * commitment. 97*7836SJohn.Forte@Sun.COM * @param ustatus_a The address of the status (set to NULL) 98*7836SJohn.Forte@Sun.COM */ 99*7836SJohn.Forte@Sun.COM 100*7836SJohn.Forte@Sun.COM void 101*7836SJohn.Forte@Sun.COM spcs_s_ufree(spcs_s_info_t *ustatus_a); 102*7836SJohn.Forte@Sun.COM 103*7836SJohn.Forte@Sun.COM /* 104*7836SJohn.Forte@Sun.COM * Write message to log file. 105*7836SJohn.Forte@Sun.COM * @param product Product code for tagging in log file. 106*7836SJohn.Forte@Sun.COM * @param ustatus The status - may be NULL. 107*7836SJohn.Forte@Sun.COM * @param format printf style format. 108*7836SJohn.Forte@Sun.COM */ 109*7836SJohn.Forte@Sun.COM 110*7836SJohn.Forte@Sun.COM void 111*7836SJohn.Forte@Sun.COM spcs_log(const char *product, spcs_s_info_t *ustatus, const char *format, ...); 112*7836SJohn.Forte@Sun.COM 113*7836SJohn.Forte@Sun.COM #ifdef __cplusplus 114*7836SJohn.Forte@Sun.COM } 115*7836SJohn.Forte@Sun.COM #endif 116*7836SJohn.Forte@Sun.COM 117*7836SJohn.Forte@Sun.COM #endif /* _SPCS_S_U_H */ 118