2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
10 * By using this file, you agree to the terms and conditions set
11 * forth in the LICENSE file which can be found at the top level of
12 * the sendmail distribution.
16 SM_RCSID("@(#)$Id: sscanf.c,v 1.25 2002/02/01 02:28:00 ca Exp $")
18 #include <sm/varargs.h>
23 ** SM_EOFREAD -- dummy read function for faked file below
27 ** buf -- location to place read data
28 ** len -- number of bytes to read
42 sm_eofread(fp
, buf
, len
)
51 ** SM_IO_SSCANF -- scan a string to find data units
54 ** str -- strings containing data
55 ** fmt -- format directive for finding data units
56 ** ... -- memory locations to place format found data units
60 ** Success: number of data units found
63 ** Attempts to strlen() 'str'; if not a '\0' terminated string
64 ** then the call may SEGV/fail.
65 ** Faking the string 'str' as a file.
70 sm_io_sscanf(const char *str
, char const *fmt
, ...)
72 sm_io_sscanf(str
, fmt
, va_alist
)
76 #endif /* SM_VA_STD */
82 fake
.sm_magic
= SmFileMagic
;
84 fake
.f_bf
.smb_base
= fake
.f_p
= (unsigned char *) str
;
85 fake
.f_bf
.smb_size
= fake
.f_r
= strlen(str
);
87 fake
.f_read
= sm_eofread
;
92 fake
.f_setinfo
= fake
.f_getinfo
= NULL
;
93 fake
.f_type
= "sm_io_sscanf:fake";
94 fake
.f_flushfp
= NULL
;
95 fake
.f_ub
.smb_base
= NULL
;
96 fake
.f_timeout
= SM_TIME_FOREVER
;
97 fake
.f_timeoutstate
= SM_TIME_BLOCK
;
99 ret
= sm_vfscanf(&fake
, SM_TIME_FOREVER
, fmt
, ap
);