190792Sgshapiro/*
2261194Sgshapiro * Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers.
390792Sgshapiro *      All rights reserved.
490792Sgshapiro * Copyright (c) 1990, 1993
590792Sgshapiro *	The Regents of the University of California.  All rights reserved.
690792Sgshapiro *
790792Sgshapiro * This code is derived from software contributed to Berkeley by
890792Sgshapiro * Chris Torek.
990792Sgshapiro *
1090792Sgshapiro * By using this file, you agree to the terms and conditions set
1190792Sgshapiro * forth in the LICENSE file which can be found at the top level of
1290792Sgshapiro * the sendmail distribution.
1390792Sgshapiro */
1490792Sgshapiro
1590792Sgshapiro#include <sm/gen.h>
16266527SgshapiroSM_RCSID("@(#)$Id: fscanf.c,v 1.18 2013-11-22 20:51:42 ca Exp $")
1790792Sgshapiro#include <sm/varargs.h>
1890792Sgshapiro#include <sm/assert.h>
1990792Sgshapiro#include <sm/io.h>
2090792Sgshapiro#include "local.h"
2190792Sgshapiro
2290792Sgshapiro/*
2390792Sgshapiro**  SM_IO_FSCANF -- convert input data to translated format
2490792Sgshapiro**
2590792Sgshapiro**	Parameters:
2690792Sgshapiro**		fp -- the file pointer to obtain the data from
2790792Sgshapiro**		timeout -- time to complete scan
2890792Sgshapiro**		fmt -- the format to translate the data to
29363466Sgshapiro**		... -- memory locations to place the formatted data
3090792Sgshapiro**
3190792Sgshapiro**	Returns:
3290792Sgshapiro**		Failure: returns SM_IO_EOF
3390792Sgshapiro**		Success: returns the number of data units translated
3490792Sgshapiro*/
3590792Sgshapiro
3690792Sgshapiroint
3790792Sgshapiro#if SM_VA_STD
3890792Sgshapirosm_io_fscanf(SM_FILE_T *fp, int timeout, char const *fmt, ...)
3990792Sgshapiro#else /* SM_VA_STD */
4090792Sgshapirosm_io_fscanf(fp, timeout, fmt, va_alist)
4190792Sgshapiro	SM_FILE_T *fp;
4290792Sgshapiro	int timeout;
4390792Sgshapiro	char *fmt;
4490792Sgshapiro	va_dcl
4590792Sgshapiro#endif /* SM_VA_STD */
4690792Sgshapiro{
4790792Sgshapiro	int ret;
4890792Sgshapiro	SM_VA_LOCAL_DECL
4990792Sgshapiro
5090792Sgshapiro	SM_REQUIRE_ISA(fp, SmFileMagic);
5190792Sgshapiro	SM_VA_START(ap, fmt);
5290792Sgshapiro	ret = sm_vfscanf(fp, timeout, fmt, ap);
5390792Sgshapiro	SM_VA_END(ap);
5490792Sgshapiro	return ret;
5590792Sgshapiro}
56