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

Revision 19204, 1.4 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-2001 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 * Chris Torek.
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: fwalk.c,v 1.1.1.1 2003-04-08 15:06:04 zacheiss Exp $")
17#include <errno.h>
18#include <sm/io.h>
19#include "local.h"
20#include "glue.h"
21
22/*
23**  SM_FWALK -- apply a function to all found-open file pointers
24**
25**      Parameters:
26**              function -- a function vector to be applied
27**              timeout -- time to complete actions (milliseconds)
28**
29**      Returns:
30**              The (binary) OR'd result of each function call
31*/
32
33int
34sm_fwalk(function, timeout)
35        int (*function) __P((SM_FILE_T *, int *));
36        int *timeout;
37{
38        register SM_FILE_T *fp;
39        register int n, ret;
40        register struct sm_glue *g;
41        int fptimeout;
42
43        ret = 0;
44        for (g = &smglue; g != NULL; g = g->gl_next)
45        {
46                for (fp = g->gl_iobs, n = g->gl_niobs; --n >= 0; fp++)
47                {
48                        if (fp->f_flags != 0)
49                        {
50                                if (*timeout == SM_TIME_DEFAULT)
51                                        fptimeout = fp->f_timeout;
52                                else
53                                        fptimeout = *timeout;
54                                if (fptimeout == SM_TIME_IMMEDIATE)
55                                        continue; /* skip it */
56                                ret |= (*function)(fp, &fptimeout);
57                        }
58                }
59        }
60        return ret;
61}
Note: See TracBrowser for help on using the repository browser.