1 /*
2  * Copyright (C) 2001-2005 Chris Ross, Stephan Engstrom, Alex Holden et al
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this
9  *   list of conditions and the following disclaimer.
10  * o Redistributions in binary form must reproduce the above copyright notice,
11  *   this list of conditions and the following disclaimer in the documentation
12  *   and/or other materials provided with the distribution.
13  * o Neither the name of the ferite software nor the names of its contributors may
14  *   be used to endorse or promote products derived from this software without
15  *   specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <unistd.h>
33 #include <string.h>
34 #include <sys/types.h>
35 
36 #include "../../config.h"
37 
38 #ifdef WIN32
39 #include <windows.h>
40 #include <sys/time.h>
41 #include <time.h>
42 #include <utime.h>
43 #endif
44 
45 #ifndef WIN32
46 #include <sys/socket.h>
47 #include <sys/file.h>
48 #include <netinet/in.h>
49 #include <arpa/inet.h>
50 #include <netdb.h>
51 #include <dirent.h>
52 #include <sys/select.h>
53 #include <sys/time.h>
54 #include <sys/un.h>
55 #include <pwd.h>
56 #include <sys/stat.h>
57 #include <fcntl.h>
58 #include <errno.h>
59 #include <time.h>
60 #include <syslog.h>
61 #include <utime.h>
62 #include <signal.h>
63 #include <sys/wait.h>
64 #include <sys/utsname.h>
65 #include <sys/resource.h>
66 #include <sys/time.h>
67 #endif
68 
69 #include "ferite.h"
70 
71 extern int errno;
72 
73 struct FeTm
74 {
75     FeriteVariable *tm_sec;
76     FeriteVariable *tm_min;
77     FeriteVariable *tm_hour;
78     FeriteVariable *tm_mday;
79     FeriteVariable *tm_mon;
80     FeriteVariable *tm_year;
81     FeriteVariable *tm_wday;
82     FeriteVariable *tm_yday;
83     FeriteVariable *tm_isdst;
84     FeriteVariable *tm_zone;
85     FeriteVariable *tm_gmtoff;
86 };
87 
88 struct alarm_data {
89     FeriteFunction       *function;
90     FeriteScript         *script;
91     int                  interval;
92     int                  recurring;
93     int                  timeleft;
94 };
95 typedef struct alarm_data AlarmData;
96 void timer_sig_alarm( int );
97 #ifndef FE_SYS_ALARM_OWNER
98 extern AlarmData *currentAlarm;
99 #endif
100 
101 FeriteVariable *system_call_tm( FeriteScript *script, struct tm *tm );
102 int system_sync_to_tm( struct FeTm *Tm, struct tm *tm );
103 int system_sync_to_FeTm( struct FeTm *Tm, struct tm *tm );
104 
105 #ifndef PF_LOCAL
106 #define PF_LOCAL PF_UNIX
107 #endif
108