added cmd_peek and added example arguments for language strings with placeholders
[NeonServV5.git] / modcmd.c
1
2 #include "modcmd.h"
3 #include "IRCEvents.h"
4 #include "IRCParser.h"
5 #include "ClientSocket.h"
6 #include "UserNode.h"
7 #include "ChanNode.h"
8 #include "ChanUser.h"
9 #include "WHOHandler.h"
10 #include "lang.h"
11 #include "mysqlConn.h"
12 #include "DBHelper.h"
13 #include "EventLogger.h"
14
15 struct trigger_callback {
16     int botid;
17     trigger_callback_t *func;
18     
19     struct trigger_callback *next;
20 };
21
22 struct command_check_user_cache {
23     struct ClientSocket *client, *textclient;
24     struct UserNode *user;
25     struct ChanNode *chan, *sent_chan;
26     char **argv;
27     int argc;
28     char *message;
29     struct cmd_binding *cbind;
30 };
31
32 static struct cmd_binding **cmd_binds;
33 static struct cmd_function *cmd_functions = NULL;
34 static struct trigger_callback *trigger_callbacks = NULL;
35 static struct ClientSocket *tmp_text_client;
36
37 static const struct default_language_entry msgtab[] = {
38     {"MODCMD_LESS_PARAM_COUNT", "This command requires more parameters."},
39     {"MODCMD_CHAN_REQUIRED",    "You must provide the name of a channel that exists."},
40     {"MODCMD_AUTH_REQUIRED",    "You need to be authenticated with AuthServ to use this command."},
41     {"MODCMD_PRIVILEGED",       "\002%s\002 is a privileged command."}, /* {ARGS: "god"} */
42     {"MODCMD_PUBCMD",           "Public commands in \002%s\002 are restricted."}, /* {ARGS: "#TestChan"} */
43     {"MODCMD_ACCESS_DENIED",    "Access denied."},
44     {NULL, NULL}
45 };
46
47 static int get_binds_index(char first_char) {
48     if(tolower(first_char) >= 'a' && tolower(first_char) <= 'z') {
49         return tolower(first_char) - 'a';
50     }
51     return 26;
52 }
53
54 struct ClientSocket* get_prefered_bot(int botid) {
55     struct ClientSocket *client;
56     for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
57         if(client->botid == botid && (client->flags & SOCKET_FLAG_PREFERRED))
58             return client;
59     }
60     return NULL;
61 }
62
63 static char* get_channel_trigger(int botid, struct ChanNode *chan) {
64     struct trigger_cache *trigger;
65     for(trigger = chan->trigger; trigger; trigger = trigger->next) {
66         if(trigger->botid == botid)
67             return trigger->trigger;
68     }
69     struct trigger_callback *cb;
70     for(cb = trigger_callbacks; cb; cb = cb->next) {
71         if(cb->botid == botid)
72             break;
73     }
74     char triggerStr[TRIGGERLEN];
75     if(cb)
76         cb->func(chan, triggerStr);
77     else
78         strcpy(triggerStr, "+");
79     trigger = malloc(sizeof(*trigger));
80     if (!trigger) {
81         perror("malloc() failed");
82         return 0;
83     }
84     trigger->botid = botid;
85     trigger->trigger = strdup(triggerStr);
86     trigger->next = chan->trigger;
87     chan->trigger = trigger;
88     return trigger->trigger;
89 }
90
91 static void handle_command_async(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct ChanNode *sent_chan, struct cmd_binding *cbind, char **argv, int argc);
92
93 static USERAUTH_CALLBACK(command_checked_auth) {
94     struct command_check_user_cache *cache = data;
95     tmp_text_client = cache->textclient;
96     handle_command_async(cache->client, user, cache->chan, cache->sent_chan, cache->cbind, cache->argv, cache->argc);
97     free(cache->message);
98     free(cache);
99 }
100
101 static void handle_command(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, char *message) {
102     struct ChanNode *sent_chan = chan;
103     if(message[0] == '#') {
104         char *chanName = message;
105         message = strstr(message, " ");
106         if(!message) return;
107         *message = '\0';
108         message++;
109         struct ChanNode *chan2 = getChanByName(chanName);
110         if(chan2)
111             chan = chan2;
112     }
113     message = strdup(message);
114     int bind_index = get_binds_index(message[0]);
115     char *args = strstr(message, " ");
116     if(args) {
117         *args = '\0';
118         args++;
119     }
120     struct cmd_binding *cbind;
121     for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
122         if(cbind->botid == client->botid && stricmp(cbind->cmd, message) == 0) {
123             //get a text bot
124             tmp_text_client = get_prefered_bot(client->botid);
125             //parse the arguments...
126             char *arga[MAXNUMPARAMS];
127             char **argv;
128             int argc = 0;
129             if(args) {
130                 while(*args) {
131                     //skip leading spaces
132                     while (*args == ' ')
133                         *args++ = 0;
134                     arga[argc++] = args;
135                     if (argc >= MAXNUMPARAMS)
136                         break;
137                     while (*args != ' ' && *args)
138                         args++;
139                 }
140             }
141             argv = arga;
142             if(argc != 0 && argv[0][0] == '#' && !(cbind->func->flags & CMDFLAG_CHAN_PARAM)) {
143                 struct ChanNode *chan2 = getChanByName(argv[0]);
144                 if(chan2) {
145                     argv += 1;
146                     argc -= 1;
147                     chan = chan2;
148                 }
149             }
150             if(cbind->parameters) {
151                 //userdefined parameters...
152                 char *uarga[MAXNUMPARAMS];
153                 char params[strlen(cbind->parameters)+1];
154                 strcpy(params, cbind->parameters);
155                 int uargpos = 0, argi, allargs = 0;
156                 char *ppos = params;
157                 char *prev_ppos = params;
158                 while((ppos = strstr(ppos, " "))) {
159                     *ppos = '\0';
160                     if(prev_ppos[0] == '%') {
161                         prev_ppos++;
162                         if(prev_ppos[strlen(prev_ppos)-1] == '-') {
163                             allargs = 1;
164                             prev_ppos[strlen(prev_ppos)-1] = '\0';
165                         } else
166                             allargs = 0;
167                         argi = atoi(prev_ppos);
168                         if(argi > 0) {
169                             if(argi <= argc) continue;
170                             uarga[uargpos++] = argv[argi-1];
171                             if(allargs) {
172                                 for(;argi < argc; argi++)
173                                     uarga[uargpos++] = argv[argi-1];
174                             }
175                         } else if(!strcmp(prev_ppos, "c"))
176                             uarga[uargpos++] = (chan ? chan->name : NULL);
177                         else if(!strcmp(prev_ppos, "n")) 
178                             uarga[uargpos++] = user->nick;
179                     } else {
180                         uarga[uargpos++] = prev_ppos;
181                     }
182                     ppos++;
183                     prev_ppos = ppos;
184                 }
185                 argv = uarga;
186                 argc = uargpos;
187             }
188             if(argc < cbind->func->paramcount) {
189                 reply(tmp_text_client, user, "MODCMD_LESS_PARAM_COUNT");
190                 break;
191             }
192             if((cbind->func->flags & CMDFLAG_REQUIRE_CHAN) && !chan) {
193                 reply(tmp_text_client, user, "MODCMD_CHAN_REQUIRED");
194                 break;
195             }
196             if((cbind->func->flags & CMDFLAG_CHECK_AUTH) && !(user->flags & USERFLAG_ISAUTHED)) {
197                 //check auth...
198                 struct command_check_user_cache *data = malloc(sizeof(*data));
199                 char **temp_argv = malloc(argc*sizeof(*temp_argv));
200                 if (!data || !temp_argv) {
201                     perror("malloc() failed");
202                     break;
203                 }
204                 memcpy(temp_argv, argv, argc*sizeof(*temp_argv));
205                 data->argv = temp_argv;
206                 data->argc = argc;
207                 data->client = client;
208                 data->user = user;
209                 data->chan = chan;
210                 data->sent_chan = sent_chan;
211                 data->message = message;
212                 data->cbind = cbind;
213                 data->textclient = tmp_text_client;
214                 get_userauth(user, command_checked_auth, data);
215                 return;
216             } else
217                 handle_command_async(client, user, chan, sent_chan, cbind, argv, argc);
218             break;
219         }
220     }
221     free(message);
222 }
223
224 static void handle_command_async(struct ClientSocket *client, struct UserNode *user, struct ChanNode *chan, struct ChanNode *sent_chan, struct cmd_binding *cbind, char **argv, int argc) {
225     MYSQL_RES *res;
226     MYSQL_ROW row;
227     int uaccess;
228     int eventflags = (cbind->func->flags & (CMDFLAG_LOG | CMDFLAG_OPLOG));
229     if((cbind->func->flags & CMDFLAG_REQUIRE_AUTH) && !(user->flags & USERFLAG_ISAUTHED)) {
230         reply(tmp_text_client, user, "MODCMD_AUTH_REQUIRED");
231         return;
232     }
233     if(sent_chan && sent_chan != chan) {
234         //check pubcmd of this channel
235         printf_mysql_query("SELECT `channel_pubcmd` FROM `channels` WHERE `channel_name` = '%s'", escape_string(sent_chan->name));
236         res = mysql_use();
237         if ((row = mysql_fetch_row(res)) != NULL) {
238             uaccess = getChannelAccess(user, sent_chan, 1);
239             if(row[0] && uaccess < atoi(row[0])) { //NOTE: HARDCODED DEFAULT: pubcmd = 0
240                 reply(tmp_text_client, user, "MODCMD_PUBCMD", sent_chan->name);
241                 return;
242             }
243         }
244     }
245     int global_access = ((cbind->flags & CMDFLAG_OVERRIDE_GLOBAL_ACCESS) ? cbind->global_access : cbind->func->global_access);
246     if(global_access > 0) {
247         int user_global_access = 0;
248         printf_mysql_query("SELECT `user_access` FROM `users` WHERE `user_user` = '%s'", escape_string(user->auth));
249         res = mysql_use();
250         if ((row = mysql_fetch_row(res)) != NULL) {
251             user_global_access = atoi(row[0]);
252         }
253         if(user_global_access < global_access) {
254             if(!user_global_access)
255                 reply(tmp_text_client, user, "MODCMD_PRIVILEGED", cbind->cmd);
256             else
257                 reply(tmp_text_client, user, "MODCMD_ACCESS_DENIED");
258             return;
259         }
260     }
261     if((cbind->func->flags & CMDFLAG_REGISTERED_CHAN)) {
262         MYSQL_ROW defaults = NULL;
263         char access_list[256];
264         int access_pos = 0;
265         int access_count = 0;
266         int minaccess = 0;
267         char *str_a, *str_b = cbind->func->channel_access, *str_c;
268         if(cbind->flags & CMDFLAG_OVERRIDE_CHANNEL_ACCESS)
269             str_b = cbind->channel_access;
270         access_list[0] = '\0';
271         if(str_b) {
272             str_c = strdup(str_b);
273             str_b = str_c;
274             while((str_a = str_b)) {
275                 str_b = strstr(str_a, ",");
276                 if(str_b) {
277                     *str_b = '\0';
278                     str_b++;
279                 }
280                 if(*str_a == '#') {
281                     str_a++;
282                     access_pos += sprintf(access_list+access_pos, ", `%s`", str_a);
283                     access_count++;
284                 } else {
285                     if(atoi(str_a) > minaccess)
286                         minaccess = atoi(str_a);
287                 }
288             }
289             free(str_c);
290         }
291         if(!(chan->flags & CHANFLAG_REQUESTED_CHANINFO) || (sent_chan && sent_chan == chan) || access_count || minaccess) {
292             printf_mysql_query("SELECT `channel_id`, `channel_pubcmd` %s FROM `channels` WHERE `channel_name` = '%s'", access_list, escape_string(chan->name));
293             res = mysql_use();
294             if ((row = mysql_fetch_row(res)) != NULL) {
295                 chan->flags |= CHANFLAG_CHAN_REGISTERED;
296                 chan->channel_id = atoi(row[0]);
297                 if((sent_chan && sent_chan == chan) || access_count || minaccess) {
298                     uaccess = getChannelAccess(user, chan, 0);
299                     if(uaccess < minaccess && isGodMode(user)) {
300                         eventflags |= CMDFLAG_OPLOG;
301                     } else if(uaccess < minaccess) {
302                         //ACCESS DENIED
303                         reply(tmp_text_client, user, "MODCMD_ACCESS_DENIED");
304                         return;
305                     }
306                     if(!row[1] && !defaults) {
307                         printf_mysql_query("SELECT `channel_id`, `channel_pubcmd` %s FROM `channels` WHERE `channel_name` = 'defaults'", access_list);
308                         defaults = mysql_fetch_row(mysql_use());
309                     }
310                     if(sent_chan && (sent_chan == chan) && uaccess < (row[1] ? atoi(row[1]) : atoi(defaults[1]))) {
311                         if(isGodMode(user)) {
312                             eventflags |= CMDFLAG_OPLOG;
313                         } else {
314                             //PUBCMD
315                             reply(tmp_text_client, user, "MODCMD_PUBCMD", chan->name);
316                             return;
317                         }
318                     }
319                     int i;
320                     for(i = 0; i < access_count; i++) {
321                         if(!row[2+i] && !defaults) {
322                             printf_mysql_query("SELECT `channel_id`, `channel_pubcmd` %s FROM `channels` WHERE `channel_name` = 'defaults'", access_list);
323                             defaults = mysql_fetch_row(mysql_use());
324                         }
325                         if(uaccess < (row[2+i] ? atoi(row[2+i]) : atoi(defaults[2+i]))) {
326                             if(isGodMode(user)) {
327                                 eventflags |= CMDFLAG_OPLOG;
328                             } else {
329                                 reply(tmp_text_client, user, "MODCMD_ACCESS_DENIED");
330                                 return;
331                             }
332                         }
333                     }
334                 }
335             }
336             chan->flags |= CHANFLAG_REQUESTED_CHANINFO;
337         }
338         if(!(chan->flags & CHANFLAG_CHAN_REGISTERED)) {
339             reply(tmp_text_client, user, "MODCMD_CHAN_REQUIRED");
340             return;
341         }
342         printf_mysql_query("SELECT `botid` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '%d'", chan->channel_id, client->botid);
343         res = mysql_use();
344         if ((row = mysql_fetch_row(res)) == NULL) {
345             reply(tmp_text_client, user, "MODCMD_CHAN_REQUIRED");
346             return;
347         }
348     }
349     if((cbind->func->flags & CMDFLAG_REQUIRE_GOD) && !isGodMode(user)) {
350         reply(tmp_text_client, user, "MODCMD_PRIVILEGED", cbind->cmd);
351         return;
352     }
353     struct Event *event = createEvent(client, user, chan, cbind->func->name, argv, argc, eventflags);
354     cbind->func->func(client, user, chan, argv, argc, event);
355 }
356
357 static void got_chanmsg(struct UserNode *user, struct ChanNode *chan, char *message) {
358     fd_set fds;
359     char *trigger;
360     struct ClientSocket *client;
361     FD_ZERO(&fds);
362     for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
363         if(isUserOnChan(client->user, chan) && (client->flags & SOCKET_FLAG_PREFERRED) && !FD_ISSET(client->botid, &fds)) {
364             FD_SET(client->botid, &fds);
365             trigger = get_channel_trigger(client->botid, chan);
366             if(stricmplen(message, trigger, strlen(trigger)) == 0) {
367                 handle_command(client, user, chan, message + strlen(trigger));
368             }
369         }
370     }
371     for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
372         if(isUserOnChan(client->user, chan) && !FD_ISSET(client->botid, &fds)) {
373             FD_SET(client->botid, &fds);
374             trigger = get_channel_trigger(client->botid, chan);
375             if(stricmplen(message, trigger, strlen(trigger)) == 0) {
376                 handle_command(client, user, chan, message + strlen(trigger));
377             }
378         }
379     }
380 }
381
382 static void got_privmsg(struct UserNode *user, struct UserNode *target, char *message) {
383     struct ClientSocket *client;
384     for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
385         if(client->user == target) {
386             handle_command(client, user, NULL, message);
387         }
388     }
389 }
390
391 int register_command(int botid, char *name, cmd_bind_t *func, int paramcount, unsigned int flags, char *channel_access, int global_access) {
392     struct cmd_function *cmdfunc;
393     for(cmdfunc = cmd_functions; cmdfunc; cmdfunc = cmdfunc->next) {
394         if(cmdfunc->botid == botid && strcmp(cmdfunc->name, name) == 0)
395             return 0;
396     }
397     cmdfunc = malloc(sizeof(*cmdfunc));
398     if (!cmdfunc) {
399         perror("malloc() failed");
400         return 0;
401     }
402     cmdfunc->botid = botid;
403     cmdfunc->name = strdup(name);
404     cmdfunc->func = func;
405     cmdfunc->flags = flags;
406     cmdfunc->paramcount = paramcount;
407     cmdfunc->channel_access = channel_access;
408     cmdfunc->global_access = global_access;
409     cmdfunc->next = cmd_functions;
410     cmd_functions = cmdfunc;
411     return 1;
412 }
413
414 int set_trigger_callback(int botid, trigger_callback_t *func) {
415     static struct trigger_callback *cb = NULL;
416     for(cb = trigger_callbacks; cb; cb = cb->next) {
417         if(cb->botid == botid)
418             break;
419     }
420     if(!cb) {
421         cb = malloc(sizeof(*cb));
422         if (!cb) {
423             perror("malloc() failed");
424             return 0;
425         }
426         cb->botid = botid;
427         cb->next = trigger_callbacks;
428         trigger_callbacks = cb;
429     }
430     cb->func = func;
431     return 1;
432 }
433
434 int changeChannelTrigger(int botid, struct ChanNode *chan, char *new_trigger) {
435     struct trigger_cache *trigger;
436     for(trigger = chan->trigger; trigger; trigger = trigger->next) {
437         if(trigger->botid == botid) {
438             free(trigger->trigger);
439             trigger->trigger = strdup(new_trigger);
440             return 1;
441         }
442     }
443     return 0;
444 }
445
446 int bind_cmd_to_function(int botid, char *cmd, struct cmd_function *func) {
447     int bind_index = get_binds_index(cmd[0]);
448     struct cmd_binding *cbind;
449     for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
450         if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0)
451             return 0;
452     }
453     cbind = malloc(sizeof(*cbind));
454     if (!cbind) {
455         perror("malloc() failed");
456         return 0;
457     }
458     cbind->botid = botid;
459     cbind->cmd = strdup(cmd);
460     cbind->func = func;
461     cbind->parameters = NULL;
462     cbind->global_access = 0;
463     cbind->channel_access = NULL;
464     cbind->flags = 0;
465     cbind->next = cmd_binds[bind_index];
466     cmd_binds[bind_index] = cbind;
467     return 1;
468 }
469
470 int bind_cmd_to_command(int botid, char *cmd, char *func) {
471     struct cmd_function *cmdfunc;
472     for(cmdfunc = cmd_functions; cmdfunc; cmdfunc = cmdfunc->next) {
473         if(cmdfunc->botid == botid && strcmp(cmdfunc->name, func) == 0)
474             break;
475     }
476     if(!cmdfunc) return 0;
477     int bind_index = get_binds_index(cmd[0]);
478     struct cmd_binding *cbind;
479     for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
480         if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0)
481             return 0;
482     }
483     cbind = malloc(sizeof(*cbind));
484     if (!cbind) {
485         perror("malloc() failed");
486         return 0;
487     }
488     cbind->botid = botid;
489     cbind->cmd = strdup(cmd);
490     cbind->func = cmdfunc;
491     cbind->next = cmd_binds[bind_index];
492     cbind->parameters = NULL;
493     cbind->global_access = 0;
494     cbind->channel_access = NULL;
495     cbind->flags = 0;
496     cmd_binds[bind_index] = cbind;
497     return 1;
498 }
499
500 int unbind_cmd(int botid, char *cmd) {
501     int bind_index = get_binds_index(cmd[0]);
502     struct cmd_binding *cbind, *last = NULL;
503     for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
504         if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0) {
505             if(last)
506                 last->next = cbind->next;
507             else
508                 cmd_binds[bind_index] = cbind->next;
509             free(cbind->cmd);
510             if(cbind->parameters)
511                 free(cbind->parameters);
512             free(cbind);
513             return 1;
514         } else
515             last = cbind;
516     }
517     return 0;
518 }
519
520 struct ClientSocket *getTextBot() {
521     return tmp_text_client;
522 }
523
524 void init_modcmd() {
525     cmd_binds = calloc(27, sizeof(*cmd_binds));
526     bind_chanmsg(got_chanmsg);
527     bind_privmsg(got_privmsg);
528     register_default_language_table(msgtab);
529 }
530
531 void free_modcmd() {
532     int i;
533     for(i = 0; i < 27; i++) {
534         struct cmd_binding *cbind, *next;
535         for(cbind = cmd_binds[i]; cbind; cbind = next) {
536             next = cbind->next;
537             free(cbind->cmd);
538             if(cbind->parameters)
539                 free(cbind->parameters);
540             if(cbind->channel_access)
541                 free(cbind->channel_access);
542             free(cbind);
543         }
544     }
545     free(cmd_binds);
546     struct cmd_function *cmdfunct, *next;
547     for(cmdfunct = cmd_functions; cmdfunct; cmdfunct = next) {
548         next = cmdfunct->next;
549         free(cmdfunct->name);
550         free(cmdfunct);
551     }
552     struct trigger_callback *cb, *next_cb;
553     for(cb = trigger_callbacks; cb; cb = next_cb) {
554         next_cb = cb->next;
555         free(next_cb);
556     }
557     cmd_functions = NULL;
558     trigger_callbacks = NULL;
559 }
560
561 void bind_set_parameters(int botid, char *cmd, char *parameters) {
562     int bind_index = get_binds_index(cmd[0]);
563     struct cmd_binding *cbind;
564     for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
565         if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0) {
566             if(cbind->parameters)
567                 free(cbind->parameters);
568             cbind->parameters = strdup(parameters);
569             return;
570         }
571     }
572 }
573
574 void bind_set_global_access(int botid, char *cmd, int gaccess) {
575     int bind_index = get_binds_index(cmd[0]);
576     struct cmd_binding *cbind;
577     for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
578         if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0) {
579             if(gaccess > -1) {
580                 cbind->global_access = gaccess;
581                 cbind->flags |= CMDFLAG_OVERRIDE_GLOBAL_ACCESS;
582             } else {
583                 cbind->flags &= ~CMDFLAG_OVERRIDE_GLOBAL_ACCESS;
584             }
585             return;
586         }
587     }
588 }
589
590 void bind_set_channel_access(int botid, char *cmd, char *chanaccess) {
591     int bind_index = get_binds_index(cmd[0]);
592     struct cmd_binding *cbind;
593     for(cbind = cmd_binds[bind_index]; cbind; cbind = cbind->next) {
594         if(cbind->botid == botid && strcmp(cbind->cmd, cmd) == 0) {
595             if(cbind->channel_access)
596                 free(cbind->channel_access);
597             if(chanaccess) {
598                 cbind->channel_access = strdup(chanaccess);
599                 cbind->flags |= CMDFLAG_OVERRIDE_CHANNEL_ACCESS;
600             } else {
601                 cbind->channel_access = NULL;
602                 cbind->flags &= ~CMDFLAG_OVERRIDE_CHANNEL_ACCESS;
603             }
604             return;
605         }
606     }
607 }