ecoli_strvec(3)

πŸ“¦
version 0.11.3 Β· 4 versions
, in epel 9

πŸŽ€ ecoli_strvec β€” string vector, but make it a vibe πŸŽ€

okay so bestie, this is a Libecoli page πŸ’œ β€” ecoli_strvec(3), the string-vector situation. get comfy, we're going through every single thing, no cap.


✨ NAME ✨

ecoli_strvec β€” String vector

  • Helpers for strings vectors manipulation. πŸ’…

🌸 SYNOPSIS 🌸

Macros

#define EC_STRVEC(args...)
#define EC_STRVEC_ATTR_START   'start'
#define EC_STRVEC_ATTR_END   'end'

Enumerations

enum ec_strvec_flag_t { EC_STRVEC_STRICT = 0x1, EC_STRVEC_TRAILSP = 0x2
    }

Functions

struct ec_strvec * ec_strvec (void)
struct ec_strvec * ec_strvec_from_array (const char *const *strarr,
    size_t n)
struct ec_strvec * ec_strvec_sh_lex_str (const char *str,
    ec_strvec_flag_t flags, char *unclosed_quote)
int ec_strvec_set (struct ec_strvec *strvec, size_t idx, const char *s)
int ec_strvec_add (struct ec_strvec *strvec, const char *s)
int ec_strvec_del_last (struct ec_strvec *strvec)
struct ec_strvec * ec_strvec_dup (const struct ec_strvec *strvec)
struct ec_strvec * ec_strvec_ndup (const struct ec_strvec *strvec,
    size_t off, size_t len)
void ec_strvec_free (struct ec_strvec *strvec)
size_t ec_strvec_len (const struct ec_strvec *strvec)
const char * ec_strvec_val (const struct ec_strvec *strvec, size_t idx)
const struct ec_dict * ec_strvec_get_attrs (const struct ec_strvec
    *strvec, size_t idx)
int ec_strvec_set_attrs (struct ec_strvec *strvec, size_t idx, struct
    ec_dict *attrs)
int ec_strvec_cmp (const struct ec_strvec *strvec1, const struct
    ec_strvec *strvec2)
void ec_strvec_sort (struct ec_strvec *strvec, int(*str_cmp)(const char
    *s1, const char *s2))
void ec_strvec_dump (FILE *out, const struct ec_strvec *strvec)

πŸ¦‹ Detailed Description πŸ¦‹

Helpers for strings vectors manipulation. πŸ’–

The ec_strvec API provides helpers to manipulate string vectors. When duplicating vectors, the strings are not duplicated in memory β€” a reference counter is used. (obsessed, honestly. so efficient. ✨)


πŸ‘‘ Macro Definition Documentation πŸ‘‘

#define EC_STRVEC(args...)

Value β€” literally this:

({
    const char *_arr[] = {args};
    ec_strvec_from_array(_arr, EC_COUNT_OF(_arr));
})

Allocate a new string vector. 🫢

The string vector is initialized with the list of const strings passed as arguments.

Returns The new strvec object, or NULL on error (errno is set).

Definition at line 39 of file strvec.h. πŸŽ€

#define EC_STRVEC_ATTR_START 'start'

All elements of the vector returned by ec_strvec_sh_lex_str() have two attributes accessible via ec_strvec_get_attrs(). This one is the start index in the original line passed to ec_strvec_sh_lex_str().

Definition at line 80 of file strvec.h. πŸŽ€

#define EC_STRVEC_ATTR_END 'end'

The end index in the original line passed to ec_strvec_sh_lex_str().

Definition at line 82 of file strvec.h. πŸŽ€


🌈 Enumeration Type Documentation 🌈

enum ec_strvec_flag_t

Options for ec_strvec_sh_lex_str().

Enumerator

  • EC_STRVEC_STRICT β€” fail if a quote is not closed properly, or if the provided string ends with an unterminated escape sequence. πŸ’€ (yeah, it will simply refuse, iconic behavior)
  • EC_STRVEC_TRAILSP β€” if there is trailing white space, add an empty element to the output string vector.

Definition at line 62 of file strvec.h. πŸŽ€


πŸ’œ Function Documentation πŸ’œ

struct ec_strvec* ec_strvec (void)

Allocate a new empty string vector. 🫧

Returns The new strvec object, or NULL on error (errno is set).

struct ec_strvec* ec_strvec_from_array (const char *const * strarr, size_t n)

Allocate a new string vector.

The string vector is initialized with the array of const strings passed as arguments.

Parameters

  • strarr β€” the array of const strings.
  • n β€” the number of strings in the array.

Returns The new strvec object, or NULL on error (errno is set).

