
\begin{DoxyItemize}
\item infos = Information about glob plugin is in keys below
\item infos/author = Felix Berlakovich \href{mailto:elektra@berlakovich.net}{\texttt{ elektra@berlakovich.\+net}}
\item infos/licence = BSD
\item infos/provides = apply
\item infos/needs =
\item infos/recommends =
\item infos/ordering = check keytometa
\item infos/stacking = no
\item infos/placements = presetstorage postgetstorage
\item infos/status = unittest nodep libc configurable difficult
\item infos/description = copies metadata to keys with the help of globbing
\end{DoxyItemize}\hypertarget{md_src_plugins_glob_README_src_plugins_glob_README_md}{}\doxysection{Introduction}\label{md_src_plugins_glob_README_src_plugins_glob_README_md}
The glob plugin provides coping metadata given by the plugin\textquotesingle{}s configuration to keys identified using {\itshape glob expressions}. Globbing resembles regular expressions. They do not have the same expressive power, but are easier to use. The semantics are more suitable to match path names\+:


\begin{DoxyItemize}
\item {\ttfamily $\ast$} matches any key name of just one hierarchy. This means it complies with any character except slash or null.
\item {\ttfamily ?} satisfies single characters with the same exclusions.
\item Additionally, there are ranges and character classes. They can also be inverted.
\end{DoxyItemize}

