ECONF_SETVALUE(3)

πŸ’– ECONF_SETVALUE(3) πŸ’–

okay bestie, so this is a page from the libeconf Manual, and it's about the little family of functions that go by the collective name econf_set<type>Value β€” aka the glow-up crew that lets you set a value for a key inside a configuration file object. putting values in configs has never been this cunty, fr fr. πŸŽ€


✨ NAME ✨

econf_set<type>Value β€” set a value for a key in a configuration file object πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <libeconf.h>

econf_err econf_setBoolValue(econf_file *kf, const char *group,
const char *key, bool value);

econf_err econf_setDoubleValue(econf_file *kf, const char *group,
const char *key, double value);

econf_err econf_setFloatValue(econf_file *kf, const char *group,
const char *key, float value);

econf_err econf_setIntValue(econf_file *kf, const char *group,
const char *key, int value);

econf_err econf_setInt64Value(econf_file *kf, const char *group,
const char *key, int64_t value);

econf_err econf_setUInt64Value(econf_file *kf, const char *group,
const char *key, uint64_t value);

econf_err econf_setStringValue(econf_file *kf, const char *group,
const char *key, const char *value);

econf_err econf_setValue(econf_file *kf, const char *group,
const char *key, const char *value);

bestie, that's eight whole functions and every single one of them is your new fav. 🫢


🌸 DESCRIPTION 🌸

So the way this works: these functions set the value of a key inside the given configuration file object kf. you tell it where the key lives with group, and which key it is with key. iconic behaviour, truly.

major tea: if group is NULL, the key is considered to belong to none group. that's it, that's the vibe. no group, no drama.

If the key already exists, its value gets updated β€” like a glow-up in place. and if the key or the group doesn't exist yet? it gets created. not me manifesting new config entries out of thin air ✨

and here's the detail you need: the typed function econf_setBoolValue converts the given value into a string representation before storing it. so it takes your bool and gives it a little string costume before it goes in. πŸ’…


πŸ‘‘ RETURN VALUE πŸ‘‘

when everything's slaying and it all works out, these functions return ECONF_SUCCESS. main character energy only.

but if something goes wrong, you get a non-zero error code back instead (peep the next section, bestie β€” that's the section called β€œERRORS”).


πŸ’€ ERRORS πŸ’€

okay so here's the tea on what can go wrong, and what each little error code means:

  • ECONF_NOMEM β€” not enough memory to allocate the new entry or group. the malloc said "i'm tired" 😭
  • ECONF_FILE_LIST_IS_NULL β€” the conf file list is NULL. literally nothing there. the void. πŸ™ˆ
  • ECONF_EMPTYKEY β€” the key is NULL or has an empty value. we need a name, bestie. 🌸
  • ECONF_NOKEY β€” key not found. it's not giving what it needs to give. πŸ’€
  • ECONF_WRONG_BOOLEAN_VALUE β€” wrong boolean value. the vibes allowed are 1/0 or true/false or yes/no, and you gave it something else entirely. pick one that's actually on the list. 🧚

🌈 SEE ALSO 🌈

libeconf(3), econf_errString(3) πŸ’œ


aaand that's the whole page, bestie!! go set some values, you're gonna absolutely ate this. and just so we're keeping it ✨official✨ β€” this page comes to you from libeconf, dated 2024-12-13, and yes it's still called ECONF_SETVALUE(3) at the top of every page like the icon it is. mwah, love u, bye!! πŸ’–πŸŽ€πŸ’…πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from