Standard Functions

The following table specifies all the standard functions which are built into SDL.

Table 22.2. Standard Functions

SyntaxReturn ValueDescription
CmdClose(Cmd_t $Handle) Close a Cmd_t handle.
ArrayLen(Array_t $Array)Number_tReturn the number of members in array $Array.
CmdOpen(String_t $Command, String_t $Args, String $Opts)Cmd_tOpen a new command. $Command should be the path to the command to run and $Args are the arguments to pass to $Command. $Opts is a comma seperated list of options understood by CmdOpen() itself. The only currently supported option is "withstderr" which includes standard error output in the input stream read by CmdReadLine().
CmdReadLine(Cmd_t $Handle)String_tRead one line of output from the command handle $Handle.
DataTreeGetIndex(DataTree_t $Data, Number_t $Index)DataTree_tGet the DataTree_t at offset $Index from $Data.
DataTreeGetTree(DataTree_t $Data, String_t $Path, String_t $Attr, String_t $Opts)DataTree_tSearch through data tree $Data for attribute matching $Path and optionally $Attr. $Opts is a comma separated list of options. Valid options are "CHILDREN" (return Children of match, not the top node itself).Get the DataTree_t at offset $Index from $Data.
DataTreeGetValue(DataTree_t $Data, String_t $Attr)String_tSearch through data tree $Data for attribute matching $Attr.
DataTreeGetKeys(DataTree_t $Data)Array_tReturn an Array of Key values for each member of $Data and it's peer nodes. Does not descend.
DataTreeGetValues(DataTree_t $Data)Array_tReturn an Array of Values for each member of $Data and it's peer nodes. Does not descend.
Debug(String_t $Msg) If SDL debugging is enabled, then output $Msg.
Error(String_t $Msg) Print an error message.
Exit(Number_t $Num) Exit the current SDL script and return $Num to the invoker as the return value for this script.
FileClose(File_t $Handle) Close a File_t handle.
FileOpen(String_t $Path, String_t $Mode, String $Opts)File_tOpen a new file handle. $Path should be the path of the file to be opened. $Mode should be "READ" to open the file in read mode. $Opts is not used at this time.
FileReadLine(File_t $Handle)String_tRead one line of output from the file handle $Handle.
FileSize(String_t $File)Number_tGet the size of file $File in bytes.
GetEnv(String_t $Var)String_tGet an environment variable $Var and return it's value.
GetGrEnt(String_t $Name)String_tLook for a system group called $Name. If found returns an string array consisting of: [0] group name, [1] group password, [2], GID, [3] list of members seperated by comma.
GetPwEnt(String_t $Name)String_tLook for a system user (defined in /etc/passwd or similar location) called $Name. If found returns an string array consisting of: [0] user name, [1] password, [2], UID, [3] GID, [4] full name (GECOS), [5] home directory, [6] shell.
PathBaseName(String_t $Path)String_tGet the base (file) name of $Path.
PathDirName(String_t $Path)String_tGet the directory name of $Path.
PathExists(String_t $Path, String_t $Type)Boolean_tIf $Path exists and is of file type $Type (optional), return True.
PathFind(String_t $Dir, String_t $Pattern, String_t $Type, Number_t $MaxMatch, Number_t $MaxDepth)Array_t of String_tFind the path matching $Pattern (regular expression) somewhere under directory $Dir of type $Type. If $MaxMatch is set, return once this number of matches are found. If $MaxDepth is set, the search will not descend more the $MaxDepth directory levels. Returns an array of matching String_t paths.
ProcessFind(String_t $Pattern)String_tLook for a running process matching $Pattern and return the first matching command found.
Return(ANY) Return any SDL data type literal or variable from the current function to it's caller.
SoftInfoAdd(SoftInfo_t $Handle) Add a SoftInfo_t entry $Handle to the list of discovered software products to report.
SoftInfoCreate(String_t $Name, String_t $Version)SoftInfo_tCreate a new SoftInfo_t handle with a product name of $Name and version of $Version.
SoftInfoSet(SoftInfo_t $Handle, String_t $Key, $Value) Set $Value in the SoftInfo_t $Handle based on the type $Key. The $Value data type varies according to the $Key required type. See SoftInfoSet Key Values table for a description of value $Key values.
StrArrayFind(String_t $Pattern, Number_t $PatternLen, Array_t $Array)String_tFind a pattern matching $Pattern in $Array. $Pattern can be either a literal string or a regular expression. If $PatternLen is greather than 0, then only that number of characters are compared.
StrClean(String_t $String)String_tClean $String by removing quote characters.
StrCopy(String_t $String)String_tMake a copy of $String and return the new copy value.
StrEdit(String_t $Pattern, String_t $String, String_t $Replace, String_t $Options)String_tReplace first occurance of $Pattern in $String with $Replace. The $Pattern can be a literal or a regular expression. The $Options value contains a comma seperated list of options affecting the editing of $String. If the "g" option is given, then multiple occurances of $Pattern are replaced with $Replace.
StrLen(String_t $String)Number_tReturn the number of characters in $String.
StrMatch(String_t $String1, String_t $String2)Boolean_tIf strings $String1 and $String2 exactly match (case sensitive), then return True.
StrMatchN(String_t $String1, String_t $String2, Number_t $NumChars)Boolean_tIf strings $String1 and $String2 match (case sensitive) in the first $NumChars characters, then return True.
StrMatchCase(String_t $String1, String_t $String2)Boolean_tIf strings $String1 and $String2 exactly match (case in-sensitive), then return True.
StrMatchCaseN(String_t $String1, String_t $String2, Number_t $NumChars)Boolean_tIf strings $String1 and $String2 match (case in-sensitive) in the first $NumChars characters, then return True.
StrProductMakeName(String_t $Title)String_tConvert a string $Title like "Acme Widget" into a proper product name like "acme-widget".
StrRegExMatch(String_t $String, String_t $Pattern)Boolean_tIf string $String matches regular expression $Pattern, then return True.
StrSplit(String_t $SepStr, String_t $String)Array_tSplit string $String along $SepStr boundries. If $SepStr is empty, then SPACE and TAB will be used as the separator chars and back-to-back repeating SPACE/TAB chars will be de-duplicated.
XmlClose(Xmlhandle_t $Handle) Close XML handle $Handle.
XmlOpen(String_t $File)XmlHandle_tOpen an XML file $File and return a handle to it's contents.
XmlGetAll(XmlHandle_t $Handle, String_t $Path, String_t $Attr)Array_tGet all occurances matching XML path $Path and attribute $Attr in XML data in $Handle. Returns array of matching values.
XmlGetValue(XmlHandle_t $Handle, String_t $Path, String_t $Attr)String_t>Get first matching occurance of XML path $Path and attribute $Attr in XML data in $Handle.


