1N/A/*
1N/A * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
1N/A * All rights reserved.
1N/A * Copyright (c) 1990, 1993
1N/A * The Regents of the University of California. All rights reserved.
1N/A *
1N/A * This code is derived from software contributed to Berkeley by
1N/A * Chris Torek.
1N/A *
1N/A * By using this file, you agree to the terms and conditions set
1N/A * forth in the LICENSE file which can be found at the top level of
1N/A * the sendmail distribution.
1N/A */
1N/A
1N/A#pragma ident "%Z%%M% %I% %E% SMI"
1N/A
1N/A#include <sm/gen.h>
1N/ASM_RCSID("@(#)$Id: fwalk.c,v 1.19 2001/03/02 03:22:18 ca Exp $")
1N/A#include <errno.h>
1N/A#include <sm/io.h>
1N/A#include "local.h"
1N/A#include "glue.h"
1N/A
1N/A/*
1N/A** SM_FWALK -- apply a function to all found-open file pointers
1N/A**
1N/A** Parameters:
1N/A** function -- a function vector to be applied
1N/A** timeout -- time to complete actions (milliseconds)
1N/A**
1N/A** Returns:
1N/A** The (binary) OR'd result of each function call
1N/A*/
1N/A
1N/Aint
1N/Asm_fwalk(function, timeout)
1N/A int (*function) __P((SM_FILE_T *, int *));
1N/A int *timeout;
1N/A{
1N/A register SM_FILE_T *fp;
1N/A register int n, ret;
1N/A register struct sm_glue *g;
1N/A int fptimeout;
1N/A
1N/A ret = 0;
1N/A for (g = &smglue; g != NULL; g = g->gl_next)
1N/A {
1N/A for (fp = g->gl_iobs, n = g->gl_niobs; --n >= 0; fp++)
1N/A {
1N/A if (fp->f_flags != 0)
1N/A {
1N/A if (*timeout == SM_TIME_DEFAULT)
1N/A fptimeout = fp->f_timeout;
1N/A else
1N/A fptimeout = *timeout;
1N/A if (fptimeout == SM_TIME_IMMEDIATE)
1N/A continue; /* skip it */
1N/A ret |= (*function)(fp, &fptimeout);
1N/A }
1N/A }
1N/A }
1N/A return ret;
1N/A}