1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23 /* 24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 28 #include <sys/smbios_impl.h> 29 30 #include <strings.h> 31 #include <unistd.h> 32 #include <stdlib.h> 33 #include <stdarg.h> 34 #include <stdio.h> 35 36 smbios_hdl_t * 37 smb_open_error(smbios_hdl_t *shp, int *errp, int err) 38 { 39 if (shp != NULL) 40 smbios_close(shp); 41 42 if (errp != NULL) 43 *errp = err; 44 45 return (NULL); 46 } 47 48 const char * 49 smb_strerror(int err) 50 { 51 return (strerror(err)); 52 } 53 54 void * 55 smb_alloc(size_t len) 56 { 57 return (len ? malloc(len) : NULL); 58 } 59 60 void * 61 smb_zalloc(size_t len) 62 { 63 void *buf; 64 65 if ((buf = smb_alloc(len)) != NULL) 66 bzero(buf, len); 67 68 return (buf); 69 } 70 71 /*ARGSUSED*/ 72 void 73 smb_free(void *buf, size_t len) 74 { 75 free(buf); 76 } 77 78 /*PRINTFLIKE2*/ 79 void 80 smb_dprintf(smbios_hdl_t *shp, const char *format, ...) 81 { 82 va_list ap; 83 84 if (!(shp->sh_flags & SMB_FL_DEBUG)) 85 return; 86 87 (void) fprintf(stderr, "smb DEBUG: "); 88 va_start(ap, format); 89 (void) vfprintf(stderr, format, ap); 90 va_end(ap); 91 } 92