The following table specifies all the standard functions which are built into SDL.
Table 22.2. Standard Functions
| Syntax | Return Value | Description | |
|---|---|---|---|
| CmdClose(Cmd_t $Handle) | Close a Cmd_t handle. | ||
| ArrayLen(Array_t $Array) | Number_t | Return the number of members in array $Array. | |
| CmdOpen(String_t $Command, String_t $Args, String $Opts) | Cmd_t | Open 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_t | Read one line of output from the command handle $Handle. | |
| DataTreeGetIndex(DataTree_t $Data, Number_t $Index) | DataTree_t | Get the DataTree_t at offset $Index from $Data. | |
| DataTreeGetTree(DataTree_t $Data, String_t $Path, String_t $Attr, String_t $Opts) | DataTree_t | Search 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_t | Search through data tree $Data for attribute matching $Attr. | |
| DataTreeGetKeys(DataTree_t $Data) | Array_t | Return an Array of Key values for each member of $Data and it's peer nodes. Does not descend. | |
| DataTreeGetValues(DataTree_t $Data) | Array_t | Return 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_t | Open 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_t | Read one line of output from the file handle $Handle. | |
| FileSize(String_t $File) | Number_t | Get the size of file $File in bytes. | |
| GetEnv(String_t $Var) | String_t | Get an environment variable $Var and return it's value. | |
| GetGrEnt(String_t $Name) | String_t | Look 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_t | Look 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_t | Get the base (file) name of $Path. | |
| PathDirName(String_t $Path) | String_t | Get the directory name of $Path. | |
| PathExists(String_t $Path, String_t $Type) | Boolean_t | If $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_t | Find 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_t | Look 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_t | Create 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_t | Find 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_t | Clean $String by removing quote characters. | |
| StrCopy(String_t $String) | String_t | Make a copy of $String and return the new copy value. | |
| StrEdit(String_t $Pattern, String_t $String, String_t $Replace, String_t $Options) | String_t | Replace 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_t | Return the number of characters in $String. | |
| StrMatch(String_t $String1, String_t $String2) | Boolean_t | If strings $String1 and $String2 exactly match (case sensitive), then return True. | |
| StrMatchN(String_t $String1, String_t $String2, Number_t $NumChars) | Boolean_t | If strings $String1 and $String2 match (case sensitive) in the first $NumChars characters, then return True. | |
| StrMatchCase(String_t $String1, String_t $String2) | Boolean_t | If strings $String1 and $String2 exactly match (case in-sensitive), then return True. | |
| StrMatchCaseN(String_t $String1, String_t $String2, Number_t $NumChars) | Boolean_t | If strings $String1 and $String2 match (case in-sensitive) in the first $NumChars characters, then return True. | |
| StrProductMakeName(String_t $Title) | String_t | Convert a string $Title like "Acme Widget" into a proper product name like "acme-widget". | |
| StrRegExMatch(String_t $String, String_t $Pattern) | Boolean_t | If string $String matches regular expression $Pattern, then return True. | |
| StrSplit(String_t $SepStr, String_t $String) | Array_t | Split 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_t | Open an XML file $File and return a handle to it's contents. | |
| XmlGetAll(XmlHandle_t $Handle, String_t $Path, String_t $Attr) | Array_t | Get 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
| Key | Description |
|---|---|
| EntryType | The type of entry either "pkg" or "product". |
| Name | The short, unique name of the product. |
| Version | The version of the product. |
| Revision | The revision of the product. |
| Desc | The short, one-line summary description. |
| DescVerbose | The verbose, possibly multi-line description. |
| URL | Product URL. |
| URLhelp | The product help URL. |
| URLupdate | The product update URL. |
| License | The license of the product. |
| Copyright | The product copyright notice. |
| Category | The category the product belongs to. |
| SubCategory | The sub-category the product belongs to. |
| OSname | The OS name the product requires. |
| OSversion | The OS version the product requires. |
| Arch | The hardware architecture the product requires. |
| ISArch | The instruction set architecture the product requires. |
| InstDate | Installation date. |
| BuildDate | Build date. |
| ProdStamp | Production stamp. |
| BaseDir | Base directory where product is installed. |
| PkgDeps | Package dependencies. |
| DiskUsage | The disk usage the product consumes in bytes. |
| VendorName | Name of product vendor. |
| VendorEmail | Email of product vendor. |
| VendorPhone | Phone of product vendor. |
| VendorStock | Stock number from product vendor. |
| Child | Name of child SoftInfo_t nodes. |