Tail queue of strings

Overview

Definition of API for working with tail queue of strings. More…

// typedefs

typedef struct tqe_string tqe_string;

// structs

struct tqe_string;

// global functions

typedef TAILQ_HEAD(tqh_strings, tqe_string);
void tq_strings_free(tqh_strings* head, void(*)(void*) value_free);
bool tq_strings_equal(const tqh_strings* s1, const tqh_strings* s2);
te_errno tq_strings_add_uniq_gen(tqh_strings* list, const char* value, bool duplicate);
te_errno tq_strings_add_uniq(tqh_strings* list, const char* value);
te_errno tq_strings_add_uniq_dup(tqh_strings* list, const char* value);
te_errno tq_strings_move(tqh_strings* dst, tqh_strings* src);
te_errno tq_strings_copy(tqh_strings* dst, const tqh_strings* src);
te_errno tq_strings_shallow_copy(tqh_strings* dst, const tqh_strings* src);

Detailed Documentation

Definition of API for working with tail queue of strings.

Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved.

Typedefs

typedef struct tqe_string tqe_string

Element of the list of strings

Global Functions

typedef TAILQ_HEAD(tqh_strings, tqe_string)

Head of the list of strings

void tq_strings_free(tqh_strings* head, void(*)(void*) value_free)

Free list of allocated strings.

Parameters:

head

Head of the list

value_free

Function to be called to free value or NULL

bool tq_strings_equal(const tqh_strings* s1, const tqh_strings* s2)

Compare two tail queue of strings. Queues are equal, if each element of the first queue is equal to the corresponding element of the second queue.

c true Equal c false Not equal

Parameters:

s1

The first tail queue

s2

te_errno tq_strings_add_uniq_gen(tqh_strings* list, const char* value, bool duplicate)

Add a new string into the list, if no such string is already present there.

Bug The return type of the function is actually boolean.

Parameters:

list

Head of the list

value

A new string to add

duplicate

Whether to duplicate string or not

Returns:

0 if string was added 1 if string was already presented

te_errno tq_strings_add_uniq(tqh_strings* list, const char* value)

Add a new string into the list, if no such string is already present there. String value is not duplicated.

Bug The return type of the function is actually boolean.

Parameters:

list

Head of the list

value

A new string to add

Returns:

0 if string was added 1 if string was already presented

te_errno tq_strings_add_uniq_dup(tqh_strings* list, const char* value)

Add a new string into the list, if no such string is already present there. String value is duplicated.

Bug The return type of the function is actually boolean.

Parameters:

list

Head of the list

value

A new string to add

Returns:

0 if string was added 1 if string was already presented

te_errno tq_strings_move(tqh_strings* dst, tqh_strings* src)

Move values from source queue to destination queue.

Parameters:

dst

Destination queue

src

Source queue

Returns:

Status code.

te_errno tq_strings_copy(tqh_strings* dst, const tqh_strings* src)

Copy values from source queue to destination queue.

Parameters:

dst

Destination queue

src

Source queue

Returns:

Status code.

te_errno tq_strings_shallow_copy(tqh_strings* dst, const tqh_strings* src)

Copy members from source queue to destination queue but let copied members to point to the same strings.

Parameters:

dst

Destination queue

src

Source queue

Returns:

Status code.