10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*6812Sraf * Common Development and Distribution License (the "License"). 6*6812Sraf * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21*6812Sraf 220Sstevel@tonic-gate /* 23*6812Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */ 280Sstevel@tonic-gate /* All Rights Reserved */ 290Sstevel@tonic-gate 30*6812Sraf #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 32*6812Sraf #include "lint.h" 330Sstevel@tonic-gate #include "file64.h" 340Sstevel@tonic-gate #include "mtlib.h" 350Sstevel@tonic-gate #include <stdio.h> 360Sstevel@tonic-gate #include <stdarg.h> 370Sstevel@tonic-gate #include <string.h> 380Sstevel@tonic-gate #include <thread.h> 390Sstevel@tonic-gate #include <synch.h> 400Sstevel@tonic-gate #include "libc.h" 410Sstevel@tonic-gate #include "stdiom.h" 420Sstevel@tonic-gate #include "mse.h" 430Sstevel@tonic-gate #include <stdio_ext.h> 440Sstevel@tonic-gate 450Sstevel@tonic-gate /*VARARGS1*/ 460Sstevel@tonic-gate int 470Sstevel@tonic-gate scanf(const char *fmt, ...) 480Sstevel@tonic-gate { 490Sstevel@tonic-gate int ret; 500Sstevel@tonic-gate va_list ap; 510Sstevel@tonic-gate 520Sstevel@tonic-gate va_start(ap, fmt); 530Sstevel@tonic-gate ret = vscanf(fmt, ap); 540Sstevel@tonic-gate va_end(ap); 550Sstevel@tonic-gate 560Sstevel@tonic-gate return (ret); 570Sstevel@tonic-gate } 580Sstevel@tonic-gate 590Sstevel@tonic-gate /*VARARGS2*/ 600Sstevel@tonic-gate int 610Sstevel@tonic-gate fscanf(FILE *iop, const char *fmt, ...) 620Sstevel@tonic-gate { 630Sstevel@tonic-gate int ret; 640Sstevel@tonic-gate va_list ap; 650Sstevel@tonic-gate 660Sstevel@tonic-gate va_start(ap, fmt); 670Sstevel@tonic-gate ret = vfscanf(iop, fmt, ap); 680Sstevel@tonic-gate va_end(ap); 690Sstevel@tonic-gate 700Sstevel@tonic-gate return (ret); 710Sstevel@tonic-gate } 720Sstevel@tonic-gate 730Sstevel@tonic-gate /*VARARGS2*/ 740Sstevel@tonic-gate int 750Sstevel@tonic-gate sscanf(const char *str, const char *fmt, ...) 760Sstevel@tonic-gate { 770Sstevel@tonic-gate int ret; 780Sstevel@tonic-gate va_list ap; 790Sstevel@tonic-gate 800Sstevel@tonic-gate va_start(ap, fmt); 810Sstevel@tonic-gate ret = vsscanf(str, fmt, ap); 820Sstevel@tonic-gate va_end(ap); 830Sstevel@tonic-gate 840Sstevel@tonic-gate return (ret); 850Sstevel@tonic-gate } 860Sstevel@tonic-gate 870Sstevel@tonic-gate #ifndef _LP64 880Sstevel@tonic-gate 890Sstevel@tonic-gate /* 900Sstevel@tonic-gate * 32-bit shadow functions _scanf_c89(), _fscanf_c89(), _sscanf_c89() 910Sstevel@tonic-gate * included here. 920Sstevel@tonic-gate * When using the c89 compiler to build 32-bit applications, the size 930Sstevel@tonic-gate * of intmax_t is 32-bits, otherwise the size of intmax_t is 64-bits. 940Sstevel@tonic-gate * The shadow function uses 32-bit size of intmax_t for %j conversion. 950Sstevel@tonic-gate * The #pragma redefine_extname in <stdio.h> selects the proper routine 960Sstevel@tonic-gate * at compile time for the user application. 970Sstevel@tonic-gate * NOTE: the shadow function only exists in the 32-bit library. 980Sstevel@tonic-gate */ 990Sstevel@tonic-gate 1000Sstevel@tonic-gate int 1010Sstevel@tonic-gate _scanf_c89(const char *fmt, ...) 1020Sstevel@tonic-gate { 1030Sstevel@tonic-gate int ret; 1040Sstevel@tonic-gate va_list ap; 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate va_start(ap, fmt); 1070Sstevel@tonic-gate ret = _vscanf_c89(fmt, ap); 1080Sstevel@tonic-gate va_end(ap); 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate return (ret); 1110Sstevel@tonic-gate } 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate int 1140Sstevel@tonic-gate _fscanf_c89(FILE *iop, const char *fmt, ...) 1150Sstevel@tonic-gate { 1160Sstevel@tonic-gate int ret; 1170Sstevel@tonic-gate va_list ap; 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate va_start(ap, fmt); 1200Sstevel@tonic-gate ret = _vfscanf_c89(iop, fmt, ap); 1210Sstevel@tonic-gate va_end(ap); 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate return (ret); 1240Sstevel@tonic-gate } 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate int 1270Sstevel@tonic-gate _sscanf_c89(const char *str, const char *fmt, ...) 1280Sstevel@tonic-gate { 1290Sstevel@tonic-gate int ret; 1300Sstevel@tonic-gate va_list ap; 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate va_start(ap, fmt); 1330Sstevel@tonic-gate ret = _vsscanf_c89(str, fmt, ap); 1340Sstevel@tonic-gate va_end(ap); 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate return (ret); 1370Sstevel@tonic-gate } 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate #endif /* _LP64 */ 140