So this plugin adds metadata to keys identified by globbing expressions. The plugin copies the metadata of the corresponding globbing keys in its configuration. Globbing can be applied in get and set direction or both.\hypertarget{md_src_plugins_glob_README_autotoc_md233}{}\doxysection{Globbing Keys}\label{md_src_plugins_glob_README_autotoc_md233}
The plugin is configured with globbing keys in its configuration. Each key below the configuration is interpreted as a globbing key. The value of the key contains the globbing expression. When a key matching the glob expression contained in one of the globbing keys is found, the metakeys of the corresponding globbing key are copied. Once a match is found, no further keys will be considered for globbing. The reason for this are catch all globbing keys that can be used to match all keys that have not been matched by a preceding globbing key.\hypertarget{md_src_plugins_glob_README_autotoc_md234}{}\doxysubsection{Globbing Direction}\label{md_src_plugins_glob_README_autotoc_md234}
Globbing keys located directly below the configuration (e.\+g {\ttfamily config/glob/\#1}) are applied in both directions (get and set). Keys below \char`\"{}get\char`\"{} (e.\+g. {\ttfamily config/glob/get/\#1}) are applied only in the get direction and keys below set (e.\+g. {\ttfamily config/glob/set/\#1}) are applied only in the set direction.

So the glob plugin iterates over a list of glob expressions for every key. Metadata is applied only for the first expression that matches. So later expressions can be used as default values.\hypertarget{md_src_plugins_glob_README_autotoc_md235}{}\doxysubsection{Globbing Flags}\label{md_src_plugins_glob_README_autotoc_md235}
Globbing keys may contain a subkey named \char`\"{}flags\char`\"{}. This optional key contains the flags to be passed to the globbing function (currently fnmatch) as a comma separated list. Unknown flag names will be ignored. The allowed flag names are


\begin{DoxyItemize}
\item \char`\"{}noescape\char`\"{} which enables the FNM\+\_\+\+NOESCAPE flag
\item \char`\"{}pathname\char`\"{} which enables the FNM\+\_\+\+PATHNAME flag
\item \char`\"{}period\char`\"{} which enables the FNM\+\_\+\+PERIOD flag
\end{DoxyItemize}

If the flag key does not exist, FNM\+\_\+\+PATHNAME is used as a default (see fnmatch(3) for more details). An empty string disables all flags (i.\+e. also the default flag).\hypertarget{md_src_plugins_glob_README_autotoc_md236}{}\doxysection{Contracts}\label{md_src_plugins_glob_README_autotoc_md236}
Glob statements are very useful together with contracts. Storage plugins can request the glob plugin to fill up metadata before they receive the keys in {\ttfamily elektra\+Plugin\+Set()}. In {\ttfamily config/needs}, the plugin declares which keys should obtain which metadata. If the glob expression starts with a slash, the contract checker will automatically prepend the mount point.

For example, the hosts plugin contract contained\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{\mbox{\hyperlink{group__keyset_ga671e1aaee3ae9dc13b4834a4ddbd2c3c}{ksNew}} (30,}
\DoxyCodeLine{  \textcolor{comment}{// …}}
\DoxyCodeLine{  \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}system:/elektra/modules/hosts/config/needs/glob/\#1"{}},}
\DoxyCodeLine{      \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}/*"{}},}
\DoxyCodeLine{      \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}{KEY\_META}}, \textcolor{stringliteral}{"{}check/ipaddr"{}}, \textcolor{stringliteral}{"{}"{}}, \textcolor{comment}{/* Preferred way to check */}}
\DoxyCodeLine{          \textcolor{comment}{/* Can be checked additionally */}}
\DoxyCodeLine{      \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}{KEY\_META}}, \textcolor{stringliteral}{"{}check/validation"{}}, \textcolor{stringliteral}{"{}\string^[0-\/9.:]+\$"{}},}
\DoxyCodeLine{      \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}{KEY\_META}}, \textcolor{stringliteral}{"{}check/validation/message"{}},}
\DoxyCodeLine{          \textcolor{stringliteral}{"{}Character present not suitable for ip address"{}},}
\DoxyCodeLine{      \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{  \mbox{\hyperlink{group__key_gad23c65b44bf48d773759e1f9a4d43b89}{keyNew}} (\textcolor{stringliteral}{"{}system:/elektra/modules/hosts/config/needs/glob/\#2"{}},}
\DoxyCodeLine{      \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8ac66e4a49d09212b79f5754ca6db5bd2e}{KEY\_VALUE}}, \textcolor{stringliteral}{"{}/*/*"{}},}
\DoxyCodeLine{          \textcolor{comment}{/* Strict character validation */}}
\DoxyCodeLine{      \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}{KEY\_META}}, \textcolor{stringliteral}{"{}check/validation"{}}, \textcolor{stringliteral}{"{}\string^[0-\/9a-\/zA-\/Z.:]+\$"{}},}
\DoxyCodeLine{      \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8a040582834bb2d90049947d7ef74e87e2}{KEY\_META}}, \textcolor{stringliteral}{"{}check/validation/message"{}},}
\DoxyCodeLine{          \textcolor{stringliteral}{"{}Character present not suitable for host address"{}},}
\DoxyCodeLine{      \mbox{\hyperlink{group__key_gga9b703ca49f48b482def322b77d3e6bc8aa8adb6fcb92dec58fb19410eacfdd403}{KEY\_END}}),}
\DoxyCodeLine{  \textcolor{comment}{// …}}
\DoxyCodeLine{);}

\end{DoxyCode}


We see that the {\ttfamily hosts} plugin added two glob statements with the clause {\ttfamily config/needs}. The first one matches with hostnames, the second with aliases.

The glob plugin only fills the metadata in {\ttfamily \mbox{\hyperlink{group__kdb_ga11436b058408f83d303ca5e996832bcf}{kdb\+Set()}}}. This makes a difference compared with adding the metadata already in {\ttfamily \mbox{\hyperlink{group__kdb_ga28e385fd9cb7ccfe0b2f1ed2f62453a1}{kdb\+Get()}}}. Using the glob plugin, the user will not see the metadata, but later plugins in {\ttfamily \mbox{\hyperlink{group__kdb_ga11436b058408f83d303ca5e996832bcf}{kdb\+Set()}}} will.

To sum up, the glob plugin replenishes the keys with metadata. The plugin applies metadata in a flexible way. This metadata can be used for later checks. Limited configuration storage plugins, like the {\ttfamily hosts} plugin, use this feature. They need it because they are not able to store metadata themselves. It is obviously not possible to apply values to non-\/existing keys. 