RC_STRLIST(3)

πŸ’– RC_STRLIST πŸ’–

okay bestie, so this is RC_STRLIST(3) from the System Manager's Manual β€” it's the string list page and it's lowkey the backbone of like everything in OpenRC, no cap. let's get into it 🫢


✨ NAME ✨

rc_stringlist_add, rc_stringlist_addu, rc_stringlist_delete, rc_stringlist_free, rc_stringlist_new, rc_stringlist_sort β€” the RC string list functions. that's the whole squad, they ride together πŸ’…


πŸ“š LIBRARY πŸ“š

Run Command library (librc, -lrc)

like. that's the library. that's it. link it and you're in πŸŽ€


🌸 SYNOPSIS 🌸

#include <rc.h>

RC_STRINGLIST *
rc_stringlist_new(void);

RC_STRING *
rc_stringlist_add(RC_STRINGLIST *list, const char *item);

RC_STRING *
rc_stringlist_addu(RC_STRINGLIST *list, const char *item);

bool
rc_stringlist_delete(RC_STRINGLIST, const char *item);

void
rc_stringlist_free(RC_STRINGLIST *list);

void
rc_stringlist_sort(RC_STRINGLIST *list);

copy it exactly bestie, don't freestyle the signatures, i'm begging πŸ™ˆ


πŸ¦‹ DESCRIPTION πŸ¦‹

so these functions are your little helpers for wrangling string lists. and when i say little helpers, i mean they're basically wrappers around the TAILQ macros from queue(3). iconic behavior honestly β€” why reinvent the wheel when the wheel is already slaying πŸ’€

Here's the whole roster, one by one:

  • rc_stringlist_new() β€” makes you a brand new list head to store the list in. it's giving fresh start, main character energy ✨
  • rc_stringlist_add() β€” adds a malloced copy of item to list. returns a pointer to the new item when it goes well, or NULL if it doesn't, and sets errno accordingly. so like, check your return values, bestie, please 😭
  • rc_stringlist_addu() β€” same vibe as above but it only works if list does not already contain item. it's the picky one. it's got standards. we respect it.
  • rc_stringlist_delete() β€” removes and frees item from list, returning true on success, otherwise false. cute and destructive πŸ’…
  • rc_stringlist_sort() β€” sorts the list according to C locale. not your locale, not your friend's locale, the C one. periodt.
  • rc_stringlist_free() β€” frees every single item on list and then the list itself. it's the closer. it takes everything with it. no survivors 🫢

πŸ‘€ SEE ALSO πŸ‘€

malloc(3), free(3), queue(3), strcmp(3)

go read those too, iykyk πŸ“–


πŸ‘‘ AUTHORS πŸ‘‘

Roy Marples <roy@marples.name> β€” the legend themselves, we love and appreciate πŸ₯°


okay that's the page!! this one came out of the OpenRC crew and it's dated Mar 16, 2008 β€” yes it's old, it's vintage, it's still serving πŸ’– go sort some strings bestie, you got this 🌈⭐

πŸ“¦ where this page comes from