execScriptRestricted()

This function, like execScript(), allows for execution of a script during runtime. Use this function to run void main-functions which have no return value. Contrasting to execScript() the functions that can be used inside the executed script are limited to provide better security against insertion of malicious code.

Synopsis

int execScriptRestricted(string script, [dyn_string dollars [,<type> <arg> ...]])

Parameters

Parameter Description
script The executed script
dollars The $parameter of the script
arg The parameters of any existing main function

Return value

The function returns 0 if an execution has been successful or in event of an error, -1.

Error

An error can be, for example, a syntax error of a script or a missing main function.

Description

Functionality is like execScript(), it allows the user to execute a script during runtime. The functions allowed within the script are greatly reduced from the unrestricted function.

Note:
Starting from version 3.19, this function can be called recursively from within a restricted script.

The following function types can not be used:

  • UI functions
  • Functions from a CTRL extension

The following functions are allowed in restricted mode:

abs()acos()asin()
assignPtr()atan()atan2()
availableEncodings()base64Decode()base64Encode()
blobAppendValue()blobGetValue()bloblen()
blobSetValue()blobZero()callFunction()
ceil()checkLicenseOption()checkPattern()
checkScript()classConnect()classConnectUserData()
classDisconnect()clearLastError()convManIdToInt()
convManIntToName()cos()cosh()
createUuid()crypt()cryptoHash()
dataHost()dataPort()day()
daylightsaving()daySecond()Debug()
DebugBreak()DebugFN()DebugFTN()
DebugN()DebugTN()deg2rad()
delay()dollarSubstitute()dpAliases()
dpAliasToName()dpAttributeType()dpElementType()
dpExists()dpGetAlias()dpGetAllAliases()
dpGetAllAttributes()dpGetAllComments()dpGetAllConfigs()
dpGetAllDescriptions()dpGetAllDetails()dpGetComment()
dpGetDescription()dpGetDpTypeRefs()dpGetFormat()
dpGetId()dpGetName()dpGetRefsToDpType()
dpGetStatusBit()dpGetUnit()dpIsLegalName()
dpNames()dpNameToAlias()dpSubStr()
dpTypeGet()dpTypeName()dpTypeRefName()
dpTypes()dpValToString()dynAppend()
dynAppendConst()dynAvg()dynAvgWT()
dynClear()dynContains()dynCount()
dynDynSort()dynDynTurn()dynInsertAt()
dynInsertAtConst()dynIntersect()dynlen()
dynMax()dynMin()dynPatternMatch()
dynRemove()dynSort()dynSortAsc()
dynSum()dynUnique()ecdhDeriveSharedSecret()
ecdhGenerateKeyPair()ecdhGetPublicKey()ecdhReleaseKeyPair()
enumKeys()enumValues()equalPtr()
errorText()evalScriptRestricted()eventHost()
eventPort()execScriptRestricted()exp()
fabs()floor()fmod()
formatDebug()formatTime()formatTimeUTC()
getACount()getActiveLang()getActiveLangId()
getAIdentifier()getAllDpAliases()getAllLangIds()
getAllSystemNames()getBit()getCatStr()
getComponentName()getCurrentTime()getDollarValue()
getDpComment()getDynAnytype()getDynATime()
getDynBit32()getDynBit64()getDynBool()
getDynChar()getDynFloat()getDynInt()
getDynLong()getDynMixed()getDynString()
getDynTime()getDynUInt()getDynULong()
getErrorCatalog()getErrorCode()getErrorDpName()
getErrorManId()getErrorPriority()getErrorStackTrace()
getErrorText()getErrorType()getErrorUserId()
getGlobalLangId()getHostByAddr()getHostByName()
getHostname()getKerberosSecurity()getLangCommentById()
getLangId()getLangIdx()getLastError()
getLastException()getLicenseOption()getLocale()
getManIdFromInt()getNoOfLangs()getParamLang()
getProjectLangIds()getStackTrace()getSystemId()
getSystemName()getSystemNames()getThreadId()
getThrowErrorAsException()getType()getTypeName()
getUserPermission()getVariable()getVersionInfo()
hour()httpParseDate()isConnActive()
isConnOpen()isDbgFlag()isDistributed()
isDollarDefined()isEvConnOpen()isFunctionDefined()
isinf()isInstanceOf()isLightRedundant()
isModeExtended()isnan()isReduActive()
isRedundant()jsonDecode()jsonEncode()
jwkFromRsa()jwtDecode()jwtEncode()
ldexp()log()log10()
makeATime()makeDynAnytype()makeDynATime()
makeDynBit32()makeDynBit64()makeDynBool()
makeDynChar()makeDynFloat()makeDynInt()
makeDynLong()makeDynMapping()makeDynMixed()
makeDynShape()makeDynString()makeDynTime()
makeDynUInt()makeDynULong()makeError()
makeMapping()makeTime()makeVector()
mappingClear()mappingGetKey()mappingGetValue()
mappingHasKey()mappingKeys()mappinglen()
mappingRemove()maxFLOAT()maxINT()
maxLONG()maxUINT()maxULONG()
milliSecond()minFLOAT()minINT()
minLONG()minUINT()minULONG()
minute()month()myManId()
myManNum()myManType()myReduHost()
myReduHostNum()numberMatch()patternMatch()
period()pmonPort()pow()
quarter()rad2deg()rand()
recode()recodeBlob()regexpIndex()
regexpLastIndex()regexpReplace()regexpSplit()
scanTimeUTC()second()secureRandom()
setACount()setAIdentifier()setBit()
setLangString()setPattern()setPeriod()
setThrowErrorAsException()setTime()setTrace()
setVariable()sin()sinh()
sizeof()sprintf()sprintfPL()
sprintfUL()sqrt()srand()
sscanf()sscanfPL()sscanfUL()
startThread()stopThread()strchange()
strexpand()strformat()strjoin()
strlen()strltrim()strpos()
strreplace()strrtrim()strsplit()
strtok()strtolower()strtoupper()
strwalk()substr()tan()
tanh()throw()throwError()
timeFromGMT()triggerClassEvent()triggerClassEventWait()
uniDynPatternMatch()uniPatternMatch()uniSPrintf()
uniSPrintfPL()uniSPrintfUL()uniStrChange()
uniStrExpand()uniStrFormat()uniStrLen()
uniStrPos()uniStrReplace()uniStrTok()
uniStrToLower()uniStrToUpper()uniSubStr()
urlDecode()urlEncode()va_arg()
va_end()va_start()waitThread()
weekDay()year()yearDay()

The following additional functions are allowed since version 3.20:

checkCrypt()classInfo()getTranslationFile()
reloadSecurityEventConfig()scriptInfo()securityEvent()
tr()yamlDecode()yamlEncode()

The following additional functions are allowed since version 3.21:

getAuthConfig()getClassPtr()getConnStartTime()
getErrorUserData()jwtEncodeWithHeader()maxTIME()
minTIME()setErrorUserData()

Example

The following script adds the values 17 and 8.

main()
{
  int rc = execScriptRestricted(
      "int main(int a, int b)" +
      "{" +
      "  int val;" +
      "  val = 3;" +
      "  DebugN(\"$ Value:\", $val1 + \" val:\", a + b );" +
      "}",
      makeDynString("$val1:12345"), 17, 8);
  DebugN(rc);
}

Assignment

Miscellaneous Functions, Waiting Control Functions

Availability

CTRL