190792Sgshapiro/* 2261194Sgshapiro * Copyright (c) 1998-2001, 2004 Proofpoint, Inc. and its suppliers. 390792Sgshapiro * All rights reserved. 490792Sgshapiro * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 590792Sgshapiro * Copyright (c) 1988, 1993 690792Sgshapiro * The Regents of the University of California. All rights reserved. 790792Sgshapiro * 890792Sgshapiro * By using this file, you agree to the terms and conditions set 990792Sgshapiro * forth in the LICENSE file which can be found at the top level of 1090792Sgshapiro * the sendmail distribution. 1190792Sgshapiro * 12266527Sgshapiro * $Id: clock.h,v 1.14 2013-11-22 20:51:31 ca Exp $ 1390792Sgshapiro */ 1490792Sgshapiro 1590792Sgshapiro/* 1690792Sgshapiro** CLOCK.H -- for co-ordinating timed events 1790792Sgshapiro*/ 1890792Sgshapiro 1990792Sgshapiro#ifndef _SM_CLOCK_H 2090792Sgshapiro# define _SM_CLOCK_H 1 2190792Sgshapiro 2290792Sgshapiro# include <sm/signal.h> 2390792Sgshapiro# if SM_CONF_SETITIMER 2490792Sgshapiro# include <sys/time.h> 2590792Sgshapiro# endif /* SM_CONF_SETITIMER */ 2690792Sgshapiro 2790792Sgshapiro/* 2890792Sgshapiro** STRUCT SM_EVENT -- event queue. 2990792Sgshapiro** 3090792Sgshapiro** Maintained in sorted order. 3190792Sgshapiro** 3290792Sgshapiro** We store the pid of the process that set this event to insure 3390792Sgshapiro** that when we fork we will not take events intended for the parent. 3490792Sgshapiro*/ 3590792Sgshapiro 3690792Sgshapirostruct sm_event 3790792Sgshapiro{ 3890792Sgshapiro# if SM_CONF_SETITIMER 3990792Sgshapiro struct timeval ev_time; /* time of the call (microseconds) */ 4090792Sgshapiro# else /* SM_CONF_SETITIMER */ 4190792Sgshapiro time_t ev_time; /* time of the call (seconds) */ 4290792Sgshapiro# endif /* SM_CONF_SETITIMER */ 4390792Sgshapiro void (*ev_func)__P((int)); 4490792Sgshapiro /* function to call */ 4590792Sgshapiro int ev_arg; /* argument to ev_func */ 4690792Sgshapiro pid_t ev_pid; /* pid that set this event */ 4790792Sgshapiro struct sm_event *ev_link; /* link to next item */ 4890792Sgshapiro}; 4990792Sgshapiro 5090792Sgshapirotypedef struct sm_event SM_EVENT; 5190792Sgshapiro 5290792Sgshapiro/* functions */ 5390792Sgshapiroextern void sm_clrevent __P((SM_EVENT *)); 5490792Sgshapiroextern void sm_clear_events __P((void)); 55141858Sgshapiroextern SM_EVENT *sm_seteventm __P((int, void(*)__P((int)), int)); 56141858Sgshapiroextern SM_EVENT *sm_sigsafe_seteventm __P((int, void(*)__P((int)), int)); 5790792Sgshapiroextern SIGFUNC_DECL sm_tick __P((int)); 5890792Sgshapiro 5990792Sgshapiro/* 6090792Sgshapiro** SM_SETEVENT -- set an event to happen at a specific time in seconds. 6190792Sgshapiro** 62244833Sgshapiro** Translates the seconds into milliseconds and calls sm_seteventm() 6390792Sgshapiro** to get a specific event to happen in the future at a specific time. 6490792Sgshapiro** 6590792Sgshapiro** Parameters: 6690792Sgshapiro** t -- intvl until next event occurs (seconds). 6790792Sgshapiro** f -- function to call on event. 6890792Sgshapiro** a -- argument to func on event. 6990792Sgshapiro** 7090792Sgshapiro** Returns: 7190792Sgshapiro** result of sm_seteventm(). 7290792Sgshapiro** 7390792Sgshapiro** Side Effects: 7490792Sgshapiro** Any that sm_seteventm() have. 7590792Sgshapiro*/ 7690792Sgshapiro 7790792Sgshapiro#define sm_setevent(t, f, a) sm_seteventm((int)((t) * 1000), (f), (a)) 7890792Sgshapiro#define sm_sigsafe_setevent(t, f, a) sm_sigsafe_seteventm((int)((t) * 1000), (f), (a)) 7990792Sgshapiro 8090792Sgshapiro#endif /* _SM_CLOCK_H */ 81