The SoftInfoSet() takes a String_t key value which indicates what type of data to set into the SoftInfo_t handle. The following table describes the valid values for this key:

Table 22.3. SoftInfoSet() Key Definetions

KeyDescription
EntryTypeThe type of entry either "pkg" or "product".
NameThe short, unique name of the product.
VersionThe version of the product.
RevisionThe revision of the product.
DescThe short, one-line summary description.
DescVerboseThe verbose, possibly multi-line description.
URLProduct URL.
URLhelpThe product help URL.
URLupdateThe product update URL.
LicenseThe license of the product.
CopyrightThe product copyright notice.
CategoryThe category the product belongs to.
SubCategoryThe sub-category the product belongs to.
OSnameThe OS name the product requires.
OSversionThe OS version the product requires.
ArchThe hardware architecture the product requires.
ISArchThe instruction set architecture the product requires.
InstDateInstallation date.
BuildDateBuild date.
ProdStampProduction stamp.
BaseDirBase directory where product is installed.
PkgDepsPackage dependencies.
DiskUsageThe disk usage the product consumes in bytes.
VendorNameName of product vendor.
VendorEmailEmail of product vendor.
VendorPhonePhone of product vendor.
VendorStockStock number from product vendor.
ChildName of child SoftInfo_t nodes.