140266059SGregory Neil Shapiro /* 25dd76dd0SGregory Neil Shapiro * Copyright (c) 1998-2001, 2004 Proofpoint, Inc. and its suppliers. 340266059SGregory Neil Shapiro * All rights reserved. 440266059SGregory Neil Shapiro * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 540266059SGregory Neil Shapiro * Copyright (c) 1988, 1993 640266059SGregory Neil Shapiro * The Regents of the University of California. All rights reserved. 740266059SGregory Neil Shapiro * 840266059SGregory Neil Shapiro * By using this file, you agree to the terms and conditions set 940266059SGregory Neil Shapiro * forth in the LICENSE file which can be found at the top level of 1040266059SGregory Neil Shapiro * the sendmail distribution. 1140266059SGregory Neil Shapiro * 124313cc83SGregory Neil Shapiro * $Id: clock.h,v 1.14 2013-11-22 20:51:31 ca Exp $ 1340266059SGregory Neil Shapiro */ 1440266059SGregory Neil Shapiro 1540266059SGregory Neil Shapiro /* 1640266059SGregory Neil Shapiro ** CLOCK.H -- for co-ordinating timed events 1740266059SGregory Neil Shapiro */ 1840266059SGregory Neil Shapiro 1940266059SGregory Neil Shapiro #ifndef _SM_CLOCK_H 2040266059SGregory Neil Shapiro # define _SM_CLOCK_H 1 2140266059SGregory Neil Shapiro 2240266059SGregory Neil Shapiro # include <sm/signal.h> 2340266059SGregory Neil Shapiro # if SM_CONF_SETITIMER 2440266059SGregory Neil Shapiro # include <sys/time.h> 25*5b0945b5SGregory Neil Shapiro # endif 2640266059SGregory Neil Shapiro 2740266059SGregory Neil Shapiro /* 2840266059SGregory Neil Shapiro ** STRUCT SM_EVENT -- event queue. 2940266059SGregory Neil Shapiro ** 3040266059SGregory Neil Shapiro ** Maintained in sorted order. 3140266059SGregory Neil Shapiro ** 3240266059SGregory Neil Shapiro ** We store the pid of the process that set this event to insure 3340266059SGregory Neil Shapiro ** that when we fork we will not take events intended for the parent. 3440266059SGregory Neil Shapiro */ 3540266059SGregory Neil Shapiro 3640266059SGregory Neil Shapiro struct sm_event 3740266059SGregory Neil Shapiro { 3840266059SGregory Neil Shapiro # if SM_CONF_SETITIMER 3940266059SGregory Neil Shapiro struct timeval ev_time; /* time of the call (microseconds) */ 40*5b0945b5SGregory Neil Shapiro # else 4140266059SGregory Neil Shapiro time_t ev_time; /* time of the call (seconds) */ 42*5b0945b5SGregory Neil Shapiro # endif 4340266059SGregory Neil Shapiro void (*ev_func)__P((int)); 4440266059SGregory Neil Shapiro /* function to call */ 4540266059SGregory Neil Shapiro int ev_arg; /* argument to ev_func */ 4640266059SGregory Neil Shapiro pid_t ev_pid; /* pid that set this event */ 4740266059SGregory Neil Shapiro struct sm_event *ev_link; /* link to next item */ 4840266059SGregory Neil Shapiro }; 4940266059SGregory Neil Shapiro 5040266059SGregory Neil Shapiro typedef struct sm_event SM_EVENT; 5140266059SGregory Neil Shapiro 5240266059SGregory Neil Shapiro /* functions */ 5340266059SGregory Neil Shapiro extern void sm_clrevent __P((SM_EVENT *)); 5440266059SGregory Neil Shapiro extern void sm_clear_events __P((void)); 55b6bacd31SGregory Neil Shapiro extern SM_EVENT *sm_seteventm __P((int, void(*)__P((int)), int)); 56b6bacd31SGregory Neil Shapiro extern SM_EVENT *sm_sigsafe_seteventm __P((int, void(*)__P((int)), int)); 5740266059SGregory Neil Shapiro extern SIGFUNC_DECL sm_tick __P((int)); 5840266059SGregory Neil Shapiro 5940266059SGregory Neil Shapiro /* 6040266059SGregory Neil Shapiro ** SM_SETEVENT -- set an event to happen at a specific time in seconds. 6140266059SGregory Neil Shapiro ** 62ba00ec3dSGregory Neil Shapiro ** Translates the seconds into milliseconds and calls sm_seteventm() 6340266059SGregory Neil Shapiro ** to get a specific event to happen in the future at a specific time. 6440266059SGregory Neil Shapiro ** 6540266059SGregory Neil Shapiro ** Parameters: 6640266059SGregory Neil Shapiro ** t -- intvl until next event occurs (seconds). 6740266059SGregory Neil Shapiro ** f -- function to call on event. 6840266059SGregory Neil Shapiro ** a -- argument to func on event. 6940266059SGregory Neil Shapiro ** 7040266059SGregory Neil Shapiro ** Returns: 7140266059SGregory Neil Shapiro ** result of sm_seteventm(). 7240266059SGregory Neil Shapiro ** 7340266059SGregory Neil Shapiro ** Side Effects: 7440266059SGregory Neil Shapiro ** Any that sm_seteventm() have. 7540266059SGregory Neil Shapiro */ 7640266059SGregory Neil Shapiro 7740266059SGregory Neil Shapiro #define sm_setevent(t, f, a) sm_seteventm((int)((t) * 1000), (f), (a)) 7840266059SGregory Neil Shapiro #define sm_sigsafe_setevent(t, f, a) sm_sigsafe_seteventm((int)((t) * 1000), (f), (a)) 7940266059SGregory Neil Shapiro 8040266059SGregory Neil Shapiro #endif /* _SM_CLOCK_H */ 81