! This is the HylaFAX Enterprise Appliance dialing rules
! This file is controlled by the Appliance console
!
! This file describes how to process user-specified dialing strings
! to create two items:
!
! CanonicalNumber: a unique string that is derived from all dialing
! strings to the same destination phone number.  This string is used
! by the fax server for ``naming'' the destination.
!
! DialString: the string passed to the modem for use in dialing the
! telephone.  This string should be void of any characters that might
! confuse the modem.
!
Area=${AreaCode}		! local area code
Country=${CountryCode}		! local country code
IDPrefix=${InternationalPrefix}	! prefix for placing an international call
LDPrefix=${LongDistancePrefix}	! prefix for placing a long distance call
!! Console settings
LocalAreaCodeDial=${AreaCode}
! Integer values:
OutsidePrefix=
MinLocalNumber=7
MinLDNumber=10
! Regexes: (Warning, do not leave empty)
OtherLocalAreaCodes=NONE
!! End of console settings
!
WS=" 	"			! our notion of white space
!
! Convert a phone number to a canonical format:
!
!    +<country><areacode><rest>
!
! by (possibly) stripping off leading dialing prefixes for
! long distance and/or international dialing.
!
CanonicalNumber := [
!#.*			=			! strip calling card stuff
^(sip:)?(.*)@.*		= \2			! strip sip gateway
[abcABC]		= 2			! these convert alpha to numbers
[defDEF]		= 3
[ghiGHI]		= 4
[jklJKL]		= 5
[mnoMNO]		= 6
[prsPRS]		= 7
[tuvTUV]		= 8
[wxyWXY]		= 9
[^+0-9]+		=			! strip white space etc.
^${IDPrefix}		= +			! replace int. dialing code
^${LDPrefix}([0-9]{${MinLocalNumber}}[0-9]*)	= +${Country}\1		! replace l.d. dialing code
^[0-9]{${MinLDNumber}}				= +${Country}&		! In country number
^[0-9]{${MinLocalNumber}}			= +${Country}${Area}&	! local area number
]
!
! Process a dialing string according to local requirements.
!
DialString := [
^sip:			=			! Strip facultative sip prefix
^[^@]*			= \CanonicalNumber(&)
^[+]${Country}${Area}	= ${LocalAreaCodeDial}	! Most ${Area} are local
^[+]${Country}(${OtherLocalAreaCodes}.*)	= \1	! Other local area codes
^[+]${Country}		= ${LDPrefix}		! long distance call
^[+]                    = ${IDPrefix}           ! international call

^[0-9]{${MinLocalNumber}}	= ${OutsidePrefix}&	! Dial prefix if necessary for every external call
]

DisplayNumber := [
(sip:)?(.*)@.*		= \2			! strip sip gateway
]
