Elektra  0.9.4
Ensure

Applications want to ensure that some functionality (=global plugin) is present in Elektra.

Integrate kdbEnsure in kdbOpen(Key *errorKey, KeySet *contract) but only allow global plugins.

elektraNotificationOpen will only return a contract KeySet:

KeySet * contract = ksNew (0, KS_END);
elektraNotificationContract (contract, iobinding);

The same for gopts:

elektraGOptsContract (contract, argc, argv, environ);

Finally, we create KDB with the contracts we got before:

KDB * kdb = kdbOpen (key, contract);

Opening KDB will fail if any of the contracts cannot be ensured.

As the contract gets copied, at any point after kdbOpen the contract can be safely deleted:

ksDel (contract);

The cleanup of the global plugins happens within:

kdbClose (kdb, errorKey);

It is safe to use the contract KeySet also for kdbGet and kdbSet invocations.