2 * Copyright (c) 2000-2002 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
8 * Donn Seeley at UUNET Technologies, Inc.
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: vsscanf.c,v 1.23 2002/02/01 02:28:00 ca Exp $")
21 ** SM_EOFREAD -- dummy read function for faked file below
25 ** buf -- location to place read data
26 ** len -- number of bytes to read
32 /* type declaration for later use */
33 static ssize_t sm_eofread __P((SM_FILE_T *, char *, size_t));
37 sm_eofread(fp, buf, len)
46 ** SM_VSSCANF -- scan a string to find data units
49 ** str -- strings containing data
50 ** fmt -- format directive for finding data units
51 ** ap -- memory locations to place format found data units
55 ** Success: number of data units found
58 ** Attempts to strlen() 'str'; if not a '\0' terminated string
59 ** then the call may SEGV/fail.
60 ** Faking the string 'str' as a file.
64 sm_vsscanf(str, fmt, ap)
71 fake.sm_magic = SmFileMagic;
72 fake.f_timeout = SM_TIME_FOREVER;
73 fake.f_timeoutstate = SM_TIME_BLOCK;
76 fake.f_bf.smb_base = fake.f_p = (unsigned char *)str;
77 fake.f_bf.smb_size = fake.f_r = strlen(str);
78 fake.f_read = sm_eofread;
79 fake.f_ub.smb_base = NULL;
84 fake.f_setinfo = fake.f_getinfo = NULL;
85 fake.f_type = "sm_vsscanf:fake";
86 return sm_vfscanf(&fake, SM_TIME_FOREVER, fmt, ap);