1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1996-2011 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                                                                      *
19 ***********************************************************************/
20 #pragma prototyped
21 /*
22  * Glenn Fowler
23  * AT&T Research
24  *
25  * at interface definitions
26  */
27 
28 #ifndef _AT_H
29 #define _AT_H
30 
31 #include <ast.h>
32 #include <coshell.h>
33 #include <css.h>
34 #include <ctype.h>
35 #include <error.h>
36 #include <tm.h>
37 
38 #ifndef AT_STRICT
39 #define AT_STRICT	3
40 #endif
41 
42 #if _WINIX
43 
44 #undef	csstat
45 #define csstat(s,h,p)	(memset(p,0,sizeof(*(p))),0)
46 
47 #define AT_DIR_MODE	(S_IRUSR|S_IWUSR|S_IXUSR|S_IXGRP|S_IXOTH|S_IRGRP|S_IROTH)
48 #define AT_JOB_MODE	(S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
49 #define AT_RUN_MODE	(AT_JOB_MODE|S_IXUSR)
50 
51 #if AT_STRICT > 1
52 
53 #define AT_EXEC_OK(d,x)	(S_ISREG((x)->st_mode)&&((x)->st_mode&(S_IXUSR|S_IXGRP|S_IWOTH|S_IXOTH))==(S_IXUSR|S_IXGRP|S_IXOTH))
54 #define AT_DIR_OK(d)	(S_ISDIR((d)->st_mode)&&(((d)->st_mode)&S_IPERM)==AT_DIR_MODE)
55 #define AT_JOB_OK(d,j)	((d)->st_uid==(j)->st_uid&&S_ISREG((j)->st_mode)&&(((j)->st_mode)&S_IPERM)==AT_JOB_MODE)
56 #define AT_OLD_OK(d,j)	((d)->st_uid==(j)->st_uid&&S_ISREG((j)->st_mode)&&(((j)->st_mode)&(S_IPERM&~(AT_JOB_MODE^AT_RUN_MODE)))==AT_JOB_MODE)
57 #define AT_RUN_OK(d,j)	((d)->st_uid==(j)->st_uid&&S_ISREG((j)->st_mode)&&(((j)->st_mode)&S_IPERM)==AT_RUN_MODE&&(unsigned long)(j)->st_mtime<=NOW)
58 
59 #else
60 
61 #define AT_EXEC_OK(d,x)	(S_ISREG((x)->st_mode))
62 #define AT_DIR_OK(d)	(S_ISDIR((d)->st_mode))
63 #define AT_JOB_OK(d,j)	(S_ISREG((j)->st_mode)&&(d)->st_uid==(j)->st_uid)
64 #define AT_OLD_OK(d,j)	(AT_JOB_OK(d,j))
65 #define AT_RUN_OK(d,j)	(AT_JOB_OK(d,j)&&(unsigned long)(j)->st_mtime<=NOW)
66 
67 #endif
68 
69 #else
70 
71 #define AT_DIR_MODE	(S_IRUSR|S_IWUSR|S_IXUSR|S_IXGRP|S_IXOTH)
72 #define AT_JOB_MODE	(S_IRUSR|S_IWUSR)
73 #define AT_RUN_MODE	(AT_JOB_MODE|S_IXUSR)
74 
75 #define AT_EXEC_OK(d,x)	(S_ISREG((x)->st_mode)&&((x)->st_mode&(S_IXUSR|S_IWGRP|S_IXGRP|S_IWOTH|S_IXOTH))==(S_IXUSR|S_IXGRP|S_IXOTH))
76 #define AT_DIR_OK(d)	(S_ISDIR((d)->st_mode)&&(((d)->st_mode)&S_IPERM)==AT_DIR_MODE)
77 #define AT_JOB_OK(d,j)	((d)->st_uid==(j)->st_uid&&S_ISREG((j)->st_mode)&&(((j)->st_mode)&S_IPERM)==AT_JOB_MODE)
78 #define AT_OLD_OK(d,j)	((d)->st_uid==(j)->st_uid&&S_ISREG((j)->st_mode)&&(((j)->st_mode)&(S_IPERM&~(AT_JOB_MODE^AT_RUN_MODE)))==AT_JOB_MODE)
79 #define AT_RUN_OK(d,j)	((d)->st_uid==(j)->st_uid&&S_ISREG((j)->st_mode)&&(((j)->st_mode)&S_IPERM)==AT_RUN_MODE&&(unsigned long)(j)->st_mtime<=NOW)
80 
81 #endif
82 
83 #define AT_SERVICE	"/dev/tcp/local/at"
84 
85 #ifndef AT_JOB_DIR
86 #define AT_JOB_DIR	"lib/at/jobs"
87 #endif
88 
89 #define AT_CRON_DIR	"../../../cron"
90 #define AT_ALLOW_FILE	"at.allow"
91 #define AT_DENY_FILE	"at.deny"
92 
93 #define AT_EXEC_FILE	"../atx"
94 #define AT_QUEUE_FILE	"../../queues"
95 #define AT_LOG_FILE	"../../log"
96 
97 #define AT_TIME_FORMAT	"%Y-%m-%d+%H:%M:%S"
98 
99 #define AT_ACCESS	'a'
100 #define AT_ADMIN	'A'
101 #define AT_DEBUG	'D'
102 #define AT_INFO		'i'
103 #define AT_JOB		'j'
104 #define AT_LABEL	'h'
105 #define AT_LIST		'l'
106 #define AT_LOG		'L'
107 #define AT_MAIL		'm'
108 #define AT_QUEUE	'q'
109 #define AT_QUIT		'Q'
110 #define AT_REMOVE	'r'
111 #define AT_STATUS	'p'
112 #define AT_TIME		't'
113 #define AT_UPDATE	'U'
114 #define AT_USER		'u'
115 #define AT_VERSION	'v'
116 
117 #ifndef NOW
118 #define NOW		(unsigned long)time((time_t*)0)
119 #endif
120 
121 #endif
122