strlist.h 2 KB
Newer Older
Bernhard Link's avatar
Bernhard Link committed
1 2
#ifndef REPREPRO_STRLIST_H
#define REPREPRO_STRLIST_H
Bernhard Link's avatar
Bernhard Link committed
3

Bernhard Link's avatar
Bernhard Link committed
4
#ifndef REPREPRO_ERROR_H
Bernhard Link's avatar
Bernhard Link committed
5 6 7
#include "error.h"
#warning "What's hapening here?"
#endif
Bernhard Link's avatar
Bernhard Link committed
8 9 10 11
#ifndef REPREPRO_GLOBALS_H
#include "globals.h"
#warning "What's hapening here?"
#endif
Bernhard Link's avatar
Bernhard Link committed
12 13 14

struct strlist {
	char **values;
15
	int count, size;
Bernhard Link's avatar
Bernhard Link committed
16 17
};

18 19 20
void strlist_init(/*@out@*/struct strlist *);
retvalue strlist_init_n(int /*startsize*/, /*@out@*/struct strlist *);
retvalue strlist_init_singleton(/*@only@*/char *, /*@out@*/struct strlist *);
21
void strlist_done(/*@special@*/struct strlist *strlist) /*@releases strlist->values @*/;
Bernhard Link's avatar
Bernhard Link committed
22 23

/* add a string, will get property of the strlist and free'd by it */
24
retvalue strlist_add(struct strlist *, /*@only@*/char *);
25
/* include a string at the beginning, otherwise like strlist_add */
26
retvalue strlist_include(struct strlist *, /*@only@*/char *);
27
/* add a string alphabetically, discarding if already there. */
28
retvalue strlist_adduniq(struct strlist *, /*@only@*/char *);
Bernhard Link's avatar
Bernhard Link committed
29 30
/* like strlist_add, but strdup it first */
retvalue strlist_add_dup(struct strlist *strlist, const char *todup);
Bernhard Link's avatar
Bernhard Link committed
31

Bernhard Link's avatar
Bernhard Link committed
32
/* print a space separated list of elements */
33
retvalue strlist_fprint(FILE *, const struct strlist *);
34

Bernhard Link's avatar
Bernhard Link committed
35
/* replace the contents of dest with those from orig, which get emptied */
36
void strlist_move(/*@out@*/struct strlist *dest, /*@special@*/struct strlist *orig) /*@releases orig->values @*/;
37

38 39
bool strlist_in(const struct strlist *, const char *);
int strlist_ofs(const struct strlist *, const char *);
40

41
bool strlist_intersects(const struct strlist *, const struct strlist *);
42
/* if missing != NULL And subset no subset of strlist, set *missing to the first missing one */
43
bool strlist_subset(const struct strlist *, const struct strlist * /*subset*/, const char ** /*missing_p*/);
Bernhard Link's avatar
Bernhard Link committed
44

45
/* concatenate <prefix> <values separated by infix> <suffix> */
46
char *strlist_concat(const struct strlist *, const char * /*prefix*/, const char * /*infix*/, const char * /*suffix*/);
Bernhard Link's avatar
Bernhard Link committed
47 48 49

/* remove all strings equal to the argument */
void strlist_remove(struct strlist *, const char *);
Bernhard Link's avatar
Bernhard Link committed
50
#endif