61 lines
2.2 KiB
C
61 lines
2.2 KiB
C
/*
|
|
* This file is part of corelibs. (https://git.redxen.eu/corelibs)
|
|
* Copyright (c) 2021 Alex-David Denes
|
|
*
|
|
* corelibs is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* any later version.
|
|
*
|
|
* corelibs is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with corelibs. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <stdint.h> // uintmax_t
|
|
|
|
#ifndef CORELIBS_GUARD_LLIST
|
|
#define CORELIBS_GUARD_LLIST
|
|
|
|
typedef struct cl_llist_t cl_llist_t;
|
|
typedef signed short int cl_llist_err;
|
|
|
|
struct corelibs_llist_interface {
|
|
cl_llist_err (*const create)(void* content, void (*const free_function)(void*), cl_llist_t** save);
|
|
cl_llist_err (*const link)(uintmax_t elements, ...);
|
|
cl_llist_err (*const rep)(cl_llist_t* dest, cl_llist_t* src);
|
|
const struct {
|
|
cl_llist_err (*const list)(cl_llist_t* element);
|
|
cl_llist_err (*const elem)(cl_llist_t* element);
|
|
} free;
|
|
const struct {
|
|
cl_llist_err (*const cont)(cl_llist_t* element, void* content);
|
|
cl_llist_err (*const free)(cl_llist_t* element, void (*const free_function)(void*));
|
|
} set;
|
|
const struct {
|
|
cl_llist_err (*const prev)(const cl_llist_t* element, cl_llist_t** save);
|
|
cl_llist_err (*const next)(const cl_llist_t* element, cl_llist_t** save);
|
|
cl_llist_err (*const cont)(const cl_llist_t* element, void** save);
|
|
} get;
|
|
const struct {
|
|
const cl_llist_err ok, // No error
|
|
unknown, // Unknown error
|
|
undef; // Fetched element is undefined
|
|
const struct {
|
|
const cl_llist_err null, // NULL address was passed
|
|
alloc; // Allocation failed
|
|
} mem;
|
|
const struct {
|
|
const cl_llist_err mis; // Missing arguments / Not enough arguments
|
|
} args;
|
|
} err;
|
|
};
|
|
extern const struct corelibs_llist_interface cl_llist;
|
|
|
|
#endif /* CORELIBS_GUARD_LLIST */
|
|
|