blob: dcc6763eeb8de546d6535c1415028457aac7995b (
plain) (
tree)
|
|
/* cklist.h - List data structure for ck -------------------------------*- C -*-
*
* This file is part of ck, the config keeper
*
* -----------------------------------------------------------------------------
*
* Copyright (C) 2018 Anastasis Grammenos
* GPLv3 (see LICENCE for the full notice)
*
* -----------------------------------------------------------------------------
*
* Data structure to hold a dynamic list of strings used accross ck.
*
* -------------------------------------------------------------------------- */
#ifndef CKLIST_H
#define CKLIST_H
typedef struct cklist_st cklist;
struct cklist_st {
unsigned int size;
unsigned int pos;
char **arr;
};
extern cklist* list_make_new();
extern void list_add(cklist *ckl, const char *str);
extern cklist* list_make_and_add(const char *str);
extern void list_rewind(cklist *ckl);
extern int list_next(cklist *ckl);
extern char* list_get(cklist *ckl);
extern char* list_get_at(cklist *ckl,unsigned int pos);
extern unsigned int list_size(cklist *ckl);
/* rewinds */
extern cklist* list_duplicate(cklist *ckl);
/* rewinds */
extern cklist* list_move(cklist *ckl);
/* rewinds
* copy from index (>=) to the end */
extern cklist* list_copy_from(cklist *ckl,unsigned int index);
/* rewinds
* copy from the start until (<) index*/
extern cklist* list_copy_until(cklist *ckl,unsigned int index);
/* rewinds
* copy from (>=) until (<) */
extern cklist* list_copy_part(cklist *ckl,unsigned int from,unsigned int until);
/* return 1 if str exists in the list, 0 otherwise */
extern int list_exists(cklist *ckl, const char *str);
/* rewinds */
extern void list_print_lisp(cklist *ckl);
extern void list_print_python(cklist *ckl);
extern void list_print(cklist *ckl);
extern void list_print_concat(cklist *ckl);
/* Deallocate resources */
extern void list_free(cklist *ckl);
#endif /* CKLIST_H */
|