1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * Copyright (c) 1998-2001, 2004 Sendmail, Inc. and its suppliers. 3*7c478bd9Sstevel@tonic-gate * All rights reserved. 4*7c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 5*7c478bd9Sstevel@tonic-gate * Copyright (c) 1988, 1993 6*7c478bd9Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 7*7c478bd9Sstevel@tonic-gate * 8*7c478bd9Sstevel@tonic-gate * By using this file, you agree to the terms and conditions set 9*7c478bd9Sstevel@tonic-gate * forth in the LICENSE file which can be found at the top level of 10*7c478bd9Sstevel@tonic-gate * the sendmail distribution. 11*7c478bd9Sstevel@tonic-gate * 12*7c478bd9Sstevel@tonic-gate * $Id: clock.h,v 1.12 2004/08/03 19:57:21 ca Exp $ 13*7c478bd9Sstevel@tonic-gate */ 14*7c478bd9Sstevel@tonic-gate 15*7c478bd9Sstevel@tonic-gate /* 16*7c478bd9Sstevel@tonic-gate ** CLOCK.H -- for co-ordinating timed events 17*7c478bd9Sstevel@tonic-gate */ 18*7c478bd9Sstevel@tonic-gate 19*7c478bd9Sstevel@tonic-gate #ifndef _SM_CLOCK_H 20*7c478bd9Sstevel@tonic-gate # define _SM_CLOCK_H 1 21*7c478bd9Sstevel@tonic-gate 22*7c478bd9Sstevel@tonic-gate # include <sm/signal.h> 23*7c478bd9Sstevel@tonic-gate # if SM_CONF_SETITIMER 24*7c478bd9Sstevel@tonic-gate # include <sys/time.h> 25*7c478bd9Sstevel@tonic-gate # endif /* SM_CONF_SETITIMER */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* 28*7c478bd9Sstevel@tonic-gate ** STRUCT SM_EVENT -- event queue. 29*7c478bd9Sstevel@tonic-gate ** 30*7c478bd9Sstevel@tonic-gate ** Maintained in sorted order. 31*7c478bd9Sstevel@tonic-gate ** 32*7c478bd9Sstevel@tonic-gate ** We store the pid of the process that set this event to insure 33*7c478bd9Sstevel@tonic-gate ** that when we fork we will not take events intended for the parent. 34*7c478bd9Sstevel@tonic-gate */ 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate struct sm_event 37*7c478bd9Sstevel@tonic-gate { 38*7c478bd9Sstevel@tonic-gate # if SM_CONF_SETITIMER 39*7c478bd9Sstevel@tonic-gate struct timeval ev_time; /* time of the call (microseconds) */ 40*7c478bd9Sstevel@tonic-gate # else /* SM_CONF_SETITIMER */ 41*7c478bd9Sstevel@tonic-gate time_t ev_time; /* time of the call (seconds) */ 42*7c478bd9Sstevel@tonic-gate # endif /* SM_CONF_SETITIMER */ 43*7c478bd9Sstevel@tonic-gate void (*ev_func)__P((int)); 44*7c478bd9Sstevel@tonic-gate /* function to call */ 45*7c478bd9Sstevel@tonic-gate int ev_arg; /* argument to ev_func */ 46*7c478bd9Sstevel@tonic-gate pid_t ev_pid; /* pid that set this event */ 47*7c478bd9Sstevel@tonic-gate struct sm_event *ev_link; /* link to next item */ 48*7c478bd9Sstevel@tonic-gate }; 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate typedef struct sm_event SM_EVENT; 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate /* functions */ 53*7c478bd9Sstevel@tonic-gate extern void sm_clrevent __P((SM_EVENT *)); 54*7c478bd9Sstevel@tonic-gate extern void sm_clear_events __P((void)); 55*7c478bd9Sstevel@tonic-gate extern SM_EVENT *sm_seteventm __P((int, void(*)__P((int)), int)); 56*7c478bd9Sstevel@tonic-gate extern SM_EVENT *sm_sigsafe_seteventm __P((int, void(*)__P((int)), int)); 57*7c478bd9Sstevel@tonic-gate extern SIGFUNC_DECL sm_tick __P((int)); 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate /* 60*7c478bd9Sstevel@tonic-gate ** SM_SETEVENT -- set an event to happen at a specific time in seconds. 61*7c478bd9Sstevel@tonic-gate ** 62*7c478bd9Sstevel@tonic-gate ** Translates the seconds into millseconds and calls sm_seteventm() 63*7c478bd9Sstevel@tonic-gate ** to get a specific event to happen in the future at a specific time. 64*7c478bd9Sstevel@tonic-gate ** 65*7c478bd9Sstevel@tonic-gate ** Parameters: 66*7c478bd9Sstevel@tonic-gate ** t -- intvl until next event occurs (seconds). 67*7c478bd9Sstevel@tonic-gate ** f -- function to call on event. 68*7c478bd9Sstevel@tonic-gate ** a -- argument to func on event. 69*7c478bd9Sstevel@tonic-gate ** 70*7c478bd9Sstevel@tonic-gate ** Returns: 71*7c478bd9Sstevel@tonic-gate ** result of sm_seteventm(). 72*7c478bd9Sstevel@tonic-gate ** 73*7c478bd9Sstevel@tonic-gate ** Side Effects: 74*7c478bd9Sstevel@tonic-gate ** Any that sm_seteventm() have. 75*7c478bd9Sstevel@tonic-gate */ 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate #define sm_setevent(t, f, a) sm_seteventm((int)((t) * 1000), (f), (a)) 78*7c478bd9Sstevel@tonic-gate #define sm_sigsafe_setevent(t, f, a) sm_sigsafe_seteventm((int)((t) * 1000), (f), (a)) 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate #endif /* _SM_CLOCK_H */ 81