struct ec_strvec* ec_strvec_sh_lex_str (const char * str, ec_strvec_flag_t flags, char * unclosed_quote)

Split a string into multiple tokens following basic shell lexing rules. 🐚✨ lowkey the main character of this whole page.

Parameters

  • str β€” the string to split.
  • flags β€” options for controlling behavior.
  • unclosed_quote β€” if not NULL and if the provided string has an unterminated quote. The opening quote will be stored here.

Returns The new strvec object, or NULL on error (errno is set).

int ec_strvec_set (struct ec_strvec * strvec, size_t idx, const char * s)

Set a string in the vector at specified index.

Parameters

  • strvec β€” the pointer to the string vector.
  • idx β€” the index of the string to set.
  • s β€” the string to be set.

Returns 0 on success or -1 on error (errno is set).

int ec_strvec_add (struct ec_strvec * strvec, const char * s)

Add a string in a vector.

Parameters

  • strvec β€” the pointer to the string vector.
  • s β€” the string to be added at the end of the vector.

Returns 0 on success or -1 on error (errno is set).

int ec_strvec_del_last (struct ec_strvec * strvec)

Delete the last entry in the string vector. bye bestie πŸ‘‹

Parameters

  • strvec β€” the pointer to the string vector.

Returns 0 on success or -1 on error (errno is set).

struct ec_strvec* ec_strvec_dup (const struct ec_strvec * strvec)

Duplicate a string vector.

Attributes are duplicated if any. πŸŽ€

Parameters

  • strvec β€” the pointer to the string vector.

Returns The duplicated strvec object, or NULL on error (errno is set).

struct ec_strvec* ec_strvec_ndup (const struct ec_strvec * strvec, size_t off, size_t len)

Duplicate a part of a string vector. βœ‚οΈ

Attributes are duplicated if any.

Parameters

  • strvec β€” the pointer to the string vector.
  • off β€” the index of the first string to duplicate.
  • len β€” the number of strings to duplicate.

Returns The duplicated strvec object, or NULL on error (errno is set).

void ec_strvec_free (struct ec_strvec * strvec)

Free a string vector. πŸ—‘οΈβœ¨

Parameters

  • strvec β€” the pointer to the string vector.

size_t ec_strvec_len (const struct ec_strvec * strvec)

Get the length of a string vector.

Parameters

  • strvec β€” the pointer to the string vector.

Returns The length of the vector.

const char* ec_strvec_val (const struct ec_strvec * strvec, size_t idx)

Get a string element from a vector.

Parameters

  • strvec β€” the pointer to the string vector.
  • idx β€” the index of the string to get.

Returns The string stored at given index, or NULL on error (strvec is NULL or invalid index).

const struct ec_dict* ec_strvec_get_attrs (const struct ec_strvec * strvec, size_t idx)

Get the attributes of a vector element.

Parameters

  • strvec β€” the pointer to the string vector.
  • idx β€” the index of the string to get.

Returns The read-only attributes (dictionary) of the string at specified index, or NULL if there is no attribute.

int ec_strvec_set_attrs (struct ec_strvec * strvec, size_t idx, struct ec_dict * attrs)

Set the attributes of a vector element.

Parameters

  • strvec β€” the pointer to the string vector.
  • idx β€” the index of the string to get.
  • attrs β€” the attributes to be set.

Returns 0 on success, -1 on error (errno is set).

⚠️ bestie listen β€” on error, attrs are freed and must not be used by the caller. like, do not touch them. dead. πŸ’€

int ec_strvec_cmp (const struct ec_strvec * strvec1, const struct ec_strvec * strvec2)

Compare two string vectors. πŸ†š

Parameters

  • strvec1 β€” the pointer to the first string vector.
  • strvec2 β€” the pointer to the second string vector.

Returns 0 if the string vectors are equal.

void ec_strvec_sort (struct ec_strvec * strvec, int(*)(const char *s1, const char *s2) str_cmp)

Sort the string vector. πŸ“šβœ¨

Attributes are not compared.

Parameters

  • strvec β€” the pointer to the first string vector.
  • str_cmp β€” the sort function to use. If NULL, use strcmp.

void ec_strvec_dump (FILE * out, const struct ec_strvec * strvec)

Dump a string vector. πŸͺ£

Parameters

  • out β€” the stream where the dump is sent.
  • strvec β€” the pointer to the string vector.

⭐ Author ⭐

Generated automatically by Doxygen for Libecoli from the source code.


aaaand that's the whole page, you ate that fr fr πŸ’…βœ¨

Version 0.11.3 β€” Thu Apr 9 2026 β€” Libecoli πŸ¦‹πŸŽ€πŸ’–

now go forth and manipulate those string vectors, bestie 🫢

πŸ“¦ where this page comes from