issue #5354
[asterisk/asterisk.git] / pbx / pbx_ael.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18
19 /*! \file
20  *
21  * \brief Compile symbolic Asterisk Extension Logic into Asterisk extensions
22  * 
23  */
24
25 #include <sys/types.h>
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <string.h>
29 #include <ctype.h>
30 #include <errno.h>
31
32 #include "asterisk.h"
33
34 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
35
36 #include "asterisk/pbx.h"
37 #include "asterisk/config.h"
38 #include "asterisk/module.h"
39 #include "asterisk/logger.h"
40 #include "asterisk/cli.h"
41 #include "asterisk/callerid.h"
42
43 struct stringlink {
44         struct stringlink *next;
45         char data[0];
46 };
47
48 #define FILLIN_BREAK            1
49 #define FILLIN_CONTINUE         2
50
51 struct fillin {
52         struct fillin *next;
53         char exten[AST_MAX_EXTENSION];
54         int priority;
55         int type;
56 };
57
58 #ifdef __AST_DEBUG_MALLOC
59 static void FREE(void *ptr)
60 {
61         free(ptr);
62 }
63 #else
64 #define FREE free
65 #endif
66
67 #define DEBUG_READ   (1 << 0)
68 #define DEBUG_TOKENS (1 << 1)
69 #define DEBUG_MACROS (1 << 2)
70 #define DEBUG_CONTEXTS (1 << 3)
71
72 static int aeldebug = 0;
73
74 static char *dtext = "Asterisk Extension Language Compiler";
75 static char *config = "extensions.ael";
76 static char *registrar = "pbx_ael";
77
78 static char *__grab_token(char *src, const char *filename, int lineno, int link)
79 {
80         char *c;
81         char *b;
82         char *a;
83         int level = 0;
84         char *ret;
85 #if 0
86         if (aeldebug || DEBUG_TOKENS) 
87                 ast_verbose("Searching for token in '%s'!\n", src);
88 #endif
89         c = src;
90         while(*c) {
91                 if ((*c == '\\')) {
92                         c++;
93                         if (!*c)
94                                 c--;
95                 } else {
96                         if ((*c == '{') || (*c == '(')) {
97                                 level++;
98                         } else if ((*c == '}') || (*c == ')')) {
99                                 if (level)
100                                         level--;
101                                 else
102                                         ast_log(LOG_WARNING, "Syntax error at line %d of '%s', too many closing braces!\n", lineno, filename);
103                         } else if ((*c == ';') && !level) {
104                                 /* Got a token! */
105                                 *c = '\0';
106                                 b = c;
107                                 b--;
108                                 c++;
109                                 while((b > src) && (*b < 33)) { 
110                                         *b = '\0'; 
111                                         b--; 
112                                 }
113                                 a = ast_skip_blanks(src);
114                                 if (link) {
115                                         ret = malloc(strlen(a) + sizeof(struct stringlink) + 1);
116                                         if (ret)
117                                                 strcpy(ret + sizeof(struct stringlink), a);
118                                 } else
119                                         ret = strdup(a);
120                                 /* Save remainder */
121                                 memmove(src, c, strlen(c) + 1);
122                                 return ret;
123                         }
124                 }
125                 c++;
126         }
127         return NULL;            
128 }
129
130 static char *grab_token(char *src, const char *filename, int lineno)
131 {
132         return __grab_token(src, filename, lineno, 0);
133 }
134
135 static struct stringlink *arg_parse(char *args, const char *filename, int lineno)
136 {
137         struct stringlink *cur, *prev=NULL, *root=NULL;
138         if (args) {
139                 if (aeldebug & DEBUG_TOKENS) 
140                         ast_verbose("Parsing args '%s'!\n", args);
141                 if (args[0] == '{') {
142                         /* Strip mandatory '}' from end */
143                         args[strlen(args) - 1] = '\0';
144                         while ((cur = (struct stringlink *)__grab_token(args + 1, filename, lineno, 1))) {
145                                 cur->next = NULL;
146                                 if (prev)
147                                         prev->next = cur;
148                                 else
149                                         root = cur;
150                                 prev = cur;
151                         }
152                 } else if (*args) {
153                         root = malloc(sizeof(struct stringlink) + strlen(args) + 1);
154                         if (root) {
155                                 strcpy(root->data, args);
156                                 root->next = NULL;
157                         }
158                 }
159         }
160         return root;
161 }
162
163 static char *grab_else(char *args, const char *filename, int lineno)
164 {
165         char *ret = NULL;
166         int level=0;
167         char *c;
168         if (args) {
169                 if (args[0] == '{') {
170                         c = args;
171                         while(*c) {
172                                 if (*c == '{')
173                                         level++;
174                                 else if (*c == '}') {
175                                         level--;
176                                         if (!level) {
177                                                 c++;
178                                                 while(*c && (*c < 33)) { *c = '\0'; c++; };
179                                                 if (!strncasecmp(c, "else", 4) && 
180                                                         ((c[4] == '{') || (c[4] < 33))) {
181                                                                 /* Ladies and gentlemen, we have an else clause */
182                                                         *c = '\0';
183                                                         c += 4;
184                                                         c = ast_skip_blanks(c);
185                                                         ret = c;
186                                                         if (aeldebug & DEBUG_TOKENS)
187                                                                 ast_verbose("Returning else clause '%s'\n", c);
188                                                 }
189                                                 break;
190                                         }
191                                 }
192                                 c++;
193                         }
194                 }
195         }
196         return ret;
197 }
198
199 static struct stringlink *param_parse(char *parms, const char *macro, const char *filename, int lineno)
200 {
201         char *s, *e;
202         struct stringlink *root = NULL, *prev=NULL, *cur;
203         if (!parms || !*parms)
204                 return NULL;
205         if (*parms != '(') {
206                 ast_log(LOG_NOTICE, "Syntax error in parameter list for macro '%s' at about line %d of %s: Expecting '(' but got '%c'\n", macro, lineno, filename, *parms);
207                 return NULL;
208         }
209         s = parms + 1;
210         while(*s) {
211                 s = ast_skip_blanks(s);
212                 e = s;
213                 while(*e &&  (*e != ')') && (*e != ',')) {
214                         if (*e < 33)
215                                 *e = '\0';
216                         e++;
217                 }
218                 if (*e) {
219                         /* Strip token */
220                         *e = '\0';
221                         e++;
222                         /* Skip over whitespace */
223                         e = ast_skip_blanks(e);
224                         /* Link */
225                         cur = malloc(strlen(s) + sizeof(struct stringlink) + 1);
226                         if (cur) {
227                                 cur->next = NULL;
228                                 strcpy(cur->data, s);
229                                 if (prev)
230                                         prev->next = cur;
231                                 else
232                                         root = cur;
233                                 prev = cur;
234                         }
235                         s = e;
236                 }
237         }
238         return root;
239 }
240
241 static void arg_free(struct stringlink *cur)
242 {
243         struct stringlink *last;
244         while(cur) {
245                 last = cur;
246                 cur = cur->next;
247                 free(last);
248         }
249 }
250
251 static void handle_globals(struct stringlink *vars)
252 {
253         while(vars) {
254                 pbx_builtin_setvar(NULL, vars->data);
255                 vars = vars->next;
256         }
257 }
258
259 static struct stringlink *split_token(char *token, const char *filename, int lineno)
260 {
261         char *args, *p;
262         struct stringlink *argv;
263         args = token;
264         while (*args && (*args > 32) && (*args != '{') && (*args != '(')) args++;
265         if (*args) {
266                 p = args;
267                 args = ast_skip_blanks(args);
268                 if (*args != '(') {
269                         *p = '\0';
270                 } else {
271                         while (*args && (*args != ')')) args++;
272                         if (*args == ')') {
273                                 args++;
274                                 args = ast_skip_blanks(args);
275                         }
276                 }
277                 if (!*args)
278                         args = NULL;
279         } else args = NULL;
280         argv = arg_parse(args, filename, lineno);
281         if (args)
282                 *args = '\0';
283         return argv;
284 }
285
286 static int matches_keyword(const char *data, const char *keyword)
287 {
288         char c;
289         if (!strncasecmp(data, keyword, strlen(keyword))) {
290                 c = data[strlen(keyword)];
291                 if ((c < 33) || (c == '(') || (c == '{'))
292                         return 1;
293         }
294         return 0;
295 }
296
297 static struct stringlink *split_params(char *token, const char *filename, int lineno)
298 {
299         char *params;
300         struct stringlink *paramv;
301         params = token;
302         while(*params && (*params > 32) && (*params != '(')) params++;
303         if (*params) {
304                 if (*params != '(') {
305                         *params = '\0';
306                         params++;
307                         params = ast_skip_blanks(params);
308                 }
309                 if (!*params)
310                         params = NULL;
311         } else params = NULL;
312         paramv = param_parse(params, token, filename, lineno);
313         if (params)
314                 *params = '\0';
315         return paramv;
316 }
317
318 static const char *get_case(char *s, char **restout, int *pattern)
319 {
320         char *newcase=NULL;
321         char *rest=NULL;
322         if (!strncasecmp(s, "case", 4) && s[4] && ((s[4] < 33) || (s[4] == ':'))) {
323                 newcase = s + 4;
324                 newcase = ast_skip_blanks(newcase);
325                 rest = newcase;
326                 *pattern = 0;
327         } else if (!strncasecmp(s, "pattern", 7) && s[7] && ((s[7] < 33) || (s[7] == ':'))) {
328                 newcase = s + 8;
329                 newcase = ast_skip_blanks(newcase);
330                 rest = newcase;
331                 *pattern = 1;
332         } else if (!strncasecmp(s, "default", 7) && ((s[7] < 33) || (s[7] == ':'))) {
333                 newcase = ".";
334                 rest = s + 7;
335                 rest = ast_skip_blanks(rest);
336                 *pattern = 1;
337         }
338
339         if (rest) {
340                 while (*rest && (*rest > 32) && (*rest != ':')) rest++;
341                 if (*rest) {
342                         *rest = 0;
343                         rest++;
344                         while (*rest && ((*rest == ':') || (*rest < 33))) rest++;
345                         *restout = rest;
346                 } else {
347                         *restout = "";
348                 }
349         } else
350                 *restout = s;
351         if (aeldebug & DEBUG_TOKENS)
352                 ast_verbose("GETCASE: newcase is '%s', rest = '%s'\n", newcase, *restout);
353         return newcase;
354 }
355
356 static void fillin_free(struct fillin *fillin)
357 {
358         struct fillin *cur, *next;
359         cur =  fillin;
360         while(cur) {
361                 next = cur->next;
362                 free(cur);
363                 cur = next;
364         }
365 }
366
367 static void fillin_process(struct ast_context *con, struct fillin *fillin, const char *filename, int lineno, const char *breakexten, int breakprio, const char *contexten, int contprio)
368 {
369         struct fillin *cur;
370         char *app;
371         char mdata[AST_MAX_EXTENSION + 20];
372         cur = fillin;
373         while(cur) {
374                 if (cur->type == FILLIN_BREAK) {
375                         if (breakexten && breakprio) {
376                                 app = "Goto";
377                                 snprintf(mdata, sizeof(mdata), "%s|%d", breakexten, breakprio);
378                         } else {
379                                 app = "NoOp";
380                                 snprintf(mdata, sizeof(mdata), "Invalid break");
381                                 ast_log(LOG_NOTICE, "Ignoring inappropriate break around line %d of %s\n", lineno, filename);
382                         }
383                         if (ast_add_extension2(con, 0, cur->exten, cur->priority, NULL, NULL, app, strdup(mdata), FREE, registrar))
384                                 ast_log(LOG_WARNING, "Unable to add step at priority '%d' of break '%s'\n", cur->priority, cur->exten);
385                 } else if (cur->type == FILLIN_CONTINUE) {
386                         if (contexten && contprio) {
387                                 app = "Goto";
388                                 snprintf(mdata, sizeof(mdata), "%s|%d", contexten, contprio);
389                         } else {
390                                 app = "NoOp";
391                                 snprintf(mdata, sizeof(mdata), "Invalid continue");
392                                 ast_log(LOG_NOTICE, "Ignoring inappropriate continue around line %d of %s\n", lineno, filename);
393                         }
394                         if (ast_add_extension2(con, 0, cur->exten, cur->priority, NULL, NULL, app, strdup(mdata), FREE, registrar))
395                                 ast_log(LOG_WARNING, "Unable to add step at priority '%d' of continue '%s'\n", cur->priority, cur->exten);
396                 } else {
397                         ast_log(LOG_WARNING, "Whoa, unknown fillin type '%d'\n", cur->type);
398                 }
399                 cur = cur->next;
400         }
401 }
402
403 static int match_assignment(char *variable, char **value)
404 {
405         char *c;
406         char *ws;
407         int inpar = 0;
408         c = variable;
409         
410         while (*c && (*c > 32)) {
411                 if(*c == ')' && (inpar > 0)) {
412                         inpar--;
413                 } else if(*c == '(' && (inpar >= 0)) {
414                         inpar++;
415                 } else if(*c == '=' && (inpar == 0)) {
416                         break;
417                 }
418                 c++;
419         } 
420         ws = c;
421         c = ast_skip_blanks(c);
422         if (*c == '=') {
423                 *ws = '\0';
424                 *c = '\0';
425                 c++;
426                 c = ast_skip_blanks(c);
427                 *value = c;
428                 return 1;
429         }
430         return 0;
431 }
432
433 static int matches_label(char *data, char **rest)
434 {
435         char last = 0;
436         char *start = data;
437         while (*data > 32) {
438                 last = *data;
439                 data++;
440         }
441         if (last != ':') {
442                 data = ast_skip_blanks(data);
443                 last = *data;
444                 data++;
445         }
446         if (last == ':') {
447                 *rest = data;
448                 /* Go back and trim up the label */
449                 while(*start && ((*start > 32) && (*start != ':'))) start++;
450                 *start = '\0';
451                 return 1;
452         }
453         return 0;
454 }
455
456 static char *argument_end(char *str)
457 {
458         int level=0;
459         while(*++str) {
460                 switch(*str) {
461                 case '(':
462                         level++;
463                         break;
464                 case ')':
465                         if(level)
466                                 level--;
467                         else
468                                 return str;
469                         break;
470                 default:
471                         break;
472                 }
473         }
474         return NULL;
475 }
476
477 static int build_step(const char *what, const char *name, const char *filename, int lineno, struct ast_context *con, char *exten, int *pos, char *data, struct fillin **fillout, char **label);
478 static int __build_step(const char *what, const char *name, const char *filename, int lineno, struct ast_context *con, char *exten, int *pos, char *data, struct fillin **fillout, char **label)
479 {
480         char *app;
481         char *args;
482         char *c;
483         char *margs=NULL;
484         char *oargs;
485         char *rest;
486         const char *curcase, *newcase;
487         struct stringlink *swargs, *cur;
488         int cpos;
489         int mlen;
490         int pattern = 0;
491         struct fillin *fillin;
492         
493         data = ast_skip_blanks(data);
494         if (matches_label(data, &c)) {
495                 *label = data;
496                 data = c;
497                 data = ast_skip_blanks(data);
498         }
499         if (ast_strlen_zero(data))
500                 return 0;
501         if (matches_keyword(data, "switch")) {
502                 fillin = NULL;
503                 /* Switch */
504                 args = data + strlen("switch");
505                 while ((*args < 33) && (*args != '(')) args++;
506                 if ((*args == '(') && (c = argument_end(args))) {
507                         args++;
508                         *c = '\0';
509                         c++;
510                         if (aeldebug & DEBUG_TOKENS)
511                                 ast_verbose("--SWITCH on : %s\n", args);
512                         mlen = strlen(exten) + 128 + strlen(args) + strlen(name);
513                         margs = alloca(mlen);
514                         app = "Goto";
515                         sprintf(margs, "sw-%d-%s|1", *pos, args);
516                         ast_process_quotes_and_slashes(margs, ',', '|');
517                         oargs = args;
518                         args = margs;
519                         if (ast_add_extension2(con, 0, exten, *pos, *label, NULL, app, strdup(args), FREE, registrar))
520                                 ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
521                         else {
522                                 *label = NULL;
523                                 (*pos)++;
524                         }
525                         app = "NoOp";
526                         sprintf(margs, "Finish switch-%d", *pos - 1);
527                         if (ast_add_extension2(con, 0, exten, *pos, *label, NULL, app, strdup(args), FREE, registrar))
528                                 ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
529                         else {
530                                 *label = NULL;
531                                 (*pos)++;
532                         }
533                         c = ast_skip_blanks(c);
534                         if (aeldebug & DEBUG_TOKENS)
535                                 ast_verbose("ARG Parsing '%s'\n", c);
536                         swargs = arg_parse(c, filename, lineno);
537                         cur = swargs;
538                         curcase = NULL;
539                         while(cur) {
540                                 if ((newcase = get_case(cur->data, &rest, &pattern))) {
541                                         if (aeldebug & DEBUG_TOKENS)
542                                                 ast_verbose("--NEWCASE: '%s'!\n", newcase);
543                                         if (curcase) {
544                                                 /* Handle fall through */
545                                                 char tmp[strlen(newcase) + strlen(name) + 40];
546                                                 sprintf(tmp, "sw-%d-%s|%d", *pos - 2, newcase, 1);
547                                                 ast_add_extension2(con, 0, margs, cpos, NULL, NULL, "Goto", strdup(tmp), FREE, registrar);
548                                         }
549                                         curcase = newcase;
550                                         cpos = 1;
551                                         if (pattern)
552                                                 snprintf(margs, mlen, "_sw-%d-%s", *pos - 2, curcase);
553                                         else
554                                                 snprintf(margs, mlen, "sw-%d-%s", *pos - 2, curcase);
555                                         if (!strcasecmp(rest, "break")) {
556                                                 char tmp[strlen(exten) + 10];
557                                                 sprintf(tmp, "%s|%d", exten, *pos - 1);
558                                                 ast_add_extension2(con, 0, exten, cpos, *label, NULL, "Goto", strdup(tmp), FREE, registrar);
559                                                 curcase = NULL;
560                                                 *label = NULL;
561                                         } else
562                                                 build_step("switch", margs, filename, lineno, con, margs, &cpos, rest, &fillin, label);
563                                 } else if (curcase) {
564                                         if (aeldebug & DEBUG_TOKENS)
565                                                 ast_verbose("Building statement from '%s'\n", rest);
566                                         if (!strcasecmp(rest, "break")) {
567                                                 char tmp[strlen(exten) + 10];
568                                                 sprintf(tmp, "%s|%d", exten, *pos - 1);
569                                                 ast_add_extension2(con, 0, margs, cpos, *label, NULL, "Goto", strdup(tmp), FREE, registrar);
570                                                 curcase = NULL;
571                                                 *label = NULL;
572                                         } else
573                                                 build_step("switch", margs, filename, lineno, con, margs, &cpos, rest, &fillin, label);
574                                 } else 
575                                         ast_log(LOG_WARNING, "Unreachable code in switch at about line %d of %s\n", lineno, filename);
576                                 if (aeldebug & DEBUG_TOKENS)
577                                         ast_verbose("--SWARG: %s\n", cur->data);
578                                 cur = cur->next;
579                         }
580                         /* Can't do anything with these */
581                         fillin_process(con, fillin, filename, lineno, NULL, 0, NULL, 0);
582                         fillin_free(fillin);
583                         arg_free(swargs);
584                 } else
585                         ast_log(LOG_WARNING, "Syntax error in switch declaration in %s around line %d!\n", filename, lineno); 
586                         
587         } else if (matches_keyword(data, "if")) {
588                 /* If... */
589                 args = data + strlen("if");
590                 while ((*args < 33) && (*args != '(')) args++;
591                 if ((*args == '(') && (c = argument_end(args))) {
592                         int ifblock;
593                         int ifstart;
594                         int elsestart;
595                         int ifend;
596                         int ifskip;
597                         char *elses;
598                         char *iflabel;
599                         args++;
600                         *c = '\0';
601                         c++;
602                         c = ast_skip_blanks(c);
603                         if (aeldebug & DEBUG_TOKENS)
604                                 ast_verbose("--IF on : '%s' : '%s'\n", args, c);
605                         mlen = strlen(exten) + 128 + strlen(args) + strlen(name);
606                         margs = alloca(mlen);
607                         /* Remember where the ifblock starts, and skip over */
608                         ifblock = (*pos)++;
609                         iflabel = *label;
610                         *label = NULL;
611                         /* Remember where the start of the ifblock is */
612                         ifstart = *pos;
613                         snprintf(margs, mlen, "if-%s-%d", name, ifblock);
614                         /* Now process the block of the if */
615                         if (aeldebug & DEBUG_TOKENS)
616                                 ast_verbose("Searching for elses in '%s'\n", c);
617                         elses = grab_else(c, filename, lineno);
618                         build_step("if", margs, filename, lineno, con, exten, pos, c, fillout, label);
619                         if (elses) {
620                                 /* Reserve a goto to exit the if */
621                                 ifskip = *pos;
622                                 (*pos)++;
623                                 elsestart = *pos;
624                                 build_step("else", margs, filename, lineno, con, exten, pos, elses, fillout, label);
625                         } else {
626                                 elsestart = *pos;
627                                 ifskip = 0;
628                         }
629                         ifend = *pos;
630                         (*pos)++;
631                         app = "NoOp";
632                         snprintf(margs, mlen, "Finish if-%s-%d", name, ifblock);
633                         if (ast_add_extension2(con, 0, exten, ifend, *label, NULL, app, strdup(margs), FREE, registrar))
634                                 ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
635                         *label = NULL;
636                         app = "GotoIf";
637                         snprintf(margs, mlen, "$[ %s ]?%d:%d", args, ifstart, elsestart);
638                         if (ast_add_extension2(con, 0, exten, ifblock, iflabel, NULL, app, strdup(margs), FREE, registrar))
639                                 ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
640                         if (ifskip) {
641                                 /* Skip as appropriate around else clause */
642                                 snprintf(margs, mlen, "%d", ifend);
643                                 if (ast_add_extension2(con, 0, exten, ifskip, NULL, NULL, "Goto", strdup(margs), FREE, registrar))
644                                         ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
645                         }
646                 } else
647                         ast_log(LOG_WARNING, "Syntax error in if declaration in %s around line %d!\n", filename, lineno); 
648         } else if (matches_keyword(data, "while")) {
649                 /* While... */
650                 fillin = NULL;
651                 args = data + strlen("while");
652                 while ((*args < 33) && (*args != '(')) args++;
653                 if ((*args == '(') && (c = argument_end(args))) {
654                         int whileblock;
655                         int whilestart;
656                         int whileend;
657                         char *whilelabel;
658                         args++;
659                         *c = '\0';
660                         c++;
661                         c = ast_skip_blanks(c);
662                         if (aeldebug & DEBUG_TOKENS)
663                                 ast_verbose("--WHILE on : '%s' : '%s'\n", args, c);
664                         mlen = strlen(exten) + 128 + strlen(args) + strlen(name);
665                         margs = alloca(mlen);
666                         /* Remember where to put the conditional, and keep its position */
667                         whilestart = (*pos);
668                         whilelabel = *label;
669                         *label = NULL;
670                         (*pos)++;
671                         /* Remember where the whileblock starts */
672                         whileblock = (*pos);
673                         snprintf(margs, mlen, "while-%s-%d", name, whilestart);
674                         build_step("while", margs, filename, lineno, con, exten, pos, c, &fillin, label);
675                         /* Close the loop */
676                         app = "Goto";
677                         snprintf(margs, mlen, "%d", whilestart);
678                         if (ast_add_extension2(con, 0, exten, (*pos)++, *label, NULL, app, strdup(margs), FREE, registrar))
679                                 ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
680                         *label = NULL;
681                         whileend = (*pos);
682                         /* Place trailer */
683                         app = "NoOp";
684                         snprintf(margs, mlen, "Finish while-%s-%d", name, whilestart);
685                         if (ast_add_extension2(con, 0, exten, (*pos)++, *label, NULL, app, strdup(margs), FREE, registrar))
686                                 ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
687                         *label = NULL;
688                         app = "GotoIf";
689                         snprintf(margs, mlen, "$[ %s ]?%d:%d", args, whileblock, whileend);
690                         if (ast_add_extension2(con, 0, exten, whilestart, whilelabel, NULL, app, strdup(margs), FREE, registrar))
691                                 ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
692                         fillin_process(con, fillin, filename, lineno, exten, whileend, exten, whilestart);
693                         fillin_free(fillin);
694                 } else
695                         ast_log(LOG_WARNING, "Syntax error in while declaration in %s around line %d!\n", filename, lineno); 
696         } else if (matches_keyword(data, "jump")) {
697                 char *p;
698                 /* Jump... */
699                 fillin = NULL;
700                 args = data + strlen("jump");
701                 args = ast_skip_blanks(args);
702                 if (aeldebug & DEBUG_TOKENS)
703                         ast_verbose("--JUMP to : '%s'\n", args);
704                 p = strchr(args, ',');
705                 if (p) {
706                         *p = '\0';
707                         p++;
708                 } else
709                         p = "1";
710                 c = strchr(args, '@');
711                 if (c) {
712                         *c = '\0';
713                         c++;
714                 }
715                 mlen = strlen(exten) + 128 + strlen(args) + strlen(name) + (c ? strlen(c) : 0);
716                 margs = alloca(mlen);
717                 if (c) 
718                         snprintf(margs, mlen, "%s|%s|%s", c,args, p);
719                 else
720                         snprintf(margs, mlen, "%s|%s", args, p);
721                 app = "Goto";
722                 if (ast_add_extension2(con, 0, exten, (*pos)++, *label, NULL, app, strdup(margs), FREE, registrar))
723                         ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
724                 *label = NULL;
725         } else if (matches_keyword(data, "goto")) {
726                 /* Jump... */
727                 fillin = NULL;
728                 args = data + strlen("goto");
729                 args = ast_skip_blanks(args);
730                 if (aeldebug & DEBUG_TOKENS)
731                         ast_verbose("--GOTO to : '%s'\n", args);
732                 app = "Goto";
733                 if (ast_add_extension2(con, 0, exten, (*pos)++, *label, NULL, app, strdup(args), FREE, registrar))
734                         ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
735                 *label = NULL;
736         } else if (matches_keyword(data, "for")) {
737                 /* While... */
738                 fillin = NULL;
739                 args = data + strlen("for");
740                 while ((*args < 33) && (*args != '(')) args++;
741                 if ((*args == '(') && (c = argument_end(args))) {
742                         int forblock;
743                         int forprep;
744                         int forstart;
745                         int forend;
746                         struct stringlink *fields;
747                         char *tmp;
748                         char *forlabel = NULL;
749                         args++;
750                         *c = '\0';
751                         c++;
752                         c = ast_skip_blanks(c);
753                         /* Parse arguments first */
754                         tmp = alloca(strlen(args) + 10);
755                         if (tmp) {
756                                 snprintf(tmp, strlen(args) + 10, "{%s;}", args);
757                                 fields = arg_parse(tmp, filename, lineno);
758                         } else
759                                 fields = NULL;
760                         if (fields && fields->next && fields->next->next) {
761                                 if (aeldebug & DEBUG_TOKENS)
762                                         ast_verbose("--FOR ('%s' ; '%s' ; '%s') : '%s'\n", fields->data, fields->next->data, fields->next->next->data, c);
763                                 mlen = strlen(exten) + 128 + strlen(args) + strlen(name);
764                                 margs = alloca(mlen);
765                                 forprep = *pos;
766                                 snprintf(margs, mlen, "for-%s-%d", name, forprep);
767                                 fillin = NULL;
768                                 build_step("while", margs, filename, lineno, con, exten, pos, fields->data, &fillin, label);
769                                 /* Remember where to put the conditional, and keep its position */
770                                 forstart = (*pos);
771                                 forlabel = *label;
772                                 (*pos)++;
773                                 *label = NULL;
774                                 /* Remember where the whileblock starts */
775                                 forblock = (*pos);
776                                 build_step("for", margs, filename, lineno, con, exten, pos, fields->next->next->data, &fillin, label);
777                                 build_step("for", margs, filename, lineno, con, exten, pos, c, &fillin, label);
778                                 /* Close the loop */
779                                 app = "Goto";
780                                 snprintf(margs, mlen, "%d", forstart);
781                                 if (ast_add_extension2(con, 0, exten, (*pos)++, *label, NULL, app, strdup(margs), FREE, registrar))
782                                         ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
783                                 *label = NULL;
784                                 forend = (*pos);
785                                 /* Place trailer */
786                                 app = "NoOp";
787                                 snprintf(margs, mlen, "Finish for-%s-%d", name, forprep);
788                                 if (ast_add_extension2(con, 0, exten, (*pos)++, *label, NULL, app, strdup(margs), FREE, registrar))
789                                         ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
790                                 *label = NULL;
791                                 app = "GotoIf";
792                                 snprintf(margs, mlen, "$[ %s ]?%d:%d", fields->next->data, forblock, forend);
793                                 if (ast_add_extension2(con, 0, exten, forstart, forlabel, NULL, app, strdup(margs), FREE, registrar))
794                                         ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", forstart, what, name);
795                                 fillin_process(con, fillin, filename, lineno, exten, forend, exten, forstart);
796                                 fillin_free(fillin);
797                         } else
798                                 ast_log(LOG_NOTICE, "Improper for declaration in %s around line %d!\n", filename, lineno); 
799                         arg_free(fields);
800                 } else
801                         ast_log(LOG_WARNING, "Syntax error in for declaration in %s around line %d!\n", filename, lineno); 
802                         
803         } else if (!strcasecmp(data, "break") || !strcasecmp(data, "continue")) {
804                 struct fillin *fi;
805                 fi = malloc(sizeof(struct fillin));
806                 if (fi) {
807                         memset(fi, 0, sizeof(struct fillin));
808                         if (!strcasecmp(data, "break"))
809                                 fi->type = FILLIN_BREAK;
810                         else
811                                 fi->type = FILLIN_CONTINUE;
812                         ast_copy_string(fi->exten, exten, sizeof(fi->exten));
813                         fi->priority = (*pos)++;
814                         fi->next = *fillout;
815                         *fillout = fi;
816                 }
817         } else if (match_assignment(data, &rest)) {
818                 if (aeldebug & DEBUG_TOKENS)
819                         ast_verbose("ASSIGN  '%s' = '%s'\n", data, rest);
820                 mlen = strlen(rest) + strlen(data) + 20;
821                 margs = alloca(mlen);
822                 snprintf(margs, mlen, "%s=$[ %s ]", data, rest);
823                 app = "Set";
824                 if (ast_add_extension2(con, 0, exten, *pos, *label, NULL, app, strdup(margs), FREE, registrar))
825                         ast_log(LOG_WARNING, "Unable to add assignment at priority '%d' of %s '%s'\n", *pos, what, name);
826                 else {
827                         *label = NULL;
828                         (*pos)++;
829                 }
830         } else {
831                 app = data;
832                 args = app;
833                 while (*args && (*args > 32) && (*args != '(')) args++;
834                         if (*args != '(') {
835                         while(*args && (*args != '(')) { *args = '\0'; args++; };
836                 }
837                 if (*args == '(') {
838                         *args = '\0';
839                         args++;
840                         /* Got arguments, trim trailing ')' */
841                         c = args + strlen(args) - 1;
842                         while((c >= args) && (*c < 33) && (*c != ')')) { *c = '\0'; c--; };
843                         if ((c >= args) && (*c == ')')) *c = '\0';
844                 } else
845                         args = "";
846                 ast_process_quotes_and_slashes(args, ',', '|');
847                 if (app[0] == '&') {
848                         app++;
849                         margs = alloca(strlen(args) + strlen(app) + 10);
850                         sprintf(margs, "%s|%s", app, args);
851                         args = margs;
852                         app = "Macro";
853                 }
854                 if (aeldebug & DEBUG_TOKENS)
855                         ast_verbose("-- APP: '%s', ARGS: '%s'\n", app, args);
856                 if (ast_add_extension2(con, 0, exten, *pos, *label, NULL, app, strdup(args), FREE, registrar))
857                         ast_log(LOG_WARNING, "Unable to add step at priority '%d' of %s '%s'\n", *pos, what, name);
858                 else {
859                         (*pos)++;
860                         *label = NULL;
861                 }
862         }
863         return 0;
864 }
865
866 static int build_step(const char *what, const char *name, const char *filename, int lineno, struct ast_context *con, char *exten, int *pos, char *data, struct fillin **fillout, char **label)
867 {
868         struct stringlink *args, *cur;
869         int res=0;
870         struct fillin *fillin=NULL;
871         int dropfill = 0;
872         char *labelin = NULL;
873         if (!fillout) {
874                 fillout = &fillin;
875                 dropfill = 1;
876         }
877         if (!label) {
878                 label = &labelin;
879         };
880         args = arg_parse(data, filename, lineno);
881         cur = args;
882         while(cur) {
883                 res |= __build_step(what, name, filename, lineno, con, exten, pos, cur->data, fillout, label);
884                 cur = cur->next;
885         }
886         arg_free(args);
887         if (dropfill) {
888                 fillin_process(con, fillin, filename, lineno, NULL, 0, NULL, 0);
889                 fillin_free(fillin);
890         }
891         return res;
892 }
893
894 static int parse_catch(char *data, char **catch, char **rest)
895 {
896         /* Skip the word 'catch' */
897         data += 5;
898         data = ast_skip_blanks(data);
899         /* Here's the extension */
900         *catch = data;
901         if (!*data)
902                 return 0;
903         while (*data && (*data > 32)) data++;
904         if (!*data)
905                 return 0;
906         /* Trim any trailing spaces */
907         *data = '\0';
908         data++;
909         data = ast_skip_blanks(data);
910         if (!*data)
911                 return 0;
912         *rest = data;
913         return 1;
914 }
915
916 static void handle_macro(struct ast_context **local_contexts, struct stringlink *vars, const char *filename, int lineno)
917 {
918         struct stringlink *argv;
919         struct stringlink *paramv;
920         struct stringlink *cur;
921         struct ast_context *con;
922         struct fillin *fillin;
923         char *catch, *rest;
924         char name[256];
925         int pos;
926         int cpos;
927
928         if (aeldebug & DEBUG_MACROS)
929                 ast_verbose("Root macro def is '%s'\n", vars->data);
930         argv = split_token(vars->data, filename, lineno);
931         paramv = split_params(vars->data, filename, lineno);
932         if (aeldebug & DEBUG_MACROS) 
933                 ast_verbose("Found macro '%s'\n", vars->data);
934         snprintf(name, sizeof(name), "macro-%s", vars->data);
935         con = ast_context_create(local_contexts, name, registrar);
936         if (con) {
937                 pos = 1;
938                 cur = paramv;
939                 while(cur) {
940                         if (aeldebug & DEBUG_MACROS)
941                                 ast_verbose("  PARAM => '%s'\n", cur->data);
942                         snprintf(name, sizeof(name), "%s=${ARG%d}", cur->data, pos);
943                         if (ast_add_extension2(con, 0, "s", pos, NULL, NULL, "Set", strdup(name), FREE, registrar))
944                                 ast_log(LOG_WARNING, "Unable to add step at priority '%d' of macro '%s'\n", pos, vars->data);
945                         else
946                                 pos++;
947                         cur = cur->next;
948                 }
949                 cur = argv;
950                 while(cur) {
951                         if (aeldebug & DEBUG_MACROS)
952                                 ast_verbose("  STEP => '%s'\n", cur->data);
953                         if (matches_keyword(cur->data, "catch")) {
954                                 if (aeldebug & DEBUG_MACROS)
955                                         ast_verbose("--CATCH: '%s'\n", cur->data);
956                                 if (parse_catch(cur->data, &catch, &rest)) {
957                                         cpos = 1;
958                                         build_step("catch", catch, filename, lineno, con, catch, &cpos, rest, NULL, NULL);
959                                 } else
960                                         ast_log(LOG_NOTICE, "Parse error for catch at about line %d of %s\n", lineno, filename);
961                         } else {
962                                 fillin = NULL;
963                                 build_step("macro", vars->data, filename, lineno, con, "s", &pos, cur->data, NULL, NULL);
964                         }
965                         cur = cur->next;
966                 }
967         } else
968                 ast_log(LOG_WARNING, "Unable to create context '%s'\n", name);
969         arg_free(paramv);
970         arg_free(argv);
971         if (vars->next)
972                 ast_log(LOG_NOTICE, "Ignoring excess tokens in macro definition around line %d of %s!\n", lineno, filename);
973 }
974
975 static int matches_extension(char *exten, char **extout)
976 {
977         char *c;
978         *extout = NULL;
979         c = exten;
980         while(*c && (*c > 32)) c++;
981         if (*c) {
982                 *c = '\0';
983                 c++;
984                 c = ast_skip_blanks(c);
985                 if (*c) {
986                         if (*c == '=') {
987                                 *c = '\0';
988                                 c++;
989                                 if (*c == '>')
990                                         c++;
991                                 c = ast_skip_blanks(c);
992                                 *extout = c;
993                                 return 1;
994                         }
995                 }
996         }
997         return 0;
998 }
999
1000 static void parse_keyword(char *s, char **o)
1001 {
1002         char *c;
1003         c = s;
1004         while((*c) && (*c > 32)) c++;
1005         if (*c) {
1006                 *c = '\0';
1007                 c++;
1008                 c = ast_skip_blanks(c);
1009                 *o = c;
1010         } else
1011                 *o = NULL;
1012 }
1013
1014 static void handle_context(struct ast_context **local_contexts, struct stringlink *vars, const char *filename, int lineno)
1015 {
1016         struct stringlink *argv;
1017         struct stringlink *cur2;
1018         struct stringlink *argv2;
1019         struct stringlink *cur;
1020         struct ast_context *con;
1021         char *rest;
1022         char *c;
1023         char name[256];
1024         int pos;
1025
1026         if (aeldebug & DEBUG_CONTEXTS)
1027                 ast_verbose("Root context def is '%s'\n", vars->data);
1028         argv = split_token(vars->data, filename, lineno);
1029         if (aeldebug & DEBUG_CONTEXTS) 
1030                 ast_verbose("Found context '%s'\n", vars->data);
1031         snprintf(name, sizeof(name), "%s", vars->data);
1032         con = ast_context_create(local_contexts, name, registrar);
1033         if (con) {
1034                 cur = argv;
1035                 while(cur) {
1036                         if (matches_keyword(cur->data, "includes")) {
1037                                 if (aeldebug & DEBUG_CONTEXTS)
1038                                         ast_verbose("--INCLUDES: '%s'\n", cur->data);
1039                                 parse_keyword(cur->data, &rest);
1040                                 if (rest) {
1041                                         argv2 = arg_parse(rest, filename, lineno);
1042                                         cur2 = argv2;
1043                                         while(cur2) {
1044                                                 ast_context_add_include2(con, cur2->data, registrar);
1045                                                 cur2 = cur2->next;
1046                                         }
1047                                         arg_free(argv2);
1048                                 }
1049                         } else if (matches_keyword(cur->data, "ignorepat")) {
1050                                 if (aeldebug & DEBUG_CONTEXTS)
1051                                         ast_verbose("--IGNOREPAT: '%s'\n", cur->data);
1052                                 parse_keyword(cur->data, &rest);
1053                                 if (rest) {
1054                                         argv2 = arg_parse(rest, filename, lineno);
1055                                         cur2 = argv2;
1056                                         while(cur2) {
1057                                                 ast_context_add_ignorepat2(con, cur2->data, registrar);
1058                                                 cur2 = cur2->next;
1059                                         }
1060                                         arg_free(argv2);
1061                                 }
1062                         } else if (matches_keyword(cur->data, "switches") || matches_keyword(cur->data, "eswitches")) {
1063                                 if (aeldebug & DEBUG_CONTEXTS)
1064                                         ast_verbose("--[E]SWITCH: '%s'\n", cur->data);
1065                                 parse_keyword(cur->data, &rest);
1066                                 if (rest) {
1067                                         argv2 = arg_parse(rest, filename, lineno);
1068                                         cur2 = argv2;
1069                                         while(cur2) {
1070                                                 c = strchr(cur2->data, '/');
1071                                                 if (c) {
1072                                                         *c = '\0';
1073                                                         c++;
1074                                                 } else
1075                                                         c = "";
1076                                                 ast_context_add_switch2(con, cur2->data, c, (cur->data[0] == 'e'), registrar);
1077                                                 cur2 = cur2->next;
1078                                         }
1079                                         arg_free(argv2);
1080                                 }
1081                         } else if (matches_extension(cur->data, &rest)) {
1082                                 if (aeldebug & DEBUG_CONTEXTS)
1083                                         ast_verbose("Extension: '%s' => '%s'\n", cur->data, rest);
1084                                 pos = 1;
1085                                 build_step("extension", cur->data, filename, lineno, con, cur->data, &pos, rest, NULL, NULL);
1086                         }
1087                         cur = cur->next;
1088                 }
1089         } else
1090                         ast_log(LOG_WARNING, "Unable to create context '%s'\n", name);
1091         arg_free(argv);
1092         if (vars->next)
1093                 ast_log(LOG_NOTICE, "Ignoring excess tokens in macro definition around line %d of %s!\n", lineno, filename);
1094 }
1095
1096 static int handle_root_token(struct ast_context **local_contexts, char *token, int level, const char *filename, int lineno)
1097 {
1098         struct stringlink *argv, *cur;
1099         argv = split_token(token, filename, lineno);
1100         if (aeldebug & DEBUG_TOKENS) {
1101                 ast_verbose("Found root token '%s' at level %d (%s:%d)!\n", token, level, filename, lineno);
1102                 cur = argv;
1103                 while(cur) {
1104                         ast_verbose("   ARG => '%s'\n", cur->data);
1105                         cur = cur->next;
1106                 }
1107         }
1108         if (!strcasecmp(token, "globals")) {
1109                 handle_globals(argv);
1110         } else if (!strcasecmp(token, "macro")) {
1111                 handle_macro(local_contexts, argv, filename, lineno);
1112         } else if (!strcasecmp(token, "context")) {
1113                 handle_context(local_contexts, argv, filename, lineno);
1114         } else {
1115                 ast_log(LOG_NOTICE, "Unknown root token '%s'\n", token);
1116         }
1117         arg_free(argv);
1118         return 0;
1119 }
1120
1121
1122 static int ast_ael_compile(struct ast_context **local_contexts, const char *filename)
1123 {
1124         char *rfilename;
1125         char *buf, *tbuf;
1126         int bufsiz;
1127         FILE *f;
1128         char *c;
1129         char *token;
1130         int lineno=0;
1131
1132         if (filename[0] == '/')
1133                 rfilename = (char *)filename;
1134         else {
1135                 rfilename = alloca(strlen(filename) + strlen(ast_config_AST_CONFIG_DIR) + 2);
1136                 sprintf(rfilename, "%s/%s", ast_config_AST_CONFIG_DIR, filename);
1137         }
1138         
1139         f = fopen(rfilename, "r");
1140         if (!f) {
1141                 ast_log(LOG_WARNING, "Unable to open '%s': %s\n", rfilename, strerror(errno));
1142                 return -1;
1143         }
1144         buf = malloc(4096);
1145         if (!buf) {
1146                 ast_log(LOG_WARNING, "Out of memory!\n");
1147                 fclose(f);
1148                 return -1;
1149         }
1150         buf[0] = 0;
1151         bufsiz = 4096;
1152         while(!feof(f)) {
1153                 if (bufsiz - strlen(buf) < 2048) {
1154                         bufsiz += 4096;
1155                         tbuf = realloc(buf, bufsiz);
1156                         if (tbuf) {
1157                                 buf = tbuf;
1158                         } else {
1159                                 free(buf);
1160                                 ast_log(LOG_WARNING, "Out of memory!\n");
1161                                 fclose(f);
1162                         }
1163                 }
1164                 if (fgets(buf + strlen(buf), bufsiz - strlen(buf), f)) {
1165                         lineno++;
1166                         while(*buf && buf[strlen(buf) - 1] < 33)
1167                                 buf[strlen(buf) - 1] = '\0';
1168                         c = strstr(buf, "//");
1169                         if (c)
1170                                 *c = '\0';
1171                         if (*buf) {
1172                                 if (aeldebug & DEBUG_READ)
1173                                         ast_verbose("Newly composed line '%s'\n", buf);
1174                                 while((token = grab_token(buf, filename, lineno))) {
1175                                         handle_root_token(local_contexts, token, 0, filename, lineno);
1176                                         free(token);
1177                                 }
1178                         }
1179                 }
1180         };
1181         free(buf);
1182         fclose(f);
1183         return 0;
1184 }
1185
1186 static int pbx_load_module(void)
1187 {
1188         struct ast_context *local_contexts=NULL, *con;
1189         ast_ael_compile(&local_contexts, config);
1190         ast_merge_contexts_and_delete(&local_contexts, registrar);
1191         for (con = ast_walk_contexts(NULL); con; con = ast_walk_contexts(con))
1192                 ast_context_verify_includes(con);
1193
1194         return 0;
1195 }
1196
1197 /* CLI interface */
1198 static int ael_debug_read(int fd, int argc, char *argv[])
1199 {
1200         aeldebug |= DEBUG_READ;
1201         return 0;
1202 }
1203
1204 static int ael_debug_tokens(int fd, int argc, char *argv[])
1205 {
1206         aeldebug |= DEBUG_TOKENS;
1207         return 0;
1208 }
1209
1210 static int ael_debug_macros(int fd, int argc, char *argv[])
1211 {
1212         aeldebug |= DEBUG_MACROS;
1213         return 0;
1214 }
1215
1216 static int ael_debug_contexts(int fd, int argc, char *argv[])
1217 {
1218         aeldebug |= DEBUG_CONTEXTS;
1219         return 0;
1220 }
1221
1222 static int ael_no_debug(int fd, int argc, char *argv[])
1223 {
1224         aeldebug = 0;
1225         return 0;
1226 }
1227
1228 static int ael_reload(int fd, int argc, char *argv[])
1229 {
1230         ast_context_destroy(NULL, registrar);
1231         return (pbx_load_module());
1232 }
1233
1234 static struct ast_cli_entry  ael_cli[] = {
1235         { { "ael", "reload", NULL }, ael_reload, "Reload AEL configuration"},
1236         { { "ael", "debug", "read", NULL }, ael_debug_read, "Enable AEL read debug"},
1237         { { "ael", "debug", "tokens", NULL }, ael_debug_tokens, "Enable AEL tokens debug"},
1238         { { "ael", "debug", "macros", NULL }, ael_debug_macros, "Enable AEL macros debug"},
1239         { { "ael", "debug", "contexts", NULL }, ael_debug_contexts, "Enable AEL contexts debug"},
1240         { { "ael", "no", "debug", NULL }, ael_no_debug, "Disable AEL debug messages"},
1241 };
1242
1243 /*
1244  * Standard module functions ...
1245  */
1246 int unload_module(void)
1247 {
1248         ast_context_destroy(NULL, registrar);
1249         ast_cli_unregister_multiple(ael_cli, sizeof(ael_cli)/ sizeof(ael_cli[0]));
1250         return 0;
1251 }
1252
1253
1254 int load_module(void)
1255 {
1256         ast_cli_register_multiple(ael_cli, sizeof(ael_cli)/ sizeof(ael_cli[0]));
1257         return (pbx_load_module());
1258 }
1259
1260 int reload(void)
1261 {
1262         unload_module();
1263         return (load_module());
1264 }
1265
1266 int usecount(void)
1267 {
1268         return 0;
1269 }
1270
1271 char *description(void)
1272 {
1273         return dtext;
1274 }
1275
1276 char *key(void)
1277 {
1278         return ASTERISK_GPL_KEY;
1279 }