#include <unistd.h>#include <ctype.h>#include <stdio.h>#include <regex.h>#include <libintl.h>#include <iostream>#include <string>#include "ycp/YCPBuiltinString.h"#include "ycp/YCPString.h"#include "ycp/YCPInteger.h"#include "ycp/YCPPath.h"#include "ycp/YCPSymbol.h"#include "ycp/YCPBoolean.h"#include "ycp/YCPVoid.h"#include "ycp/y2log.h"#include "y2string.h"#include "y2crypt.h"#include "ycp/StaticDeclaration.h"| #define _GNU_SOURCE |
| #define _XOPEN_SOURCE |
| #define ERR_MAX 80 |
| #define SUB_MAX 10 |
crypt Encrypts a string Encrypts the string UNENCRYPTED using the standard password encryption provided by the system.
| string | UNENCRYPTED |
cryptbigcrypt Encrypts a string using bigcrypt Encrypts the string UNENCRYPTED using bigcrypt password encryption. The password is not truncated.
| string | UNENCRYPTED |
cryptblowfish Encrypts a string with blowfish Encrypts the string UNENCRYPTED using blowfish password encryption. The password is not truncated.
| string | UNENCRYPTED |
cryptmd5 Encrypts a string using md5 Encrypts the string UNENCRYPTED using MD5 password encryption.
| string | UNENCRYPTED |
_(string text) -> string Translates the text using the current textdomain.
Example
_("File") -> "Soubor"
dgettext Translates the text using the given text domain Translates the text using the given text domain into the current language.
This is a special case builtin not intended for general use. See _() instead.
| string | textdomain | |
| string | text |
| static YCPValue s_dngettext | ( | const YCPString & | domain, | |
| const YCPString & | singular, | |||
| const YCPString & | plural, | |||
| const YCPInteger & | count | |||
| ) | [static] |
_(string singular, string plural, integer value) -> string Translates the text using a locale-aware plural form handling and the current textdomain. The chosen form of the translation depends on the value.
Example
_("%1 File", "%1 Files", 2) -> "%1 soubory"
dngettext Translates the text using a locale-aware plural form handling Translates the text using a locale-aware plural form handling using the given textdomain.
The chosen form of the translation depend on the value.
This is a special case builtin not intended for general use. See _() instead.
| string | textdomain | |
| string | singular | |
| string | plural | |
| integer | value |
filterchars Filters characters out of a String
| string | STRING | |
| string | CHARS chars to be included |
STRING by removing all characters that do not occur in CHARS.
find Returns position of a substring
| string | STRING1 String | |
| string | STRING2 Substring |
The find function searches string for the first occurency of a specified substring (possibly a single character) and returns its starting position.
Returns the first position in STRING1 where the string STRING2 is contained in STRING1. OFFSET starts with 0.
findfirstnotof
search find ("abcdefghi", "efg") -> 4 find ("aaaaa", "z") -> -1
findfirstnotof Searches string for the first non matching chars
| string | STRING | |
| string | CHARS |
findfirstnotof function searches the first element of string that doesn't match any character stored in chars and returns its position.
STRING that is not contained in CHARS.find findfirstnotof ("abcdefghi", "abcefghi") -> 3 findfirstnotof ("aaaaa", "a") -> nil
findfirstof Finds position of the first matching characters in string
| string | STRING | |
| string | CHARS Characters to find |
findfirstof function searches string for the first match of any character stored in chars and returns its position.If no match is found findfirstof returns `nil'.
STRING that is contained in CHARS.find findfirstof ("abcdefghi", "cxdv") -> 2 findfirstof ("aaaaa", "z") -> nil
findlastnotof Searches the last element of string that doesn't match
| string | STRING | |
| string | CHARS Characters The `findlastnotof' function searches the last element of string that doesn't match any character stored in chars and returns its position. |
STRING that is NOT contained in CHARS.
findlastof Searches string for the last match The `findlastof' function searches string for the last match of any character stored in chars and returns its position.
| string | STRING String | |
| string | CHARS Characters to find |
STRING that is contained in CHARS.
issubstring searches for a specific string within another string
| string | s String to be searched | |
| string | substring Pattern to be searched for |
substring is a substring of s.
mergestring Joins list elements with a string
| list<string> | PIECES A List of strings | |
| string | GLUE |
List elements which are not of type strings are ignored.
string s1 + string s2 -> string Returns concatenation of s1 and s2.
Example:
"YaST" + "2" -> "YaST2"
| static YCPValue s_plus2 | ( | const YCPString & | s1, | |
| const YCPInteger & | i2 | |||
| ) | [static] |
string s1 + integer i2 -> string String and integer Concatenation
Returns concatenation of s1 and i2 after transforming i2 to a string.
Example:
"YaST" + 2 -> "YaST2"
string s1 + path p2 -> string String and path Concatenation Returns concatenation of s1 and p2 after transforming p2 to a string.
Example: "YaST" + .two -> "YaST.two"
string s1 + symbol s2 -> string String and symbol Concatenation
Returns concatenation of s1 and s2 after transforming s2 to a string AND stripping the leading backquote.
Example: "YaST" + `two -> "YaSTtwo"
regexpmatch
Searches a string for a POSIX Extended Regular Expression match.
| string | INPUT | |
| string | PATTERN |
regexppos Returns a pair with position and length of the first match.
| string | INPUT | |
| string | PATTERN |
| static YCPValue s_regexpsub | ( | const YCPString & | i, | |
| const YCPString & | p, | |||
| const YCPString & | m | |||
| ) | [static] |
regexpsub Regex Substitution
| string | INPUT | |
| string | PATTERN | |
| string | OUTPUT |
regexptokenize Regex tokenize
| string | INPUT | |
| string | PATTERN |
If the pattern is invalid, 'nil' is returned.
Examples: // e == [ "aaabbB" ] list e = regexptokenize ("aaabbBb", "(.*[A-Z]).*");
// h == [ "aaab", "bb" ] list h = regexptokenize ("aaabbb", "(.*ab)(.*)");
// h == [] list h = regexptokenize ("aaabbb", "(.*ba).*");
// h == nil list h = regexptokenize ("aaabbb", "(.*ba).*(");
deletechars
Removes all characters from a string
| string | STRING | |
| string | REMOVE Characters to be removed from STRING |
STRING by removing all characters that occur in string REMOVE.
search Returns position of a substring
| string | STRING1 String | |
| string | STRING2 Substring |
The search function searches string for the first occurency of a specified substring (possibly a single character) and returns its starting position.
Returns the first position in STRING1 where the string STRING2 is contained in STRING1. OFFSET starts with 0.
findfirstnotof
find search ("abcdefghi", "efg") -> 4 search ("aaaaa", "z") -> nil
size Returns the number of characters of the string s
| string | s String |
ssize("size") -> 4
| static YCPValue s_substring1 | ( | const YCPString & | s, | |
| const YCPInteger & | i1 | |||
| ) | [static] |
substring substring_1 Returns part of a string
| string | STRING Original String | |
| integer | OFFSET Start position integer LENGTH Length of new string |
STRING specified by the OFFSET and LENGHT parameters. OFFSET starts with 0.substring ("some text", 5) -> "text" substring ("some text", 42) -> "" substring ("some text", 5, 2) -> "te" substring ("some text", 42, 2) -> "" substring("123456789", 2, 3) -> "345"
| static YCPValue s_substring2 | ( | const YCPString & | s, | |
| const YCPInteger & | i1, | |||
| const YCPInteger & | i2 | |||
| ) | [static] |
substring substring_2 Extracts a substring
Extracts a substring of the string STRING, starting at OFFSET after the first one with length of at most LENGTH. OFFSET starts with 0.
| string | STRING | |
| integer | OFFSET | |
| integer | LENGTH |
| static YCPValue s_timestring | ( | const YCPString & | fmt, | |
| const YCPInteger & | time, | |||
| const YCPBoolean & | utc_flag | |||
| ) | [static] |
timestring Returns time string Combination of standard libc functions gmtime or localtime and strftime.
| string | FORMAT | |
| integer | TIME | |
| boolean | UTC |
toascii Returns characters below 0x7F included in STRING
| string | STRING |
STRING by copying each character that is below 0x7F (127).toascii ("aBë") -> "aB" toascii ("123+-abcABCöëä") -> "123+-abcABC"
| static YCPValue s_tohexstring | ( | const YCPInteger & | i | ) | [static] |
tohexstring Converts an integer to a hexadecimal string.
| integer | number Number |
tohexstring (31) -> "0x1f"
tolower Makes a string lowercase
| string | s String |
tolower ("aBcDeF") -> "abcdef" tolower ("ABCÁÄÖČ") -> "abcÁÄÖČ"
tostring Converts a value to a string.
| any | VALUE |
toupper Makes a string uppercase
Returns string with all alphabetic characters converted to uppercase.
| Reg_Ret solve_regular_expression | ( | const char * | input, | |
| const char * | pattern, | |||
| const char * | result | |||
| ) |
1.5.3