.TH "md_src_plugins_ccode_README" 3elektra "Tue Aug 6 2019" "Version 0.9.0" "Elektra" \" -*- nroff -*- .ad l .nh .SH NAME md_src_plugins_ccode_READMEPlugin: ccode \- .IP "\(bu" 2 infos = Information about ccode plugin is in keys below .IP "\(bu" 2 infos/author = Markus Raab elektra@libelektra.org .IP "\(bu" 2 infos/licence = BSD .IP "\(bu" 2 infos/provides = code .IP "\(bu" 2 infos/needs = .IP "\(bu" 2 infos/recommends = .IP "\(bu" 2 infos/placements = postgetstorage presetstorage .IP "\(bu" 2 infos/status = maintained unittest nodep libc configurable .IP "\(bu" 2 infos/description = Decoding/Encoding engine which escapes unwanted characters\&. .PP .SH "CCode" .PP .SS "Introduction" .PP The \fCccode\fP plugin replaces (escapes) any special characters with two characters: .PP .IP "\(bu" 2 an escape character (default: \fC\\\fP) and .IP "\(bu" 2 another character representing the escaped character (e\&.g \fCn\fP for newline) .PP .PP before writing a \fCKeySet\fP\&. The plugin undoes this modification after reading a \fCKeySet\fP\&. .PP CCode provides a reasonable default configuration, using the usual escape sequences for C strings (e\&.g\&. \fC\\n\fP for newline, \fC\\t\fP for tab)\&. You can also configure the escape character (\fC/escape\fP) and the mapping for special characters (\fCchars\fP)\&. .PP .SS "Examples" .PP .SS "Default Configuration" .PP .PP .nf # Mount `tcl` storage plugin together with the required `base64` plugin\&. # We use the `ccode` plugin to escape special characters\&. sudo kdb mount config\&.tcl user/tests/ccode tcl ccode base64 # Add a key value containing newline characters kdb set user/tests/ccode/multiline "`printf 'one\ntwo\nthree'`" # By default the plugin uses `\n` to escape newline characters grep 'multiline' `kdb file user/tests/ccode` | sed 's/[[:space:]]*//' #> multiline = one\ntwo\nthree # The `ccode` plugin escapes and unescapes the data\&. The `tcl` plugin # returns the unescaped values\&. kdb get user/tests/ccode/multiline #> one #> two #> three # Write and read a key value containing a tab character kdb set user/tests/ccode/tab 'Tab Fabulous' kdb get user/tests/ccode/tab #> Tab Fabulous # The plugin also escapes special characters inside key names kdb set 'user/tests/ccode/tab/t\ta b' 'Escaped Tabs' grep 'tab/' `kdb file user/tests/ccode` | sed 's/[[:space:]]*//' #> tab/t\\ta\tb = Escaped Tabs # Undo modifications to database kdb rm -r user/tests/ccode sudo kdb umount user/tests/ccode .fi .PP .PP .SS "Custom Configuration" .PP ``\fC