Function string_replace_if_exists

Source
pub unsafe extern "C" fn string_replace_if_exists(
    string: *mut c_char,
    ...
) -> *mut c_char
Expand description

Items {key} are replaced by the value if {key} is passed as key/value pair, otherwise removed from string. If the {key} is in between [] all the text between [] are removed if {key} is not found. Otherwise key is replaced and & removed.

This allows for optional replacement, e.g. {ssh-client} [-t {title}] -e "{cmd}" the -t {title} is only there if {title} is set.

Returns a new string with the keys replaced.

  • string: The string with elements to be replaced.
  • ...: Set of {key}, value that will be replaced, terminated by a null.