author | viric@mandarina |
Wed, 07 Oct 2009 21:20:12 +0200 | |
changeset 283 | f049b802be64 |
parent 278 | 1698b327528d |
child 295 | a63f43a17fd7 |
permissions | -rw-r--r-- |
49 | 1 |
/* |
2 |
Task Spooler - a task queue system for the unix user |
|
267 | 3 |
Copyright (C) 2007-2009 LluĂs Batlle i Rossell |
49 | 4 |
|
5 |
Please find the license in the provided COPYING file. |
|
6 |
*/ |
|
1 | 7 |
#include <unistd.h> |
44 | 8 |
#include <stdlib.h> |
9 |
#include <string.h> |
|
95 | 10 |
#include <signal.h> |
1 | 11 |
|
12 |
#include <stdio.h> |
|
146 | 13 |
#include <sys/time.h> |
1 | 14 |
|
3 | 15 |
#include "main.h" |
16 |
||
1 | 17 |
extern char *optarg; |
18 |
extern int optind, opterr, optopt; |
|
19 |
||
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
20 |
/* Globals */ |
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
21 |
struct Command_line command_line; |
1 | 22 |
int server_socket; |
23 |
||
76
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
24 |
/* Globals for the environment of getopt */ |
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
25 |
static char getopt_env[] = "POSIXLY_CORRECT=YES"; |
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
26 |
static char *old_getopt_env; |
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
27 |
|
283
f049b802be64
Updating version references to 0.6.6, and Changelog.
viric@mandarina
parents:
278
diff
changeset
|
28 |
static char version[] = "Task Spooler v0.6.6 - a task queue system for the unix user.\n" |
266
e35af91aa426
Fixing the help messages and man page for 0.6.3.
viric@mandarina
parents:
263
diff
changeset
|
29 |
"Copyright (C) 2007-2009 Lluis Batlle i Rossell"; |
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
30 |
|
95 | 31 |
|
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
32 |
static void default_command_line() |
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
33 |
{ |
36 | 34 |
command_line.request = c_LIST; |
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
35 |
command_line.need_server = 0; |
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
36 |
command_line.store_output = 1; |
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
37 |
command_line.should_go_background = 1; |
55
678ca291d545
Now the '-nf' doesn't leave a job in 'finished' state.
viric@llimona
parents:
53
diff
changeset
|
38 |
command_line.should_keep_finished = 1; |
65 | 39 |
command_line.gzip = 0; |
71 | 40 |
command_line.send_output_by_mail = 0; |
150 | 41 |
command_line.label = 0; |
259 | 42 |
command_line.do_depend = 0; |
43 |
command_line.depend_on = -1; /* -1 means depend on previous */ |
|
219 | 44 |
command_line.max_slots = 1; |
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
45 |
} |
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
46 |
|
18 | 47 |
void get_command(int index, int argc, char **argv) |
48 |
{ |
|
68
3ae9b38d7d30
Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents:
65
diff
changeset
|
49 |
command_line.command.array = &(argv[index]); |
3ae9b38d7d30
Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents:
65
diff
changeset
|
50 |
command_line.command.num = argc - index; |
18 | 51 |
} |
3 | 52 |
|
66
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
53 |
static int get_two_jobs(const char *str, int *j1, int *j2) |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
54 |
{ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
55 |
char tmp[50]; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
56 |
char *tmp2; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
57 |
|
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
58 |
if(strlen(str) >= 50) |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
59 |
return 0; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
60 |
strcpy(tmp, str); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
61 |
|
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
62 |
tmp2 = strchr(tmp , '-'); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
63 |
if (tmp2 == NULL) |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
64 |
return 0; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
65 |
|
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
66 |
/* We change the '-' to '\0', so we have a delimiter, |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
67 |
* and we can access the two strings for the ids */ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
68 |
*tmp2 = '\0'; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
69 |
/* Skip the '\0', and point tmp2 to the second id */ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
70 |
++tmp2; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
71 |
|
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
72 |
*j1 = atoi(tmp); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
73 |
*j2 = atoi(tmp2); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
74 |
return 1; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
75 |
} |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
76 |
|
1 | 77 |
void parse_opts(int argc, char **argv) |
78 |
{ |
|
2 | 79 |
int c; |
66
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
80 |
int res; |
1 | 81 |
|
2 | 82 |
/* Parse options */ |
83 |
while(1) { |
|
259 | 84 |
c = getopt(argc, argv, ":VhKgClnfmr:t:c:o:p:w:u:s:U:i:L:dS:D:"); |
1 | 85 |
|
2 | 86 |
if (c == -1) |
87 |
break; |
|
1 | 88 |
|
2 | 89 |
switch(c) |
90 |
{ |
|
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
91 |
case 'K': |
31 | 92 |
command_line.request = c_KILL_SERVER; |
95 | 93 |
command_line.should_go_background = 0; |
2 | 94 |
break; |
3 | 95 |
case 'l': |
31 | 96 |
command_line.request = c_LIST; |
3 | 97 |
break; |
36 | 98 |
case 'h': |
99 |
command_line.request = c_SHOW_HELP; |
|
100 |
break; |
|
155 | 101 |
case 'd': |
259 | 102 |
command_line.do_depend = 1; |
103 |
command_line.depend_on = -1; |
|
155 | 104 |
break; |
37 | 105 |
case 'V': |
106 |
command_line.request = c_SHOW_VERSION; |
|
107 |
break; |
|
33 | 108 |
case 'C': |
109 |
command_line.request = c_CLEAR_FINISHED; |
|
110 |
break; |
|
20
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
18
diff
changeset
|
111 |
case 'c': |
33 | 112 |
command_line.request = c_CAT; |
113 |
command_line.jobid = atoi(optarg); |
|
114 |
break; |
|
115 |
case 'o': |
|
116 |
command_line.request = c_SHOW_OUTPUT_FILE; |
|
117 |
command_line.jobid = atoi(optarg); |
|
20
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
18
diff
changeset
|
118 |
break; |
22 | 119 |
case 'n': |
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
120 |
command_line.store_output = 0; |
22 | 121 |
break; |
150 | 122 |
case 'L': |
123 |
command_line.label = optarg; |
|
124 |
break; |
|
65 | 125 |
case 'g': |
126 |
command_line.gzip = 1; |
|
127 |
break; |
|
31 | 128 |
case 'f': |
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
129 |
command_line.should_go_background = 0; |
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
130 |
break; |
71 | 131 |
case 'm': |
132 |
command_line.send_output_by_mail = 1; |
|
133 |
break; |
|
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
134 |
case 't': |
31 | 135 |
command_line.request = c_TAIL; |
32 | 136 |
command_line.jobid = atoi(optarg); |
29
ca47653a4cbc
Add an option for electing not to go into background.
viric@llimona
parents:
27
diff
changeset
|
137 |
break; |
35 | 138 |
case 'p': |
139 |
command_line.request = c_SHOW_PID; |
|
140 |
command_line.jobid = atoi(optarg); |
|
141 |
break; |
|
146 | 142 |
case 'i': |
143 |
command_line.request = c_INFO; |
|
144 |
command_line.jobid = atoi(optarg); |
|
145 |
break; |
|
41 | 146 |
case 'r': |
147 |
command_line.request = c_REMOVEJOB; |
|
148 |
command_line.jobid = atoi(optarg); |
|
149 |
break; |
|
42 | 150 |
case 'w': |
151 |
command_line.request = c_WAITJOB; |
|
152 |
command_line.jobid = atoi(optarg); |
|
153 |
break; |
|
53 | 154 |
case 'u': |
155 |
command_line.request = c_URGENT; |
|
156 |
command_line.jobid = atoi(optarg); |
|
157 |
break; |
|
63 | 158 |
case 's': |
159 |
command_line.request = c_GET_STATE; |
|
160 |
command_line.jobid = atoi(optarg); |
|
161 |
break; |
|
218 | 162 |
case 'S': |
219 | 163 |
command_line.request = c_SET_MAX_SLOTS; |
164 |
command_line.max_slots = atoi(optarg); |
|
165 |
if (command_line.max_slots < 1) |
|
166 |
{ |
|
167 |
fprintf(stderr, "You should set at minimum 1 slot.\n"); |
|
168 |
exit(-1); |
|
169 |
} |
|
218 | 170 |
break; |
259 | 171 |
case 'D': |
172 |
command_line.do_depend = 1; |
|
173 |
command_line.depend_on = atoi(optarg); |
|
174 |
break; |
|
66
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
175 |
case 'U': |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
176 |
command_line.request = c_SWAP_JOBS; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
177 |
res = get_two_jobs(optarg, &command_line.jobid, |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
178 |
&command_line.jobid2); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
179 |
if (!res) |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
180 |
{ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
181 |
fprintf(stderr, "Wrong <id-id> for -U.\n"); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
182 |
exit(-1); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
183 |
} |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
184 |
if (command_line.jobid == command_line.jobid2) |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
185 |
{ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
186 |
fprintf(stderr, "Wrong <id-id> for -U. " |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
187 |
"Use different ids.\n"); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
188 |
exit(-1); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
189 |
} |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
190 |
break; |
31 | 191 |
case ':': |
192 |
switch(optopt) |
|
193 |
{ |
|
194 |
case 't': |
|
32 | 195 |
command_line.request = c_TAIL; |
31 | 196 |
command_line.jobid = -1; /* This means the 'last' job */ |
197 |
break; |
|
33 | 198 |
case 'c': |
199 |
command_line.request = c_CAT; |
|
200 |
command_line.jobid = -1; /* This means the 'last' job */ |
|
201 |
break; |
|
202 |
case 'o': |
|
203 |
command_line.request = c_SHOW_OUTPUT_FILE; |
|
204 |
command_line.jobid = -1; /* This means the 'last' job */ |
|
205 |
break; |
|
35 | 206 |
case 'p': |
207 |
command_line.request = c_SHOW_PID; |
|
208 |
command_line.jobid = -1; /* This means the 'last' job */ |
|
209 |
break; |
|
146 | 210 |
case 'i': |
211 |
command_line.request = c_INFO; |
|
212 |
command_line.jobid = -1; /* This means the 'last' job */ |
|
213 |
break; |
|
41 | 214 |
case 'r': |
215 |
command_line.request = c_REMOVEJOB; |
|
216 |
command_line.jobid = -1; /* This means the 'last' |
|
217 |
added job */ |
|
218 |
break; |
|
42 | 219 |
case 'w': |
220 |
command_line.request = c_WAITJOB; |
|
221 |
command_line.jobid = -1; /* This means the 'last' |
|
222 |
added job */ |
|
223 |
break; |
|
53 | 224 |
case 'u': |
225 |
command_line.request = c_URGENT; |
|
226 |
command_line.jobid = -1; /* This means the 'last' |
|
227 |
added job */ |
|
228 |
break; |
|
63 | 229 |
case 's': |
230 |
command_line.request = c_GET_STATE; |
|
231 |
command_line.jobid = -1; /* This means the 'last' |
|
232 |
added job */ |
|
233 |
break; |
|
253
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
247
diff
changeset
|
234 |
case 'S': |
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
247
diff
changeset
|
235 |
command_line.request = c_GET_MAX_SLOTS; |
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
247
diff
changeset
|
236 |
break; |
31 | 237 |
default: |
150 | 238 |
fprintf(stderr, "Option %c missing argument.\n", |
239 |
optopt); |
|
31 | 240 |
exit(-1); |
241 |
} |
|
242 |
break; |
|
243 |
case '?': |
|
244 |
fprintf(stderr, "Wrong option %c.\n", optopt); |
|
245 |
exit(-1); |
|
2 | 246 |
} |
247 |
} |
|
1 | 248 |
|
68
3ae9b38d7d30
Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents:
65
diff
changeset
|
249 |
command_line.command.num = 0; |
18 | 250 |
|
37 | 251 |
/* if the request is still the default option... |
252 |
* (the default values should be centralized) */ |
|
253 |
if (optind < argc && command_line.request == c_LIST) |
|
31 | 254 |
{ |
255 |
command_line.request = c_QUEUE; |
|
18 | 256 |
get_command(optind, argc, argv); |
31 | 257 |
} |
3 | 258 |
|
37 | 259 |
if (command_line.request != c_SHOW_HELP && |
260 |
command_line.request != c_SHOW_VERSION) |
|
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
261 |
command_line.need_server = 1; |
55
678ca291d545
Now the '-nf' doesn't leave a job in 'finished' state.
viric@llimona
parents:
53
diff
changeset
|
262 |
|
678ca291d545
Now the '-nf' doesn't leave a job in 'finished' state.
viric@llimona
parents:
53
diff
changeset
|
263 |
if ( ! command_line.store_output && ! command_line.should_go_background ) |
678ca291d545
Now the '-nf' doesn't leave a job in 'finished' state.
viric@llimona
parents:
53
diff
changeset
|
264 |
command_line.should_keep_finished = 0; |
71 | 265 |
|
266 |
if ( command_line.send_output_by_mail && ((! command_line.store_output) || |
|
267 |
command_line.gzip) ) |
|
268 |
{ |
|
269 |
fprintf(stderr, |
|
270 |
"For e-mail, you should store the output (not through gzip)\n"); |
|
271 |
exit(-1); |
|
272 |
} |
|
1 | 273 |
} |
274 |
||
66
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
275 |
static void fill_first_3_handles() |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
276 |
{ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
277 |
int tmp_pipe1[2]; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
278 |
int tmp_pipe2[2]; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
279 |
/* This will fill handles 0 and 1 */ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
280 |
pipe(tmp_pipe1); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
281 |
/* This will fill handles 2 and 3 */ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
282 |
pipe(tmp_pipe2); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
283 |
|
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
284 |
close(tmp_pipe2[1]); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
285 |
} |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
286 |
|
44 | 287 |
static void go_background() |
11
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
288 |
{ |
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
289 |
int pid; |
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
290 |
pid = fork(); |
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
291 |
|
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
292 |
switch(pid) |
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
293 |
{ |
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
294 |
case -1: |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
295 |
error("fork failed"); |
11
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
296 |
break; |
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
297 |
case 0: |
66
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
298 |
close(0); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
299 |
close(1); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
300 |
close(2); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
301 |
/* This is a weird thing. But we will later want to |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
302 |
* allocate special files to the 0, 1 or 2 fds. It's |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
303 |
* almost impossible, if other important things got |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
304 |
* allocated here. */ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
305 |
fill_first_3_handles(); |
133 | 306 |
setsid(); |
11
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
307 |
break; |
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
308 |
default: |
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
309 |
exit(0); |
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
310 |
} |
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
311 |
} |
bb94b9890001
Going to background at for new command queued.
lbatlle@npdl268.bpo.hp.com
parents:
8
diff
changeset
|
312 |
|
37 | 313 |
static void print_help(const char *cmd) |
36 | 314 |
{ |
266
e35af91aa426
Fixing the help messages and man page for 0.6.3.
viric@mandarina
parents:
263
diff
changeset
|
315 |
printf("usage: %s [action] [-ngfmd] [-L <lab>] [-D <id>] [cmd...]\n", cmd); |
73 | 316 |
printf("Env vars:\n"); |
183
95d49e8a8cec
Updating 'help' and some other related files to 0.5
viric@llimona
parents:
174
diff
changeset
|
317 |
printf(" TS_SOCKET the path to the unix socket used by the ts command.\n"); |
95d49e8a8cec
Updating 'help' and some other related files to 0.5
viric@llimona
parents:
174
diff
changeset
|
318 |
printf(" TS_MAILTO where to mail the result (on -m). Local user by default.\n"); |
95d49e8a8cec
Updating 'help' and some other related files to 0.5
viric@llimona
parents:
174
diff
changeset
|
319 |
printf(" TS_MAXFINISHED maximum finished jobs in the queue.\n"); |
278 | 320 |
printf(" TS_MAXCONN maximum number of ts connections at once.\n"); |
183
95d49e8a8cec
Updating 'help' and some other related files to 0.5
viric@llimona
parents:
174
diff
changeset
|
321 |
printf(" TS_ONFINISH binary called on job end (passes jobid, error, outfile, command).\n"); |
95d49e8a8cec
Updating 'help' and some other related files to 0.5
viric@llimona
parents:
174
diff
changeset
|
322 |
printf(" TS_ENV command called on enqueue. Its output determines the job information.\n"); |
95d49e8a8cec
Updating 'help' and some other related files to 0.5
viric@llimona
parents:
174
diff
changeset
|
323 |
printf(" TS_SAVELIST filename which will store the list, if the server dies.\n"); |
239
18301d7a56d4
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
viric@vicerveza
parents:
237
diff
changeset
|
324 |
printf(" TS_SLOTS amount of jobs which can run at once, read on server start.\n"); |
52 | 325 |
printf("Actions:\n"); |
36 | 326 |
printf(" -K kill the task spooler server\n"); |
327 |
printf(" -C clear the list of finished jobs\n"); |
|
328 |
printf(" -l show the job list (default action)\n"); |
|
263 | 329 |
printf(" -S [num] get/set the number of max simultaneous jobs of the server.\n"); |
204
cd474500b9e1
Removing the code related to tail -f and cat. Updated help.
lbatlle@npdl268.bpo.hp.com
parents:
203
diff
changeset
|
330 |
printf(" -t [id] \"tail -n 10 -f\" the output of the job. Last run if not specified.\n"); |
cd474500b9e1
Removing the code related to tail -f and cat. Updated help.
lbatlle@npdl268.bpo.hp.com
parents:
203
diff
changeset
|
331 |
printf(" -c [id] like -t, but shows all the lines. Last run if not specified.\n"); |
132 | 332 |
printf(" -p [id] show the pid of the job. Last run if not specified.\n"); |
61 | 333 |
printf(" -o [id] show the output file. Of last job run, if not specified.\n"); |
151 | 334 |
printf(" -i [id] show job information. Of last job run, if not specified.\n"); |
78 | 335 |
printf(" -s [id] show the job state. Of the last added, if not specified.\n"); |
42 | 336 |
printf(" -r [id] remove a job. The last added, if not specified.\n"); |
337 |
printf(" -w [id] wait for a job. The last added, if not specified.\n"); |
|
53 | 338 |
printf(" -u [id] put that job first. The last added, if not specified.\n"); |
66
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
339 |
printf(" -U <id-id> swap two jobs in the queue.\n"); |
37 | 340 |
printf(" -h show this help\n"); |
341 |
printf(" -V show the program version\n"); |
|
52 | 342 |
printf("Options adding jobs:\n"); |
36 | 343 |
printf(" -n don't store the output of the command.\n"); |
65 | 344 |
printf(" -g gzip the stored output (if not -n).\n"); |
36 | 345 |
printf(" -f don't fork into background.\n"); |
71 | 346 |
printf(" -m send the output by e-mail (uses sendmail).\n"); |
158 | 347 |
printf(" -d the job will be run only if the job before ends well\n"); |
259 | 348 |
printf(" -D <id> the job will be run only if the job of given id ends well \n"); |
159 | 349 |
printf(" -L <lab> name this task with a label, to be distinguished on listing.\n"); |
36 | 350 |
} |
351 |
||
37 | 352 |
static void print_version() |
353 |
{ |
|
354 |
puts(version); |
|
44 | 355 |
} |
37 | 356 |
|
76
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
357 |
static void set_getopt_env() |
48 | 358 |
{ |
76
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
359 |
old_getopt_env = getenv("POSIXLY_CORRECT"); |
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
360 |
putenv(getopt_env); |
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
361 |
} |
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
362 |
|
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
363 |
static void unset_getopt_env() |
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
364 |
{ |
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
365 |
if (old_getopt_env == NULL) |
87
18dc656315eb
Finally fixed the POSIXLY_CORRECT env problem
lbatlle@npdl268.bpo.hp.com
parents:
81
diff
changeset
|
366 |
{ |
76
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
367 |
/* Wipe the string from the environment */ |
87
18dc656315eb
Finally fixed the POSIXLY_CORRECT env problem
lbatlle@npdl268.bpo.hp.com
parents:
81
diff
changeset
|
368 |
putenv("POSIXLY_CORRECT"); |
18dc656315eb
Finally fixed the POSIXLY_CORRECT env problem
lbatlle@npdl268.bpo.hp.com
parents:
81
diff
changeset
|
369 |
} |
76
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
370 |
else |
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
371 |
sprintf(getopt_env, "POSIXLY_CORRECT=%s", old_getopt_env); |
48 | 372 |
} |
373 |
||
1 | 374 |
int main(int argc, char **argv) |
375 |
{ |
|
38
768d009604b3
The program returns the errorlevel of the job, if it doesn't go to background.
viric@llimona
parents:
37
diff
changeset
|
376 |
int errorlevel = 0; |
41 | 377 |
|
104 | 378 |
process_type = CLIENT; |
379 |
||
76
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
380 |
set_getopt_env(); |
41 | 381 |
/* This is needed in a gnu system, so getopt works well */ |
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
382 |
default_command_line(); |
2 | 383 |
parse_opts(argc, argv); |
76
14bc35eee745
Fixed two bugs: POSIXLY_CORRECT=YES no more in the child's env, and a
viric@mandarina
parents:
73
diff
changeset
|
384 |
unset_getopt_env(); |
1 | 385 |
|
95 | 386 |
/* This will be inherited by the server, if it's run */ |
387 |
ignore_sigpipe(); |
|
388 |
||
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
389 |
if (command_line.need_server) |
260
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
259
diff
changeset
|
390 |
{ |
3 | 391 |
ensure_server_up(); |
260
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
259
diff
changeset
|
392 |
c_check_version(); |
ecd09b351170
Adding version control in the protocol. It can't check with older versions.
viric@mandarina
parents:
259
diff
changeset
|
393 |
} |
3 | 394 |
|
31 | 395 |
switch(command_line.request) |
3 | 396 |
{ |
37 | 397 |
case c_SHOW_VERSION: |
398 |
print_version(argv[0]); |
|
399 |
break; |
|
36 | 400 |
case c_SHOW_HELP: |
401 |
print_help(argv[0]); |
|
37 | 402 |
break; |
31 | 403 |
case c_QUEUE: |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
404 |
if (command_line.command.num <= 0) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
405 |
error("Tried to queue a void command. parameters: %i", |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
406 |
command_line.command.num); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
407 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
408 |
error("The command %i needs the server", command_line.request); |
68
3ae9b38d7d30
Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents:
65
diff
changeset
|
409 |
c_new_job(); |
71 | 410 |
command_line.jobid = c_wait_newjob_ok(); |
62 | 411 |
if (command_line.store_output) |
66
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
412 |
{ |
71 | 413 |
printf("%i\n", command_line.jobid); |
66
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
414 |
fflush(stdout); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
415 |
} |
62 | 416 |
if (command_line.should_go_background) |
417 |
{ |
|
418 |
go_background(); |
|
68
3ae9b38d7d30
Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents:
65
diff
changeset
|
419 |
c_wait_server_commands(); |
62 | 420 |
} else |
421 |
{ |
|
68
3ae9b38d7d30
Now the orders don't run under 'bash'. They run as is.
viric@llimona
parents:
65
diff
changeset
|
422 |
errorlevel = c_wait_server_commands(); |
62 | 423 |
} |
31 | 424 |
break; |
425 |
case c_LIST: |
|
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
426 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
427 |
error("The command %i needs the server", command_line.request); |
8 | 428 |
c_list_jobs(); |
5 | 429 |
c_wait_server_lines(); |
31 | 430 |
break; |
431 |
case c_KILL_SERVER: |
|
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
432 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
433 |
error("The command %i needs the server", command_line.request); |
3 | 434 |
c_shutdown_server(); |
31 | 435 |
break; |
436 |
case c_CLEAR_FINISHED: |
|
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
437 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
438 |
error("The command %i needs the server", command_line.request); |
20
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
18
diff
changeset
|
439 |
c_clear_finished(); |
31 | 440 |
break; |
32 | 441 |
case c_TAIL: |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
442 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
443 |
error("The command %i needs the server", command_line.request); |
174
c112f67965fb
Our implementation of -t (equivalent tail -f), which now
viric@llimona
parents:
166
diff
changeset
|
444 |
errorlevel = c_tail(); |
32 | 445 |
/* This will not return! */ |
446 |
break; |
|
33 | 447 |
case c_CAT: |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
448 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
449 |
error("The command %i needs the server", command_line.request); |
203
664044b1de73
Making '-c' to behave as 'tail -f', but showing *all* the file.
lbatlle@npdl268.bpo.hp.com
parents:
199
diff
changeset
|
450 |
errorlevel = c_cat(); |
33 | 451 |
/* This will not return! */ |
452 |
break; |
|
453 |
case c_SHOW_OUTPUT_FILE: |
|
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
454 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
455 |
error("The command %i needs the server", command_line.request); |
33 | 456 |
c_show_output_file(); |
457 |
break; |
|
35 | 458 |
case c_SHOW_PID: |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
459 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
460 |
error("The command %i needs the server", command_line.request); |
35 | 461 |
c_show_pid(); |
462 |
break; |
|
146 | 463 |
case c_INFO: |
464 |
if (!command_line.need_server) |
|
465 |
error("The command %i needs the server", command_line.request); |
|
466 |
c_show_info(); |
|
467 |
break; |
|
41 | 468 |
case c_REMOVEJOB: |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
469 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
470 |
error("The command %i needs the server", command_line.request); |
41 | 471 |
c_remove_job(); |
472 |
break; |
|
42 | 473 |
case c_WAITJOB: |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
474 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
475 |
error("The command %i needs the server", command_line.request); |
51
aa6e05d77537
'-w' returns the waited errorlevel. Added a testbench.
viric@llimona
parents:
49
diff
changeset
|
476 |
errorlevel = c_wait_job(); |
42 | 477 |
break; |
53 | 478 |
case c_URGENT: |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
479 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
480 |
error("The command %i needs the server", command_line.request); |
53 | 481 |
c_move_urgent(); |
482 |
break; |
|
219 | 483 |
case c_SET_MAX_SLOTS: |
484 |
c_send_max_slots(command_line.max_slots); |
|
485 |
break; |
|
253
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
247
diff
changeset
|
486 |
case c_GET_MAX_SLOTS: |
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
247
diff
changeset
|
487 |
c_get_max_slots(); |
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
247
diff
changeset
|
488 |
break; |
66
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
489 |
case c_SWAP_JOBS: |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
490 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
491 |
error("The command %i needs the server", command_line.request); |
66
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
492 |
c_swap_jobs(); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
65
diff
changeset
|
493 |
break; |
63 | 494 |
case c_GET_STATE: |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
495 |
if (!command_line.need_server) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
87
diff
changeset
|
496 |
error("The command %i needs the server", command_line.request); |
63 | 497 |
/* This will also print the state into stdout */ |
498 |
c_get_state(); |
|
499 |
break; |
|
20
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
18
diff
changeset
|
500 |
} |
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
18
diff
changeset
|
501 |
|
30
ab88478a7e9b
The commandline parameters are centered in a struct.
viric@llimona
parents:
29
diff
changeset
|
502 |
if (command_line.need_server) |
2 | 503 |
{ |
3 | 504 |
close(server_socket); |
2 | 505 |
} |
1 | 506 |
|
38
768d009604b3
The program returns the errorlevel of the job, if it doesn't go to background.
viric@llimona
parents:
37
diff
changeset
|
507 |
return errorlevel; |
1 | 508 |
} |