From: Russell Bryant Date: Fri, 16 Mar 2007 01:41:00 +0000 (+0000) Subject: Making these documentation changes in the 1.4 branch upset various people, so X-Git-Tag: 1.4.2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b8da31130bce5fc2eb0f25ba40aea5897055fa8;p=thirdparty%2Fasterisk.git Making these documentation changes in the 1.4 branch upset various people, so these chanes will only be done in the trunk. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@58955 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/Makefile b/Makefile index 6e85a2c20f..c423ff8dfe 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,6 @@ export AGI_DIR export ASTCONFPATH export NOISY_BUILD export MENUSELECT_CFLAGS -export AST_DEVMODE export CC export CXX export AR @@ -685,24 +684,4 @@ menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(di @echo "Generating input for menuselect ..." @build_tools/prep_moduledeps > $@ -asterisk.pdf: doc/asterisk.pdf - -doc/asterisk.pdf: $(wildcard doc/*.tex) -ifeq ($(findstring rubber,$(RUBBER)),) - @echo "**********************************************" - @echo "** You must install the \"rubber\" tool ***" - @echo "** to generate the Asterisk reference PDF. ***" - @echo "**********************************************" -else - @echo "**********************************************" - @echo "** The Asterisk reference PDF will now be ***" - @echo "** generated. When complete, it will be ***" - @echo "** located at doc/asterisk.pdf. ***" - @echo "**********************************************" - @cp doc/asterisk.tex doc/asterisk.tex.orig - @sed -i -e 's/ASTERISKVERSION/$(ASTERISKVERSION)/' doc/asterisk.tex - @cd doc && $(RUBBER) --pdf asterisk.tex - @mv doc/asterisk.tex.orig doc/asterisk.tex -endif - .PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 184ef125fa..c374679001 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -1905,7 +1905,7 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in fprintf(p, "Subject: New message %d in mailbox %s" ENDL, msgnum + 1, mailbox); else fprintf(p, "Subject: [PBX]: New message %d in mailbox %s" ENDL, msgnum + 1, mailbox); - fprintf(p, "Message-ID: " ENDL, msgnum + 1, (unsigned int)ast_random(), mailbox, getpid(), host); + fprintf(p, "Message-ID: " ENDL, msgnum, (unsigned int)ast_random(), mailbox, getpid(), host); if(imap) { /* additional information needed for IMAP searching */ fprintf(p, "X-Asterisk-VM-Message-Num: %d" ENDL, msgnum + 1); @@ -1930,7 +1930,7 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in fprintf(p, "MIME-Version: 1.0" ENDL); if (attach_user_voicemail) { /* Something unique. */ - snprintf(bound, sizeof(bound), "voicemail_%d%s%d%d", msgnum + 1, mailbox, getpid(), (unsigned int)ast_random()); + snprintf(bound, sizeof(bound), "voicemail_%d%s%d%d", msgnum, mailbox, getpid(), (unsigned int)ast_random()); fprintf(p, "Content-Type: multipart/mixed; boundary=\"%s\"" ENDL ENDL ENDL, bound); @@ -1946,7 +1946,7 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in memset(passdata, 0, vmlen); prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, cidnum, cidname, dur, date, passdata, vmlen, category); pbx_substitute_variables_helper(ast, emailbody, passdata, vmlen); - fprintf(p, "%s" ENDL, passdata); + fprintf(p, "%s\r\n", passdata); } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n"); ast_channel_free(ast); @@ -1978,19 +1978,19 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox); } fprintf(p, "--%s" ENDL, bound); - fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum + 1, format); + fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum, format); fprintf(p, "Content-Transfer-Encoding: base64" ENDL); fprintf(p, "Content-Description: Voicemail sound attachment." ENDL); - fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.%s\"" ENDL ENDL, msgnum + 1, format); + fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.%s\"" ENDL ENDL, msgnum, format); snprintf(fname, sizeof(fname), "%s.%s", attach, format); base_encode(fname, p); /* only attach if necessary */ if (imap && !strcmp(format, "gsm")) { fprintf(p, "--%s" ENDL, bound); - fprintf(p, "Content-Type: audio/x-gsm; name=\"msg%04d.%s\"" ENDL, msgnum + 1, format); + fprintf(p, "Content-Type: audio/x-gsm; name=\"msg%04d.%s\"" ENDL, msgnum, format); fprintf(p, "Content-Transfer-Encoding: base64" ENDL); fprintf(p, "Content-Description: Voicemail sound attachment." ENDL); - fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.gsm\"" ENDL ENDL, msgnum + 1); + fprintf(p, "Content-Disposition: attachment; filename=\"msg%04d.gsm\"" ENDL ENDL, msgnum); snprintf(fname, sizeof(fname), "%s.gsm", attach); base_encode(fname, p); } diff --git a/build_tools/make_buildopts_h b/build_tools/make_buildopts_h index 203387e319..9970c0c0ba 100755 --- a/build_tools/make_buildopts_h +++ b/build_tools/make_buildopts_h @@ -9,9 +9,5 @@ cat << END END TMP=`grep MENUSELECT_CFLAGS menuselect.makeopts | sed 's/MENUSELECT_CFLAGS\=//g' | sed 's/-D//g'` for x in ${TMP}; do - echo "#define ${x} 1" + echo "#define ${x} 1" done -if grep AST_DEVMODE makeopts | grep -q yes -then - echo "#define AST_DEVMODE 1" -fi diff --git a/build_tools/prep_tarball b/build_tools/prep_tarball index b5b64a24ee..c2adefc11d 100755 --- a/build_tools/prep_tarball +++ b/build_tools/prep_tarball @@ -6,5 +6,3 @@ # It will be executed from the top-level directory of the project. make -C sounds all MENUSELECT_CORE_SOUNDS=CORE-SOUNDS-EN-GSM MENUSELECT_MOH=MOH-FREEPLAY-WAV WGET=wget DOWNLOAD=wget - -cd doc && rubber --pdf asterisk.tex diff --git a/configure.ac b/configure.ac index dd7d8a920c..5305a8ff8f 100644 --- a/configure.ac +++ b/configure.ac @@ -146,7 +146,6 @@ AC_PATH_PROG([LN], [ln], :) AC_PATH_PROG([DOT], [dot], :) AC_PATH_PROG([STRIP], [strip], :) AC_PATH_PROG([WGET], [wget], :) -AC_PATH_PROG([RUBBER], [rubber], :) if test "${WGET}" != ":" ; then DOWNLOAD=${WGET} else diff --git a/doc/00README.1st b/doc/00README.1st new file mode 100644 index 0000000000..c006d56a88 --- /dev/null +++ b/doc/00README.1st @@ -0,0 +1,74 @@ +Files in the /doc directory: +---------------------------- +In addition to these files, there is a lot of documentation of various +configuration options in the sample configuration files, in the /configs +directory of your source code + +Start here +---------- +security.txt IMPORTANT INFORMATION ABOUT ASTERISK SECURITY +hardware.txt Hardware supported by Asterisk + +Configuration +------------- +configuration.txt Features in the configuration parser +extensions.txt Basics about the dialplan +extconfig.txt How to use databases for configuration of Asterisk (ARA) +ip-tos.txt About the IP Type Of Service settings +realtime.txt The Asterisk Realtime Architecture - database support +freetds.txt Information about the FreeTDS support +ael.txt Information about the Asterisk Extension Language + +Misc +---- +PEERING The General Peering Agreement for Dundi +ajam.txt About the HTTP-based manager interface +app_sms.txt How to configure the SMS application +asterisk.conf.txt Documentation of various options in asterisk.conf +callingpres.txt Settings for Caller ID presentation +billing.txt Call Data Record information +cliprompt.txt How to change the Asterisk CLI prompt +dundi.txt Dundi - a discovery protocol +enum.txt Enum support in Asterisk +ices.txt Integrating ICEcast streaming in Asterisk +jitterbuffer.txt About the IAX2 jitterbuffer implementation +math.txt About the math() application +mp3.txt About MP3 support in Asterisk +musiconhold-fpm.txt Free Music On Hold music +mysql.txt About MYSQL support in Asterisk +odbcstorage.txt Voicemail storage of messages in UnixODBC +privacy.txt Privacy enhancements in Asterisk +queuelog.txt Agent and queue logging +channelvariables.txt Channel variables +cdrdrivers.txt About CDR storage in various databases (needs update) +asterisk-mib.txt SNMP mib for Asterisk (net-snmp) +digium-mib.txt SNMP mib for Asterisk (net-snmp) + +Channel drivers +--------------- +misdn.txt The mISDN channel driver for ISDN BRI cards +h323.txt How to compile and configure the H.323 channel +chaniax.txt About the IAX2 protocol support in Asterisk +localchannel.txt The local channel is a "gosub" in the dialplan + +Portability +----------- +cygwin.txt Compiling Asterisk on CygWin platforms (Windows) + +For developers +-------------- +See http://www.asterisk.org/developers for more information + +manager.txt About the AMI - Asterisk Manager Interface + for third party call control and PBX management +backtrace.txt How to produce a backtrace when Asterisk crashes +CODING-GUIDELINES Guidelines for developers +channels.txt What is a channel? +externalivr.txt Documentation of the protocol used in externalivr() +linkedlists.txt How to develop linked lists in Asterisk (old) +iax.txt About the IAX protocol +apps.txt About application development +model.txt About the call model in Asterisk (old) +modules.txt How Asterisk modules work +datastores.txt About channel data stores +speechrec.txt The Generic Speech Recognition API diff --git a/doc/PEERING b/doc/PEERING index ba05ffb9c6..c1f0b38312 100644 --- a/doc/PEERING +++ b/doc/PEERING @@ -1,5 +1,3 @@ -\begin{verbatim} - DIGIUM GENERAL PEERING AGREEMENT (TM) Version 1.0.0, September 2004 Copyright (C) 2004 Digium, Inc. @@ -499,5 +497,3 @@ member of the Peering System and be able to make Routes available in accordance with this GPA. DUNDi, IAX, Asterisk and GPA are trademarks of Digium, Inc. - -\end{verbatim} diff --git a/doc/ael.tex b/doc/ael.txt similarity index 79% rename from doc/ael.tex rename to doc/ael.txt index d675190ccf..f72f2805bd 100644 --- a/doc/ael.tex +++ b/doc/ael.txt @@ -1,4 +1,5 @@ -\section{Introduction} +The Asterisk Extension Language - v 2 +===================================== AEL is a specialized language intended purely for describing Asterisk dial plans. @@ -12,22 +13,21 @@ functionality. AEL is really the merger of 4 different 'languages', or syntaxes: -\begin{itemize} - \item The first and most obvious is the AEL syntax itself. A BNF is + * The first and most obvious is the AEL syntax itself. A BNF is provided near the end of this document. - \item The second syntax is the Expression Syntax, which is normally + * The second syntax is the Expression Syntax, which is normally handled by Asterisk extension engine, as expressions enclosed in - \$[...]. The right hand side of assignments are wrapped in \$[ ... ] + $[...]. The right hand side of assignments are wrapped in $[ ... ] by AEL, and so are the if and while expressions, among others. - \item The third syntax is the Variable Reference Syntax, the stuff - enclosed in \${..} curly braces. It's a bit more involved than just + * The third syntax is the Variable Reference Syntax, the stuff + enclosed in ${..} curly braces. It's a bit more involved than just putting a variable name in there. You can include one of dozens of 'functions', and their arguments, and there are even some string manipulation notation in there. - \item The last syntax that underlies AEL, and is not used + * The last syntax that underlies AEL, and is not used directly in AEL, is the Extension Language Syntax. The extension language is what you see in extensions.conf, and AEL compiles the higher level AEL language into extensions and @@ -36,13 +36,14 @@ AEL is really the merger of 4 different 'languages', or syntaxes: commands, of which one application call per step, or priority can be made. You can think of this as a "macro assembler" language, that AEL will compile into. -\end{itemize} + Any programmer of AEL should be familiar with it's syntax, of course, as well as the Expression syntax, and the Variable syntax. - -\section{Asterisk in a Nutshell} +************************** +* Asterisk in a Nutshell * +************************** Asterisk acts as a server. Devices involved in telephony, like Zapata cards, or Voip phones, all indicate some context that should be @@ -51,7 +52,8 @@ zapata.conf, etc. They all help describe a device, and they all specify a context to activate when somebody picks up a phone, or a call comes in from the phone company, or a voip phone, etc. -\subsection{Contexts} +Contexts +-------- Contexts are a grouping of extensions. @@ -59,7 +61,8 @@ Contexts can also include other contexts. Think of it as a sort of merge operation at runtime, whereby the included context's extensions are added to the contexts making the inclusion. -\subsection{Extensions and priorities} +Extensions and priorities +------------------------- A Context contains zero or more Extensions. There are several predefined extensions. The "s" extension is the "start" extension, and @@ -91,7 +94,8 @@ The extensions can also contain "goto" or "jump" commands to skip to extensions in other contexts. Conditionals provide the ability to react to different stimuli, and there you have it. -\subsection{Macros} +Macros +------ Think of a macro as a combination of a context with one nameless extension, and a subroutine. It has arguments like a subroutine @@ -100,7 +104,8 @@ individual statements there are executed until it ends. At this point, execution returns to the next statement after the macro call. Macros can call other macros. And they work just like function calls. -\subsection{Applications} +Applications +------------ Application calls, like "Dial()", or "Hangup()", or "Answer()", are available for users to use to accomplish the work of the @@ -112,11 +117,14 @@ services. Hopefully, the above objects will allow you do anything you need to in the Asterisk environment! -\section{Getting Started} -The AEL parser (pbx\_ael.so) is completely separate from the module -that parses extensions.conf (pbx\_config.so). To use AEL, the only -thing that has to be done is the module pbx\_ael.so must be loaded by +******************* +* Getting Started * +******************* + +The AEL parser (pbx_ael.so) is completely separate from the module +that parses extensions.conf (pbx_config.so). To use AEL, the only +thing that has to be done is the module pbx_ael.so must be loaded by Asterisk. This will be done automatically if using 'autoload=yes' in /etc/asterisk/modules.conf. When the module is loaded, it will look for 'extensions.ael' in /etc/asterisk/. extensions.conf and @@ -125,7 +133,9 @@ each other if that is what is desired. Some users may want to keep extensions.conf for the features that are configured in the 'general' section of extensions.conf. -Reloading extensions.ael +------------------------------ +- Reloading extensions.ael - +------------------------------ To reload extensions.ael, the following command can be issued at the CLI: @@ -133,7 +143,10 @@ CLI: *CLI> ael reload -\section{Debugging} + +************* +* Debugging * +************* Right at this moment, the following commands are available, but do nothing: @@ -161,7 +174,9 @@ facilities to debug your file: 3. the standalone executable, "aelparse" built in the utils/ dir in the source. -\section{About "aelparse"} +***************************** +* About "aelparse" * +***************************** You can use the "aelparse" program to check your extensions.ael file before feeding it to asterisk. Wouldn't it be nice to eliminate @@ -173,24 +188,20 @@ spot in your PATH. aelparse has two optional arguments: -\begin{itemize} - \item -d - \begin{itemize} - \item Override the normal location of the config file dir, (usually +-d - Override the normal location of the config file dir, (usually /etc/asterisk), and use the current directory instead as the config file dir. Aelparse will then expect to find the file "./extensions.ael" in the current directory, and any included files in the current directory as well. - \end{itemize} - \item -n - \begin{itemize} - \item don't show all the function calls to set priorities and contexts + +-n - don't show all the function calls to set priorities and contexts within asterisk. It will just show the errors and warnings from the parsing and semantic checking phases. - \end{itemize} -\end{itemize} -\section{General Notes about Syntax} + +****************************** +* General Notes about Syntax * +****************************** Note that the syntax and style are now a little more free-form. The opening '{' (curly-braces) do not have to be on the same line as the @@ -200,13 +211,10 @@ be included on a single line. Whatever you think is best! You can just as easily say, -\begin{verbatim} if(${x}=1) { NoOp(hello!); goto s|3; } else { NoOp(Goodbye!); goto s|12; } -\end{verbatim} as you can say: -\begin{verbatim} if(${x}=1) { NoOp(hello!); @@ -217,11 +225,9 @@ else NoOp(Goodbye!); goto s|12; } -\end{verbatim} or: -\begin{verbatim} if(${x}=1) { NoOp(hello!); goto s|3; @@ -229,19 +235,33 @@ if(${x}=1) { NoOp(Goodbye!); goto s|12; } -\end{verbatim} or: -\begin{verbatim} if (${x}=1) { NoOp(hello!); goto s|3; } else { NoOp(Goodbye!); goto s|12; } -\end{verbatim} -\section{Keywords} +or even: + +if +(${x}=1) +{ +NoOp(hello!); +goto s|3; +} +else +{ +NoOp(Goodbye!); +goto s|12; +} + + +************ +* Keywords * +************ The AEL keywords are case-sensitive. If an application name and a keyword overlap, there is probably good reason, and you should @@ -251,38 +271,41 @@ capitalized letter somewhere in its name. In the Asterisk extension language, application names are NOT case-sensitive. The following are keywords in the AEL language: -\begin{itemize} - \item abstract - \item context - \item macro - \item globals - \item ignorepat - \item switch - \item if - \item ifTime - \item else - \item random - \item goto - \item jump - \item return - \item break - \item continue - \item regexten - \item hint - \item for - \item while - \item case - \item pattern - \item default NOTE: the "default" keyword can be used as a context name, + + * abstract + * context + * macro + * globals + * ignorepat + * switch + * if + * ifTime + * else + * random + * goto + * jump + * return + * break + * continue + * regexten + * hint + * for + * while + * case + * pattern + * default NOTE: the "default" keyword can be used as a context name, for those who would like to do so. - \item catch - \item switches - \item eswitches - \item includes -\end{itemize} + * catch + * switches + * eswitches + * includes + -\section{Procedural Interface and Internals} + + +Procedural Interface and Internals +================================== AEL first parses the extensions.ael file into a memory structure representing the file. The entire file is represented by a tree of "pval" structures linked together. @@ -300,19 +323,25 @@ asterisk dialplan. The modularity of the design offers several opportunities for developers to simplify apps to generate dialplan data. -\subsection{AEL version 2 BNF} + +========================= + AEL version 2 BNF +========================= + + (hopefully, something close to bnf). First, some basic objects -\begin{verbatim} ------------------------ + a lexical token consisting of characters matching this pattern: [-a-zA-Z0-9"_/.\<\>\*\+!$#\[\]][-a-zA-Z0-9"_/.!\*\+\<\>\{\}$#\[\]]* a concatenation of up to 3 s. all characters encountered until the character that follows the in the grammar. + ------------------------- :== @@ -488,27 +517,29 @@ First, some basic objects :== 'includes' '{' '}' | 'includes' '{' '}' -\end{verbatim} +************************** +* AEL Example USAGE ***** +************************** -\section{AEL Example USAGE} - -\subsection{Comments} +Comments +======== Comments begin with // and end with the end of the line. Comments are removed by the lexical scanner, and will not be recognized in places where it is busy gathering expressions to wrap in -\$[] , or inside application call argument lists. The safest place to put +$[] , or inside application call argument lists. The safest place to put comments is after terminating semicolons, or on otherwise empty lines. -\subsection{Context} +Context +======= Contexts in AEL represent a set of extensions in the same way that they do in extensions.conf. -\begin{verbatim} + context default { } @@ -520,20 +551,21 @@ only be included by another context, and not "stand on its own". The current effect of this keyword is to prevent "goto " statements from being checked. -\begin{verbatim} + abstract context longdist { - _1NXXNXXXXXX => NoOp(generic long distance dialing actions in the US); + _1NXXNXXXXXX => NoOp(generic long distance dialing actions in the US); } -\end{verbatim} -\subsection{Extensions} + +Extensions +========== To specify an extension in a context, the following syntax is used. If more than one application is be called in an extension, they can be listed in order inside of a block. -\begin{verbatim} + context default { 1234 => Playback(tt-monkeys); 8000 => { @@ -543,7 +575,7 @@ context default { }; _5XXX => NoOp(it's a pattern!); } -\end{verbatim} + Two optional items have been added to the AEL syntax, that allow the specification of hints, and a keyword, regexten, that will force the @@ -552,38 +584,36 @@ numbering of priorities to start at 2. The ability to make extensions match by CID is preserved in AEL; just use '/' and the CID number in the specification. See below. -\begin{verbatim} + context default { regexten _5XXX => NoOp(it's a pattern!); } -\end{verbatim} -\begin{verbatim} + + context default { hint(Sip/1) _5XXX => NoOp(it's a pattern!); } -\end{verbatim} -\begin{verbatim} + + context default { regexten hint(Sip/1) _5XXX => NoOp(it's a pattern!); } -\end{verbatim} + The regexten must come before the hint if they are both present. CID matching is done as with the extensions.conf file. Follow the extension name/number with a slash (/) and the number to match against the Caller ID: -\begin{verbatim} context zoombo { 819/7079953345 => { NoOp(hello, 3345); } } -\end{verbatim} In the above, the 819/7079953345 extension will only be matched if the CallerID is 7079953345, and the dialed number is 819. Hopefully you have @@ -591,12 +621,13 @@ another 819 extension defined for all those who wish 819, that are not so lucky as to have 7079953345 as their CallerID! -\subsection{Includes} +Includes +======== Contexts can be included in other contexts. All included contexts are listed within a single block. -\begin{verbatim} + context default { includes { local; @@ -604,13 +635,13 @@ context default { international; } } -\end{verbatim} + Time-limited inclusions can be specified, as in extensions.conf format, with the fields described in the wiki page Asterisk cmd GotoIfTime. -\begin{verbatim} + context default { includes { local; @@ -618,19 +649,20 @@ context default { international; } } -\end{verbatim} -\subsection{\#include} -You can include other files with the \#include "filepath" construct. +#include +======== + +You can include other files with the #include "filepath" construct. + -\begin{verbatim} #include "/etc/asterisk/testfor.ael" -\end{verbatim} -An interesting property of the \#include, is that you can use it almost + +An interesting property of the #include, is that you can use it almost anywhere in the .ael file. It is possible to include the contents of -a file in a macro, context, or even extension. The \#include does not +a file in a macro, context, or even extension. The #include does not have to occur at the beginning of a line. Included files can include other files, up to 50 levels deep. If the path provided in quotes is a relative path, the parser looks in the config file directory for the @@ -638,13 +670,14 @@ file (usually /etc/asterisk). -\subsection{Dialplan Switches} +Dialplan Switches +================= Switches are listed in their own block within a context. For clues as to what these are used for, see Asterisk - dual servers, and Asterisk config extensions.conf. -\begin{verbatim} + context default { switches { DUNDi/e164; @@ -654,40 +687,43 @@ context default { IAX2/context@${CURSERVER}; } } -\end{verbatim} -\subsection{Ignorepat} + +Ignorepat +========= ignorepat can be used to instruct channel drivers to not cancel dialtone upon receipt of a particular pattern. The most commonly used example is '9'. -\begin{verbatim} + context outgoing { ignorepat => 9; } -\end{verbatim} -\subsection{Variables} + + +Variables +========= Variables in Asterisk do not have a type, so to define a variable, it just has to be specified with a value. Global variables are set in their own block. -\begin{verbatim} + globals { CONSOLE=Console/dsp; TRUNK=Zap/g2; } -\end{verbatim} + Variables can be set within extensions as well. -\begin{verbatim} + context foo { 555 => { x=5; @@ -696,35 +732,36 @@ context foo { NoOp(x is ${x} and y is ${y} !); } } -\end{verbatim} -NOTE: AEL wraps the right hand side of an assignment with \$[ ] to allow + +NOTE: AEL wraps the right hand side of an assignment with $[ ] to allow expressions to be used If this is unwanted, you can protect the right hand side from being wrapped by using the Set() application. Read the README.variables about the requirements and behavior -of \$[ ] expressions. +of $[ ] expressions. -NOTE: These things are wrapped up in a \$[ ] expression: The while() test; +NOTE: These things are wrapped up in a $[ ] expression: The while() test; the if() test; the middle expression in the for( x; y; z) statement -(the y expression); Assignments - the right hand side, so a = b -> Set(a=\$[b]) +(the y expression); Assignments - the right hand side, so a = b -> Set(a=$[b]) Writing to a dialplan function is treated the same as writing to a variable. -\begin{verbatim} + context blah { s => { CALLERID(name)=ChickenMan; NoOp(My name is ${CALLERID(name)} !); } } -\end{verbatim} -\subsection{Loops} + +Loops +===== AEL has implementations of 'for' and 'while' loops. -\begin{verbatim} + context loops { 1 => { for (x=0; ${x} < 3; x=${x} + 1) { @@ -739,15 +776,16 @@ context loops { } } } -\end{verbatim} -NOTE: The conditional expression (the "\${y} >= 0" above) is wrapped in - \$[ ] so it can be evaluated. NOTE: The for loop test expression - (the "\${x} < 3" above) is wrapped in \$[ ] so it can be evaluated. +NOTE: The conditional expression (the "${y} >= 0" above) is wrapped in + $[ ] so it can be evaluated. NOTE: The for loop test expression + (the "${x} < 3" above) is wrapped in $[ ] so it can be evaluated. -\subsection{Conditionals} + +Conditionals +============ AEL supports if and switch statements, like AEL, but adds ifTime, and random. Unlike the original AEL, though, you do NOT need to put curly @@ -755,7 +793,7 @@ braces around a single statement in the "true" branch of an if(), the random(), or an ifTime() statement. The if(), ifTime(), and random() statements allow optional else clause. -\begin{verbatim} + context conditional { _8XXX => { Dial(SIP/${EXTEN}); @@ -809,14 +847,14 @@ context conditional { } } } -\end{verbatim} + NOTE: The conditional expression in if() statements (the - "\${DIALSTATUS}" = "BUSY" above) is wrapped by the compiler in - \$[] for evaluation. + "${DIALSTATUS}" = "BUSY" above) is wrapped by the compiler in + $[] for evaluation. -NOTE: Neither the switch nor case values are wrapped in \$[ ]; they can - be constants, or \${var} type references only. +NOTE: Neither the switch nor case values are wrapped in $[ ]; they can + be constants, or ${var} type references only. NOTE: AEL generates each case as a separate extension. case clauses with no terminating 'break', or 'goto', have a goto inserted, to @@ -828,7 +866,7 @@ NOTE: AEL introduces the ifTime keyword/statement, which works just Asterisk cmd GotoIfTime NOTE: The pattern statement makes sure the new extension that is - created has an '\_' preceding it to make sure asterisk recognizes + created has an '_' preceding it to make sure asterisk recognizes the extension name as a pattern. NOTE: Every character enclosed by the switch expression's parenthesis @@ -840,7 +878,9 @@ NOTE: NEW: Previous to version 0.13, the random statement used the the RAND() function instead, in the GotoIf application. -\subsection{Break, Continue, and Return} +Break, Continue, and Return +=========================== + Three keywords, break, continue, and return, are included in the syntax to provide flow of control to loops, and switches. @@ -858,11 +898,12 @@ context, or macro, and can be used anywhere. -\subsection{goto, jump, and labels} +goto, jump, and labels +====================== This is an example of how to do a goto in AEL. -\begin{verbatim} + context gotoexample { s => { begin: @@ -884,7 +925,6 @@ context gotoexample2 { goto gotoexample|s|begin; // go to label in different context } } -\end{verbatim} You can use the special label of "1" in the goto and jump statements. It means the "first" statement in the extension. I would @@ -898,7 +938,7 @@ extension[,priority][@context] If priority is absent, it defaults to "1". If context is not present, it is assumed to be the same as that which contains the "jump". -\begin{verbatim} + context gotoexample { s => { begin: @@ -920,7 +960,6 @@ context gotoexample2 { jump s@gotoexample; // go to label in different context } } -\end{verbatim} NOTE: goto labels follow the same requirements as the Goto() application, except the last value has to be a label. If the @@ -941,14 +980,15 @@ NOTE: A NEW addition to AEL: you can now use ',' instead of '|' to -\subsection{Macros} +Macros +====== A macro is defined in its own block like this. The arguments to the macro are specified with the name of the macro. They are then referred to by that same name. A catch block can be specified to catch special extensions. -\begin{verbatim} + macro std-exten( ext , dev ) { Dial(${dev}/${ext},20); switch(${DIALSTATUS) { @@ -964,25 +1004,26 @@ macro std-exten( ext , dev ) { return; } } -\end{verbatim} + A macro is then called by preceding the macro name with an ampersand. Empty arguments can be passed simply with nothing between comments(0.11). -\begin{verbatim} + context example { _5XXX => &std-exten(${EXTEN}, "IAX2"); _6XXX => &std-exten(, "IAX2"); _7XXX => &std-exten(${EXTEN},); _8XXX => &std-exten(,); } -\end{verbatim} -\section{Examples} -\begin{verbatim} +Examples +======== + + context demo { s => { Wait(1); @@ -1026,121 +1067,117 @@ hangup: t => goto #|hangup; i => Playback(invalid); } -\end{verbatim} -\section{Semantic Checks} +Semantic Checks +=============== AEL, after parsing, but before compiling, traverses the dialplan tree, and makes several checks: -\begin{itemize} - \item Macro calls to non-existent macros. - \item Macro calls to contexts. - \item Macro calls with argument count not matching the definition. - \item application call to macro. (missing the '\&') - \item application calls to "GotoIf", "GotoIfTime", "while", + * Macro calls to non-existent macros. + * Macro calls to contexts. + * Macro calls with argument count not matching the definition. + * application call to macro. (missing the '&') + * application calls to "GotoIf", "GotoIfTime", "while", "endwhile", "Random", and "execIf", will generate a message to consider converting the call to AEL goto, while, etc. constructs. - \item goto a label in an empty extension. - \item goto a non-existent label, either a within-extension, + * goto a label in an empty extension. + * goto a non-existent label, either a within-extension, within-context, or in a different context, or in any included contexts. Will even check "sister" context references. - \item All the checks done on the time values in the dial plan, are + * All the checks done on the time values in the dial plan, are done on the time values in the ifTime() and includes times: o the time range has to have two times separated by a dash; o the times have to be in range of 0 to 24 hours. o The weekdays have to match the internal list, if they are provided; o the day of the month, if provided, must be in range of 1 to 31; o the month name or names have to match those in the internal list. - \item (0.5) If an expression is wrapped in \$[ ... ], and the compiler + * (0.5) If an expression is wrapped in $[ ... ], and the compiler will wrap it again, a warning is issued. - \item (0.5) If an expression had operators (you know, - +,-,*,/,%,!,etc), but no \${ } variables, a warning is + * (0.5) If an expression had operators (you know, + +,-,*,/,%,!,etc), but no ${ } variables, a warning is issued. Maybe someone forgot to wrap a variable name? - \item (0.12) check for duplicate context names. - \item (0.12) check for abstract contexts that are not included by any context. - \item (0.13) Issue a warning if a label is a numeric value. -\end{itemize} + * (0.12) check for duplicate context names. + * (0.12) check for abstract contexts that are not included by any context. + * (0.13) Issue a warning if a label is a numeric value. There are a subset of checks that have been removed until the proposed AAL (Asterisk Argument Language) is developed and incorporated into Asterisk. These checks will be: -\begin{itemize} - \item (if the application argument analyzer is working: the presence + * (if the application argument analyzer is working: the presence of the 'j' option is reported as error. - \item if options are specified, that are not available in an + * if options are specified, that are not available in an application. - \item if you specify too many arguments to an application. - \item a required argument is not present in an application call. - \item Switch-case using "known" variables that applications set, that + * if you specify too many arguments to an application. + * a required argument is not present in an application call. + * Switch-case using "known" variables that applications set, that does not cover all the possible values. (a "default" case will solve this problem. Each "unhandled" value is listed. - \item a Switch construct is used, which is uses a known variable, and + * a Switch construct is used, which is uses a known variable, and the application that would set that variable is not called in the same extension. This is a warning only... - \item Calls to applications not in the "applist" database (installed + * Calls to applications not in the "applist" database (installed in /var/lib/asterisk/applist" on most systems). - \item In an assignment statement, if the assignment is to a function, + * In an assignment statement, if the assignment is to a function, the function name used is checked to see if it one of the currently known functions. A warning is issued if it is not. -\end{itemize} + Differences with the original version of AEL ============================================ -\begin{enumerate} - \item The \$[...] expressions have been enhanced to include the ==, ||, - and \&\& operators. These operators are exactly equivalent to the - =, |, and \& operators, respectively. Why? So the C, Java, C++ + 1. The $[...] expressions have been enhanced to include the ==, ||, + and && operators. These operators are exactly equivalent to the + =, |, and & operators, respectively. Why? So the C, Java, C++ hackers feel at home here. - \item It is more free-form. The newline character means very little, + 2. It is more free-form. The newline character means very little, and is pulled out of the white-space only for line numbers in error messages. - \item It generates more error messages -- by this I mean that any + 3. It generates more error messages -- by this I mean that any difference between the input and the grammar are reported, by file, line number, and column. - \item It checks the contents of \$[ ] expressions (or what will end up - being \$[ ] expressions!) for syntax errors. It also does + 4. It checks the contents of $[ ] expressions (or what will end up + being $[ ] expressions!) for syntax errors. It also does matching paren/bracket counts. - \item It runs several semantic checks after the parsing is over, but + 5. It runs several semantic checks after the parsing is over, but before the compiling begins, see the list above. - \item It handles \#include "filepath" directives. -- ALMOST + 6. It handles #include "filepath" directives. -- ALMOST anywhere, in fact. You could easily include a file in a context, in an extension, or at the root level. Files can be included in files that are included in files, down to 50 levels of hierarchy... - \item Local Goto's inside Switch statements automatically have the + 7. Local Goto's inside Switch statements automatically have the extension of the location of the switch statement appended to them. - \item A pretty printer function is available within pbx\_ael.so. - \item In the utils directory, two standalone programs are supplied for + 8. A pretty printer function is available within pbx_ael.so. + 9. In the utils directory, two standalone programs are supplied for debugging AEL files. One is called "aelparse", and it reads in the /etc/asterisk/extensions.ael file, and shows the results of syntax and semantic checking on stdout, and also shows the results of compilation to stdout. The other is "aelparse1", which uses the original ael compiler to do the same work, reading in "/etc/asterisk/extensions.ael", using the original - 'pbx\_ael.so' instead. - \item AEL supports the "jump" statement, and the "pattern" statement + 'pbx_ael.so' instead. + 10. AEL supports the "jump" statement, and the "pattern" statement in switch constructs. Hopefully these will be documented in the AEL README. - \item Added the "return" keyword, which will jump to the end of an + 11. Added the "return" keyword, which will jump to the end of an extension/Macro. - \item Added the ifTime (