source: trunk/third/sendmail/libsm/vsscanf.c @ 19204

Revision 19204, 2.1 KB checked in by zacheiss, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r19203, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * Copyright (c) 2000-2002 Sendmail, Inc. and its suppliers.
3 *      All rights reserved.
4 * Copyright (c) 1990, 1993
5 *      The Regents of the University of California.  All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Donn Seeley at UUNET Technologies, Inc.
9 *
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.
13 */
14
15#include <sm/gen.h>
16SM_RCSID("@(#)$Id: vsscanf.c,v 1.1.1.1 2003-04-08 15:06:55 zacheiss Exp $")
17#include <string.h>
18#include <sm/io.h>
19
20/*
21**  SM_EOFREAD -- dummy read function for faked file below
22**
23**      Parameters:
24**              fp -- file pointer
25**              buf -- location to place read data
26**              len -- number of bytes to read
27**
28**      Returns:
29**              0 (zero) always
30*/
31
32/* type declaration for later use */
33static ssize_t sm_eofread __P((SM_FILE_T *, char *, size_t));
34
35/* ARGSUSED0 */
36static ssize_t
37sm_eofread(fp, buf, len)
38        SM_FILE_T *fp;
39        char *buf;
40        size_t len;
41{
42        return 0;
43}
44
45/*
46**  SM_VSSCANF -- scan a string to find data units
47**
48**      Parameters:
49**              str -- strings containing data
50**              fmt -- format directive for finding data units
51**              ap -- memory locations to place format found data units
52**
53**      Returns:
54**              Failure: SM_IO_EOF
55**              Success: number of data units found
56**
57**      Side Effects:
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.
61*/
62
63int
64sm_vsscanf(str, fmt, ap)
65        const char *str;
66        const char *fmt;
67        SM_VA_LOCAL_DECL
68{
69        SM_FILE_T fake;
70
71        fake.sm_magic = SmFileMagic;
72        fake.f_timeout = SM_TIME_FOREVER;
73        fake.f_timeoutstate = SM_TIME_BLOCK;
74        fake.f_file = -1;
75        fake.f_flags = SMRD;
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;
80        fake.f_close = NULL;
81        fake.f_open = NULL;
82        fake.f_write = NULL;
83        fake.f_seek = 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);
87}
Note: See TracBrowser for help on using the repository browser.