1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers. 3*7c478bd9Sstevel@tonic-gate * All rights reserved. 4*7c478bd9Sstevel@tonic-gate * Copyright (c) 1990, 1993 5*7c478bd9Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 6*7c478bd9Sstevel@tonic-gate * 7*7c478bd9Sstevel@tonic-gate * This code is derived from software contributed to Berkeley by 8*7c478bd9Sstevel@tonic-gate * Chris Torek. 9*7c478bd9Sstevel@tonic-gate * 10*7c478bd9Sstevel@tonic-gate * By using this file, you agree to the terms and conditions set 11*7c478bd9Sstevel@tonic-gate * forth in the LICENSE file which can be found at the top level of 12*7c478bd9Sstevel@tonic-gate * the sendmail distribution. 13*7c478bd9Sstevel@tonic-gate */ 14*7c478bd9Sstevel@tonic-gate 15*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 16*7c478bd9Sstevel@tonic-gate 17*7c478bd9Sstevel@tonic-gate #include <sm/gen.h> 18*7c478bd9Sstevel@tonic-gate SM_RCSID("@(#)$Id: fscanf.c,v 1.15 2001/03/02 23:53:41 ca Exp $") 19*7c478bd9Sstevel@tonic-gate #include <sm/varargs.h> 20*7c478bd9Sstevel@tonic-gate #include <sm/assert.h> 21*7c478bd9Sstevel@tonic-gate #include <sm/io.h> 22*7c478bd9Sstevel@tonic-gate #include "local.h" 23*7c478bd9Sstevel@tonic-gate 24*7c478bd9Sstevel@tonic-gate /* 25*7c478bd9Sstevel@tonic-gate ** SM_IO_FSCANF -- convert input data to translated format 26*7c478bd9Sstevel@tonic-gate ** 27*7c478bd9Sstevel@tonic-gate ** Parameters: 28*7c478bd9Sstevel@tonic-gate ** fp -- the file pointer to obtain the data from 29*7c478bd9Sstevel@tonic-gate ** timeout -- time to complete scan 30*7c478bd9Sstevel@tonic-gate ** fmt -- the format to translate the data to 31*7c478bd9Sstevel@tonic-gate ** ... -- memory locations to place the formated data 32*7c478bd9Sstevel@tonic-gate ** 33*7c478bd9Sstevel@tonic-gate ** Returns: 34*7c478bd9Sstevel@tonic-gate ** Failure: returns SM_IO_EOF 35*7c478bd9Sstevel@tonic-gate ** Success: returns the number of data units translated 36*7c478bd9Sstevel@tonic-gate */ 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate int 39*7c478bd9Sstevel@tonic-gate #if SM_VA_STD 40*7c478bd9Sstevel@tonic-gate sm_io_fscanf(SM_FILE_T *fp, int timeout, char const *fmt, ...) 41*7c478bd9Sstevel@tonic-gate #else /* SM_VA_STD */ 42*7c478bd9Sstevel@tonic-gate sm_io_fscanf(fp, timeout, fmt, va_alist) 43*7c478bd9Sstevel@tonic-gate SM_FILE_T *fp; 44*7c478bd9Sstevel@tonic-gate int timeout; 45*7c478bd9Sstevel@tonic-gate char *fmt; 46*7c478bd9Sstevel@tonic-gate va_dcl 47*7c478bd9Sstevel@tonic-gate #endif /* SM_VA_STD */ 48*7c478bd9Sstevel@tonic-gate { 49*7c478bd9Sstevel@tonic-gate int ret; 50*7c478bd9Sstevel@tonic-gate SM_VA_LOCAL_DECL 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate SM_REQUIRE_ISA(fp, SmFileMagic); 53*7c478bd9Sstevel@tonic-gate SM_VA_START(ap, fmt); 54*7c478bd9Sstevel@tonic-gate ret = sm_vfscanf(fp, timeout, fmt, ap); 55*7c478bd9Sstevel@tonic-gate SM_VA_END(ap); 56*7c478bd9Sstevel@tonic-gate return ret; 57*7c478bd9Sstevel@tonic-gate } 58